[PATCH] Fix "In file included from" for files generated with -frewrite-includes

Lubos Lunak l.lunak at centrum.cz
Fri Apr 4 03:16:23 PDT 2014


 Option -frewrite-includes comments out #include directives it replaces by 
enclosing it in #if 0, which moves the included contents, changing their 
perceived line numbers e.g. in the "In file included from" messages in a 
follow-up compilation:

$ cat b.cpp
#include "b.h"
$ cat b.h
void f()
    {
    int unused_variable;
    }
$ clang++ -E -frewrite-includes b.cpp | clang++ -Wall -x c++ -c -
In file included from b.cpp:4:
./b.h:3:9: warning: unused variable 'unused_variable' [-Wunused-variable]
    int unused_variable;
        ^
1 warning generated.
$ clang++ -Wall -c b.cpp
In file included from b.cpp:1:
./b.h:3:9: warning: unused variable 'unused_variable' [-Wunused-variable]
    int unused_variable;
        ^
1 warning generated.

 The attached patch fixes this.

-- 
 Lubos Lunak
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-write-a-line-marker-right-before-adding-included-fil.patch
Type: text/x-diff
Size: 8631 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140404/58893255/attachment.patch>


More information about the cfe-commits mailing list