================
@@ -5589,6 +5596,20 @@ void ASTWriter::computeNonAffectingInputFiles() {
auto AffectingModuleMaps = GetAffectingModuleMaps(*PP, WritingModule);
+ // A FileID is serialized as an index into this module's SLoc table, so
+ // collect the local files named by records written below. The invalid FileID
+ // cannot be stored in a DenseSet, so skip it.
+ llvm::DenseSet<FileID> NamedFileIDs;
+ if (SrcMgr.getMainFileID().isValid())
+ NamedFileIDs.insert(SrcMgr.getMainFileID());
+ if (SrcMgr.hasLineTable())
+ for (const auto &L : SrcMgr.getLineTable())
+ if (L.first.ID > 0)
+ NamedFileIDs.insert(L.first);
+ for (const auto &F : PP->getDiagnostics().DiagStatesByLoc.Files)
+ if (F.first.isValid() && F.second.HasLocalTransitions)
+ NamedFileIDs.insert(F.first);
----------------
ayokunle321 wrote:
The three functions that put a FileID in a record are ASTWriter::AddFileID,
WriteInputFiles and WriteSubmodules.
WriteInputFiles only runs for affecting files so it never has to worry about
dropped files.
WriteSubmodules only names module maps which are only dropped and not
redirected.
Which leaves us with `ASTWriter::AddFileID` and its called three times for the
main file, the line table, and the diagstates.
I don't think there's any way we can automatically register these. Not sure if
a comment will suffice.
https://github.com/llvm/llvm-project/pull/209795
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits