[clang] [clang][modules] Avoid calling expensive `SourceManager::translateFile()` (PR #86216)

Ben Langmuir via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 25 14:38:12 PDT 2024


================
@@ -1337,9 +1337,24 @@ static bool compileModule(CompilerInstance &ImportingInstance,
   // Get or create the module map that we'll use to build this module.
   ModuleMap &ModMap
     = ImportingInstance.getPreprocessor().getHeaderSearchInfo().getModuleMap();
+  SourceManager &SourceMgr = ImportingInstance.getSourceManager();
   bool Result;
-  if (OptionalFileEntryRef ModuleMapFile =
-          ModMap.getContainingModuleMapFile(Module)) {
+  if (FileID ModuleMapFID = ModMap.getContainingModuleMapFileID(Module);
+      ModuleMapFID.isValid()) {
+    // We want to use the top-level module map. If we don't, the compiling
----------------
benlangmuir wrote:

What is the connection between this change and the rest of the commit?

https://github.com/llvm/llvm-project/pull/86216


More information about the cfe-commits mailing list