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