[ExplicitModuleBuild] Don't leak chained bridging header in objc header

When generating an objc header from the swift module when a bridging
header is used, make sure to use the original bridging header, not
the chained bridging header. This also avoids incorrectly generated a
header include when no actual bridging header is used, just a chained
bridging header that is coming from a dependency.

rdar://148446465
This commit is contained in:
Steven Wu
2025-04-02 11:18:53 -07:00
parent f61a3c941b
commit 80f726a815
2 changed files with 15 additions and 2 deletions

View File

@@ -912,14 +912,17 @@ SourceFile *CompilerInstance::getIDEInspectionFile() const {
std::string CompilerInstance::getBridgingHeaderPath() const {
const FrontendOptions &opts = Invocation.getFrontendOptions();
if (opts.ImplicitObjCPCHPath.empty())
if (!opts.ModuleHasBridgingHeader)
return std::string();
if (!opts.ImplicitObjCHeaderPath.empty())
return opts.ImplicitObjCHeaderPath;
auto clangImporter =
static_cast<ClangImporter *>(getASTContext().getClangModuleLoader());
// No clang importer created. Report error?
if (!clangImporter)
if (!clangImporter || opts.ImplicitObjCPCHPath.empty())
return std::string();
return clangImporter->getOriginalSourceFile(opts.ImplicitObjCPCHPath);