From 23e9146fba298d38142337b615e17067fb8ccb91 Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Fri, 30 Apr 2021 15:09:09 -0700 Subject: [PATCH] Modules: Rename ModuleBuildFailed => DisableGeneratingGlobalModuleIndex, NFC Rename CompilerInstance's ModuleBuildFailed field to DisableGeneratingGlobalModuleIndex, which more precisely describes its role. Otherwise, it's hard to suss out how it's different from ModuleLoader::HadFatalFailure, and what sort of code simplifications are safe. Differential Revision: https://reviews.llvm.org/D101670 --- clang/include/clang/Frontend/CompilerInstance.h | 2 +- clang/lib/Frontend/CompilerInstance.cpp | 28 ++++++++++++------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/clang/include/clang/Frontend/CompilerInstance.h b/clang/include/clang/Frontend/CompilerInstance.h index 54d5701..7778924 100644 --- a/clang/include/clang/Frontend/CompilerInstance.h +++ b/clang/include/clang/Frontend/CompilerInstance.h @@ -150,7 +150,7 @@ class CompilerInstance : public ModuleLoader { bool HaveFullGlobalModuleIndex = false; /// One or more modules failed to build. - bool ModuleBuildFailed = false; + bool DisableGeneratingGlobalModuleIndex = false; /// The stream for verbose output if owned, otherwise nullptr. std::unique_ptr OwnedVerboseOutputStream; diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index 695c7e3..54917b3 100644 --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/lib/Frontend/CompilerInstance.cpp @@ -77,7 +77,7 @@ bool CompilerInstance::shouldBuildGlobalModuleIndex() const { return (BuildGlobalModuleIndex || (TheASTReader && TheASTReader->isGlobalIndexUnavailable() && getFrontendOpts().GenerateGlobalModuleIndex)) && - !ModuleBuildFailed; + !DisableGeneratingGlobalModuleIndex; } void CompilerInstance::setDiagnostics(DiagnosticsEngine *Value) { @@ -1683,7 +1683,7 @@ ModuleLoadResult CompilerInstance::findOrCompileModuleAndReadAST( // We can't find a module, error out here. getDiagnostics().Report(ModuleNameLoc, diag::err_module_not_found) << ModuleName << SourceRange(ImportLoc, ModuleNameLoc); - ModuleBuildFailed = true; + DisableGeneratingGlobalModuleIndex = true; return nullptr; } if (ModuleFilename.empty()) { @@ -1695,7 +1695,7 @@ ModuleLoadResult CompilerInstance::findOrCompileModuleAndReadAST( getDiagnostics().Report(ModuleNameLoc, diag::err_module_build_disabled) << ModuleName; - ModuleBuildFailed = true; + DisableGeneratingGlobalModuleIndex = true; return nullptr; } @@ -1742,7 +1742,7 @@ ModuleLoadResult CompilerInstance::findOrCompileModuleAndReadAST( if (*ModuleFile == M->getASTFile()) return M; - ModuleBuildFailed = true; + DisableGeneratingGlobalModuleIndex = true; getDiagnostics().Report(ModuleNameLoc, diag::err_module_prebuilt) << ModuleName; return ModuleLoadResult(); @@ -1764,14 +1764,14 @@ ModuleLoadResult CompilerInstance::findOrCompileModuleAndReadAST( LLVM_FALLTHROUGH; case ASTReader::VersionMismatch: case ASTReader::HadErrors: - // FIXME: Should this set ModuleBuildFailed = true? + // FIXME: Should this set DisableGeneratingGlobalModuleIndex = true? ModuleLoader::HadFatalFailure = true; // FIXME: The ASTReader will already have complained, but can we shoehorn // that diagnostic information into a more useful form? return ModuleLoadResult(); case ASTReader::Failure: - // FIXME: Should this set ModuleBuildFailed = true? + // FIXME: Should this set DisableGeneratingGlobalModuleIndex = true? ModuleLoader::HadFatalFailure = true; return ModuleLoadResult(); } @@ -1781,7 +1781,7 @@ ModuleLoadResult CompilerInstance::findOrCompileModuleAndReadAST( // We don't know the desired configuration for this module and don't // necessarily even have a module map. Since ReadAST already produces // diagnostics for these two cases, we simply error out here. - ModuleBuildFailed = true; + DisableGeneratingGlobalModuleIndex = true; return ModuleLoadResult(); } @@ -1806,7 +1806,7 @@ ModuleLoadResult CompilerInstance::findOrCompileModuleAndReadAST( getDiagnostics().Report(ModuleNameLoc, diag::err_module_cycle) << ModuleName << CyclePath; - // FIXME: Should this set ModuleBuildFailed = true? + // FIXME: Should this set DisableGeneratingGlobalModuleIndex = true? return nullptr; } @@ -1816,7 +1816,7 @@ ModuleLoadResult CompilerInstance::findOrCompileModuleAndReadAST( getPreprocessorOpts().FailedModules->hasAlreadyFailed(ModuleName)) { getDiagnostics().Report(ModuleNameLoc, diag::err_module_not_built) << ModuleName << SourceRange(ImportLoc, ModuleNameLoc); - ModuleBuildFailed = true; + DisableGeneratingGlobalModuleIndex = true; return nullptr; } @@ -1827,7 +1827,7 @@ ModuleLoadResult CompilerInstance::findOrCompileModuleAndReadAST( "undiagnosed error in compileModuleAndReadAST"); if (getPreprocessorOpts().FailedModules) getPreprocessorOpts().FailedModules->addFailed(ModuleName); - ModuleBuildFailed = true; + DisableGeneratingGlobalModuleIndex = true; return nullptr; } @@ -1871,16 +1871,16 @@ CompilerInstance::loadModule(SourceLocation ImportLoc, //if (Module == nullptr) { // getDiagnostics().Report(ModuleNameLoc, diag::err_module_not_found) // << ModuleName; - // ModuleBuildFailed = true; + // DisableGeneratingGlobalModuleIndex = true; // return ModuleLoadResult(); //} MM.cacheModuleLoad(*Path[0].first, Module); } else { ModuleLoadResult Result = findOrCompileModuleAndReadAST( ModuleName, ImportLoc, ModuleNameLoc, IsInclusionDirective); - // FIXME: Can we pull 'ModuleBuildFailed = true' out of the return - // sequences for findOrCompileModuleAndReadAST and do it here (as long as - // the result is not a config mismatch)? See FIXMEs there. + // FIXME: Can we pull 'DisableGeneratingGlobalModuleIndex = true' out of + // the return sequences for findOrCompileModuleAndReadAST and do it here + // (as long as the result is not a config mismatch)? See FIXMEs there. if (!Result.isNormal()) return Result; Module = Result; -- 2.7.4