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