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

Lubos Lunak l.lunak at suse.cz
Mon Mar 19 13:43:23 PDT 2012

On Friday 16 of March 2012, Lubos Lunak wrote:
> On Friday 16 of March 2012, Chandler Carruth wrote:
> > I've not looked at the patch in detail, but a simple idea: #if 0 block,
> > with a comment explaining why.
>  That's a very good idea and it seems to work nicely.
>  I've also added commenting out #pragma once, and now the patch should be
> hopefully fully ready. I've also done a LibreOffice build again and this
> time there wasn't a single problem.

 I've still found two minor details, and also made it noticeably faster while 
I was at it. But now it's perfect, honest :).

 The latest version is attached. This time it is a patch and separately the 
new source file (to be put in clang/lib/Rewrite), to make review it easier. I 
also do not intend to make further changes until reviewed.

 The changes needed elsewhere are:

- adding the new option and invoking the functionality, trivial duplication 
of -rewrite-macros

- changes in Lexer class to not access the (null) Preprocessor pointer in raw 
mode, which the code normally uses, but temporarily switches to 
ParsingPreprocessorDirective mode (apparently a use case that's not been 
needed yet)

- addition of MacroExpansionInDirectivesOverride flag to Preprocessor, which 
makes it possible to avoid macro expansion everywhere else except in macro 
directives, which reduces the time to process files to less than a half (and 
to less than with plain -E, making icecream's distributed compilation 
actually faster this way). It could be made even faster if the lexer could be 
switched to mode where it would parse only comments and preprocessor 
directives (nothing else matters in this case), and I expect it would be an 
additional boost to distributed compiles, as this step is the bottleneck, but 
maybe later ;).

- and a test, which of course passes. Moreover, as already said, I've 
successfully compiled LibreOffice using this feature.

 Lubos Lunak
 l.lunak at suse.cz
-------------- next part --------------
A non-text attachment was scrubbed...
Name: RewriteIncludes.cpp
Type: text/x-c++src
Size: 12624 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120319/4ed42ba3/attachment.cpp>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rewrite-includes.patch
Type: text/x-diff
Size: 14687 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120319/4ed42ba3/attachment.patch>

More information about the cfe-commits mailing list