Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGenCXX / debug-info-composite-triviality.cpp
blob962b82743a881cf4267b3b452e69295af57e33bd
1 // RUN: %clang_cc1 -emit-llvm -debug-info-kind=standalone -triple %itanium_abi_triple %s -o - | FileCheck %s
3 // Cases to show some non-trivial types with flags combined with DIFlagNonTrivial and DIFlagTypePassByValue.
5 // CHECK-DAG: !DICompositeType({{.*}}, name: "Explicit",{{.*}}flags: DIFlagTypePassByValue | DIFlagNonTrivial
6 struct Explicit {
7 explicit Explicit();
8 int a;
9 } Explicit;
11 // CHECK-DAG: !DICompositeType({{.*}}, name: "Struct",{{.*}}flags: DIFlagTypePassByValue | DIFlagNonTrivial
12 struct Struct {
13 Struct() {}
14 } Struct;
16 // CHECK-DAG: !DICompositeType({{.*}}, name: "Annotated",{{.*}}flags: DIFlagTypePassByValue | DIFlagNonTrivial
17 struct __attribute__((trivial_abi)) Annotated {
18 Annotated() {};
19 } Annotated;
22 // Check a non-composite type
23 // CHECK-DAG: !DIGlobalVariable(name: "GlobalVar", {{.*}}type: {{.*}}, isLocal: false, isDefinition: true)
24 int GlobalVar = 0;
26 // Cases to test composite type's triviality
28 // CHECK-DAG: {{.*}}!DIGlobalVariable(name: "Union",
29 // CHECK-DAG-NEXT: {{^((?!\bDIFlagNonTrivial\b).)*$}}
30 union Union {
31 int a;
32 } Union;
34 // CHECK-DAG: {{.*}}!DIGlobalVariable(name: "Trivial",
35 // CHECK-DAG-NEXT: {{^((?!\bDIFlagNonTrivial\b).)*$}}
36 struct Trivial {
37 int i;
38 } Trivial;
40 // CHECK-DAG: {{.*}}!DIGlobalVariable(name: "TrivialA",
41 // CHECK-DAG-NEXT: {{^((?!\bDIFlagNonTrivial\b).)*$}}
42 struct TrivialA {
43 TrivialA() = default;
44 } TrivialA;
46 // CHECK-DAG: {{.*}}!DIGlobalVariable(name: "TrivialB",
47 // CHECK-DAG-NEXT: {{^((?!\bDIFlagNonTrivial\b).)*$}}
48 struct TrivialB {
49 int m;
50 TrivialB(int x) { m = x; }
51 TrivialB() = default;
52 } TrivialB;
54 // CHECK-DAG: {{.*}}!DIGlobalVariable(name: "TrivialC",
55 // CHECK-DAG-NEXT: {{^((?!\bDIFlagNonTrivial\b).)*$}}
56 struct TrivialC {
57 struct Trivial x;
58 } TrivialC;
60 // CHECK-DAG: {{.*}}!DIGlobalVariable(name: "TrivialD",
61 // CHECK-DAG-NEXT: {{^((?!\bDIFlagNonTrivial\b).)*$}}
62 struct NT {
63 NT() {};
65 struct TrivialD {
66 static struct NT x; // Member is non-trivial but is static.
67 } TrivialD;
70 // CHECK-DAG: !DICompositeType({{.*}}, name: "NonTrivial",{{.*}}flags: {{.*}}DIFlagNonTrivial
71 struct NonTrivial {
72 NonTrivial() {}
73 } NonTrivial;
75 // CHECK-DAG: !DICompositeType({{.*}}, name: "NonTrivialA",{{.*}}flags: {{.*}}DIFlagNonTrivial
76 struct NonTrivialA {
77 ~NonTrivialA();
78 } NonTrivialA;
80 // CHECK-DAG: !DICompositeType({{.*}}, name: "NonTrivialB",{{.*}}flags: {{.*}}DIFlagNonTrivial
81 struct NonTrivialB {
82 struct NonTrivial x;
83 } NonTrivialB;
85 // CHECK-DAG: !DICompositeType({{.*}}, name: "NonTrivialC",{{.*}}flags: {{.*}}DIFlagNonTrivial
86 struct NonTrivialC {
87 virtual void f() {}
88 } NonTrivialC;
90 // CHECK-DAG: !DICompositeType({{.*}}, name: "NonTrivialD",{{.*}}flags: {{.*}}DIFlagNonTrivial
91 struct NonTrivialD : NonTrivial {
92 } NonTrivialD;
94 // CHECK-DAG: !DICompositeType({{.*}}, name: "NonTrivialE",{{.*}}flags: {{.*}}DIFlagNonTrivial
95 struct NonTrivialE : Trivial, NonTrivial {
96 } NonTrivialE;