Skip to content

Commit 491a43a

Browse files
committed
AST: Re-baseline MemorySafetyAttributes feature.
1 parent b8441c1 commit 491a43a

File tree

5 files changed

+1
-63
lines changed

5 files changed

+1
-63
lines changed

include/swift/Basic/Features.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,8 @@ CONDITIONALLY_SUPPRESSIBLE_LANGUAGE_FEATURE(IsolatedAny, 431, "@isolated(any) fu
254254
LANGUAGE_FEATURE(IsolatedAny2, 431, "@isolated(any) function types")
255255
LANGUAGE_FEATURE(ObjCImplementation, 436, "@objc @implementation extensions")
256256
LANGUAGE_FEATURE(NonescapableTypes, 446, "Nonescapable types")
257-
SUPPRESSIBLE_LANGUAGE_FEATURE(MemorySafetyAttributes, 458, "@unsafe attribute")
258257
BASELINE_LANGUAGE_FEATURE(BuiltinEmplaceTypedThrows, 0, "Builtin.emplace typed throws")
258+
BASELINE_LANGUAGE_FEATURE(MemorySafetyAttributes, 458, "@unsafe attribute")
259259
BASELINE_LANGUAGE_FEATURE(ValueGenerics, 452, "Value generics feature (integer generics)")
260260
LANGUAGE_FEATURE(RawIdentifiers, 451, "Raw identifiers")
261261
LANGUAGE_FEATURE(SendableCompletionHandlers, 463, "Objective-C completion handler parameters are imported as @Sendable")

lib/AST/ASTPrinter.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3280,20 +3280,6 @@ struct ExcludeAttrRAII {
32803280
};
32813281
}
32823282

3283-
static void
3284-
suppressingFeatureMemorySafetyAttributes(PrintOptions &options,
3285-
llvm::function_ref<void()> action) {
3286-
ExcludeAttrRAII scope(options.ExcludeAttrList, DeclAttrKind::Unsafe);
3287-
ExcludeAttrRAII scope2(options.ExcludeAttrList, DeclAttrKind::Safe);
3288-
options.ExcludeAttrList.push_back(TypeAttrKind::Unsafe);
3289-
SWIFT_DEFER {
3290-
assert(options.ExcludeAttrList.back() == TypeAttrKind::Unsafe);
3291-
options.ExcludeAttrList.pop_back();
3292-
};
3293-
3294-
action();
3295-
}
3296-
32973283
static void
32983284
suppressingFeatureCoroutineAccessors(PrintOptions &options,
32993285
llvm::function_ref<void()> action) {

lib/AST/FeatureSet.cpp

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -451,35 +451,6 @@ static bool usesFeatureCDecl(Decl *decl) {
451451
return attr && !attr->Underscored;
452452
}
453453

454-
static bool usesFeatureMemorySafetyAttributes(Decl *decl) {
455-
if (decl->getAttrs().hasAttribute<SafeAttr>() ||
456-
decl->getAttrs().hasAttribute<UnsafeAttr>())
457-
return true;
458-
459-
IterableDeclContext *idc;
460-
if (auto nominal = dyn_cast<NominalTypeDecl>(decl))
461-
idc = nominal;
462-
else if (auto ext = dyn_cast<ExtensionDecl>(decl))
463-
idc = ext;
464-
else
465-
idc = nullptr;
466-
467-
// Look for an @unsafe conformance ascribed to this declaration.
468-
if (idc) {
469-
auto conformances = idc->getLocalConformances();
470-
for (auto conformance : conformances) {
471-
auto rootConformance = conformance->getRootConformance();
472-
if (auto rootNormalConformance =
473-
dyn_cast<NormalProtocolConformance>(rootConformance)) {
474-
if (rootNormalConformance->getExplicitSafety() == ExplicitSafety::Unsafe)
475-
return true;
476-
}
477-
}
478-
}
479-
480-
return false;
481-
}
482-
483454
UNINTERESTING_FEATURE(StrictMemorySafety)
484455
UNINTERESTING_FEATURE(SafeInteropWrappers)
485456
UNINTERESTING_FEATURE(AssumeResilientCxxTypes)

test/Unsafe/interface_printing.swift

Lines changed: 0 additions & 10 deletions
This file was deleted.

test/Unsafe/module-interface.swift

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22
// RUN: %target-swift-typecheck-module-from-interface(%t.swiftinterface) -module-name UserModule
33
// RUN: %FileCheck %s < %t.swiftinterface
44

5-
// CHECK: #if compiler(>=5.3) && $MemorySafetyAttributes
65
// CHECK: @unsafe public func getIntUnsafely() -> Swift.Int
7-
// CHECK: #else
8-
// CHECK: public func getIntUnsafely() -> Swift.Int
9-
// CHECK: #endif
106
@unsafe public func getIntUnsafely() -> Int { 0 }
117

128
public struct UnsafeIterator: @unsafe IteratorProtocol {
@@ -33,13 +29,8 @@ public protocol P {
3329
func f()
3430
}
3531

36-
// CHECK: #if compiler(>=5.3) && $MemorySafetyAttributes
3732
// CHECK: public struct X : @unsafe UserModule.P
3833
public struct X: @unsafe P {
3934
// CHECK: @unsafe public func f()
40-
// CHECK: #else
41-
// CHECK: public struct X : UserModule.P
42-
// CHECK: public func f()
43-
// CHECK: #endif
4435
@unsafe public func f() { }
4536
}

0 commit comments

Comments
 (0)