Skip to content

Commit 733f51a

Browse files
committed
Separate filtered flags from the typical/unfiltered case
1 parent 02d5210 commit 733f51a

File tree

2 files changed

+46
-40
lines changed

2 files changed

+46
-40
lines changed

include/swift/Basic/Features.def

Lines changed: 42 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,16 @@
5757
#ifndef EXPERIMENTAL_FEATURE
5858
// Warning: setting `AvailableInProd` to `true` on a feature means that the flag
5959
// cannot be dropped in the future.
60-
# define EXPERIMENTAL_FEATURE(FeatureName, AvailableInProd, IncludeInModuleInterface) \
60+
# define EXPERIMENTAL_FEATURE(FeatureName, AvailableInProd) \
6161
LANGUAGE_FEATURE(FeatureName, 0, #FeatureName, \
6262
langOpts.hasFeature(#FeatureName))
6363
#endif
6464

65+
#ifndef EXPERIMENTAL_FEATURE_EXCLUDED_FROM_MODULE_INTERFACE
66+
# define EXPERIMENTAL_FEATURE_EXCLUDED_FROM_MODULE_INTERFACE(FeatureName, AvailableInProd) \
67+
EXPERIMENTAL_FEATURE(#FeatureName, #AvailableInProd)
68+
#endif
69+
6570
LANGUAGE_FEATURE(AsyncAwait, 296, "async/await", true)
6671
LANGUAGE_FEATURE(EffectfulProp, 310, "Effectful properties", true)
6772
LANGUAGE_FEATURE(MarkerProtocol, 0, "@_marker protocol", true)
@@ -109,93 +114,94 @@ UPCOMING_FEATURE(BareSlashRegexLiterals, 354, 6)
109114
UPCOMING_FEATURE(ExistentialAny, 335, 6)
110115
UPCOMING_FEATURE(ImportObjcForwardDeclarations, 384, 6)
111116

112-
EXPERIMENTAL_FEATURE(StaticAssert, false, true)
113-
EXPERIMENTAL_FEATURE(VariadicGenerics, false, true)
114-
EXPERIMENTAL_FEATURE(NamedOpaqueTypes, false, true)
115-
EXPERIMENTAL_FEATURE(FlowSensitiveConcurrencyCaptures, false, true)
116-
EXPERIMENTAL_FEATURE(FreestandingMacros, true, true)
117-
EXPERIMENTAL_FEATURE(CodeItemMacros, true, true)
118-
EXPERIMENTAL_FEATURE(TupleConformances, false, true)
117+
EXPERIMENTAL_FEATURE(StaticAssert, false)
118+
EXPERIMENTAL_FEATURE(VariadicGenerics, false)
119+
EXPERIMENTAL_FEATURE(NamedOpaqueTypes, false)
120+
EXPERIMENTAL_FEATURE(FlowSensitiveConcurrencyCaptures, false)
121+
EXPERIMENTAL_FEATURE(FreestandingMacros, true)
122+
EXPERIMENTAL_FEATURE(CodeItemMacros, true)
123+
EXPERIMENTAL_FEATURE(TupleConformances, false)
119124

120125
// FIXME: MoveOnlyClasses is not intended to be in production,
121126
// but our tests currently rely on it, and we want to run those
122127
// tests in non-asserts builds too.
123-
EXPERIMENTAL_FEATURE(MoveOnlyClasses, true, true)
124-
EXPERIMENTAL_FEATURE(NoImplicitCopy, true, true)
125-
EXPERIMENTAL_FEATURE(OldOwnershipOperatorSpellings, true, true)
126-
EXPERIMENTAL_FEATURE(MoveOnlyEnumDeinits, true, true)
127-
EXPERIMENTAL_FEATURE(MoveOnlyTuples, true, true)
128+
EXPERIMENTAL_FEATURE(MoveOnlyClasses, true)
129+
EXPERIMENTAL_FEATURE(NoImplicitCopy, true)
130+
EXPERIMENTAL_FEATURE(OldOwnershipOperatorSpellings, true)
131+
EXPERIMENTAL_FEATURE(MoveOnlyEnumDeinits, true)
132+
EXPERIMENTAL_FEATURE(MoveOnlyTuples, true)
128133

129-
EXPERIMENTAL_FEATURE(OneWayClosureParameters, false, true)
130-
EXPERIMENTAL_FEATURE(TypeWitnessSystemInference, false, true)
131-
EXPERIMENTAL_FEATURE(LayoutPrespecialization, true, true)
134+
EXPERIMENTAL_FEATURE(OneWayClosureParameters, false)
135+
EXPERIMENTAL_FEATURE(TypeWitnessSystemInference, false)
136+
EXPERIMENTAL_FEATURE(LayoutPrespecialization, true)
132137

133-
EXPERIMENTAL_FEATURE(ModuleInterfaceExportAs, true, true)
134-
EXPERIMENTAL_FEATURE(AccessLevelOnImport, true, true)
138+
EXPERIMENTAL_FEATURE(ModuleInterfaceExportAs, true)
139+
EXPERIMENTAL_FEATURE(AccessLevelOnImport, true)
135140

136141
/// Whether to enable experimental layout string value witnesses
137-
EXPERIMENTAL_FEATURE(LayoutStringValueWitnesses, true, false)
138-
EXPERIMENTAL_FEATURE(LayoutStringValueWitnessesInstantiation, true, false)
142+
EXPERIMENTAL_FEATURE_EXCLUDED_FROM_MODULE_INTERFACE(LayoutStringValueWitnesses, true)
143+
EXPERIMENTAL_FEATURE_EXCLUDED_FROM_MODULE_INTERFACE(LayoutStringValueWitnessesInstantiation, true)
139144

140145
/// Whether to enable experimental differentiable programming features:
141146
/// `@differentiable` declaration attribute, etc.
142-
EXPERIMENTAL_FEATURE(DifferentiableProgramming, false, true)
147+
EXPERIMENTAL_FEATURE(DifferentiableProgramming, false)
143148

144149
/// Whether to enable forward mode differentiation.
145-
EXPERIMENTAL_FEATURE(ForwardModeDifferentiation, false, true)
150+
EXPERIMENTAL_FEATURE(ForwardModeDifferentiation, false)
146151

147152
/// Whether to enable experimental `AdditiveArithmetic` derived
148153
/// conformances.
149-
EXPERIMENTAL_FEATURE(AdditiveArithmeticDerivedConformances, false, true)
154+
EXPERIMENTAL_FEATURE(AdditiveArithmeticDerivedConformances, false)
150155

151156
/// Whether Objective-C completion handler parameters are imported as
152157
/// @Sendable.
153-
EXPERIMENTAL_FEATURE(SendableCompletionHandlers, false, true)
158+
EXPERIMENTAL_FEATURE(SendableCompletionHandlers, false)
154159

155160
/// Enables opaque type erasure without also enabling implict dynamic
156-
EXPERIMENTAL_FEATURE(OpaqueTypeErasure, false, true)
161+
EXPERIMENTAL_FEATURE(OpaqueTypeErasure, false)
157162

158163
/// Whether to perform round-trip testing of the Swift Swift parser.
159-
EXPERIMENTAL_FEATURE(ParserRoundTrip, false, true)
164+
EXPERIMENTAL_FEATURE(ParserRoundTrip, false)
160165

161166
/// Whether to perform validation of the parse tree produced by the Swift
162167
/// Swift parser.
163-
EXPERIMENTAL_FEATURE(ParserValidation, false, true)
168+
EXPERIMENTAL_FEATURE(ParserValidation, false)
164169

165170
/// Whether to emit diagnostics from the new parser first, and only emit
166171
/// diagnostics from the existing parser when there are none from the new
167172
/// parser.
168-
EXPERIMENTAL_FEATURE(ParserDiagnostics, false, true)
173+
EXPERIMENTAL_FEATURE(ParserDiagnostics, false)
169174

170175
/// Enables implicit some while also enabling existential `any`
171-
EXPERIMENTAL_FEATURE(ImplicitSome, false, true)
176+
EXPERIMENTAL_FEATURE(ImplicitSome, false)
172177

173178
/// Parse using the Swift (swift-syntax) parser and use ASTGen to generate the
174179
/// corresponding syntax tree.
175-
EXPERIMENTAL_FEATURE(ParserASTGen, false, true)
180+
EXPERIMENTAL_FEATURE(ParserASTGen, false)
176181

177182
/// Parse using the Swift (swift-syntax) parser and use ASTGen to generate the
178183
/// corresponding syntax tree.
179-
EXPERIMENTAL_FEATURE(BuiltinMacros, false, true)
184+
EXPERIMENTAL_FEATURE(BuiltinMacros, false)
180185

181186
/// Whether to enable experimental @runtimeMetadata feature which allows to
182187
/// declare an attribute which is discoverable and constructable at runtime.
183-
EXPERIMENTAL_FEATURE(RuntimeDiscoverableAttrs, false, true)
188+
EXPERIMENTAL_FEATURE(RuntimeDiscoverableAttrs, false)
184189

185190
/// Import C++ class templates as semantically-meaningless symbolic
186191
/// Swift types and C++ methods as symbolic functions with blank
187192
/// signatures.
188-
EXPERIMENTAL_FEATURE(ImportSymbolicCXXDecls, false, true)
193+
EXPERIMENTAL_FEATURE(ImportSymbolicCXXDecls, false)
189194

190195
/// Generate bindings for functions that 'throw' in the C++ section of the generated Clang header.
191-
EXPERIMENTAL_FEATURE(GenerateBindingsForThrowingFunctionsInCXX, false, true)
196+
EXPERIMENTAL_FEATURE(GenerateBindingsForThrowingFunctionsInCXX, false)
192197

193198
/// Enable reference bindings.
194-
EXPERIMENTAL_FEATURE(ReferenceBindings, false, true)
199+
EXPERIMENTAL_FEATURE(ReferenceBindings, false)
195200

196201
/// Enable the explicit 'import Builtin' and allow Builtin usage.
197-
EXPERIMENTAL_FEATURE(BuiltinModule, true, true)
202+
EXPERIMENTAL_FEATURE(BuiltinModule, true)
198203

204+
#undef EXPERIMENTAL_FEATURE_EXCLUDED_FROM_MODULE_INTERFACE
199205
#undef EXPERIMENTAL_FEATURE
200206
#undef UPCOMING_FEATURE
201207
#undef SUPPRESSIBLE_LANGUAGE_FEATURE

lib/Basic/LangOptions.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ bool swift::isFeatureAvailableInProduction(Feature feature) {
489489
switch (feature) {
490490
#define LANGUAGE_FEATURE(FeatureName, SENumber, Description, Option) \
491491
case Feature::FeatureName: return true;
492-
#define EXPERIMENTAL_FEATURE(FeatureName, AvailableInProd, IncludeInModuleInterface) \
492+
#define EXPERIMENTAL_FEATURE(FeatureName, AvailableInProd) \
493493
case Feature::FeatureName: return AvailableInProd;
494494
#include "swift/Basic/Features.def"
495495
}
@@ -508,7 +508,7 @@ llvm::Optional<Feature> swift::getUpcomingFeature(llvm::StringRef name) {
508508
llvm::Optional<Feature> swift::getExperimentalFeature(llvm::StringRef name) {
509509
return llvm::StringSwitch<Optional<Feature>>(name)
510510
#define LANGUAGE_FEATURE(FeatureName, SENumber, Description, Option)
511-
#define EXPERIMENTAL_FEATURE(FeatureName, AvailableInProd, IncludeInModuleInterface) \
511+
#define EXPERIMENTAL_FEATURE(FeatureName, AvailableInProd) \
512512
.Case(#FeatureName, Feature::FeatureName)
513513
#include "swift/Basic/Features.def"
514514
.Default(None);
@@ -528,8 +528,8 @@ bool swift::includeInModuleInterface(Feature feature) {
528528
switch (feature) {
529529
#define LANGUAGE_FEATURE(FeatureName, SENumber, Description, Option) \
530530
case Feature::FeatureName: return true;
531-
#define EXPERIMENTAL_FEATURE(FeatureName, AvailableInProd, IncludeInModuleInterface) \
532-
case Feature::FeatureName: return IncludeInModuleInterface;
531+
#define EXPERIMENTAL_FEATURE_EXCLUDED_FROM_MODULE_INTERFACE(FeatureName, AvailableInProd) \
532+
case Feature::FeatureName: return false;
533533
#include "swift/Basic/Features.def"
534534
}
535535
llvm_unreachable("covered switch");

0 commit comments

Comments
 (0)