aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CompilerInstance.cpp
diff options
context:
space:
mode:
authorAlexandre Rames <arames@apple.com>2020-11-10 09:21:05 -0800
committerAlexandre Rames <arames@apple.com>2020-11-10 10:14:13 -0800
commit58c586e701889250c08285193dc75d94a7ed302d (patch)
tree58dd2a00fd9e9a5f3faf1d8d5f76d2969b64f981 /clang/lib/Frontend/CompilerInstance.cpp
parentae032e2714675354457c474f4c8f5581714e33d1 (diff)
downloadllvm-58c586e701889250c08285193dc75d94a7ed302d.zip
llvm-58c586e701889250c08285193dc75d94a7ed302d.tar.gz
llvm-58c586e701889250c08285193dc75d94a7ed302d.tar.bz2
Allow searching for prebuilt implicit modules.
This reverts commit c67656b994c87224e0b33e2c4b09093986a5cfa6, and addresses the build issue.
Diffstat (limited to 'clang/lib/Frontend/CompilerInstance.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInstance.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp
index 030ef42..f4b00df 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -428,8 +428,12 @@ void CompilerInstance::createPreprocessor(TranslationUnitKind TUKind) {
PP->setPreprocessedOutput(getPreprocessorOutputOpts().ShowCPP);
- if (PP->getLangOpts().Modules && PP->getLangOpts().ImplicitModules)
- PP->getHeaderSearchInfo().setModuleCachePath(getSpecificModuleCachePath());
+ if (PP->getLangOpts().Modules && PP->getLangOpts().ImplicitModules) {
+ std::string ModuleHash = getInvocation().getModuleHash();
+ PP->getHeaderSearchInfo().setModuleHash(ModuleHash);
+ PP->getHeaderSearchInfo().setModuleCachePath(
+ getSpecificModuleCachePath(ModuleHash));
+ }
// Handle generating dependencies, if requested.
const DependencyOutputOptions &DepOpts = getDependencyOutputOpts();
@@ -477,13 +481,11 @@ void CompilerInstance::createPreprocessor(TranslationUnitKind TUKind) {
}
}
-std::string CompilerInstance::getSpecificModuleCachePath() {
- // Set up the module path, including the hash for the
- // module-creation options.
+std::string CompilerInstance::getSpecificModuleCachePath(StringRef ModuleHash) {
+ // Set up the module path, including the hash for the module-creation options.
SmallString<256> SpecificModuleCache(getHeaderSearchOpts().ModuleCachePath);
if (!SpecificModuleCache.empty() && !getHeaderSearchOpts().DisableModuleHash)
- llvm::sys::path::append(SpecificModuleCache,
- getInvocation().getModuleHash());
+ llvm::sys::path::append(SpecificModuleCache, ModuleHash);
return std::string(SpecificModuleCache.str());
}
@@ -1673,6 +1675,8 @@ static ModuleSource selectModuleSource(
if (!HSOpts.PrebuiltModuleFiles.empty() ||
!HSOpts.PrebuiltModulePaths.empty()) {
ModuleFilename = HS.getPrebuiltModuleFileName(ModuleName);
+ if (HSOpts.EnablePrebuiltImplicitModules && ModuleFilename.empty())
+ ModuleFilename = HS.getPrebuiltImplicitModuleFileName(M);
if (!ModuleFilename.empty())
return MS_PrebuiltModulePath;
}