| 1 |
// RUN: %clang_cc1 -debug-info-kind=constructor -emit-llvm %s -o - | FileCheck %s |
| 2 |
// RUN: %clang_cc1 -debug-info-kind=constructor -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=ITANIUM %s |
| 3 |
|
| 4 |
// CHECK-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: "A"{{.*}}DIFlagTypePassByValue |
| 5 |
struct A { |
| 6 |
} TestA; |
| 7 |
|
| 8 |
// CHECK-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: "B"{{.*}}flags: DIFlagFwdDecl |
| 9 |
struct B { |
| 10 |
B(); |
| 11 |
} TestB; |
| 12 |
|
| 13 |
// CHECK-DAG: ![[C:[0-9]+]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "C"{{.*}}DIFlagTypePassByValue |
| 14 |
struct C { |
| 15 |
C() {} |
| 16 |
} TestC; |
| 17 |
|
| 18 |
// CHECK-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: "D"{{.*}}DIFlagTypePassByValue |
| 19 |
struct D { |
| 20 |
D(); |
| 21 |
}; |
| 22 |
D::D() {} |
| 23 |
|
| 24 |
// Test for constexpr constructor. |
| 25 |
// CHECK-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: "E"{{.*}}DIFlagTypePassByValue |
| 26 |
struct E { |
| 27 |
constexpr E(){}; |
| 28 |
} TestE; |
| 29 |
|
| 30 |
// Test for trivial constructor. |
| 31 |
// CHECK-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: "F"{{.*}}DIFlagTypePassByValue |
| 32 |
struct F { |
| 33 |
F() = default; |
| 34 |
F(int) {} |
| 35 |
int i; |
| 36 |
} TestF; |
| 37 |
|
| 38 |
// Test for trivial constructor. |
| 39 |
// CHECK-DAG: ![[G:.*]] ={{.*}}!DICompositeType({{.*}}name: "G"{{.*}}DIFlagTypePassByValue |
| 40 |
// CHECK-DAG: !DICompositeType({{.*}}scope: ![[G]], {{.*}}DIFlagTypePassByValue |
| 41 |
struct G { |
| 42 |
G() : g_(0) {} |
| 43 |
struct { |
| 44 |
int g_; |
| 45 |
}; |
| 46 |
} TestG; |
| 47 |
|
| 48 |
// Test for an aggregate class with an implicit non-trivial default constructor |
| 49 |
// that is not instantiated. |
| 50 |
// CHECK-DAG: !DICompositeType({{.*}}name: "H",{{.*}}DIFlagTypePassByValue |
| 51 |
struct H { |
| 52 |
B b; |
| 53 |
}; |
| 54 |
void f(H h) {} |
| 55 |
|
| 56 |
// Test for an aggregate class with an implicit non-trivial default constructor |
| 57 |
// that is instantiated. |
| 58 |
// CHECK-DAG: !DICompositeType({{.*}}name: "J",{{.*}}DIFlagTypePassByValue |
| 59 |
struct J { |
| 60 |
B b; |
| 61 |
}; |
| 62 |
void f(decltype(J()) j) {} |
| 63 |
|
| 64 |
// Test for a class with trivial default constructor that is not instantiated. |
| 65 |
// CHECK-DAG: !DICompositeType({{.*}}name: "K",{{.*}}DIFlagTypePassByValue |
| 66 |
class K { |
| 67 |
int i; |
| 68 |
}; |
| 69 |
void f(K k) {} |
| 70 |
|
| 71 |
// CHECK-DAG: !DICompositeType({{.*}}name: "DeletedCtors",{{.*}}DIFlagTypePassBy |
| 72 |
struct NonTrivial { |
| 73 |
NonTrivial(); |
| 74 |
}; |
| 75 |
struct DeletedCtors { |
| 76 |
DeletedCtors() = delete; |
| 77 |
DeletedCtors(const DeletedCtors &) = default; |
| 78 |
void f1(); |
| 79 |
NonTrivial t; |
| 80 |
}; |
| 81 |
|
| 82 |
const NonTrivial &f(const DeletedCtors &D) { |
| 83 |
return D.t; |
| 84 |
} |
| 85 |
|
| 86 |
// Test that we don't use constructor homing on lambdas. |
| 87 |
// CHECK-DAG: ![[L:.*]] ={{.*}}!DISubprogram({{.*}}name: "L" |
| 88 |
// CHECK-DAG: !DICompositeType({{.*}}scope: ![[L]], {{.*}}DIFlagTypePassByValue |
| 89 |
void L() { |
| 90 |
auto func = [&]() {}; |
| 91 |
} |
| 92 |
|
| 93 |
// Check that types are being added to retained types list. |
| 94 |
// CHECK-DAG: !DICompileUnit{{.*}}retainedTypes: ![[RETAINED:[0-9]+]] |
| 95 |
// CHECK-DAG: ![[RETAINED]] = {{.*}}![[C]] |
| 96 |
|
| 97 |
|
| 98 |
struct VTableAndCtor { |
| 99 |
virtual void f1(); |
| 100 |
VTableAndCtor(); |
| 101 |
}; |
| 102 |
|
| 103 |
VTableAndCtor::VTableAndCtor() { |
| 104 |
} |
| 105 |
|
| 106 |
// ITANIUM-DAG: !DICompositeType({{.*}}name: "VTableAndCtor", {{.*}}flags: DIFlagFwdDecl |
| 107 |
|