diff options
author | Zancanaro; Carlo <czan8762@plang3.cs.usyd.edu.au> | 2012-09-24 09:58:17 +1000 |
---|---|---|
committer | Zancanaro; Carlo <czan8762@plang3.cs.usyd.edu.au> | 2012-09-24 09:58:17 +1000 |
commit | 222e2a7620e6520ffaf4fc4e69d79c18da31542e (patch) | |
tree | 7bfbc05bfa3b41c8f9d2e56d53a0bc3e310df239 /clang/INPUTS/cfg-nested-var-scopes.cpp | |
parent | 3d206f03985b50beacae843d880bccdc91a9f424 (diff) |
Add the clang library to the repo (with some of my changes, too).
Diffstat (limited to 'clang/INPUTS/cfg-nested-var-scopes.cpp')
-rw-r--r-- | clang/INPUTS/cfg-nested-var-scopes.cpp | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/clang/INPUTS/cfg-nested-var-scopes.cpp b/clang/INPUTS/cfg-nested-var-scopes.cpp new file mode 100644 index 0000000..0944ec2 --- /dev/null +++ b/clang/INPUTS/cfg-nested-var-scopes.cpp @@ -0,0 +1,59 @@ +// Hammer the CFG with large numbers of overlapping variable scopes, which +// implicit destructors triggered at each edge. + +#define EXPAND_BASIC_STRUCT(i) struct X##i { X##i(int); ~X##i(); }; +#define EXPAND_NORET_STRUCT(i) struct X##i { X##i(int); ~X##i() __attribute__((noreturn)); }; +EXPAND_BASIC_STRUCT(0000); EXPAND_NORET_STRUCT(0001); +EXPAND_BASIC_STRUCT(0010); EXPAND_BASIC_STRUCT(0011); +EXPAND_BASIC_STRUCT(0100); EXPAND_NORET_STRUCT(0101); +EXPAND_NORET_STRUCT(0110); EXPAND_BASIC_STRUCT(0111); +EXPAND_BASIC_STRUCT(1000); EXPAND_NORET_STRUCT(1001); +EXPAND_BASIC_STRUCT(1010); EXPAND_BASIC_STRUCT(1011); +EXPAND_NORET_STRUCT(1100); EXPAND_NORET_STRUCT(1101); +EXPAND_BASIC_STRUCT(1110); EXPAND_BASIC_STRUCT(1111); + +#define EXPAND_2_VARS(c, i, x) const X##i var_##c##_##i##0(x), &var_##c##_##i##1 = X##i(x) +#define EXPAND_4_VARS(c, i, x) EXPAND_2_VARS(c, i##0, x); EXPAND_2_VARS(c, i##1, x) +#define EXPAND_8_VARS(c, i, x) EXPAND_4_VARS(c, i##0, x); EXPAND_4_VARS(c, i##1, x) +#define EXPAND_16_VARS(c, i, x) EXPAND_8_VARS(c, i##0, x); EXPAND_8_VARS(c, i##1, x) +#define EXPAND_32_VARS(c, x) EXPAND_16_VARS(c, 0, x); EXPAND_16_VARS(c, 1, x) + +#define EXPAND_2_INNER_CASES(i, x, y) INNER_CASE(i, x, y); INNER_CASE(i + 1, x, y); +#define EXPAND_4_INNER_CASES(i, x, y) EXPAND_2_INNER_CASES(i, x, y) EXPAND_2_INNER_CASES(i + 2, x, y) +#define EXPAND_8_INNER_CASES(i, x, y) EXPAND_4_INNER_CASES(i, x, y) EXPAND_4_INNER_CASES(i + 4, x, y) +#define EXPAND_16_INNER_CASES(i, x, y) EXPAND_8_INNER_CASES(i, x, y) EXPAND_8_INNER_CASES(i + 8, x, y) +#define EXPAND_32_INNER_CASES(i, x, y) EXPAND_16_INNER_CASES(i, x, y) EXPAND_16_INNER_CASES(i + 16, x, y) + +#define EXPAND_2_OUTER_CASES(i, x, y) OUTER_CASE(i, x, y); OUTER_CASE(i + 1, x, y); +#define EXPAND_4_OUTER_CASES(i, x, y) EXPAND_2_OUTER_CASES(i, x, y) EXPAND_2_OUTER_CASES(i + 2, x, y) +#define EXPAND_8_OUTER_CASES(i, x, y) EXPAND_4_OUTER_CASES(i, x, y) EXPAND_4_OUTER_CASES(i + 4, x, y) +#define EXPAND_16_OUTER_CASES(i, x, y) EXPAND_8_OUTER_CASES(i, x, y) EXPAND_8_OUTER_CASES(i + 8, x, y) +#define EXPAND_32_OUTER_CASES(i, x, y) EXPAND_16_OUTER_CASES(i, x, y) EXPAND_16_OUTER_CASES(i + 16, x, y) + +unsigned cfg_nested_vars(int x) { + int y = 0; + while (x > 0) { + EXPAND_32_VARS(a, x); + switch (x) { +#define INNER_CASE(i, x, y) \ + case i: { \ + int case_var = 3*x + i; \ + EXPAND_32_VARS(c, case_var); \ + y += case_var - 1; \ + break; \ + } +#define OUTER_CASE(i, x, y) \ + case i: { \ + int case_var = y >> 8; \ + EXPAND_32_VARS(b, y); \ + switch (case_var) { \ + EXPAND_32_INNER_CASES(0, x, y); \ + } \ + break; \ + } +EXPAND_32_OUTER_CASES(0, x, y); + } + --x; + } + return y; +} |