1 // RUN: %clang_cc1 -triple x86_64-none-linux-gnu -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s --check-prefix=CHECK --check-prefix=BOTH 2 // RUN: %clang_cc1 -triple i686-pc-windows-msvc -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s --check-prefix=MSVC --check-prefix=BOTH 3 4 // CHECK: @_ZN6pr96081xE = global [3 x i8]* null, align 8, !dbg [[X:![0-9]+]] 5 6 // CHECK: define void @_ZN7pr147634funcENS_3fooE 7 // CHECK: call void @llvm.dbg.declare({{.*}}, metadata ![[F:[0-9]+]], metadata ![[EXPR:[0-9]+]]) 8 9 // !llvm.dbg.cu pulls in globals and their types first. 10 // CHECK-NOT: !DIGlobalVariable(name: "c" 11 // CHECK: [[X]] = distinct !DIGlobalVariable(name: "x", linkageName: "_ZN6pr96081xE" 12 // CHECK-SAME: type: [[INCARRAYPTR:![0-9]*]] 13 // CHECK: [[INCARRAYPTR]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: [[INCARRAY:![0-9]+]] 14 // CHECK: [[INCARRAY]] = !DICompositeType(tag: DW_TAG_array_type 15 // CHECK-NOT: line: 16 // CHECK-NOT: size: 17 // CHECK-NOT: align: 18 // CHECK-NOT: offset: 19 // CHECK-SAME: baseType: ![[INCTYPE:[0-9]+]] 20 21 // CHECK: ![[INCTYPE]] = !DICompositeType(tag: DW_TAG_structure_type, name: "incomplete" 22 // CHECK-SAME: DIFlagFwdDecl 23 24 template<typename T> struct Identity { 25 typedef T Type; 26 }; 27 28 void f(Identity<int>::Type a) {} 29 void f(Identity<int> a) {} 30 void f(int& a) { } 31 32 template<typename T> struct A { 33 A<T> *next; 34 }; 35 void f(A<int>) { } 36 37 struct B { }; 38 39 void f() { 40 int B::*a = 0; 41 void (B::*b)() = 0; 42 } 43 44 namespace EmptyNameCrash { 45 struct A { A(); }; 46 typedef struct { A x; } B; 47 B x; 48 } 49 50 // PR4890 51 namespace PR4890 { 52 struct X { 53 ~X(); 54 }; 55 56 X::~X() { } 57 } 58 59 namespace VirtualDtor { 60 struct Y { 61 virtual ~Y(); 62 }; 63 64 Y::~Y() { } 65 } 66 67 namespace VirtualBase { 68 struct A { int a; }; 69 struct B : virtual A { int b; }; 70 // BOTH: ![[VBASE_B:[0-9]+]] ={{.*}}!DICompositeType(tag: DW_TAG_structure_type, name: "B",{{.*}} line: [[@LINE-1]], 71 // MSVC-SAME: size: 96, align: 32 72 // CHECK-SAME: size: 128, align: 64, 73 // BOTH-NOT: offset: 74 // BOTH-NOT: DIFlagFwdDecl 75 // BOTH-SAME: elements: [[VBASE_B_DEF:![0-9]+]] 76 // BOTH: [[VBASE_B_DEF]] = !{[[VBASE_A_IN_B:![0-9]+]], 77 // 78 // Look for the vbtable offset of A, which should be 4 for MSVC, 24 otherwise. 79 // BOTH: [[VBASE_A_IN_B]] = !DIDerivedType(tag: DW_TAG_inheritance, scope: ![[VBASE_B]], 80 // BOTH-SAME: baseType: ![[VBASE_A:[0-9]+]], 81 // MSVC-SAME: offset: 4, 82 // CHECK-SAME: offset: 24, 83 // 84 // BOTH: ![[VBASE_A]] ={{.*}}!DICompositeType(tag: DW_TAG_structure_type, name: "A", 85 86 void f() { 87 B b; 88 } 89 } 90 91 namespace b5249287 { 92 template <typename T> class A { 93 struct B; 94 }; 95 96 class Cls { 97 template <typename T> friend class A<T>::B; 98 }; 99 100 Cls obj; 101 } 102 103 // CHECK: [[FUNC:[0-9]+]] = distinct !DISubprogram(name: "func", linkageName: "_ZN7pr147634funcENS_3fooE" 104 // CHECK-SAME: type: {{![0-9]+}} 105 // CHECK-SAME: isDefinition: true 106 107 // CHECK: [[PR14763:![0-9]+]] = !DINamespace(name: "pr14763" 108 namespace pr14763 { 109 struct foo { 110 // CHECK: ![[FOO:[0-9]+]] ={{.*}}!DICompositeType(tag: DW_TAG_structure_type, name: "foo" 111 // CHECK-SAME: scope: [[PR14763]] 112 // CHECK-SAME: identifier: 113 foo(const foo&); 114 }; 115 116 // For some reason function arguments ended up down here 117 // CHECK: ![[F]] = !DILocalVariable(name: "f", arg: 1, scope: ![[FUNC]] 118 // CHECK-SAME: type: ![[FOO]] 119 // CHECK: ![[EXPR]] = !DIExpression(DW_OP_deref) 120 foo func(foo f) { 121 return f; // reference 'f' for now because otherwise we hit another bug 122 } 123 124 } 125 126 void foo() { 127 // CHECK: !DILocalVariable(name: "c" 128 // CHECK-NOT: arg: 129 // CHECK-SAME: ) 130 const wchar_t c = L'x'; 131 wchar_t d = c; 132 } 133 134 namespace pr9608 { // also pr9600 135 struct incomplete; 136 incomplete (*x)[3]; 137 } 138 139 namespace pr16214 { 140 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "a" 141 // CHECK-SAME: elements: [[A_MEM:![0-9]+]] 142 // CHECK-SAME: identifier: "_ZTSN7pr162141aE" 143 // CHECK: [[A_MEM]] = !{[[A_I:![0-9]*]]} 144 struct a { 145 // CHECK: [[A_I]] = !DIDerivedType(tag: DW_TAG_member, name: "i" 146 int i; 147 }; 148 149 typedef a at; 150 151 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "b" 152 // CHECK-SAME: DIFlagFwdDecl 153 struct b { 154 }; 155 156 typedef b bt; 157 158 void func() { 159 at a_inst; 160 bt *b_ptr_inst; 161 const bt *b_cnst_ptr_inst; 162 } 163 164 } 165