Skip to content

Commit 894095a

Browse files
committed
Add a flag to enable/disable usage of objective c protocol symbolic references
1 parent b042475 commit 894095a

File tree

7 files changed

+20
-3
lines changed

7 files changed

+20
-3
lines changed

include/swift/AST/IRGenOptions.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,8 @@ class IRGenOptions {
399399
/// Enable runtime instantiation of value witness strings for generic types
400400
unsigned EnableLayoutStringValueWitnessesInstantiation : 1;
401401

402+
unsigned EnableObjectiveCProtocolSymbolicReferences : 1;
403+
402404
/// Instrument code to generate profiling information.
403405
unsigned GenerateProfile : 1;
404406

@@ -518,6 +520,7 @@ class IRGenOptions {
518520
UseTypeLayoutValueHandling(true), ForceStructTypeLayouts(false),
519521
EnableLayoutStringValueWitnesses(false),
520522
EnableLayoutStringValueWitnessesInstantiation(false),
523+
EnableObjectiveCProtocolSymbolicReferences(false),
521524
GenerateProfile(false), EnableDynamicReplacementChaining(false),
522525
DisableDebuggerShadowCopies(false),
523526
DisableConcreteTypeMetadataMangledNameAccessors(false),

include/swift/Option/FrontendOptions.td

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,6 +1233,13 @@ def disable_new_llvm_pass_manager :
12331233
Flag<["-"], "disable-new-llvm-pass-manager">,
12341234
HelpText<"Disable the new llvm pass manager">;
12351235

1236+
def enable_objective_c_protocol_symbolic_references :
1237+
Flag<["-"], "enable-objective-c-protocol-symbolic-references">,
1238+
HelpText<"Enable objective-c protocol symbolic references">;
1239+
def disable_objective_c_protocol_symbolic_references :
1240+
Flag<["-"], "disable-objective-c-protocol-symbolic-references">,
1241+
HelpText<"Disable objective-c protocol symbolic references">;
1242+
12361243
def disable_emit_generic_class_ro_t_list :
12371244
Flag<["-"], "disable-emit-generic-class-ro_t-list">,
12381245
HelpText<"Disable emission of a section with references to class_ro_t of "

lib/Frontend/CompilerInvocation.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2927,6 +2927,11 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
29272927
return true;
29282928
}
29292929

2930+
Opts.EnableObjectiveCProtocolSymbolicReferences =
2931+
Args.hasFlag(OPT_enable_objective_c_protocol_symbolic_references,
2932+
OPT_disable_objective_c_protocol_symbolic_references,
2933+
Opts.EnableObjectiveCProtocolSymbolicReferences);
2934+
29302935
if (const Arg *A = Args.getLastArg(options::OPT_platform_c_calling_convention)) {
29312936
Opts.PlatformCCallingConvention =
29322937
llvm::StringSwitch<llvm::CallingConv::ID>(A->getValue())

lib/IRGen/IRGenModule.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1936,6 +1936,8 @@ bool IRGenModule::shouldPrespecializeGenericMetadata() {
19361936
}
19371937

19381938
bool IRGenModule::canUseObjCSymbolicReferences() {
1939+
if (!IRGen.Opts.EnableObjectiveCProtocolSymbolicReferences)
1940+
return false;
19391941
auto &context = getSwiftModule()->getASTContext();
19401942
auto deploymentAvailability =
19411943
AvailabilityContext::forDeploymentTarget(context);

test/IRGen/objc_protocol_symbolic_reference.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend -target %target-future-triple -enable-objc-interop -emit-ir -primary-file %s -disable-objc-attr-requires-foundation-module | %FileCheck %s
1+
// RUN: %target-swift-frontend -enable-objective-c-protocol-symbolic-references -target %target-future-triple -enable-objc-interop -emit-ir -primary-file %s -disable-objc-attr-requires-foundation-module | %FileCheck %s
22

33
// REQUIRES: PTRSIZE=64
44
// REQIURES: objc_interop

test/Interpreter/objc_protocol_symbolic_reference.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: %empty-directory(%t)
2-
// RUN: %target-build-swift -target %target-future-triple %s -module-name main -o %t/main
2+
// RUN: %target-build-swift -Xfrontend -enable-objective-c-protocol-symbolic-references -target %target-future-triple %s -module-name main -o %t/main
33
// RUN: %target-codesign %t/main
44
// RUN: %target-run %t/main | %FileCheck %s
55

test/Reflection/typeref_decoding_objc.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// Test objective c symbolic references
66

77
// RUN: %empty-directory(%t)
8-
// RUN: %target-build-swift -target %target-future-triple %S/Inputs/ObjectiveCTypes.swift -parse-as-library -emit-module -emit-library -module-name TypesToReflect -o %t/%target-library-name(TypesToReflect)
8+
// RUN: %target-build-swift -Xfrontend -enable-objective-c-protocol-symbolic-references -target %target-future-triple %S/Inputs/ObjectiveCTypes.swift -parse-as-library -emit-module -emit-library -module-name TypesToReflect -o %t/%target-library-name(TypesToReflect)
99
// RUN: %target-swift-reflection-dump %t/%target-library-name(TypesToReflect) | %FileCheck %s --check-prefix=CHECK-%target-ptrsize --check-prefix=CHECK
1010

1111
// REQUIRES: objc_interop

0 commit comments

Comments
 (0)