From d520a250b6525be399c732871cdacbfcc335bbc5 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Tue, 21 Jul 2015 18:07:47 +0000 Subject: [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 --- clang/lib/Frontend/CompilerInstance.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'clang/lib/Frontend/CompilerInstance.cpp') 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(); -- cgit v1.2.3