[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
Tue Sep 1 11:38:22 PDT 2020
andrewjcg updated this revision to Diff 289236.
andrewjcg added a comment.
simplify test
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D86802/new/
https://reviews.llvm.org/D86802
Files:
clang/lib/Frontend/FrontendAction.cpp
clang/test/Modules/explicit-module-maps.cpp
Index: clang/test/Modules/explicit-module-maps.cpp
===================================================================
--- /dev/null
+++ clang/test/Modules/explicit-module-maps.cpp
@@ -0,0 +1,8 @@
+// Test that an explicit module map (which fails to parse/load in this case)
+// isn't used if modules aren't enabled.
+
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo 'DOES NOT PARSE!' > %t/invalid.modulemap
+// RUN: %clang_cc1 -fmodule-map-file=%t/invalid.modulemap -verify %s
+// expected-no-diagnostics
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.289236.patch
Type: text/x-patch
Size: 1603 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200901/fd17c5f4/attachment-0001.bin>
More information about the cfe-commits
mailing list