diff options
author | Douglas Gregor <dgregor@apple.com> | 2013-01-25 00:45:27 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2013-01-25 00:45:27 +0000 |
commit | c1bbec85a87c9a929b1814a0b316ed28e6e224af (patch) | |
tree | 52553ca2fa5983fd631cf24de2c553baecd96384 /clang/lib/Frontend/CompilerInstance.cpp | |
parent | 00a50f742a5f7c4d95645558d3e7f961f4613a71 (diff) | |
download | bcm5719-llvm-c1bbec85a87c9a929b1814a0b316ed28e6e224af.tar.gz bcm5719-llvm-c1bbec85a87c9a929b1814a0b316ed28e6e224af.zip |
Rename the -cc1 option "-generate-module-index" to
"-fmodules-global-index" and expand its behavior to include both the
use and generation of the global module index.
llvm-svn: 173404
Diffstat (limited to 'clang/lib/Frontend/CompilerInstance.cpp')
-rw-r--r-- | clang/lib/Frontend/CompilerInstance.cpp | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index 07c0248b6c3..0e60c399220 100644 --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/lib/Frontend/CompilerInstance.cpp @@ -49,7 +49,7 @@ using namespace clang; CompilerInstance::CompilerInstance() : Invocation(new CompilerInvocation()), ModuleManager(0), - BuildGlobalModuleIndex(false) { + BuildGlobalModuleIndex(false), ModuleBuildFailed(false) { } CompilerInstance::~CompilerInstance() { @@ -60,6 +60,10 @@ void CompilerInstance::setInvocation(CompilerInvocation *Value) { Invocation = Value; } +bool CompilerInstance::shouldBuildGlobalModuleIndex() const { + return BuildGlobalModuleIndex && !ModuleBuildFailed; +} + void CompilerInstance::setDiagnostics(DiagnosticsEngine *Value) { Diagnostics = Value; } @@ -290,7 +294,8 @@ void CompilerInstance::createPCHExternalASTSource(StringRef Path, AllowPCHWithCompilerErrors, getPreprocessor(), getASTContext(), DeserializationListener, - Preamble)); + Preamble, + getFrontendOpts().UseGlobalModuleIndex)); ModuleManager = static_cast<ASTReader*>(Source.get()); getASTContext().setExternalSource(Source); } @@ -303,12 +308,14 @@ CompilerInstance::createPCHExternalASTSource(StringRef Path, Preprocessor &PP, ASTContext &Context, void *DeserializationListener, - bool Preamble) { + bool Preamble, + bool UseGlobalModuleIndex) { OwningPtr<ASTReader> Reader; Reader.reset(new ASTReader(PP, Context, Sysroot.empty() ? "" : Sysroot.c_str(), DisablePCHValidation, - AllowPCHWithCompilerErrors)); + AllowPCHWithCompilerErrors, + UseGlobalModuleIndex)); Reader->setDeserializationListener( static_cast<ASTDeserializationListener *>(DeserializationListener)); @@ -786,7 +793,7 @@ static void compileModule(CompilerInstance &ImportingInstance, FrontendOptions &FrontendOpts = Invocation->getFrontendOpts(); FrontendOpts.OutputFile = ModuleFileName.str(); FrontendOpts.DisableFree = false; - FrontendOpts.GenerateModuleIndex = false; + FrontendOpts.GenerateGlobalModuleIndex = false; FrontendOpts.Inputs.clear(); InputKind IK = getSourceInputKindFromOptions(*Invocation->getLangOpts()); @@ -863,7 +870,7 @@ static void compileModule(CompilerInstance &ImportingInstance, // We've rebuilt a module. If we're allowed to generate or update the global // module index, record that fact in the importing compiler instance. - if (ImportingInstance.getFrontendOpts().GenerateModuleIndex) { + if (ImportingInstance.getFrontendOpts().GenerateGlobalModuleIndex) { ImportingInstance.setBuildGlobalModuleIndex(true); } } @@ -953,7 +960,7 @@ CompilerInstance::loadModule(SourceLocation ImportLoc, getDiagnostics().Report(ModuleNameLoc, diag::err_module_not_built) << ModuleName << SourceRange(ImportLoc, ModuleNameLoc); - + ModuleBuildFailed = true; return ModuleLoadResult(); } @@ -971,6 +978,7 @@ CompilerInstance::loadModule(SourceLocation ImportLoc, : diag::err_module_not_found) << ModuleName << SourceRange(ImportLoc, ModuleNameLoc); + ModuleBuildFailed = true; return ModuleLoadResult(); } @@ -983,7 +991,9 @@ CompilerInstance::loadModule(SourceLocation ImportLoc, const PreprocessorOptions &PPOpts = getPreprocessorOpts(); ModuleManager = new ASTReader(getPreprocessor(), *Context, Sysroot.empty() ? "" : Sysroot.c_str(), - PPOpts.DisablePCHValidation); + PPOpts.DisablePCHValidation, + /*AllowASTWithCompilerErrors=*/false, + getFrontendOpts().UseGlobalModuleIndex); if (hasASTConsumer()) { ModuleManager->setDeserializationListener( getASTConsumer().GetASTDeserializationListener()); @@ -1024,6 +1034,7 @@ CompilerInstance::loadModule(SourceLocation ImportLoc, getDiagnostics().Report(ModuleNameLoc, diag::err_module_not_built) << ModuleName << SourceRange(ImportLoc, ModuleNameLoc); + ModuleBuildFailed = true; return ModuleLoadResult(); } @@ -1039,6 +1050,7 @@ CompilerInstance::loadModule(SourceLocation ImportLoc, if (getPreprocessorOpts().FailedModules) getPreprocessorOpts().FailedModules->addFailed(ModuleName); KnownModules[Path[0].first] = 0; + ModuleBuildFailed = true; return ModuleLoadResult(); } @@ -1057,6 +1069,7 @@ CompilerInstance::loadModule(SourceLocation ImportLoc, case ASTReader::Failure: // Already complained, but note now that we failed. KnownModules[Path[0].first] = 0; + ModuleBuildFailed = true; return ModuleLoadResult(); } |