Skip to content

Commit ab68c29

Browse files
committed
AST: Remove interface guards for a bunch of experimental features.
Since these features are experimental features, they can't be catagorized as "baseline" features. However, there is no need to guard code in swiftinterfaces that potentially uses syntax related to these features since all supported compilers can parse the syntax.
1 parent d944488 commit ab68c29

File tree

2 files changed

+14
-122
lines changed

2 files changed

+14
-122
lines changed

lib/AST/FeatureSet.cpp

Lines changed: 13 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -68,25 +68,7 @@ UNINTERESTING_FEATURE(ForwardTrailingClosures)
6868
UNINTERESTING_FEATURE(StrictConcurrency)
6969
UNINTERESTING_FEATURE(BareSlashRegexLiterals)
7070
UNINTERESTING_FEATURE(DeprecateApplicationMain)
71-
72-
static bool usesFeatureImportObjcForwardDeclarations(Decl *decl) {
73-
ClangNode clangNode = decl->getClangNode();
74-
if (!clangNode)
75-
return false;
76-
77-
const clang::Decl *clangDecl = clangNode.getAsDecl();
78-
if (!clangDecl)
79-
return false;
80-
81-
if (auto objCInterfaceDecl = dyn_cast<clang::ObjCInterfaceDecl>(clangDecl))
82-
return !objCInterfaceDecl->hasDefinition();
83-
84-
if (auto objCProtocolDecl = dyn_cast<clang::ObjCProtocolDecl>(clangDecl))
85-
return !objCProtocolDecl->hasDefinition();
86-
87-
return false;
88-
}
89-
71+
UNINTERESTING_FEATURE(ImportObjcForwardDeclarations)
9072
UNINTERESTING_FEATURE(DisableOutwardActorInference)
9173
UNINTERESTING_FEATURE(InternalImportsByDefault)
9274
UNINTERESTING_FEATURE(IsolatedDefaultValues)
@@ -103,53 +85,19 @@ UNINTERESTING_FEATURE(ImplicitOpenExistentials)
10385
UNINTERESTING_FEATURE(StaticAssert)
10486
UNINTERESTING_FEATURE(NamedOpaqueTypes)
10587
UNINTERESTING_FEATURE(FlowSensitiveConcurrencyCaptures)
106-
107-
static bool usesFeatureCodeItemMacros(Decl *decl) {
108-
auto macro = dyn_cast<MacroDecl>(decl);
109-
if (!macro)
110-
return false;
111-
112-
return macro->getMacroRoles().contains(MacroRole::CodeItem);
113-
}
114-
88+
UNINTERESTING_FEATURE(CodeItemMacros)
11589
UNINTERESTING_FEATURE(PreambleMacros)
11690
UNINTERESTING_FEATURE(TupleConformances)
117-
118-
static bool usesFeatureSymbolLinkageMarkers(Decl *decl) {
119-
auto &attrs = decl->getAttrs();
120-
return std::any_of(attrs.begin(), attrs.end(), [](auto *attr) {
121-
if (isa<UsedAttr>(attr))
122-
return true;
123-
if (isa<SectionAttr>(attr))
124-
return true;
125-
return false;
126-
});
127-
}
128-
91+
UNINTERESTING_FEATURE(SymbolLinkageMarkers)
12992
UNINTERESTING_FEATURE(LazyImmediate)
13093
UNINTERESTING_FEATURE(MoveOnlyClasses)
131-
132-
static bool usesFeatureNoImplicitCopy(Decl *decl) {
133-
return decl->isNoImplicitCopy();
134-
}
135-
94+
UNINTERESTING_FEATURE(NoImplicitCopy)
13695
UNINTERESTING_FEATURE(OldOwnershipOperatorSpellings)
13796
UNINTERESTING_FEATURE(MoveOnlyEnumDeinits)
13897
UNINTERESTING_FEATURE(MoveOnlyTuples)
13998
UNINTERESTING_FEATURE(MoveOnlyPartialReinitialization)
140-
14199
UNINTERESTING_FEATURE(OneWayClosureParameters)
142-
143-
static bool usesFeatureLayoutPrespecialization(Decl *decl) {
144-
auto &attrs = decl->getAttrs();
145-
return std::any_of(attrs.begin(), attrs.end(), [](auto *attr) {
146-
if (auto *specialize = dyn_cast<SpecializeAttr>(attr)) {
147-
return !specialize->getTypeErasedParams().empty();
148-
}
149-
return false;
150-
});
151-
}
152-
100+
UNINTERESTING_FEATURE(LayoutPrespecialization)
153101
UNINTERESTING_FEATURE(AccessLevelOnImport)
154102
UNINTERESTING_FEATURE(AllowNonResilientAccessInPackage)
155103
UNINTERESTING_FEATURE(ClientBypassResilientAccessInPackage)
@@ -169,65 +117,21 @@ UNINTERESTING_FEATURE(ParserASTGen)
169117
UNINTERESTING_FEATURE(BuiltinMacros)
170118
UNINTERESTING_FEATURE(ImportSymbolicCXXDecls)
171119
UNINTERESTING_FEATURE(GenerateBindingsForThrowingFunctionsInCXX)
172-
173-
static bool usesFeatureReferenceBindings(Decl *decl) {
174-
auto *vd = dyn_cast<VarDecl>(decl);
175-
return vd && vd->getIntroducer() == VarDecl::Introducer::InOut;
176-
}
177-
120+
UNINTERESTING_FEATURE(ReferenceBindings)
178121
UNINTERESTING_FEATURE(BuiltinModule)
179122
UNINTERESTING_FEATURE(RegionBasedIsolation)
180123
UNINTERESTING_FEATURE(PlaygroundExtendedCallbacks)
181124
UNINTERESTING_FEATURE(ThenStatements)
182125
UNINTERESTING_FEATURE(DoExpressions)
183126
UNINTERESTING_FEATURE(ImplicitLastExprResults)
184-
185-
static bool usesFeatureRawLayout(Decl *decl) {
186-
return decl->getAttrs().hasAttribute<RawLayoutAttr>();
187-
}
188-
127+
UNINTERESTING_FEATURE(RawLayout)
189128
UNINTERESTING_FEATURE(Embedded)
190129
UNINTERESTING_FEATURE(Volatile)
191130
UNINTERESTING_FEATURE(SuppressedAssociatedTypes)
192-
193-
static bool disallowFeatureSuppression(StringRef featureName, Decl *decl);
194-
195-
static bool usesFeatureStructLetDestructuring(Decl *decl) {
196-
auto sd = dyn_cast<StructDecl>(decl);
197-
if (!sd)
198-
return false;
199-
200-
for (auto member : sd->getStoredProperties()) {
201-
if (!member->isLet())
202-
continue;
203-
204-
auto init = member->getParentPattern();
205-
if (!init)
206-
continue;
207-
208-
if (!init->getSingleVar())
209-
return true;
210-
}
211-
212-
return false;
213-
}
214-
215-
static bool usesFeatureNonescapableTypes(Decl *decl) {
216-
if (decl->getAttrs().hasAttribute<NonEscapableAttr>() ||
217-
decl->getAttrs().hasAttribute<UnsafeNonEscapableResultAttr>()) {
218-
return true;
219-
}
220-
return false;
221-
}
222-
223-
static bool usesFeatureStaticExclusiveOnly(Decl *decl) {
224-
return decl->getAttrs().hasAttribute<StaticExclusiveOnlyAttr>();
225-
}
226-
227-
static bool usesFeatureExtractConstantsFromMembers(Decl *decl) {
228-
return decl->getAttrs().hasAttribute<ExtractConstantsFromMembersAttr>();
229-
}
230-
131+
UNINTERESTING_FEATURE(StructLetDestructuring)
132+
UNINTERESTING_FEATURE(NonescapableTypes)
133+
UNINTERESTING_FEATURE(StaticExclusiveOnly)
134+
UNINTERESTING_FEATURE(ExtractConstantsFromMembers)
231135
UNINTERESTING_FEATURE(FixedArrays)
232136
UNINTERESTING_FEATURE(GroupActorErrors)
233137

