[PATCH] Do not use "1" in linemarker for main file in -frewrite-includes

Richard Smith richard at metafoo.co.uk
Sat Apr 12 21:53:17 PDT 2014


The check for MainFileID and accompanying test LGTM.

Can you explain what the check for PredefinesFileID is for? AFAICS, there's
no test for that part of the change, and I'm concerned that we could end up
attributing lines in that FileID to some other file.


On Fri, Apr 4, 2014 at 3:09 AM, Lubos Lunak <l.lunak at centrum.cz> wrote:

>
>  The -frewrite-includes flag incorrectly uses at the beginning a linemarker
> for the main file with the "1" flag which suggests that the contents have
> been in fact included from another file. This for example
> disables -Wunused-macros, which warns only for macros from the main file:
>
> $ cat a.cpp
> #define FOO 1
> $ clang++ -E -frewrite-includes a.cpp | clang++ -Wall -Wunused-macros -x
> c++ -c -
> $ clang++ -Wall -Wunused-macros -c a.cpp
> a.cpp:1:9: warning: macro is not used [-Wunused-macros]
> #define FOO 1
>         ^
> 1 warning generated.
>
>  The attached patch fixes the code to start the resulting file with the
> correct linemarker.
>
> --
>  Lubos Lunak
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140412/5ae3724f/attachment.html>


More information about the cfe-commits mailing list