Skip to content

Commit dde6ec6

Browse files
committed
[Frontend] NFC: Add a flag to enable bridging of completion handlers to checked continuations
(cherry picked from commit b8fb94b)
1 parent 882d7d2 commit dde6ec6

File tree

5 files changed

+25
-2
lines changed

5 files changed

+25
-2
lines changed

include/swift/Basic/LangOptions.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,10 @@ namespace swift {
389389
bool DisableImplicitBacktracingModuleImport =
390390
!SWIFT_IMPLICIT_BACKTRACING_IMPORT;
391391

392+
// Whether to use checked continuations when making an async call from
393+
// Swift into ObjC. If false, will use unchecked continuations instead.
394+
bool UseCheckedAsyncObjCBridging = false;
395+
392396
/// Should we check the target OSs of serialized modules to see that they're
393397
/// new enough?
394398
bool EnableTargetOSChecking = true;

include/swift/Option/FrontendOptions.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,10 @@ def enable_experimental_async_top_level :
364364
// HIDDEN FLAGS
365365
let Flags = [FrontendOption, NoDriverOption, HelpHidden] in {
366366

367+
def checked_async_objc_bridging : Joined<["-"], "checked-async-objc-bridging=">,
368+
HelpText<"Control whether checked continuations are used when bridging "
369+
"async calls from Swift to ObjC: 'on', 'off' ">;
370+
367371
def debug_constraints : Flag<["-"], "debug-constraints">,
368372
HelpText<"Debug the constraint-based type checker">;
369373

lib/Frontend/CompilerInvocation.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,6 +1326,21 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
13261326
HadError = true;
13271327
}
13281328

1329+
if (auto A = Args.getLastArg(OPT_checked_async_objc_bridging)) {
1330+
auto value = llvm::StringSwitch<llvm::Optional<bool>>(A->getValue())
1331+
.Case("off", false)
1332+
.Case("on", true)
1333+
.Default(llvm::None);
1334+
1335+
if (value) {
1336+
Opts.UseCheckedAsyncObjCBridging = *value;
1337+
} else {
1338+
Diags.diagnose(SourceLoc(), diag::error_invalid_arg_value,
1339+
A->getAsString(Args), A->getValue());
1340+
HadError = true;
1341+
}
1342+
}
1343+
13291344
return HadError || UnsupportedOS || UnsupportedArch;
13301345
}
13311346

test/SILGen/objc_async.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-silgen -I %S/Inputs/custom-modules -disable-availability-checking %s -verify | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-%target-cpu %s
1+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-silgen -checked-async-objc-bridging=off -I %S/Inputs/custom-modules -disable-availability-checking %s -verify | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-%target-cpu %s
22
// REQUIRES: concurrency
33
// REQUIRES: objc_interop
44

test/SILGen/objc_effectful_properties.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-silgen -disable-availability-checking -I %S/Inputs/custom-modules %s -verify | %FileCheck --enable-var-scope --check-prefix=CHECK --check-prefix=CHECK-%target-cpu %s
1+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-silgen -checked-async-objc-bridging=off -disable-availability-checking -I %S/Inputs/custom-modules %s -verify | %FileCheck --enable-var-scope --check-prefix=CHECK --check-prefix=CHECK-%target-cpu %s
22
// REQUIRES: concurrency
33
// REQUIRES: objc_interop
44

0 commit comments

Comments
 (0)