1 ; Choosing CodeView generates debug metadata for class-scope typedefs that
2 ; Dwarf would normally omit. Choosing both CodeView and Dwarf triggered
3 ; assertion failures and crashes because the Dwarf handler wasn't prepared for
4 ; those records (in particular, ones with the void type represented by a
7 ; This test was generated with:
8 ; clang++ -cc1 -emit-llvm -debug-info-kind=limited -dwarf-version=4 -gcodeview -x c++
9 ; on the following source code:
12 ; typedef void _Nodeptr;
20 ; CodeView generates a DIDerivedType for the _Nodeptr typedef.
22 ; RUN: llc %s -o - 2>&1 | FileCheck %s
23 ; CHECK-NOT: Assertion failed
25 ; ModuleID = 'bug.cpp'
26 source_filename = "bug.cpp"
27 target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
28 target triple = "i686-pc-windows-msvc"
30 %class.B = type { %class.A }
31 %class.A = type { i8 }
33 ; Function Attrs: noinline nounwind optnone
34 define x86_thiscallcc zeroext i1 @"\01?m_fn1@B@@AAE_NXZ"(%class.B* %this) #0 align 2 !dbg !9 {
36 %retval = alloca i1, align 1
37 %this.addr = alloca %class.B*, align 4
38 store %class.B* %this, %class.B** %this.addr, align 4
39 call void @llvm.dbg.declare(metadata %class.B** %this.addr, metadata !22, metadata !DIExpression()), !dbg !24
40 %this1 = load %class.B*, %class.B** %this.addr, align 4
41 call void @llvm.trap(), !dbg !25
44 return: ; No predecessors!
45 %0 = load i1, i1* %retval, align 1, !dbg !25
49 ; Function Attrs: nounwind readnone speculatable
50 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
52 ; Function Attrs: noreturn nounwind
53 declare void @llvm.trap() #2
55 attributes #0 = { noinline nounwind optnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "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-features"="+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
56 attributes #1 = { nounwind readnone speculatable }
57 attributes #2 = { noreturn nounwind }
60 !llvm.module.flags = !{!3, !4, !5, !6, !7}
63 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 6.0.0 ", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
64 !1 = !DIFile(filename: "<stdin>", directory: "D:\5Csrc\5Cbug", checksumkind: CSK_MD5, checksum: "2216f11c5ddda8c48a6f92a6079ad4b6")
66 !3 = !{i32 1, !"NumRegisterParameters", i32 0}
67 !4 = !{i32 2, !"Dwarf Version", i32 4}
68 !5 = !{i32 2, !"CodeView", i32 1}
69 !6 = !{i32 2, !"Debug Info Version", i32 3}
70 !7 = !{i32 1, !"wchar_size", i32 2}
71 !8 = !{!"clang version 6.0.0 "}
72 !9 = distinct !DISubprogram(name: "m_fn1", linkageName: "\01?m_fn1@B@@AAE_NXZ", scope: !11, file: !10, line: 8, type: !18, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: false, unit: !0, declaration: !17, retainedNodes: !2)
73 !10 = !DIFile(filename: "bug.cpp", directory: "D:\5Csrc\5Cbug", checksumkind: CSK_MD5, checksum: "2216f11c5ddda8c48a6f92a6079ad4b6")
74 !11 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "B", file: !10, line: 4, size: 8, elements: !12, identifier: ".?AVB@@")
76 !13 = !DIDerivedType(tag: DW_TAG_member, name: "FailedTestsCache", scope: !11, file: !10, line: 5, baseType: !14, size: 8)
77 !14 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "A", file: !10, line: 1, size: 8, elements: !15, identifier: ".?AVA@@")
79 !16 = !DIDerivedType(tag: DW_TAG_typedef, name: "_Nodeptr", scope: !14, file: !10, line: 2, baseType: null)
80 !17 = !DISubprogram(name: "m_fn1", linkageName: "\01?m_fn1@B@@AAE_NXZ", scope: !11, file: !10, line: 6, type: !18, isLocal: false, isDefinition: false, scopeLine: 6, flags: DIFlagPrototyped, isOptimized: false)
81 !18 = !DISubroutineType(cc: DW_CC_BORLAND_thiscall, types: !19)
83 !20 = !DIBasicType(name: "bool", size: 8, encoding: DW_ATE_boolean)
84 !21 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !11, size: 32, flags: DIFlagArtificial | DIFlagObjectPointer)
85 !22 = !DILocalVariable(name: "this", arg: 1, scope: !9, type: !23, flags: DIFlagArtificial | DIFlagObjectPointer)
86 !23 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !11, size: 32)
87 !24 = !DILocation(line: 0, scope: !9)
88 !25 = !DILocation(line: 8, scope: !9)