diff options
author | Carlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au> | 2012-10-15 17:10:06 +1100 |
---|---|---|
committer | Carlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au> | 2012-10-15 17:10:06 +1100 |
commit | be1de4be954c80875ad4108e0a33e8e131b2f2c0 (patch) | |
tree | 1fbbecf276bf7c7bdcbb4dd446099d6d90eaa516 /clang/INPUTS/cfg-nested-var-scopes.cpp | |
parent | c4626a62754862d20b41e8a46a3574264ea80e6d (diff) | |
parent | f1bd2e48c5324d3f7cda4090c87f8a5b6f463ce2 (diff) |
Merge branch 'master' of ssh://bitbucket.org/czan/honours
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; +} |