summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2019-11-04 11:10:09 -0800
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2019-11-04 11:40:03 -0800
commit8112a423a8ede9bce64b6553e6451bf10995105c (patch)
tree75e9affbe6879664d46600a409e5aa62ed3f9f7c
parentb2b6a54f847f33f821f41e3e82bf3b86e08817a0 (diff)
downloadbcm5719-llvm-8112a423a8ede9bce64b6553e6451bf10995105c.tar.gz
bcm5719-llvm-8112a423a8ede9bce64b6553e6451bf10995105c.zip
clang/Modules: Bring back optimization lost in 31e14f41a21f
31e14f41a21f9016050a20f07d5da03db2e8c13e accidentally dropped caching of failed module loads. This brings it back by making ModuleMap::getCachedModuleLoad return an Optional.
-rw-r--r--clang/include/clang/Lex/ModuleMap.h7
-rw-r--r--clang/lib/Frontend/CompilerInstance.cpp7
2 files changed, 9 insertions, 5 deletions
diff --git a/clang/include/clang/Lex/ModuleMap.h b/clang/include/clang/Lex/ModuleMap.h
index 3110ead8601..1e6b28d4aa3 100644
--- a/clang/include/clang/Lex/ModuleMap.h
+++ b/clang/include/clang/Lex/ModuleMap.h
@@ -696,8 +696,11 @@ public:
}
/// Return a cached module load.
- Module *getCachedModuleLoad(const IdentifierInfo &II) {
- return CachedModuleLoads.lookup(&II);
+ llvm::Optional<Module *> getCachedModuleLoad(const IdentifierInfo &II) {
+ auto I = CachedModuleLoads.find(&II);
+ if (I == CachedModuleLoads.end())
+ return None;
+ return I->second;
}
};
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp
index cc3d848c1e0..a0663217453 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -1633,10 +1633,11 @@ CompilerInstance::loadModule(SourceLocation ImportLoc,
}
// If we don't already have information on this module, load the module now.
+ Module *Module = nullptr;
ModuleMap &MM = getPreprocessor().getHeaderSearchInfo().getModuleMap();
- clang::Module *Module = MM.getCachedModuleLoad(*Path[0].first);
- if (Module) {
- // Nothing to do here, we found it.
+ if (auto MaybeModule = MM.getCachedModuleLoad(*Path[0].first)) {
+ // Use the cached result, which may be nullptr.
+ Module = *MaybeModule;
} else if (ModuleName == getLangOpts().CurrentModule) {
// This is the module we're building.
Module = PP->getHeaderSearchInfo().lookupModule(
OpenPOWER on IntegriCloud