[clang] [clang][modules] Lazily load by name lookups in module maps (PR #132853)
Michael Spencer via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 3 13:01:13 PDT 2025
================
@@ -2128,9 +2245,16 @@ bool ModuleMap::loadModuleMapFile(FileEntryRef File, bool IsSystem,
// If the module map file wasn't already entered, do so now.
if (ID.isInvalid()) {
- auto FileCharacter =
- IsSystem ? SrcMgr::C_System_ModuleMap : SrcMgr::C_User_ModuleMap;
- ID = SourceMgr.createFileID(File, ExternModuleLoc, FileCharacter);
+ ID = SourceMgr.translateFile(File);
+ // TODO: The way we compute affecting module maps requires this to be a
+ // local FileID. This should be changed to reuse loaded FileIDs when
+ // available, and change the way that affecting module maps are
+ // computed to not require this.
+ if (ID.isInvalid() || SourceMgr.isLoadedFileID(ID)) {
----------------
Bigcheese wrote:
Yeah, the preference is that we don't create new SourceManager entries for a file as that takes up SLoc space and has a tiny bit of serialization overhead. The TODO is to remove the `isLoadedFileID()` and otherwise ensure that we never create extra FileIDs.
https://github.com/llvm/llvm-project/pull/132853
More information about the cfe-commits
mailing list