1 // RUN: %clang_analyze_cc1 -verify %s \
2 // RUN: -analyzer-checker core,debug.ExprInspection
3
4 // Stuff that used to hang.
5
6 extern void __assert_fail(__const char *__assertion, __const char *__file,
7 unsigned int __line, __const char *__function)
8 __attribute__((__noreturn__));
9 #define assert(expr) \
10 ((expr) ? (void)(0) : __assert_fail(#expr, __FILE__, __LINE__, __func__))
11
12 void clang_analyzer_eval(int);
13
14 int g();
15
f(int y)16 int f(int y) {
17 return y + g();
18 }
19
produce_a_very_large_symbol(int x)20 int produce_a_very_large_symbol(int x) {
21 return f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(
22 f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(x))))))))))))))))))))))))))))))));
23 }
24
produce_an_exponentially_exploding_symbol(int x,int y)25 void produce_an_exponentially_exploding_symbol(int x, int y) {
26 x += y; y += x + g();
27 x += y; y += x + g();
28 x += y; y += x + g();
29 x += y; y += x + g();
30 x += y; y += x + g();
31 x += y; y += x + g();
32 x += y; y += x + g();
33 x += y; y += x + g();
34 x += y; y += x + g();
35 x += y; y += x + g();
36 x += y; y += x + g();
37 }
38
produce_an_exponentially_exploding_symbol_2(int x,int y)39 void produce_an_exponentially_exploding_symbol_2(int x, int y) {
40 x &= y;
41 y &= x & g();
42 x &= y;
43 y &= x & g();
44 x &= y;
45 y &= x & g();
46 x &= y;
47 y &= x & g();
48 x &= y;
49 y &= x & g();
50 x &= y;
51 y &= x & g();
52 x &= y;
53 y &= x & g();
54 x &= y;
55 y &= x & g();
56 x &= y;
57 y &= x & g();
58 x &= y;
59 y &= x & g();
60 x &= y;
61 y &= x & g();
62 if (x > 1) {
63 if (x > 2) {
64 if (x > 3) {
65 if (x > 4) {
66 if (x > 5) {
67 if (x > 6) {
68 if (x > 7) {
69 if (x > 8) {
70 if (x > 9) {
71 if (x > 10) {
72 }
73 }
74 }
75 }
76 }
77 }
78 }
79 }
80 }
81 }
82 }
83
produce_an_exponentially_exploding_symbol_3(int x,int y)84 void produce_an_exponentially_exploding_symbol_3(int x, int y) {
85 assert(0 < x && x < 10);
86 x &= y;
87 y &= x & g();
88 x &= y;
89 y &= x & g();
90 x &= y;
91 y &= x & g();
92 x &= y;
93 y &= x & g();
94 x &= y;
95 y &= x & g();
96 x &= y;
97 y &= x & g();
98 x &= y;
99 y &= x & g();
100 x &= y;
101 y &= x & g();
102 x &= y;
103 y &= x & g();
104 x &= y;
105 y &= x & g();
106 x &= y;
107 y &= x & g();
108 x &= y;
109 y &= x & g();
110 x &= y;
111 y &= x & g();
112 x &= y;
113 y &= x & g();
114 x &= y;
115 y &= x & g();
116 x &= y;
117 y &= x & g();
118 x &= y;
119 y &= x & g();
120 x &= y;
121 y &= x & g();
122 x &= y;
123 y &= x & g();
124 x &= y;
125 y &= x & g();
126 x &= y;
127 y &= x & g();
128 x &= y;
129 y &= x & g();
130 x &= y;
131 y &= x & g();
132 x &= y;
133 y &= x & g();
134 x &= y;
135 y &= x & g();
136 x &= y;
137 y &= x & g();
138 x &= y;
139 y &= x & g();
140 x &= y;
141 y &= x & g();
142 x &= y;
143 y &= x & g();
144 x &= y;
145 y &= x & g();
146 x &= y;
147 y &= x & g();
148 x &= y;
149 y &= x & g();
150 x &= y;
151 y &= x & g();
152 x &= y;
153 y &= x & g();
154 x &= y;
155 y &= x & g();
156 x &= y;
157 y &= x & g();
158 x &= y;
159 y &= x & g();
160 x &= y;
161 y &= x & g();
162 x &= y;
163 y &= x & g();
164 x &= y;
165 y &= x & g();
166 x &= y;
167 y &= x & g();
168 x &= y;
169 y &= x & g();
170 x &= y;
171 y &= x & g();
172 x &= y;
173 y &= x & g();
174 x &= y;
175 y &= x & g();
176 x &= y;
177 y &= x & g();
178 x &= y;
179 y &= x & g();
180 x &= y;
181 y &= x & g();
182 x &= y;
183 y &= x & g();
184 x &= y;
185 y &= x & g();
186 x &= y;
187 y &= x & g();
188 x &= y;
189 y &= x & g();
190 x &= y;
191 y &= x & g();
192 x &= y;
193 y &= x & g();
194 x &= y;
195 y &= x & g();
196 x &= y;
197 y &= x & g();
198 x &= y;
199 y &= x & g();
200 x &= y;
201 y &= x & g();
202 x &= y;
203 y &= x & g();
204 x &= y;
205 y &= x & g();
206 x &= y;
207 y &= x & g();
208 x &= y;
209 y &= x & g();
210 x &= y;
211 y &= x & g();
212 x &= y;
213 y &= x & g();
214 x &= y;
215 y &= x & g();
216 x &= y;
217 y &= x & g();
218 clang_analyzer_eval(0 < x && x < 10); // expected-warning{{TRUE}}
219 // expected-warning@-1{{FALSE}}
220 }
221