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

Sebastian Redl sebastian.redl at getdesigned.at
Thu Mar 15 01:54:45 PDT 2012

On 15.03.2012, at 02:12, Lubos Lunak wrote:

> Hello,
> the attached patch is an attempt at option -rewrite-includes, which is 
> similar to -rewrite-macros, but it expands only #include directives.
> The primary motivation is a better functionality of clang together with 
> icecream, a distributed compile system (like distcc, only better, 
> http://en.opensuse.org/Icecream). Remote compilation works by first 
> preprocessing the file and sending the result for actual compilation. This 
> difference doesn't matter with gcc, but clang disables some warnings for code 
> expanded from macros, and also quotes source code, both of which no longer 
> work well in the preprocessed case. So the idea is to add -rewrite-includes, 
> which will only merge all included files into the resulting file, without any 
> other modifications, and the result will be normally compiled again.
> 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?


More information about the cfe-commits mailing list