[PATCH] D86802: [Modules] Don't parse/load explicit module maps if modules are disabled

Andrew Gallagher via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 28 12:13:02 PDT 2020


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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86802.288669.patch
Type: text/x-patch
Size: 1094 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200828/41433653/attachment.bin>


More information about the cfe-commits mailing list