From a3efd892fa57b72c2a0875a2fc9033b57f90d696 Mon Sep 17 00:00:00 2001 From: Jan Svoboda Date: Wed, 1 Nov 2023 12:00:54 -0700 Subject: [clang][modules] Don't prevent translation of FW_Private includes when explicitly building FW (#70714) We prevent translating `#include ` 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 --- clang/lib/Basic/Module.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'clang/lib/Basic/Module.cpp') 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); -- cgit v1.1