@@ -282,9 +186,7 @@ static bool usesFeatureSendingArgsAndResults(Decl *decl) {
282186
}
283187

284188
UNINTERESTING_FEATURE(DynamicActorIsolation)
285-
286189
UNINTERESTING_FEATURE(NonfrozenEnumExhaustivity)
287-
288190
UNINTERESTING_FEATURE(ClosureIsolation)
289191

290192
static bool usesFeatureBitwiseCopyable2(Decl *decl) {
@@ -311,19 +213,11 @@ static bool usesFeatureIsolatedAny(Decl *decl) {
311213

312214
UNINTERESTING_FEATURE(MemberImportVisibility)
313215
UNINTERESTING_FEATURE(IsolatedAny2)
314-
315-
static bool usesFeatureGlobalActorIsolatedTypesUsability(Decl *decl) {
316-
return false;
317-
}
318-
216+
UNINTERESTING_FEATURE(GlobalActorIsolatedTypesUsability)
319217
UNINTERESTING_FEATURE(ObjCImplementation)
320218
UNINTERESTING_FEATURE(ObjCImplementationWithResilientStorage)
321219
UNINTERESTING_FEATURE(CImplementation)
322-
323-
static bool usesFeatureSensitive(Decl *decl) {
324-
return decl->getAttrs().hasAttribute<SensitiveAttr>();
325-
}
326-
220+
UNINTERESTING_FEATURE(Sensitive)
327221
UNINTERESTING_FEATURE(DebugDescriptionMacro)
328222
UNINTERESTING_FEATURE(ReinitializeConsumeInMultiBlockDefer)
329223
UNINTERESTING_FEATURE(SE427NoInferenceOnExtension)

test/ModuleInterface/layout_pre_specialization.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@
55
// RUN: %target-swift-typecheck-module-from-interface(%t/LayoutPrespec.swiftinterface) -module-name LayoutPrespec -enable-experimental-feature LayoutPrespecialization -disable-availability-checking
66
// RUN: %FileCheck %s < %t/LayoutPrespec.swiftinterface
77

8-
// CHECK: #if compiler(>=5.3) && $LayoutPrespecialization
9-
// CHECK-NEXT: @_specialize(exported: true, kind: full, where @_noMetadata A : _Class)
8+
// CHECK: @_specialize(exported: true, kind: full, where @_noMetadata A : _Class)
109
// CHECK-NEXT: public func test<A>(a: A) -> A
11-
// CHECK-NEXT: #endif
1210
@_specialize(exported: true, where @_noMetadata A : _Class)
1311
public func test<A>(a: A) -> A {
1412
return a

0 commit comments

Comments
 (0)