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

Lubos Lunak l.lunak at centrum.cz
Fri Apr 4 03:09:35 PDT 2014


 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-do-not-use-1-for-line-marker-for-the-main-file.patch
Type: text/x-diff
Size: 1947 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140404/0c12538d/attachment.patch>


More information about the cfe-commits mailing list