andrewjcg created this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits. andrewjcg requested review of this revision.
In some build environments/systems, flags for explicit module map files may be propagated up to dependents which may not choose to enable use of modules (e.g. if a particular compilation doesn't currently work in modular builds). In this case, the explicit module files are still passed, even though they're not used (and can trigger additional I/O at header search path, like realpath'ing include roots if an explicit module map contains a umbrella dir). This diff avoids parsing/loading these module map files if modules haven't been enabled. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D86802 Files: clang/lib/Frontend/FrontendAction.cpp Index: clang/lib/Frontend/FrontendAction.cpp =================================================================== --- clang/lib/Frontend/FrontendAction.cpp +++ clang/lib/Frontend/FrontendAction.cpp @@ -807,12 +807,14 @@ goto failure; // If we were asked to load any module map files, do so now. - for (const auto &Filename : CI.getFrontendOpts().ModuleMapFiles) { - if (auto File = CI.getFileManager().getFile(Filename)) - CI.getPreprocessor().getHeaderSearchInfo().loadModuleMapFile( - *File, /*IsSystem*/false); - else - CI.getDiagnostics().Report(diag::err_module_map_not_found) << Filename; + if (CI.getLangOpts().Modules) { + for (const auto &Filename : CI.getFrontendOpts().ModuleMapFiles) { + if (auto File = CI.getFileManager().getFile(Filename)) + CI.getPreprocessor().getHeaderSearchInfo().loadModuleMapFile( + *File, /*IsSystem*/ false); + else + CI.getDiagnostics().Report(diag::err_module_map_not_found) << Filename; + } } // Add a module declaration scope so that modules from -fmodule-map-file
Index: clang/lib/Frontend/FrontendAction.cpp =================================================================== --- clang/lib/Frontend/FrontendAction.cpp +++ clang/lib/Frontend/FrontendAction.cpp @@ -807,12 +807,14 @@ goto failure; // If we were asked to load any module map files, do so now. - for (const auto &Filename : CI.getFrontendOpts().ModuleMapFiles) { - if (auto File = CI.getFileManager().getFile(Filename)) - CI.getPreprocessor().getHeaderSearchInfo().loadModuleMapFile( - *File, /*IsSystem*/false); - else - CI.getDiagnostics().Report(diag::err_module_map_not_found) << Filename; + if (CI.getLangOpts().Modules) { + for (const auto &Filename : CI.getFrontendOpts().ModuleMapFiles) { + if (auto File = CI.getFileManager().getFile(Filename)) + CI.getPreprocessor().getHeaderSearchInfo().loadModuleMapFile( + *File, /*IsSystem*/ false); + else + CI.getDiagnostics().Report(diag::err_module_map_not_found) << Filename; + } } // Add a module declaration scope so that modules from -fmodule-map-file
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits