[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [creduce-dev] [RFC] Adding passes for reducing clang crash reports

Hi Amy,

I agree that reducing include-heavy C++ is clunky.

Before running C-Reduce, I usually preprocess using "-P" which leaves out the line markers. I guess that doesn't help you if you are using a file produced by an automated crash reporter.

As Eric says, unifdef may help, it is already run very early in the pass schedule. There may be issues in this pass that could be cleaned up to make it do a better job.

Another pass that runs very early is pass_blank, which attempts to remove all lines starting with #. If this works it should give you what you want.

I would suggest doing a bit of experimentation where you look at some of our passes that should in principle do the job you want, and run just those passes alone, and see if they're doing anything useful. You can run an individual pass by clearing C-Reduce's pass schedule and explicitly adding the pass you like (see the command line help for the details).


On 2/13/19 2:10 PM, Amy Huang wrote:
Hi all,

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:

#if 0

#include "foo.h"


// 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?