Skip to content

Commit bb6c62d

Browse files
committed
[Driver] Disallow bridging headers with framework targets.
While this appears to work, it causes problems down the line -- it's a brittle configuration for debugging, and PrintAsObjC currently doesn't fail gracefully if you reference a bridging-header-only type in your public interface. We definitely want something like this to work some day, but don't have time to fix it now. Filed <rdar://problem/17615898>. Swift SVN r19762
1 parent 0f0714f commit bb6c62d

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

include/swift/AST/DiagnosticsDriver.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ ERROR(error_unknown_file_type,driver,none,
7878
ERROR(error_invalid_arch,driver,none,
7979
"invalid target architecture '%0'", (StringRef))
8080

81+
ERROR(error_framework_bridging_header,driver,none,
82+
"using bridging headers with framework targets is unsupported", ())
83+
8184
#ifndef DIAG_NO_UNDEF
8285
# if defined(DIAG)
8386
# undef DIAG

lib/Driver/Driver.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ Driver::~Driver() {
6868
llvm::DeleteContainerSeconds(ToolChains);
6969
}
7070

71+
static void validateArgs(DiagnosticEngine &diags, const ArgList &Args) {
72+
if (Args.hasArgNoClaim(options::OPT_import_underlying_module) &&
73+
Args.hasArgNoClaim(options::OPT_import_objc_header)) {
74+
diags.diagnose({}, diag::error_framework_bridging_header);
75+
}
76+
}
77+
7178
std::unique_ptr<Compilation> Driver::buildCompilation(
7279
ArrayRef<const char *> Args) {
7380
llvm::PrettyStackTraceString CrashInfo("Compilation construction");
@@ -92,6 +99,8 @@ std::unique_ptr<Compilation> Driver::buildCompilation(
9299

93100
const ToolChain &TC = getToolChain(*ArgList);
94101

102+
validateArgs(Diags, *TranslatedArgList);
103+
95104
if (Diags.hadAnyError())
96105
return nullptr;
97106

test/Driver/options.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,6 @@
5151

5252
// RUN: %swift_driver -assert-config DisableReplacement -### | FileCheck -check-prefix=ASSERTCONFIG6 %s
5353
// ASSERTCONFIG6: -assert-config DisableReplacement
54+
55+
// RUN: not %swift_driver -import-objc-header fake.h -import-underlying-module -c %s 2>&1 | FileCheck -check-prefix=FRAMEWORK_BRIDGING_HEADER %s
56+
// FRAMEWORK_BRIDGING_HEADER: error: using bridging headers with framework targets is unsupported

0 commit comments

Comments
 (0)