[cfe-dev] PCH without original files
Axel Naumann
Axel.Naumann at cern.ch
Wed Jan 26 07:19:17 PST 2011
Hi,
line and column numbers are calculated from the MemoryBuffer - which we
don't have if the file doesn't exist. Attached patch
TextDiagnosticPrinter_invalid_PLoc.diff improves the situation a bit; in
your example I now get:
/build/llvm/tmp/relopch/email/test.h (in PCH): warning: padding struct
'S' with 3 bytes to align 'y'
1 warning generated.
With this patch, a valid SourceLocation but missing PresumedLoc is not a
reason anymore for swallowing the diagnostic.
The alternative would be to store the line+column number in the PCH and
that's overkill - esp given that in a few days I plan to find the source
files even if they are at a different location than the absolute path
stored in the PCH.
Comments or should I commit?
And then okay to commit the original patch? (Attached
ASTReader_FileNotFound_v2.diff is updated to trunk.)
Cheers, Axel.
Argyrios Kyrtzidis wrote on 01/25/2011 07:59 PM:
> 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
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: TextDiagnosticPrinter_invalid_PLoc.diff
Type: text/x-patch
Size: 7355 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110126/c26766cc/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ASTReader_FileNotFound_v2.diff
Type: text/x-patch
Size: 2119 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110126/c26766cc/attachment-0001.bin>
More information about the cfe-dev
mailing list