Maintain a buffer ID -> source file(s) mapping in the source manager

Now that every source file has a buffer ID, introduce the reverse mapping
so clients can find the source file(s) in their module that reference
that buffer ID.
This commit is contained in:
Doug Gregor
2024-09-17 14:01:58 -07:00
parent 0bd519599f
commit 6f88c228df
3 changed files with 48 additions and 0 deletions

View File

@@ -3446,6 +3446,8 @@ SourceFile::SourceFile(ModuleDecl &M, SourceFileKind K,
(void)problem;
}
M.getASTContext().SourceMgr.recordSourceFile(bufferID, this);
if (Kind == SourceFileKind::MacroExpansion ||
Kind == SourceFileKind::DefaultArgument)
M.addAuxiliaryFile(*this);