[cfe-dev] Question about valid FileID values and assert

Jason Dagit dagit at galois.com
Tue Jul 29 08:07:36 PDT 2014


Hello,

I’m very new to the clang source and I’m trying to understand how AST serialization works. As far as I can tell valid FileIDs can be positive or negative but not 0. Yet I see the following in ASTReader: https://github.com/llvm-mirror/clang/blob/master/lib/Serialization/ASTReader.cpp#L1036

I’m wondering, shouldn’t that line be:
assert(FID > 0 && "Serialized line entries for non-local file.”);

It looks like SLocEntryBaseID is always initialized to 0, and I can’t find a place that changes it. if FID was 0, then `FID += F.SLocEntryBaseID - 1;` would be -1? I see that FileIDs can be negative, but in this case it looks like an error to me.

Perhaps I missed something? Does the serialization sometimes write out invalid FileIDs (meaning, 0 values) for some reason?

Thanks,
Jason


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140729/4f156474/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2199 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140729/4f156474/attachment.bin>


More information about the cfe-dev mailing list