Reducing crashes in clang is a common task for compiler developers, so we would like to make it faster. Clang produces crash reports using “clang -E -frewrite-includes”, which leaves behind macro defines, line markers, ifdefs, etc. It does this because sometimes diagnostics and crashes in diagnostic code depend on the pre-processor state controlled by these directives. For example,
- Sometimes when line markers are removed, errors in system headers are no longer suppressed; this prevents the original crash from occurring
- Sometimes the crash depends on macros
Some of the code patterns that -frewrite-includes produces are line markers, #defines, and #includes contained in this type of ifelse block:
// contents of foo.h
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?