Amy Huang <akhuang@google.com> writes:
> Currently CReduce removes the includes one by one at the beginning, and most
> of the other stuff in the lines pass, which is time consuming especially as
> they don't get collapsed by topformflat. Basically what we want to do is have
> some sort of pass to remove/simplify the line markers, macros, and ifs at the
> beginning. Maybe it could be added as an additional pass, or maybe as a sort
> of clang preprocessor step?
> Any thoughts or suggestions?
Would the `unifdef` tool, distributed with C-Reduce, be helpful here?
I think an early run of `unifdef` to remove all `#if 0` blocks would help. It would save the one-by-one removal of #include lines. Is it just a matter of reordering the existing pass?
However, unifdef doesn't seem to expand #define macros, so #defines typically remain in the source before the lines pass runs, and they still block topformflat's brace collapsing. I think it would be interesting to try removing unused macros. There are probably many unused macros from headers, consider the Linux enum pattern of `enum { EFOO = 3,\n#define EFOO EFOO\n}`. Or, expanding more than one define at a time. The clex pass runs late, and seems to only handle non-function macros.