Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGenCXX / debug-info-decl-nested.cpp
blob8d89f4138a1aa2618f4571271ee2246b1a1d9b09
1 // RUN: %clang_cc1 -std=c++11 -debug-info-kind=standalone -emit-llvm -triple x86_64-apple-darwin %s -o %t
2 // RUN: cat %t | FileCheck %s -check-prefix=CHECK0
3 // RUN: cat %t | FileCheck %s -check-prefix=CHECK1
4 // RUN: cat %t | FileCheck %s -check-prefix=CHECK2
5 //
6 // This test ensures that we associate a declaration with the
7 // definition of the constructor for OuterClass. The declaration is
8 // necessary so the backend can emit the DW_AT_specification attribute
9 // for the definition.
11 class Foo;
12 class OuterClass
14 static class InnerClass {
15 public:
16 InnerClass(); // Here createContextChain() generates a limited type for OuterClass.
17 } theInnerClass;
18 // CHECK0: ![[DECL:[0-9]+]] = !DISubprogram(name: "OuterClass"
19 // CHECK0-SAME: line: [[@LINE+2]]
20 // CHECK0-SAME: spFlags: 0
21 OuterClass(const Foo *); // line 10
23 OuterClass::InnerClass OuterClass::theInnerClass; // This toplevel decl causes InnerClass to be generated.
24 // CHECK0: !DISubprogram(name: "OuterClass"
25 // CHECK0-SAME: line: [[@LINE+3]]
26 // CHECK0-SAME: DISPFlagDefinition
27 // CHECK0-SAME: declaration: ![[DECL]]
28 OuterClass::OuterClass(const Foo *meta) { } // line 13
35 class Foo1;
36 class OuterClass1
38 static class InnerClass1 {
39 public:
40 InnerClass1();
41 } theInnerClass1;
42 // CHECK1: ![[DECL:[0-9]+]] = !DISubprogram(name: "Bar"
43 // CHECK1-SAME: line: [[@LINE+2]]
44 // CHECK1-SAME: spFlags: 0
45 void Bar(const Foo1 *);
47 OuterClass1::InnerClass1 OuterClass1::theInnerClass1;
48 // CHECK1: !DISubprogram(name: "Bar"
49 // CHECK1-SAME: line: [[@LINE+3]]
50 // CHECK1-SAME: DISPFlagDefinition
51 // CHECK1-SAME: declaration: ![[DECL]]
52 void OuterClass1::Bar(const Foo1 *meta) { }
58 class Foo2;
59 class OuterClass2
61 static class InnerClass2 {
62 public:
63 InnerClass2();
64 } theInnerClass2;
65 // CHECK2: ![[DECL:[0-9]+]] = !DISubprogram(name: "~OuterClass2"
66 // CHECK2-SAME: line: [[@LINE+2]]
67 // CHECK2-SAME: spFlags: 0
68 ~OuterClass2(); // line 10
70 OuterClass2::InnerClass2 OuterClass2::theInnerClass2;
71 // CHECK4: !DISubprogram(name: "~OuterClass2"
72 // CHECK4-SAME: line: [[@LINE+3]]
73 // CHECK4-SAME: DISPFlagDefinition
74 // CHECK4-SAME: declaration: ![[DECL]]
75 OuterClass2::~OuterClass2() { }