[cfe-commits] [PATCH] -rewrite-includes

Lubos Lunak l.lunak at suse.cz
Thu Mar 15 03:05:08 PDT 2012


On Thursday 15 of March 2012, Sebastian Redl wrote:
> On 15.03.2012, at 02:12, Lubos Lunak wrote:
> > The code is based on RewriteMacros.cpp and PrintPreprocessedOutput.cpp,
> > it more or less works now and I consider it almost ready. The only
> > remaining problem I have is commenting out the preprocessor directives -
> > I'd like to keep them in the resulting file, similarly to what
> > -rewrite-macros does. The problem is that neither /**/ nor // are safe
> > for commenting it out in all possible cases, and since this should be
> > used for transparent conversion during remote compile, I do not want to
> > make assumptions about what the code looks like (e.g. my first trivial
> > solution with /**/ failed
> > on "#include /*MSVC <cstdlib> */ <stdlib.h>" ). Does somebody know how to
> > achieve this? Otherwise I'll probably make it simply erase the
> > directives.
>
> Why isn't // safe?

 It's not in C89.

 It would also generate a warning about a multiline // comment if the 
directive had a trailing \ , which probably is way too obscure to care about, 
but the C89 reason is enough.

 Using /**/ should be actually safe enough if the original code was properly 
split if necessary, but I've already tried that and couldn't get the lexer to 
do it right.

-- 
 Lubos Lunak
 l.lunak at suse.cz



More information about the cfe-commits mailing list