Moved loading of -fmodule-map-file files to HeaderSearch initialization in 
Preprocessor initialization.
Changed diagnostic to an error.

http://reviews.llvm.org/D6324

Files:
  include/clang/Basic/DiagnosticLexKinds.td
  lib/Lex/HeaderSearch.cpp
  test/Modules/pr21217.cpp
Index: test/Modules/pr21217.cpp
===================================================================
--- test/Modules/pr21217.cpp
+++ test/Modules/pr21217.cpp
@@ -0,0 +1,6 @@
+// RUN: not %clang_cc1 -fmodules -fmodule-map-file=does-not-exist.modulemap -verify %s 2>&1 | \
+// RUN: FileCheck %s
+
+// CHECK: File 'does-not-exist.modulemap' specified via -fmodule-map-file not found
+
+#include "Inputs/private/common.h"
Index: include/clang/Basic/DiagnosticLexKinds.td
===================================================================
--- include/clang/Basic/DiagnosticLexKinds.td
+++ include/clang/Basic/DiagnosticLexKinds.td
@@ -550,6 +550,8 @@
   ShowInSystemHeader, DefaultIgnore, InGroup<DiagGroup<"date-time">>;
 
 // Module map parsing
+def err_module_map_opt_not_found : Error<
+  "File '%0' specified via -fmodule-map-file not found">;
 def err_mmap_unknown_token : Error<"skipping stray token">;
 def err_mmap_expected_module : Error<"expected module declaration">;
 def err_mmap_expected_module_name : Error<"expected module name">;
Index: lib/Lex/HeaderSearch.cpp
===================================================================
--- lib/Lex/HeaderSearch.cpp
+++ lib/Lex/HeaderSearch.cpp
@@ -62,6 +62,20 @@
   NumFrameworkLookups = NumSubFrameworkLookups = 0;
 
   EnabledModules = LangOpts.Modules;
+
+  if (!HSOpts->ModuleMapFiles.empty()) {
+	  // Preload all explicitly specified module map files. This enables modules
+	  // map files lying in a directory structure separate from the header files
+	  // that they describe. These cannot be loaded lazily upon encountering a
+	  // header file, as there is no other known mapping from a header file to its
+	  // module map file.
+	  for (const auto &Filename : HSOpts->ModuleMapFiles)
+	  if (const FileEntry *File = FileMgr.getFile(Filename))
+		  loadModuleMapFile(File, /*IsSystem=*/false);
+	  else
+		  Diags.Report(diag::err_module_map_opt_not_found) << Filename;
+	  HSOpts->ModuleMapFiles.clear();
+  }
 }
 
 HeaderSearch::~HeaderSearch() {
@@ -569,18 +583,6 @@
     ArrayRef<std::pair<const FileEntry *, const DirectoryEntry *>> Includers,
     SmallVectorImpl<char> *SearchPath, SmallVectorImpl<char> *RelativePath,
     ModuleMap::KnownHeader *SuggestedModule, bool SkipCache) {
-  if (!HSOpts->ModuleMapFiles.empty()) {
-    // Preload all explicitly specified module map files. This enables modules
-    // map files lying in a directory structure separate from the header files
-    // that they describe. These cannot be loaded lazily upon encountering a
-    // header file, as there is no other known mapping from a header file to its
-    // module map file.
-    for (const auto &Filename : HSOpts->ModuleMapFiles)
-      if (const FileEntry *File = FileMgr.getFile(Filename))
-        loadModuleMapFile(File, /*IsSystem=*/false);
-    HSOpts->ModuleMapFiles.clear();
-  }
-
   if (SuggestedModule)
     *SuggestedModule = ModuleMap::KnownHeader();
     
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to