aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/FrontendAction.cpp
diff options
context:
space:
mode:
authorJan Svoboda <jan_svoboda@apple.com>2022-02-23 14:15:47 +0100
committerJan Svoboda <jan_svoboda@apple.com>2022-02-23 14:46:23 +0100
commit27d9a58407c44c8bb3fe7b94ff8d3b9bea25afc4 (patch)
tree4681fdfb89ad377527539e155f52d1d7e70ae865 /clang/lib/Frontend/FrontendAction.cpp
parent2f300d34decba547dd07f5cd6034a6b2b2ca11a2 (diff)
downloadllvm-27d9a58407c44c8bb3fe7b94ff8d3b9bea25afc4.zip
llvm-27d9a58407c44c8bb3fe7b94ff8d3b9bea25afc4.tar.gz
llvm-27d9a58407c44c8bb3fe7b94ff8d3b9bea25afc4.tar.bz2
[clang][modules] Infer framework modules in explicit builds
This patch enables inferring framework modules in explicit builds in all contexts. Until now, inferring framework modules only worked with `-fimplicit-module-maps` due to this block of code: ``` // HeaderSearch::loadFrameworkModule case LMM_InvalidModuleMap: // Try to infer a module map from the framework directory. if (HSOpts->ImplicitModuleMaps) ModMap.inferFrameworkModule(Dir, IsSystem, /*Parent=*/nullptr); break; ``` Reviewed By: Bigcheese Differential Revision: https://reviews.llvm.org/D113880
Diffstat (limited to 'clang/lib/Frontend/FrontendAction.cpp')
-rw-r--r--clang/lib/Frontend/FrontendAction.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp
index 089f40b..c5b9e80 100644
--- a/clang/lib/Frontend/FrontendAction.cpp
+++ b/clang/lib/Frontend/FrontendAction.cpp
@@ -465,6 +465,15 @@ static bool loadModuleMapForModuleBuild(CompilerInstance &CI, bool IsSystem,
if (SrcMgr.getBufferOrFake(ModuleMapID).getBufferSize() == Offset)
Offset = 0;
+ // Infer framework module if possible.
+ if (HS.getModuleMap().canInferFrameworkModule(ModuleMap->getDir())) {
+ SmallString<128> InferredFrameworkPath = ModuleMap->getDir()->getName();
+ llvm::sys::path::append(InferredFrameworkPath,
+ CI.getLangOpts().ModuleName + ".framework");
+ if (auto Dir = CI.getFileManager().getDirectory(InferredFrameworkPath))
+ (void)HS.getModuleMap().inferFrameworkModule(*Dir, IsSystem, nullptr);
+ }
+
return false;
}