1; RUN: not --crash llc < %s -filetype=obj 2>&1 | FileCheck %s 2; 3; Verify the compiler produces an error message when trying to emit circular 4; references to unnamed structs which are not supported in CodeView debug 5; information. 6; 7; -- types-recursive-unnamed.cpp begin ----------------------------------------- 8; struct named_struct { 9; struct { 10; void method() {} 11; } unnamed_struct_with_method; 12; void anchor(); 13; }; 14; void named_struct::anchor() {} 15; -- types-recursive-unnamed.cpp end ------------------------------------------- 16; 17; To rebuild the reproducer: 18; 1. First, compile the source code: 19; $ clang -S -emit-llvm -g -gcodeview unnamed.cpp 20; 2. Remove all "name" and "identifier" attributes with a value matching 21; the form: "<unnamed-type-". 22; 23; CHECK: LLVM ERROR: cannot debug circular reference to unnamed type 24 25; ModuleID = 'types-recursive-unnamed.cpp' 26source_filename = "types-recursive-unnamed.cpp" 27target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128" 28target triple = "x86_64-pc-windows-msvc19.0.24210" 29 30%struct.named_struct = type { %struct.anon } 31%struct.anon = type { i8 } 32 33; Function Attrs: noinline nounwind uwtable 34define void @"\01?anchor@named_struct@@QEAAXXZ"(%struct.named_struct* %this) #0 align 2 !dbg !7 { 35entry: 36 %this.addr = alloca %struct.named_struct*, align 8 37 store %struct.named_struct* %this, %struct.named_struct** %this.addr, align 8 38 call void @llvm.dbg.declare(metadata %struct.named_struct** %this.addr, metadata !21, metadata !23), !dbg !24 39 %this1 = load %struct.named_struct*, %struct.named_struct** %this.addr, align 8 40 ret void, !dbg !25 41} 42 43; Function Attrs: nounwind readnone 44declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 45 46attributes #0 = { noinline nounwind uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } 47attributes #1 = { nounwind readnone } 48 49!llvm.dbg.cu = !{!0} 50!llvm.module.flags = !{!3, !4, !5} 51!llvm.ident = !{!6} 52 53!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 5.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2) 54!1 = !DIFile(filename: "types-recursive-unnamed.cpp", directory: "C:\5Cpath\5Cto\5Cdirectory", checksumkind: CSK_MD5, checksum: "59a90813f3338cfe690d9664215089df") 55!2 = !{} 56!3 = !{i32 2, !"CodeView", i32 1} 57!4 = !{i32 2, !"Debug Info Version", i32 3} 58!5 = !{i32 1, !"PIC Level", i32 2} 59!6 = !{!"clang version 5.0.0"} 60!7 = distinct !DISubprogram(name: "anchor", linkageName: "\01?anchor@named_struct@@QEAAXXZ", scope: !8, file: !1, line: 7, type: !18, isLocal: false, isDefinition: true, scopeLine: 7, flags: DIFlagPrototyped, isOptimized: false, unit: !0, declaration: !17, retainedNodes: !2) 61!8 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "named_struct", file: !1, line: 1, size: 8, elements: !9, identifier: ".?AUnamed_struct@@") 62!9 = !{!10, !16, !17} 63!10 = distinct !DICompositeType(tag: DW_TAG_structure_type, scope: !8, file: !1, line: 2, size: 8, elements: !11) 64!11 = !{!12} 65!12 = !DISubprogram(name: "method", linkageName: "\01?method@<unnamed-type-unnamed_struct_with_method>@named_struct@@QEAAXXZ", scope: !10, file: !1, line: 3, type: !13, isLocal: false, isDefinition: false, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: false) 66!13 = !DISubroutineType(types: !14) 67!14 = !{null, !15} 68!15 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !10, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer) 69!16 = !DIDerivedType(tag: DW_TAG_member, name: "unnamed_struct_with_method", scope: !8, file: !1, line: 4, baseType: !10, size: 8) 70!17 = !DISubprogram(name: "anchor", linkageName: "\01?anchor@named_struct@@QEAAXXZ", scope: !8, file: !1, line: 5, type: !18, isLocal: false, isDefinition: false, scopeLine: 5, flags: DIFlagPrototyped, isOptimized: false) 71!18 = !DISubroutineType(types: !19) 72!19 = !{null, !20} 73!20 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !8, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer) 74!21 = !DILocalVariable(name: "this", arg: 1, scope: !7, type: !22, flags: DIFlagArtificial | DIFlagObjectPointer) 75!22 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !8, size: 64) 76!23 = !DIExpression() 77!24 = !DILocation(line: 0, scope: !7) 78!25 = !DILocation(line: 7, column: 30, scope: !7) 79