r226882 - PR22299: Relocate code for handling -fmodule-map-file= so that we don't try to

Richard Smith richard-llvm at metafoo.co.uk
Thu Jan 22 16:01:14 PST 2015


Author: rsmith
Date: Thu Jan 22 18:01:13 2015
New Revision: 226882

URL: http://llvm.org/viewvc/llvm-project?rev=226882&view=rev
Log:
PR22299: Relocate code for handling -fmodule-map-file= so that we don't try to
produce diagnostics with source locations before the diagnostics system is
ready for them.

Added:
    cfe/trunk/test/Modules/diagnostics.modulemap
Modified:
    cfe/trunk/lib/Frontend/CompilerInstance.cpp
    cfe/trunk/lib/Frontend/FrontendAction.cpp

Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=226882&r1=226881&r2=226882&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Thu Jan 22 18:01:13 2015
@@ -371,14 +371,6 @@ void CompilerInstance::createPreprocesso
     AttachHeaderIncludeGen(*PP, /*ShowAllHeaders=*/false, /*OutputPath=*/"",
                            /*ShowDepth=*/true, /*MSStyle=*/true);
   }
-
-  // Load all explictly-specified module map files.
-  for (const auto &Filename : getFrontendOpts().ModuleMapFiles) {
-    if (auto *File = getFileManager().getFile(Filename))
-      PP->getHeaderSearchInfo().loadModuleMapFile(File, /*IsSystem*/false);
-    else
-      getDiagnostics().Report(diag::err_module_map_not_found) << Filename;
-  }
 }
 
 // ASTContext

Modified: cfe/trunk/lib/Frontend/FrontendAction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendAction.cpp?rev=226882&r1=226881&r2=226882&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/FrontendAction.cpp (original)
+++ cfe/trunk/lib/Frontend/FrontendAction.cpp Thu Jan 22 18:01:13 2015
@@ -383,6 +383,15 @@ bool FrontendAction::BeginSourceFile(Com
            "doesn't support modules");
   }
 
+  // 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 we were asked to load any module files, do so now.
   for (const auto &ModuleFile : CI.getFrontendOpts().ModuleFiles)
     if (!CI.loadModuleFile(ModuleFile))

Added: cfe/trunk/test/Modules/diagnostics.modulemap
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/diagnostics.modulemap?rev=226882&view=auto
==============================================================================
--- cfe/trunk/test/Modules/diagnostics.modulemap (added)
+++ cfe/trunk/test/Modules/diagnostics.modulemap Thu Jan 22 18:01:13 2015
@@ -0,0 +1,8 @@
+// RUN: cp %s %t-duplicate.modulemap
+// RUN: not %clang_cc1 -fmodules -fmodules-cache-path=%t -fmodule-map-file=%s -fmodule-map-file=%t-duplicate.modulemap -fsyntax-only -x c++ /dev/null 2>&1 | FileCheck --check-prefix=CHECK-DUPLICATE %s
+
+// PR22299: Ensure we can produce diagnostics for duplicate modules from -fmodule-map-file=.
+//
+// CHECK-DUPLICATE: duplicate.modulemap:[[@LINE+2]]:8: error: redefinition of module 'foo'
+// CHECK-DUPLICATE: diagnostics.modulemap:[[@LINE+1]]:8: note: previously defined here
+module foo {}





More information about the cfe-commits mailing list