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