[PATCH] D40746: Correctly handle line directives without filenames that come first in the file

Hans Wennborg via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 1 14:53:24 PST 2017


hans added a comment.

In https://reviews.llvm.org/D40746#942824, @rsmith wrote:

> The intent is to use a `FilenameID` of -1 to represent this situation; see the documentation of the `LineEntry::FilenameID` member. Users of that field are expected to deal with that value (see the handling of that case in `SourceManager::getPresumedLoc` for example). I think we need to handle it that way, rather than mapping to the main file name as this patch does, for correctness in the PCH case -- we don't actually *know* the correct main file name at the point where the line directive appears.
>
> I imagine the cause of the crash is that the AST writer blindly calls `LineTableInfo::getFilename(LE.FilenameID)` without checking for this case?


Yes, exactly.

I suppose the right thing to do is to just make the -1 values survive serialization, and the correct filename can be figured out when the deserialized pch gets used? Patch coming up.


https://reviews.llvm.org/D40746





More information about the cfe-commits mailing list