[cfe-dev] PCH without original files
Argyrios Kyrtzidis
kyrtzidis at apple.com
Tue Jan 25 10:59:37 PST 2011
On Jan 25, 2011, at 5:07 AM, Axel Naumann wrote:
> Hi,
>
> Attached patch allows the ASTReader to use a PCH even if the original
> files (which are store as absolute file names or relative to sysroot)
> have been removed. Drawback: without these original files, diagnostics
> referring to source locations in the original files cannot show the
> source code:
>
> $ cat test.h
> void f(){}
> $ cat test.cxx
> int f(){}
> $ clang -cc1 -x c++ -emit-pch test.h -o test.h.pch
> $ clang -cc1 -include-pch test.h.pch -emit-obj test.cxx
> test.cxx:1:5: error: functions that differ only in their return type
> cannot be overloaded
> int f(){}
> ^
> /build/llvm/tmp/relopch/email/test.h:1:6: note: previous definition is here
> void f(){}
> ^
> 1 error generated.
> $ rm test.h
> $ clang -cc1 -include-pch test.h.pch -emit-obj test.cxx
> test.cxx:1:5: error: functions that differ only in their return type
> cannot be overloaded
> int f(){}
> ^
> 1 error generated.
Shouldn't we show the messages that occured, just not the source, e.g:
test.cxx:1:5: error: functions that differ only in their return type
cannot be overloaded
int f(){}
^
/build/llvm/tmp/relopch/email/test.h:1:6: note: previous definition is here
1 error generated.
This what gcc does, and I think notes are generally informative enough to show.
You also squash some warnings, e.g:
$ cat test.h
struct S {
char x;
int y;
};
$ cat test.cxx
void qq(S*) {}
$ clang -cc1 -x c++ -emit-pch test.h -o test.h.pch
$ clang -cc1 -include-pch test.h.pch -emit-obj test.cxx -Wpadded
/Users/argiris/proj/llvm/src/tools/clang/test.h:3:6: warning: padding struct 'S' with 3 bytes to align 'y'
int y;
^
1 warning generated.
$ rm test.h
$ clang -cc1 -include-pch test.h.pch -emit-obj test.cxx -Wpadded
1 warning generated.
-Argiris
>
> make test is happy. Please let me know whether this is okay to commit.
>
> As a next step, I want to implement header search in the ASTReader if
> the relocatable flag is set, and if the original file cannot be found.
>
> Cheers, Axel.
> <ASTReader_FileNotFound.diff>_______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
More information about the cfe-dev
mailing list