Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Analysis / Inputs / ctu-other.cpp
bloba7bf1cef65b92e84ad77f1c1001d1e6447bb2166
1 #include "../ctu-hdr.h"
3 int callback_to_main(int x);
4 int f(int x) {
5 return x - 1;
8 int g(int x) {
9 return callback_to_main(x) + 1;
12 int h_chain(int);
14 int h(int x) {
15 return 2 * h_chain(x);
18 namespace myns {
19 int fns(int x) {
20 return x + 7;
23 namespace embed_ns {
24 int fens(int x) {
25 return x - 3;
27 } // namespace embed_ns
29 class embed_cls {
30 public:
31 int fecl(int x);
33 int embed_cls::fecl(int x) {
34 return x - 7;
36 } // namespace myns
38 class mycls {
39 public:
40 int fcl(int x);
41 virtual int fvcl(int x);
42 static int fscl(int x);
44 class embed_cls2 {
45 public:
46 int fecl2(int x);
50 int mycls::fcl(int x) {
51 return x + 5;
53 int mycls::fvcl(int x) {
54 return x + 7;
56 int mycls::fscl(int x) {
57 return x + 6;
59 int mycls::embed_cls2::fecl2(int x) {
60 return x - 11;
63 class derived : public mycls {
64 public:
65 virtual int fvcl(int x) override;
68 int derived::fvcl(int x) {
69 return x + 8;
72 namespace chns {
73 int chf2(int x);
75 class chcls {
76 public:
77 int chf4(int x);
80 int chf3(int x) {
81 return chcls().chf4(x);
84 int chf1(int x) {
85 return chf2(x);
89 typedef struct { int n; } Anonymous;
90 int fun_using_anon_struct(int n) { Anonymous anon; anon.n = n; return anon.n; }
92 int other_macro_diag(int x) {
93 MACRODIAG();
94 return x;
97 extern const int extInt = 2;
98 namespace intns {
99 extern const int extInt = 3;
101 struct S {
102 int a;
104 extern const S extS = {.a = 4};
105 extern S extNonConstS = {.a = 4};
106 struct NonTrivialS {
107 int a;
108 ~NonTrivialS();
110 extern const NonTrivialS extNTS = {.a = 4};
111 struct A {
112 static const int a;
114 const int A::a = 3;
115 struct SC {
116 const int a;
118 extern const SC extSC = {.a = 8};
119 struct ST {
120 static const struct SC sc;
122 const struct SC ST::sc = {.a = 2};
123 struct SCNest {
124 struct SCN {
125 const int a;
126 } scn;
128 SCNest extSCN = {.scn = {.a = 9}};
129 extern SCNest::SCN const extSubSCN = {.a = 1};
130 struct SCC {
131 SCC(int c) : a(c) {}
132 const int a;
134 SCC extSCC{7};
135 union U {
136 const int a;
137 const unsigned int b;
139 extern const U extU = {.a = 4};
141 class TestAnonUnionUSR {
142 public:
143 inline float f(int value) {
144 union {
145 float f;
146 int i;
148 i = value;
149 return f;
151 static const int Test;
153 const int TestAnonUnionUSR::Test = 5;
155 struct DefaultParmContext {
156 static const int I;
157 int f();
160 int fDefaultParm(int I = DefaultParmContext::I) {
161 return I;
164 int testImportOfIncompleteDefaultParmDuringImport(int I) {
165 return fDefaultParm(I);
168 const int DefaultParmContext::I = 0;
170 int DefaultParmContext::f() {
171 return fDefaultParm();
174 class TestDelegateConstructor {
175 public:
176 TestDelegateConstructor() : TestDelegateConstructor(2) {}
177 TestDelegateConstructor(int) {}
180 int testImportOfDelegateConstructor(int i) {
181 TestDelegateConstructor TDC;
182 return i;