Skip to content

Commit 7c57a9b

Browse files
committed
Modules: Simplify how DisableGeneratingGlobalModuleIndex is set, likely NFC
DisableGeneratingGlobalModuleIndex was being set by CompilerInstance::findOrCompileModuleAndReadAST most of (but not all of) the times it returned `nullptr` as a "normal" failure. Pull that up to the caller, CompilerInstance::loadModule, to simplify the code. This resolves a number of FIXMEs added during the refactoring in 5cca622. The extra cases where this is set are all some version of a fatal error, and the only client of the field, shouldBuildGlobalModuleIndex, seems to be unreachable in that case. Even if there is some corner case where this has an effect, it seems like the right/consistent behaviour. Differential Revision: https://reviews.llvm.org/D101672
1 parent 16d0381 commit 7c57a9b

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

clang/lib/Frontend/CompilerInstance.cpp

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1683,7 +1683,6 @@ ModuleLoadResult CompilerInstance::findOrCompileModuleAndReadAST(
16831683
// We can't find a module, error out here.
16841684
getDiagnostics().Report(ModuleNameLoc, diag::err_module_not_found)
16851685
<< ModuleName << SourceRange(ImportLoc, ModuleNameLoc);
1686-
DisableGeneratingGlobalModuleIndex = true;
16871686
return nullptr;
16881687
}
16891688
if (ModuleFilename.empty()) {
@@ -1695,7 +1694,6 @@ ModuleLoadResult CompilerInstance::findOrCompileModuleAndReadAST(
16951694

16961695
getDiagnostics().Report(ModuleNameLoc, diag::err_module_build_disabled)
16971696
<< ModuleName;
1698-
DisableGeneratingGlobalModuleIndex = true;
16991697
return nullptr;
17001698
}
17011699

@@ -1742,7 +1740,6 @@ ModuleLoadResult CompilerInstance::findOrCompileModuleAndReadAST(
17421740
if (*ModuleFile == M->getASTFile())
17431741
return M;
17441742

1745-
DisableGeneratingGlobalModuleIndex = true;
17461743
getDiagnostics().Report(ModuleNameLoc, diag::err_module_prebuilt)
17471744
<< ModuleName;
17481745
return ModuleLoadResult();
@@ -1764,14 +1761,12 @@ ModuleLoadResult CompilerInstance::findOrCompileModuleAndReadAST(
17641761
LLVM_FALLTHROUGH;
17651762
case ASTReader::VersionMismatch:
17661763
case ASTReader::HadErrors:
1767-
// FIXME: Should this set DisableGeneratingGlobalModuleIndex = true?
17681764
ModuleLoader::HadFatalFailure = true;
17691765
// FIXME: The ASTReader will already have complained, but can we shoehorn
17701766
// that diagnostic information into a more useful form?
17711767
return ModuleLoadResult();
17721768

17731769
case ASTReader::Failure:
1774-
// FIXME: Should this set DisableGeneratingGlobalModuleIndex = true?
17751770
ModuleLoader::HadFatalFailure = true;
17761771
return ModuleLoadResult();
17771772
}
@@ -1781,7 +1776,6 @@ ModuleLoadResult CompilerInstance::findOrCompileModuleAndReadAST(
17811776
// We don't know the desired configuration for this module and don't
17821777
// necessarily even have a module map. Since ReadAST already produces
17831778
// diagnostics for these two cases, we simply error out here.
1784-
DisableGeneratingGlobalModuleIndex = true;
17851779
return ModuleLoadResult();
17861780
}
17871781

@@ -1806,7 +1800,6 @@ ModuleLoadResult CompilerInstance::findOrCompileModuleAndReadAST(
18061800

18071801
getDiagnostics().Report(ModuleNameLoc, diag::err_module_cycle)
18081802
<< ModuleName << CyclePath;
1809-
// FIXME: Should this set DisableGeneratingGlobalModuleIndex = true?
18101803
return nullptr;
18111804
}
18121805

@@ -1816,7 +1809,6 @@ ModuleLoadResult CompilerInstance::findOrCompileModuleAndReadAST(
18161809
getPreprocessorOpts().FailedModules->hasAlreadyFailed(ModuleName)) {
18171810
getDiagnostics().Report(ModuleNameLoc, diag::err_module_not_built)
18181811
<< ModuleName << SourceRange(ImportLoc, ModuleNameLoc);
1819-
DisableGeneratingGlobalModuleIndex = true;
18201812
return nullptr;
18211813
}
18221814

@@ -1827,7 +1819,6 @@ ModuleLoadResult CompilerInstance::findOrCompileModuleAndReadAST(
18271819
"undiagnosed error in compileModuleAndReadAST");
18281820
if (getPreprocessorOpts().FailedModules)
18291821
getPreprocessorOpts().FailedModules->addFailed(ModuleName);
1830-
DisableGeneratingGlobalModuleIndex = true;
18311822
return nullptr;
18321823
}
18331824

@@ -1878,11 +1869,10 @@ CompilerInstance::loadModule(SourceLocation ImportLoc,
18781869
} else {
18791870
ModuleLoadResult Result = findOrCompileModuleAndReadAST(
18801871
ModuleName, ImportLoc, ModuleNameLoc, IsInclusionDirective);
1881-
// FIXME: Can we pull 'DisableGeneratingGlobalModuleIndex = true' out of
1882-
// the return sequences for findOrCompileModuleAndReadAST and do it here
1883-
// (as long as the result is not a config mismatch)? See FIXMEs there.
18841872
if (!Result.isNormal())
18851873
return Result;
1874+
if (!Result)
1875+
DisableGeneratingGlobalModuleIndex = true;
18861876
Module = Result;
18871877
MM.cacheModuleLoad(*Path[0].first, Module);
18881878
}

0 commit comments

Comments
 (0)