summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2015-07-21 18:07:47 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2015-07-21 18:07:47 +0000
commitd520a250b6525be399c732871cdacbfcc335bbc5 (patch)
tree3c078b81efcb4b50d50befd15b0e8075bcc756ff
parentbd05101e67f975ef4a42585b732ee03d135645d2 (diff)
downloadbcm5719-llvm-d520a250b6525be399c732871cdacbfcc335bbc5.tar.gz
bcm5719-llvm-d520a250b6525be399c732871cdacbfcc335bbc5.zip
[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. llvm-svn: 242819
-rw-r--r--clang/lib/Frontend/CompilerInstance.cpp15
-rw-r--r--clang/lib/Lex/HeaderSearch.cpp5
-rw-r--r--clang/test/Modules/no-implicit-builds.cpp5
3 files changed, 15 insertions, 10 deletions
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp
index c33b150e304..9da69d47664 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -372,9 +372,8 @@ void CompilerInstance::createPreprocessor(TranslationUnitKind TUKind) {
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(SourceLocation ImportLoc,
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();
diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index 983dc18b57a..5282e8d42e8 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -127,8 +127,9 @@ std::string HeaderSearch::getModuleFileName(Module *Module) {
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);
diff --git a/clang/test/Modules/no-implicit-builds.cpp b/clang/test/Modules/no-implicit-builds.cpp
index bfc3562dbcf..374ed5e4181 100644
--- a/clang/test/Modules/no-implicit-builds.cpp
+++ b/clang/test/Modules/no-implicit-builds.cpp
@@ -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 \
OpenPOWER on IntegriCloud