[cfe-commits] [PATCH] -rewrite-includes
l.lunak at suse.cz
Thu Mar 15 08:36:29 CDT 2012
On Thursday 15 of March 2012, 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.
I've fixed an off-by-one at the end of reading a file, and made it comment
out all #include directives, because clang optimizes out repeated inclusions
that would be otherwise performed. Updated patch attached.
I've successfully rebuilt LibreOffice with the patch, which should be a
pretty good testcase (especially given that the codebase has reputation for
initially breaking every single tool used to build it). The only problem I
had was one system header having "#include <foo> /* multiline\ncomment*/",
where commenting out with // does not work.
So the only remaing problem should be either finding a way of commenting out
the directives properly or otherwise removing them.
l.lunak at suse.cz
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 21914 bytes
Desc: not available
Url : http://lists.cs.uiuc.edu/pipermail/cfe-commits/attachments/20120315/0831224c/attachment-0001.bin
More information about the cfe-commits