diff options
author | Jan Svoboda <jan_svoboda@apple.com> | 2023-11-01 12:00:54 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-01 12:00:54 -0700 |
commit | a3efd892fa57b72c2a0875a2fc9033b57f90d696 (patch) | |
tree | fb018ce4bb0b64c90ee3a6356f8e907b3463b7fd /clang/lib/Basic/Module.cpp | |
parent | 243588df15ed136b52ca62315c1e18b045cdf915 (diff) | |
download | llvm-a3efd892fa57b72c2a0875a2fc9033b57f90d696.zip llvm-a3efd892fa57b72c2a0875a2fc9033b57f90d696.tar.gz llvm-a3efd892fa57b72c2a0875a2fc9033b57f90d696.tar.bz2 |
[clang][modules] Don't prevent translation of FW_Private includes when explicitly building FW (#70714)
We prevent translating `#include <FW/PrivateHeader.h>` into an import of
FW_Private when compiling the implementation of FW or FW_Private. This
is specified via `-fmodule-name=` on the TU command line (used to be
`-fmodule-implementation-of`).
This logic is supposed to only kick in when imported directly from a TU,
but it currently also kicks in when compiling the public FW module
explicitly (since it also has `-fmodule-name=` on the command line).
This patch makes sure this logic only kicks in for the case that used to
be `-fmodule-implementation-of` (for the TU), and not for all
`-fmodule-name=` cases (especially for the explicit compile of a
module).
rdar://101051277; related: rdar://37500098&38434694
Diffstat (limited to 'clang/lib/Basic/Module.cpp')
-rw-r--r-- | clang/lib/Basic/Module.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/clang/lib/Basic/Module.cpp b/clang/lib/Basic/Module.cpp index cc2e5be..e4ac1ab 100644 --- a/clang/lib/Basic/Module.cpp +++ b/clang/lib/Basic/Module.cpp @@ -161,9 +161,10 @@ bool Module::isForBuilding(const LangOptions &LangOpts) const { StringRef TopLevelName = getTopLevelModuleName(); StringRef CurrentModule = LangOpts.CurrentModule; - // When building framework Foo, we want to make sure that Foo *and* - // Foo_Private are textually included and no modules are built for both. - if (getTopLevelModule()->IsFramework && + // When building the implementation of framework Foo, we want to make sure + // that Foo *and* Foo_Private are textually included and no modules are built + // for either. + if (!LangOpts.isCompilingModule() && getTopLevelModule()->IsFramework && CurrentModule == LangOpts.ModuleName && !CurrentModule.endswith("_Private") && TopLevelName.endswith("_Private")) TopLevelName = TopLevelName.drop_back(8); |