1 // Test visualization of general branch constructs in C.
9 for (i
= 0; i
< 100; ++i
) {
13 do {} while (i
++ < 75);
18 for (int i
= 0; i
< 100; ++i
) {
62 for (i
= 0; i
< 2; ++i
) {
64 // Never reached -> no weights
98 for (i
= 0; i
< 10; ++i
) {
100 // never reached -> no weights
109 static int weights
[] = {1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5};
111 // No cases -> no weights
112 switch (weights
[0]) {
117 for (int i
= 0, len
= sizeof(weights
) / sizeof(weights
[0]); i
< len
; ++i
) {
118 switch (i
[weights
]) {
142 // Never reached -> no weights
148 for (int i
= 0; i
< 32; ++i
) {
156 case (1 << 2) ... (1 << 12):
159 // The branch for the large case range above appears after the case body.
164 case (1 << 14) ... (1 << 28):
167 // The branch for the large case range above appears after the case body.
169 case (1 << 29) ... ((1 << 29) + 1):
180 void boolean_operators() {
182 for (int i
= 0; i
< 100; ++i
) {
187 v
= i
% 3 || i
% 2 || i
;
189 v
= i
% 2 && i
% 3 && i
;
194 void boolop_loops() {
200 while ((i
% 2) || (i
> 0))
203 for (i
= 100; i
&& i
> 50; --i
);
205 for (; (i
% 2) || (i
> 0); --i
);
209 void conditional_operator() {
212 int j
= i
< 50 ? i
: 1;
218 void do_fallthrough() {
219 for (int i
= 0; i
< 10; ++i
) {
222 // The number of exits out of this do-loop via the break statement
223 // exceeds the counter value for the loop (which does not include the
224 // fallthrough count). Make sure that does not violate any assertions.
231 static void static_func() {
232 for (int i
= 0; i
< 10; ++i
) {
245 int main(int argc
, const char *argv
[]) {
254 conditional_operator();
257 extern void __llvm_profile_write_file();
258 __llvm_profile_write_file();