mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
282 lines
13 KiB
C++
282 lines
13 KiB
C++
//===--- Features.def - Swift Features Metaprogramming ----------*- C++ -*-===//
|
|
//
|
|
// This source file is part of the Swift.org open source project
|
|
//
|
|
// Copyright (c) 2021 - 2023 Apple Inc. and the Swift project authors
|
|
// Licensed under Apache License v2.0 with Runtime Library Exception
|
|
//
|
|
// See https://swift.org/LICENSE.txt for license information
|
|
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file defines macros used for macro-metaprogramming with language
|
|
// features.
|
|
//
|
|
//
|
|
// LANGUAGE_FEATURE(FeatureName, SENumber, Description)
|
|
//
|
|
// The LANGUAGE_FEATURE macro describes each named feature that is
|
|
// introduced in Swift. It allows Swift code to check for a particular
|
|
// feature with "#if $FeatureName" in source code.
|
|
//
|
|
// FeatureName: The name given to this feature to be used in source code,
|
|
// e.g., AsyncAwait.
|
|
// SENumber: The number assigned to this feature in the Swift Evolution
|
|
// process, or 0 if there isn't one.
|
|
// Description: A string literal describing the feature.
|
|
//
|
|
// Suppressible language features can be suppressed when printing
|
|
// an interface without having to suppress the entire declaration they're
|
|
// contained within. The declaration will be emitted multiple times,
|
|
// each with a subset of the suppressible features. To avoid combinatoric
|
|
// re-emission, we assume a linear history: later features in this file
|
|
// imply the existence of earlier features. (This only needs to apply to
|
|
// suppressible features.)
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LANGUAGE_FEATURE
|
|
# error define LANGUAGE_FEATURE before including Features.def
|
|
#endif
|
|
|
|
#ifndef SUPPRESSIBLE_LANGUAGE_FEATURE
|
|
#define SUPPRESSIBLE_LANGUAGE_FEATURE(FeatureName, SENumber, Description) \
|
|
LANGUAGE_FEATURE(FeatureName, SENumber, Description)
|
|
#endif
|
|
|
|
#ifndef UPCOMING_FEATURE
|
|
# define UPCOMING_FEATURE(FeatureName, SENumber, Version) \
|
|
LANGUAGE_FEATURE(FeatureName, SENumber, #FeatureName)
|
|
#endif
|
|
|
|
#ifndef EXPERIMENTAL_FEATURE
|
|
// Warning: setting `AvailableInProd` to `true` on a feature means that the flag
|
|
// cannot be dropped in the future.
|
|
# define EXPERIMENTAL_FEATURE(FeatureName, AvailableInProd) \
|
|
LANGUAGE_FEATURE(FeatureName, 0, #FeatureName)
|
|
#endif
|
|
|
|
#ifndef EXPERIMENTAL_FEATURE_EXCLUDED_FROM_MODULE_INTERFACE
|
|
# define EXPERIMENTAL_FEATURE_EXCLUDED_FROM_MODULE_INTERFACE(FeatureName, AvailableInProd) \
|
|
EXPERIMENTAL_FEATURE(FeatureName, AvailableInProd)
|
|
#endif
|
|
|
|
LANGUAGE_FEATURE(AsyncAwait, 296, "async/await")
|
|
LANGUAGE_FEATURE(EffectfulProp, 310, "Effectful properties")
|
|
LANGUAGE_FEATURE(MarkerProtocol, 0, "@_marker protocol")
|
|
LANGUAGE_FEATURE(Actors, 0, "actors")
|
|
LANGUAGE_FEATURE(ConcurrentFunctions, 0, "@concurrent functions")
|
|
LANGUAGE_FEATURE(RethrowsProtocol, 0, "@rethrows protocol")
|
|
LANGUAGE_FEATURE(GlobalActors, 316, "Global actors")
|
|
LANGUAGE_FEATURE(BuiltinJob, 0, "Builtin.Job type")
|
|
LANGUAGE_FEATURE(Sendable, 0, "Sendable and @Sendable")
|
|
LANGUAGE_FEATURE(BuiltinExecutor, 0, "Builtin.Executor type")
|
|
LANGUAGE_FEATURE(BuiltinContinuation, 0, "Continuation builtins")
|
|
LANGUAGE_FEATURE(BuiltinHopToActor, 0, "Builtin.HopToActor")
|
|
LANGUAGE_FEATURE(BuiltinTaskGroupWithArgument, 0, "TaskGroup builtins")
|
|
LANGUAGE_FEATURE(InheritActorContext, 0, "@_inheritActorContext attribute")
|
|
LANGUAGE_FEATURE(ImplicitSelfCapture, 0, "@_implicitSelfCapture attribute")
|
|
LANGUAGE_FEATURE(BuiltinBuildTaskExecutor, 0, "TaskExecutor-building builtins")
|
|
LANGUAGE_FEATURE(BuiltinBuildExecutor, 0, "Executor-building builtins")
|
|
LANGUAGE_FEATURE(BuiltinBuildComplexEqualityExecutor, 0, "Executor-building for 'complexEquality executor' builtins")
|
|
LANGUAGE_FEATURE(BuiltinBuildMainExecutor, 0, "MainActor executor building builtin")
|
|
LANGUAGE_FEATURE(BuiltinCreateAsyncTaskInGroup, 0, "Task create in task group builtin with extra flags")
|
|
LANGUAGE_FEATURE(BuiltinCreateAsyncTaskInGroupWithExecutor, 0, "Task create in task group builtin with extra flags")
|
|
LANGUAGE_FEATURE(BuiltinCreateAsyncDiscardingTaskInGroup, 0, "Task create in discarding task group builtin, accounting for the Void return type")
|
|
LANGUAGE_FEATURE(BuiltinCreateAsyncTaskWithExecutor, 0, "Task create builtin with extra executor preference")
|
|
LANGUAGE_FEATURE(BuiltinCreateAsyncDiscardingTaskInGroupWithExecutor, 0, "Task create in discarding task group with extra executor preference")
|
|
LANGUAGE_FEATURE(BuiltinCopy, 0, "Builtin.copy()")
|
|
LANGUAGE_FEATURE(BuiltinStackAlloc, 0, "Builtin.stackAlloc")
|
|
LANGUAGE_FEATURE(BuiltinUnprotectedStackAlloc, 0, "Builtin.unprotectedStackAlloc")
|
|
LANGUAGE_FEATURE(BuiltinAllocVector, 0, "Builtin.allocVector")
|
|
LANGUAGE_FEATURE(BuiltinTaskRunInline, 0, "Builtin.taskRunInline")
|
|
LANGUAGE_FEATURE(BuiltinUnprotectedAddressOf, 0, "Builtin.unprotectedAddressOf")
|
|
LANGUAGE_FEATURE(NewCxxMethodSafetyHeuristics, 0, "Only import C++ methods that return pointers (projections) on owned types as unsafe")
|
|
SUPPRESSIBLE_LANGUAGE_FEATURE(SpecializeAttributeWithAvailability, 0, "@_specialize attribute with availability")
|
|
LANGUAGE_FEATURE(BuiltinAssumeAlignment, 0, "Builtin.assumeAlignment")
|
|
LANGUAGE_FEATURE(BuiltinCreateTaskGroupWithFlags, 0, "Builtin.createTaskGroupWithFlags")
|
|
SUPPRESSIBLE_LANGUAGE_FEATURE(UnsafeInheritExecutor, 0, "@_unsafeInheritExecutor")
|
|
SUPPRESSIBLE_LANGUAGE_FEATURE(PrimaryAssociatedTypes2, 346, "Primary associated types")
|
|
SUPPRESSIBLE_LANGUAGE_FEATURE(UnavailableFromAsync, 0, "@_unavailableFromAsync")
|
|
SUPPRESSIBLE_LANGUAGE_FEATURE(NoAsyncAvailability, 340, "@available(*, noasync)")
|
|
LANGUAGE_FEATURE(BuiltinIntLiteralAccessors, 368, "Builtin.IntLiteral accessors")
|
|
LANGUAGE_FEATURE(Macros, 0, "Macros")
|
|
LANGUAGE_FEATURE(FreestandingExpressionMacros, 382, "Expression macros")
|
|
LANGUAGE_FEATURE(AttachedMacros, 389, "Attached macros")
|
|
LANGUAGE_FEATURE(ExtensionMacros, 402, "Extension macros")
|
|
LANGUAGE_FEATURE(MoveOnly, 390, "noncopyable types")
|
|
LANGUAGE_FEATURE(MoveOnlyResilientTypes, 390, "non-@frozen noncopyable types with library evolution")
|
|
LANGUAGE_FEATURE(ParameterPacks, 393, "Value and type parameter packs")
|
|
SUPPRESSIBLE_LANGUAGE_FEATURE(LexicalLifetimes, 0, "@_eagerMove/@_noEagerMove/@_lexicalLifetimes annotations")
|
|
LANGUAGE_FEATURE(FreestandingMacros, 397, "freestanding declaration macros")
|
|
SUPPRESSIBLE_LANGUAGE_FEATURE(RetroactiveAttribute, 364, "@retroactive")
|
|
SUPPRESSIBLE_LANGUAGE_FEATURE(ExtensionMacroAttr, 0, "@attached(extension)")
|
|
LANGUAGE_FEATURE(TypedThrows, 413, "Typed throws")
|
|
SUPPRESSIBLE_LANGUAGE_FEATURE(Extern, 0, "@_extern")
|
|
|
|
UPCOMING_FEATURE(ConciseMagicFile, 274, 6)
|
|
UPCOMING_FEATURE(ForwardTrailingClosures, 286, 6)
|
|
UPCOMING_FEATURE(StrictConcurrency, 0337, 6)
|
|
UPCOMING_FEATURE(BareSlashRegexLiterals, 354, 6)
|
|
UPCOMING_FEATURE(DeprecateApplicationMain, 383, 6)
|
|
UPCOMING_FEATURE(ImportObjcForwardDeclarations, 384, 6)
|
|
UPCOMING_FEATURE(DisableOutwardActorInference, 401, 6)
|
|
UPCOMING_FEATURE(InternalImportsByDefault, 409, 6)
|
|
UPCOMING_FEATURE(IsolatedDefaultValues, 411, 6)
|
|
UPCOMING_FEATURE(GlobalConcurrency, 412, 6)
|
|
UPCOMING_FEATURE(FullTypedThrows, 413, 6)
|
|
UPCOMING_FEATURE(ExistentialAny, 335, 7)
|
|
UPCOMING_FEATURE(InferSendableFromCaptures, 418, 6)
|
|
|
|
|
|
EXPERIMENTAL_FEATURE(StaticAssert, false)
|
|
EXPERIMENTAL_FEATURE(NamedOpaqueTypes, false)
|
|
EXPERIMENTAL_FEATURE(FlowSensitiveConcurrencyCaptures, false)
|
|
EXPERIMENTAL_FEATURE(CodeItemMacros, false)
|
|
EXPERIMENTAL_FEATURE(BodyMacros, true)
|
|
EXPERIMENTAL_FEATURE(TupleConformances, false)
|
|
|
|
// Whether to enable @_used and @_section attributes
|
|
EXPERIMENTAL_FEATURE(SymbolLinkageMarkers, true)
|
|
|
|
// Whether to compile scripts lazily in immediate mode
|
|
EXPERIMENTAL_FEATURE(LazyImmediate, false)
|
|
|
|
// FIXME: MoveOnlyClasses is not intended to be in production,
|
|
// but our tests currently rely on it, and we want to run those
|
|
// tests in non-asserts builds too.
|
|
EXPERIMENTAL_FEATURE(MoveOnlyClasses, true)
|
|
EXPERIMENTAL_FEATURE(NoImplicitCopy, true)
|
|
EXPERIMENTAL_FEATURE(OldOwnershipOperatorSpellings, true)
|
|
EXPERIMENTAL_FEATURE(MoveOnlyEnumDeinits, true)
|
|
EXPERIMENTAL_FEATURE(MoveOnlyTuples, true)
|
|
EXPERIMENTAL_FEATURE(MoveOnlyPartialConsumption, true)
|
|
EXPERIMENTAL_FEATURE(MoveOnlyPartialReinitialization, true)
|
|
|
|
EXPERIMENTAL_FEATURE(OneWayClosureParameters, false)
|
|
EXPERIMENTAL_FEATURE(LayoutPrespecialization, true)
|
|
|
|
EXPERIMENTAL_FEATURE(AccessLevelOnImport, true)
|
|
|
|
/// Whether to enable experimental layout string value witnesses
|
|
EXPERIMENTAL_FEATURE_EXCLUDED_FROM_MODULE_INTERFACE(LayoutStringValueWitnesses, true)
|
|
EXPERIMENTAL_FEATURE_EXCLUDED_FROM_MODULE_INTERFACE(LayoutStringValueWitnessesInstantiation, true)
|
|
|
|
/// Whether to enable experimental differentiable programming features:
|
|
/// `@differentiable` declaration attribute, etc.
|
|
EXPERIMENTAL_FEATURE(DifferentiableProgramming, false)
|
|
|
|
/// Whether to enable forward mode differentiation.
|
|
EXPERIMENTAL_FEATURE(ForwardModeDifferentiation, false)
|
|
|
|
/// Whether to enable experimental `AdditiveArithmetic` derived
|
|
/// conformances.
|
|
EXPERIMENTAL_FEATURE(AdditiveArithmeticDerivedConformances, false)
|
|
|
|
/// Whether Objective-C completion handler parameters are imported as
|
|
/// @Sendable.
|
|
EXPERIMENTAL_FEATURE(SendableCompletionHandlers, false)
|
|
|
|
/// Enables opaque type erasure without also enabling implict dynamic
|
|
EXPERIMENTAL_FEATURE(OpaqueTypeErasure, false)
|
|
|
|
/// Whether to perform round-trip testing of the Swift Swift parser.
|
|
EXPERIMENTAL_FEATURE(ParserRoundTrip, false)
|
|
|
|
/// Whether to perform validation of the parse tree produced by the Swift
|
|
/// Swift parser.
|
|
EXPERIMENTAL_FEATURE(ParserValidation, false)
|
|
|
|
/// Whether to emit diagnostics from the new parser first, and only emit
|
|
/// diagnostics from the existing parser when there are none from the new
|
|
/// parser.
|
|
EXPERIMENTAL_FEATURE(ParserDiagnostics, false)
|
|
|
|
/// Enables implicit some while also enabling existential `any`
|
|
EXPERIMENTAL_FEATURE(ImplicitSome, false)
|
|
|
|
/// Parse using the Swift (swift-syntax) parser and use ASTGen to generate the
|
|
/// corresponding syntax tree.
|
|
EXPERIMENTAL_FEATURE(ParserASTGen, false)
|
|
|
|
/// Parse using the Swift (swift-syntax) parser and use ASTGen to generate the
|
|
/// corresponding syntax tree.
|
|
EXPERIMENTAL_FEATURE(BuiltinMacros, false)
|
|
|
|
/// Import C++ class templates as semantically-meaningless symbolic
|
|
/// Swift types and C++ methods as symbolic functions with blank
|
|
/// signatures.
|
|
EXPERIMENTAL_FEATURE(ImportSymbolicCXXDecls, false)
|
|
|
|
/// Generate bindings for functions that 'throw' in the C++ section of the generated Clang header.
|
|
EXPERIMENTAL_FEATURE(GenerateBindingsForThrowingFunctionsInCXX, false)
|
|
|
|
/// Enable reference bindings.
|
|
EXPERIMENTAL_FEATURE(ReferenceBindings, true)
|
|
|
|
/// Enable the explicit 'import Builtin' and allow Builtin usage.
|
|
EXPERIMENTAL_FEATURE(BuiltinModule, true)
|
|
|
|
/// Region Based Isolation testing using the TransferNonSendable pass
|
|
EXPERIMENTAL_FEATURE(RegionBasedIsolation, false)
|
|
|
|
/// Enable extended callbacks (with additional parameters) to be used when the
|
|
/// "playground transform" is enabled.
|
|
EXPERIMENTAL_FEATURE(PlaygroundExtendedCallbacks, true)
|
|
|
|
/// Enable 'then' statements.
|
|
EXPERIMENTAL_FEATURE(ThenStatements, false)
|
|
|
|
/// Enable 'do' expressions.
|
|
EXPERIMENTAL_FEATURE(DoExpressions, false)
|
|
|
|
/// Enable the `@_rawLayout` attribute.
|
|
EXPERIMENTAL_FEATURE(RawLayout, true)
|
|
|
|
/// Enables the "embedded" swift mode (no runtime).
|
|
EXPERIMENTAL_FEATURE(Embedded, true)
|
|
|
|
/// Enables noncopyable generics
|
|
EXPERIMENTAL_FEATURE(NoncopyableGenerics, true)
|
|
|
|
/// Allow destructuring stored `let` bindings in structs.
|
|
EXPERIMENTAL_FEATURE(StructLetDestructuring, true)
|
|
|
|
/// Enable non-escapable type attributes and function attributes that support
|
|
/// lifetime-dependent results.
|
|
EXPERIMENTAL_FEATURE(NonescapableTypes, true)
|
|
|
|
// Allow optional isolated parameters.
|
|
EXPERIMENTAL_FEATURE(OptionalIsolatedParameters, true)
|
|
|
|
/// Enable the `@_staticExclusiveOnly` attribute.
|
|
EXPERIMENTAL_FEATURE(StaticExclusiveOnly, true)
|
|
|
|
/// Enable the @extractConstantsFromMembers attribute.
|
|
EXPERIMENTAL_FEATURE(ExtractConstantsFromMembers, false)
|
|
|
|
/// Enable bitwise-copyable feature.
|
|
EXPERIMENTAL_FEATURE(BitwiseCopyable, true)
|
|
|
|
/// Enables the FixedArray data type.
|
|
EXPERIMENTAL_FEATURE(FixedArrays, true)
|
|
|
|
// Group Main Actor Isolation Errors by Scope
|
|
EXPERIMENTAL_FEATURE(GroupActorErrors, true)
|
|
|
|
// Allow for the 'transferring' keyword to be applied to arguments and results.
|
|
EXPERIMENTAL_FEATURE(TransferringArgsAndResults, true)
|
|
|
|
// Enable `@preconcurrency` attribute on protocol conformances.
|
|
EXPERIMENTAL_FEATURE(PreconcurrencyConformances, false)
|
|
|
|
// Allow for `switch` of noncopyable values to be borrowing or consuming.
|
|
EXPERIMENTAL_FEATURE(BorrowingSwitch, true)
|
|
|
|
#undef EXPERIMENTAL_FEATURE_EXCLUDED_FROM_MODULE_INTERFACE
|
|
#undef EXPERIMENTAL_FEATURE
|
|
#undef UPCOMING_FEATURE
|
|
#undef SUPPRESSIBLE_LANGUAGE_FEATURE
|
|
#undef LANGUAGE_FEATURE
|