mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Merge pull request #80322 from tshortli/allow-swift-runtime-symbol-declarations
This commit is contained in:
@@ -514,6 +514,9 @@ EXPERIMENTAL_FEATURE(CompileTimeValues, true)
|
||||
/// Allow function body macros applied to closures.
|
||||
EXPERIMENTAL_FEATURE(ClosureBodyMacro, true)
|
||||
|
||||
/// Allow declarations of Swift runtime symbols using @_silgen_name.
|
||||
EXPERIMENTAL_FEATURE(AllowRuntimeSymbolDeclarations, true)
|
||||
|
||||
#undef EXPERIMENTAL_FEATURE_EXCLUDED_FROM_MODULE_INTERFACE
|
||||
#undef EXPERIMENTAL_FEATURE
|
||||
#undef UPCOMING_FEATURE
|
||||
|
||||
@@ -404,6 +404,7 @@ UNINTERESTING_FEATURE(SafeInteropWrappers)
|
||||
UNINTERESTING_FEATURE(AssumeResilientCxxTypes)
|
||||
UNINTERESTING_FEATURE(ImportNonPublicCxxMembers)
|
||||
UNINTERESTING_FEATURE(CoroutineAccessorsUnwindOnCallerError)
|
||||
UNINTERESTING_FEATURE(AllowRuntimeSymbolDeclarations)
|
||||
|
||||
static bool usesFeatureSwiftSettings(const Decl *decl) {
|
||||
// We just need to guard `#SwiftSettings`.
|
||||
|
||||
@@ -2330,6 +2330,12 @@ static bool canDeclareSymbolName(StringRef symbol, ModuleDecl *fromModule) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Allow reserved symbols to be declared if the AllowRuntimeSymbolDeclarations
|
||||
// experimental feature is enabled.
|
||||
auto &ctx = fromModule->getASTContext();
|
||||
if (ctx.LangOpts.hasFeature(Feature::AllowRuntimeSymbolDeclarations))
|
||||
return true;
|
||||
|
||||
// Swift runtime functions are a private contract between the compiler and
|
||||
// runtime, and attempting to access them directly without going through
|
||||
// builtins or proper language features breaks the compiler in various hard
|
||||
|
||||
@@ -47,6 +47,7 @@ add_swift_target_library(swift_RegexParser ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} I
|
||||
# Workaround until `_RegexParser` is imported as implementation-only
|
||||
# by `_StringProcessing`.
|
||||
-Xfrontend -disable-implicit-string-processing-module-import
|
||||
-enable-experimental-feature AllowRuntimeSymbolDeclarations
|
||||
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}"
|
||||
|
||||
INSTALL_IN_COMPONENT stdlib
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// RUN: %target-typecheck-verify-swift -enable-experimental-feature Extern
|
||||
// RUN: %target-typecheck-verify-swift -enable-experimental-feature Extern -verify-additional-prefix runtime-symbols-
|
||||
// RUN: %target-typecheck-verify-swift -enable-experimental-feature Extern -enable-experimental-feature AllowRuntimeSymbolDeclarations
|
||||
|
||||
// REQUIRES: swift_feature_Extern
|
||||
// REQUIRES: swift_feature_AllowRuntimeSymbolDeclarations
|
||||
|
||||
@_silgen_name("foo") // expected-note {{attribute already specified here}}
|
||||
@_silgen_name("bar") // expected-error {{duplicate attribute}}
|
||||
@@ -19,14 +21,14 @@ func func_with_nested__silgen_name() {
|
||||
// Ensure that magic runtime symbol names can't be declared or defined through
|
||||
// various symbol-assigning attributes
|
||||
|
||||
@_silgen_name("swift_retain") // expected-warning{{reserved}}
|
||||
@_silgen_name("swift_retain") // expected-runtime-symbols-warning {{reserved}}
|
||||
func liveDangerously() {}
|
||||
|
||||
@_silgen_name("swift_retain") // expected-warning{{reserved}}
|
||||
@_silgen_name("swift_retain") // expected-runtime-symbols-warning {{reserved}}
|
||||
func liveRecklessly();
|
||||
|
||||
@_extern(c, "swift_retain") // expected-warning{{reserved}}
|
||||
@_extern(c, "swift_retain") // expected-runtime-symbols-warning {{reserved}}
|
||||
func liveEphemerally()
|
||||
|
||||
@_cdecl("swift_retain") // expected-warning{{reserved}}
|
||||
@_cdecl("swift_retain") // expected-runtime-symbols-warning {{reserved}}
|
||||
func liveFrivolously() {}
|
||||
|
||||
Reference in New Issue
Block a user