diff options
author | Jan Svoboda <jan_svoboda@apple.com> | 2022-02-23 14:15:47 +0100 |
---|---|---|
committer | Jan Svoboda <jan_svoboda@apple.com> | 2022-02-23 14:46:23 +0100 |
commit | 27d9a58407c44c8bb3fe7b94ff8d3b9bea25afc4 (patch) | |
tree | 4681fdfb89ad377527539e155f52d1d7e70ae865 /clang/lib/Frontend/FrontendAction.cpp | |
parent | 2f300d34decba547dd07f5cd6034a6b2b2ca11a2 (diff) | |
download | llvm-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.cpp | 9 |
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; } |