1 // RUN: %clang -cc1 -debug-info-kind=constructor -emit-llvm %s -o - | FileCheck %s
2
3 // CHECK-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: "A"{{.*}}DIFlagTypePassByValue
4 struct A {
5 } TestA;
6
7 // CHECK-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: "B"{{.*}}flags: DIFlagFwdDecl
8 struct B {
9 B();
10 } TestB;
11
12 // CHECK-DAG: ![[C:[0-9]+]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "C"{{.*}}DIFlagTypePassByValue
13 struct C {
CC14 C() {}
15 } TestC;
16
17 // CHECK-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: "D"{{.*}}DIFlagTypePassByValue
18 struct D {
19 D();
20 };
D()21 D::D() {}
22
23 // Test for constexpr constructor.
24 // CHECK-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: "E"{{.*}}DIFlagTypePassByValue
25 struct E {
EE26 constexpr E(){};
27 } TestE;
28
29 // Test for trivial constructor.
30 // CHECK-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: "F"{{.*}}DIFlagTypePassByValue
31 struct F {
32 F() = default;
FF33 F(int) {}
34 int i;
35 } TestF;
36
37 // Test for trivial constructor.
38 // CHECK-DAG: ![[G:.*]] ={{.*}}!DICompositeType({{.*}}name: "G"{{.*}}DIFlagTypePassByValue
39 // CHECK-DAG: !DICompositeType({{.*}}scope: ![[G]], {{.*}}DIFlagTypePassByValue
40 struct G {
GG41 G() : g_(0) {}
42 struct {
43 int g_;
44 };
45 } TestG;
46
47 // Test for an aggregate class with an implicit non-trivial default constructor
48 // that is not instantiated.
49 // CHECK-DAG: !DICompositeType({{.*}}name: "H",{{.*}}DIFlagTypePassByValue
50 struct H {
51 B b;
52 };
f(H h)53 void f(H h) {}
54
55 // Test for an aggregate class with an implicit non-trivial default constructor
56 // that is instantiated.
57 // CHECK-DAG: !DICompositeType({{.*}}name: "J",{{.*}}DIFlagTypePassByValue
58 struct J {
59 B b;
60 };
f(decltype(J ()) j)61 void f(decltype(J()) j) {}
62
63 // Test for a class with trivial default constructor that is not instantiated.
64 // CHECK-DAG: !DICompositeType({{.*}}name: "K",{{.*}}DIFlagTypePassByValue
65 class K {
66 int i;
67 };
f(K k)68 void f(K k) {}
69
70 // Test that we don't use constructor homing on lambdas.
71 // CHECK-DAG: ![[L:.*]] ={{.*}}!DISubprogram({{.*}}name: "L"
72 // CHECK-DAG: !DICompositeType({{.*}}scope: ![[L]], {{.*}}DIFlagTypePassByValue
L()73 void L() {
74 auto func = [&]() {};
75 }
76
77 // Check that types are being added to retained types list.
78 // CHECK-DAG: !DICompileUnit{{.*}}retainedTypes: ![[RETAINED:[0-9]+]]
79 // CHECK-DAG: ![[RETAINED]] = {{.*}}![[C]]
80