sammccall added inline comments.

================
Comment at: clang-tools-extra/clangd/Headers.h:61
   SrcMgr::CharacteristicKind FileKind = SrcMgr::C_User;
+  FileID ID;
 };
----------------
Most includes are part of the preamble, so there are two relevant parse actions 
(preamble, and mainfile-using-preamble). Each has its own SourceManager and 
therefore namespace of FileIDs.

There's no rule that says a header gets the same FileID when a preamble is 
used. As written, RecordHeaders is assigning Inclusion::ID based on the 
preamble, and then we end up comparing it to FileIDs from 
compareUnusedIncludes().

From reading the ASTReader code, I *believe* that there's a simple offset 
between the two: e.g. that if a preamble uses FileIDs from 1-100, then these 
might be mapped to FileIDs 1501-1600 when that preamble is reused. We could go 
down the path of exploiting this. (Though we need to investigate the details 
and think a little about how it works with modules).

The somewhat less-coupled alternative we use today is to use the 
FileEntry::Name as documented in the private section of IncludeStructure. There 
are a few ways to build on top of this - basically we're either going to do 
most calculations in FileID space, or expose a "stable file index" from 
IncludeStructure and do most calculations in that space...


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D108194/new/

https://reviews.llvm.org/D108194

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to