summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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