Skip to content

Commit a048422

Browse files
Merge pull request #80467 from cachemeifyoucan/eng/PR-148446465
[ExplicitModuleBuild] Don't leak chained bridging header in objc header
2 parents 918d4b5 + 80f726a commit a048422

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

lib/Frontend/Frontend.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -912,14 +912,17 @@ SourceFile *CompilerInstance::getIDEInspectionFile() const {
912912

913913
std::string CompilerInstance::getBridgingHeaderPath() const {
914914
const FrontendOptions &opts = Invocation.getFrontendOptions();
915-
if (opts.ImplicitObjCPCHPath.empty())
915+
if (!opts.ModuleHasBridgingHeader)
916+
return std::string();
917+
918+
if (!opts.ImplicitObjCHeaderPath.empty())
916919
return opts.ImplicitObjCHeaderPath;
917920

918921
auto clangImporter =
919922
static_cast<ClangImporter *>(getASTContext().getClangModuleLoader());
920923

921924
// No clang importer created. Report error?
922-
if (!clangImporter)
925+
if (!clangImporter || opts.ImplicitObjCPCHPath.empty())
923926
return std::string();
924927

925928
return clangImporter->getOriginalSourceFile(opts.ImplicitObjCPCHPath);

test/ScanDependencies/bridging-header-autochaining.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,16 @@
121121
// RUN: %target-swift-frontend -module-name User -O \
122122
// RUN: -disable-implicit-string-processing-module-import -disable-implicit-concurrency-module-import -disable-implicit-swift-modules \
123123
// RUN: -explicit-swift-module-map-file %t/map3.json @%t/User2.cmd %t/user2.swift \
124+
// RUN: -emit-objc-header -emit-objc-header-path %t/User-Swift.h \
124125
// RUN: -emit-module -o %t/User2.swiftmodule
125126

127+
/// Generated ObjC Header should reference original header name, not the chained bridging header.
128+
// RUN: %FileCheck %s --check-prefix OBJC-HEADER --input-file=%t/User-Swift.h
129+
// OBJC-HEADER: import B
130+
// OBJC-HEADER: import
131+
// OBJC-HEADER-SAME: Bridging2.h
132+
// OBJC-HEADER-NOT: ChainedBridgingHeader.h
133+
126134
// RUN: %target-swift-frontend -scan-dependencies -module-name User -O \
127135
// RUN: -disable-implicit-string-processing-module-import -disable-implicit-concurrency-module-import \
128136
// RUN: -Xcc -fmodule-map-file=%t/a.modulemap -Xcc -fmodule-map-file=%t/b.modulemap \
@@ -193,6 +201,8 @@ extension Bridging2 {
193201
public func testA() {}
194202
}
195203

204+
public class BB : B {}
205+
public class Foo3 : Bridging2 {}
196206

197207
//--- Bridging.h
198208
#include "Foo.h"

0 commit comments

Comments
 (0)