[cfe-dev] PCH without original files

Axel Naumann Axel.Naumann at cern.ch
Tue Jan 25 05:07:46 PST 2011


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.

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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ASTReader_FileNotFound.diff
Type: text/x-patch
Size: 2119 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110125/76156875/attachment.bin>


More information about the cfe-dev mailing list