r242819 - [modules] Produce an error if -cc1 wants to implicitly build a module and no

Richard Smith richard-llvm at metafoo.co.uk
Tue Jul 21 11:07:47 PDT 2015


Author: rsmith
Date: Tue Jul 21 13:07:47 2015
New Revision: 242819

URL: http://llvm.org/viewvc/llvm-project?rev=242819&view=rev
Log:
[modules] Produce an error if -cc1 wants to implicitly build a module and no
module cache has been provided, rather than creating one in the current
directory.

Modified:
    cfe/trunk/lib/Frontend/CompilerInstance.cpp
    cfe/trunk/lib/Lex/HeaderSearch.cpp
    cfe/trunk/test/Modules/no-implicit-builds.cpp

Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=242819&r1=242818&r2=242819&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Tue Jul 21 13:07:47 2015
@@ -372,9 +372,8 @@ void CompilerInstance::createPreprocesso
 std::string CompilerInstance::getSpecificModuleCachePath() {
   // Set up the module path, including the hash for the
   // module-creation options.
-  SmallString<256> SpecificModuleCache(
-                           getHeaderSearchOpts().ModuleCachePath);
-  if (!getHeaderSearchOpts().DisableModuleHash)
+  SmallString<256> SpecificModuleCache(getHeaderSearchOpts().ModuleCachePath);
+  if (!SpecificModuleCache.empty() && !getHeaderSearchOpts().DisableModuleHash)
     llvm::sys::path::append(SpecificModuleCache,
                             getInvocation().getModuleHash());
   return SpecificModuleCache.str();
@@ -1406,17 +1405,17 @@ CompilerInstance::loadModule(SourceLocat
 
     auto Override = ModuleFileOverrides.find(ModuleName);
     bool Explicit = Override != ModuleFileOverrides.end();
-    if (!Explicit && !getLangOpts().ImplicitModules) {
+
+    std::string ModuleFileName =
+        Explicit ? Override->second
+                 : PP->getHeaderSearchInfo().getModuleFileName(Module);
+    if (ModuleFileName.empty()) {
       getDiagnostics().Report(ModuleNameLoc, diag::err_module_build_disabled)
           << ModuleName;
       ModuleBuildFailed = true;
       return ModuleLoadResult();
     }
 
-    std::string ModuleFileName =
-        Explicit ? Override->second
-                 : PP->getHeaderSearchInfo().getModuleFileName(Module);
-
     // If we don't already have an ASTReader, create one now.
     if (!ModuleManager)
       createModuleManager();

Modified: cfe/trunk/lib/Lex/HeaderSearch.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=242819&r1=242818&r2=242819&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/HeaderSearch.cpp (original)
+++ cfe/trunk/lib/Lex/HeaderSearch.cpp Tue Jul 21 13:07:47 2015
@@ -127,8 +127,9 @@ std::string HeaderSearch::getModuleFileN
 
 std::string HeaderSearch::getModuleFileName(StringRef ModuleName,
                                             StringRef ModuleMapPath) {
-  // If we don't have a module cache path, we can't do anything.
-  if (ModuleCachePath.empty()) 
+  // If we don't have a module cache path or aren't supposed to use one, we
+  // can't do anything.
+  if (ModuleCachePath.empty() || !LangOpts.ImplicitModules) 
     return std::string();
 
   SmallString<256> Result(ModuleCachePath);

Modified: cfe/trunk/test/Modules/no-implicit-builds.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/no-implicit-builds.cpp?rev=242819&r1=242818&r2=242819&view=diff
==============================================================================
--- cfe/trunk/test/Modules/no-implicit-builds.cpp (original)
+++ cfe/trunk/test/Modules/no-implicit-builds.cpp Tue Jul 21 13:07:47 2015
@@ -4,6 +4,11 @@
 // RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t \
 // RUN:     -fmodule-map-file=%S/Inputs/no-implicit-builds/b.modulemap \
 // RUN:     -fno-implicit-modules %s -verify
+//
+// Same thing if we're running -cc1 and no module cache path has been provided.
+// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fimplicit-module-maps \
+// RUN:     -fmodule-map-file=%S/Inputs/no-implicit-builds/b.modulemap \
+// RUN:     %s -verify
 
 // Compile the module and put it into the cache.
 // RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t \





More information about the cfe-commits mailing list