mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Rename "Unsafe" diagnostic group to "StrictMemorySafety"
This lines up with the feature name and is more consistent. Thank you, Anthony, for the suggestion.
This commit is contained in:
@@ -23,7 +23,7 @@
|
||||
GROUP(no_group, "")
|
||||
|
||||
GROUP(DeprecatedDeclaration, "deprecated-declaration.md")
|
||||
GROUP(Unsafe, "unsafe.md")
|
||||
GROUP(StrictMemorySafety, "strict-memory-safety.md")
|
||||
GROUP(UnknownWarningGroup, "unknown-warning-group.md")
|
||||
GROUP(PreconcurrencyImport, "preconcurrency-import.md")
|
||||
GROUP(StrictLanguageFeatures, "strict-language-features.md")
|
||||
|
||||
@@ -590,7 +590,7 @@ ERROR(experimental_not_supported_in_production,none,
|
||||
"experimental feature '%0' cannot be enabled in production compiler",
|
||||
(StringRef))
|
||||
|
||||
GROUPED_WARNING(command_line_conflicts_with_strict_safety,Unsafe,none,
|
||||
GROUPED_WARNING(command_line_conflicts_with_strict_safety,StrictMemorySafety,none,
|
||||
"'%0' is not memory-safe and should not be combined with "
|
||||
"strict memory safety checking", (StringRef))
|
||||
|
||||
|
||||
@@ -8196,7 +8196,7 @@ NOTE(note_use_of_unsafe_conformance_is_unsafe,none,
|
||||
NOTE(note_unsafe_storage,none,
|
||||
"%kindbase1 involves unsafe type %2", (bool, const ValueDecl *, Type))
|
||||
|
||||
GROUPED_WARNING(decl_unsafe_storage,Unsafe,none,
|
||||
GROUPED_WARNING(decl_unsafe_storage,StrictMemorySafety,none,
|
||||
"%kindbase0 has storage involving unsafe types",
|
||||
(const Decl *))
|
||||
NOTE(decl_storage_mark_unsafe,none,
|
||||
@@ -8206,11 +8206,11 @@ NOTE(decl_storage_mark_safe,none,
|
||||
"add '@safe' if this type encapsulates the unsafe storage in "
|
||||
"a safe interface", ())
|
||||
|
||||
GROUPED_WARNING(unsafe_superclass,Unsafe,none,
|
||||
GROUPED_WARNING(unsafe_superclass,StrictMemorySafety,none,
|
||||
"%kindbase0 has superclass involving unsafe type %1",
|
||||
(const ValueDecl *, Type))
|
||||
|
||||
GROUPED_WARNING(conformance_involves_unsafe,Unsafe,none,
|
||||
GROUPED_WARNING(conformance_involves_unsafe,StrictMemorySafety,none,
|
||||
"conformance of %0 to %kind1 involves unsafe code; use '@unsafe' to "
|
||||
"indicate that the conformance is not memory-safe",
|
||||
(Type, const ValueDecl *))
|
||||
@@ -8221,15 +8221,15 @@ NOTE(note_type_witness_unsafe,none,
|
||||
"unsafe type %0 cannot satisfy safe associated type %1",
|
||||
(Type, DeclName))
|
||||
|
||||
GROUPED_WARNING(override_safe_with_unsafe,Unsafe,none,
|
||||
GROUPED_WARNING(override_safe_with_unsafe,StrictMemorySafety,none,
|
||||
"override of safe %0 with unsafe %0", (DescriptiveDeclKind))
|
||||
|
||||
GROUPED_WARNING(preconcurrency_import_unsafe,Unsafe,none,
|
||||
GROUPED_WARNING(preconcurrency_import_unsafe,StrictMemorySafety,none,
|
||||
"@preconcurrency import is not memory-safe because it can silently "
|
||||
"introduce data races", ())
|
||||
GROUPED_WARNING(unsafe_without_unsafe,Unsafe,none,
|
||||
GROUPED_WARNING(unsafe_without_unsafe,StrictMemorySafety,none,
|
||||
"expression uses unsafe constructs but is not marked with 'unsafe'", ())
|
||||
GROUPED_WARNING(for_unsafe_without_unsafe,Unsafe,none,
|
||||
GROUPED_WARNING(for_unsafe_without_unsafe,StrictMemorySafety,none,
|
||||
"for-in loop uses unsafe constructs but is not marked with 'unsafe'", ())
|
||||
WARNING(no_unsafe_in_unsafe,none,
|
||||
"no unsafe operations occur within 'unsafe' expression", ())
|
||||
|
||||
@@ -91,9 +91,9 @@ func testUnsafeAsSequenceForEach() {
|
||||
|
||||
// expected-warning@+1{{expression uses unsafe constructs but is not marked with 'unsafe'}}{{12-12=unsafe }}
|
||||
for _ in uas { } // expected-note{{conformance}}
|
||||
// expected-warning@-1{{for-in loop uses unsafe constructs but is not marked with 'unsafe' [Unsafe]}}{{7-7=unsafe }}
|
||||
// expected-warning@-1{{for-in loop uses unsafe constructs but is not marked with 'unsafe' [StrictMemorySafety]}}{{7-7=unsafe }}
|
||||
|
||||
for _ in unsafe uas { } // expected-warning{{for-in loop uses unsafe constructs but is not marked with 'unsafe' [Unsafe]}}{{7-7=unsafe }}
|
||||
for _ in unsafe uas { } // expected-warning{{for-in loop uses unsafe constructs but is not marked with 'unsafe' [StrictMemorySafety]}}{{7-7=unsafe }}
|
||||
|
||||
for unsafe _ in unsafe uas { } // okay
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ class NotSafeSubclass: NotSafe {
|
||||
_ = NotSafe[ns]
|
||||
NotSafe.doStatically(NotSafe.self)
|
||||
|
||||
ns.stillUnsafe() // expected-warning{{expression uses unsafe constructs but is not marked with 'unsafe' [Unsafe]}}
|
||||
ns.stillUnsafe() // expected-warning{{expression uses unsafe constructs but is not marked with 'unsafe' [StrictMemorySafety]}}
|
||||
// expected-note@-1{{reference to parameter 'ns' involves unsafe type 'NotSafe'}}
|
||||
// expected-note@-2{{reference to unsafe instance method 'stillUnsafe()'}}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ class C {
|
||||
|
||||
class D1: C { // expected-note{{make class 'D1' @unsafe to allow unsafe overrides of safe superclass methods}}{{1-1=@unsafe }}
|
||||
@unsafe
|
||||
override func method() { } // expected-warning{{override of safe instance method with unsafe instance method [Unsafe]}}
|
||||
override func method() { } // expected-warning{{override of safe instance method with unsafe instance method [StrictMemorySafety]}}
|
||||
}
|
||||
|
||||
@unsafe class D2: C {
|
||||
@@ -34,7 +34,7 @@ protocol P {
|
||||
}
|
||||
|
||||
struct S1: P {
|
||||
// expected-warning@-1{{conformance of 'S1' to protocol 'P' involves unsafe code; use '@unsafe' to indicate that the conformance is not memory-safe [Unsafe]}}{{12-12=@unsafe }}
|
||||
// expected-warning@-1{{conformance of 'S1' to protocol 'P' involves unsafe code; use '@unsafe' to indicate that the conformance is not memory-safe [StrictMemorySafety]}}{{12-12=@unsafe }}
|
||||
@unsafe
|
||||
func protoMethod() { } // expected-note{{unsafe instance method 'protoMethod()' cannot satisfy safe requirement}}
|
||||
}
|
||||
@@ -48,7 +48,7 @@ struct S2: P {
|
||||
struct S3 { }
|
||||
|
||||
extension S3: P {
|
||||
// expected-warning@-1{{conformance of 'S3' to protocol 'P' involves unsafe code; use '@unsafe' to indicate that the conformance is not memory-safe [Unsafe]}}{{15-15=@unsafe }}
|
||||
// expected-warning@-1{{conformance of 'S3' to protocol 'P' involves unsafe code; use '@unsafe' to indicate that the conformance is not memory-safe [StrictMemorySafety]}}{{15-15=@unsafe }}
|
||||
@unsafe
|
||||
func protoMethod() { } // expected-note{{unsafe instance method 'protoMethod()' cannot satisfy safe requirement}}
|
||||
}
|
||||
@@ -116,12 +116,12 @@ extension UnsafeOuter {
|
||||
var yieldUnsafe: Int {
|
||||
_read {
|
||||
@unsafe let x = 5
|
||||
yield x // expected-warning{{expression uses unsafe constructs but is not marked with 'unsafe' [Unsafe]}}
|
||||
yield x // expected-warning{{expression uses unsafe constructs but is not marked with 'unsafe' [StrictMemorySafety]}}
|
||||
// expected-note@-1{{reference to unsafe let 'x'}}
|
||||
}
|
||||
_modify {
|
||||
@unsafe var x = 5
|
||||
yield &x // expected-warning{{expression uses unsafe constructs but is not marked with 'unsafe' [Unsafe]}}
|
||||
yield &x // expected-warning{{expression uses unsafe constructs but is not marked with 'unsafe' [StrictMemorySafety]}}
|
||||
// expected-note@-1{{reference to unsafe var 'x'}}
|
||||
}
|
||||
}
|
||||
@@ -142,9 +142,9 @@ struct UnsafeSequence: @unsafe IteratorProtocol, @unsafe Sequence {
|
||||
}
|
||||
|
||||
func forEachLoop(us: UnsafeSequence) {
|
||||
for _ in us { } // expected-warning{{expression uses unsafe constructs but is not marked with 'unsafe' [Unsafe]}}{{12-12=unsafe }}
|
||||
for _ in us { } // expected-warning{{expression uses unsafe constructs but is not marked with 'unsafe' [StrictMemorySafety]}}{{12-12=unsafe }}
|
||||
// expected-note@-1{{@unsafe conformance of 'UnsafeSequence' to protocol 'Sequence' involves unsafe code}}
|
||||
// expected-warning@-2{{for-in loop uses unsafe constructs but is not marked with 'unsafe' [Unsafe]}}
|
||||
// expected-warning@-2{{for-in loop uses unsafe constructs but is not marked with 'unsafe' [StrictMemorySafety]}}
|
||||
for _ in unsafe us { }
|
||||
// expected-warning@-1{{for-in loop uses unsafe constructs but is not marked with 'unsafe' [Unsafe]}}
|
||||
// expected-warning@-1{{for-in loop uses unsafe constructs but is not marked with 'unsafe' [StrictMemorySafety]}}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ protocol P {
|
||||
@unsafe func g()
|
||||
}
|
||||
|
||||
struct XP: P { // expected-warning{{conformance of 'XP' to protocol 'P' involves unsafe code; use '@unsafe' to indicate that the conformance is not memory-safe [Unsafe]}}{{12-12=@unsafe }}
|
||||
struct XP: P { // expected-warning{{conformance of 'XP' to protocol 'P' involves unsafe code; use '@unsafe' to indicate that the conformance is not memory-safe [StrictMemorySafety]}}{{12-12=@unsafe }}
|
||||
@unsafe func f() { } // expected-note{{unsafe instance method 'f()' cannot satisfy safe requirement}}
|
||||
@unsafe func g() { }
|
||||
}
|
||||
@@ -30,7 +30,7 @@ protocol Ptrable2 {
|
||||
}
|
||||
|
||||
extension HasAPointerType: Ptrable2 { } // expected-note{{unsafe type 'HasAPointerType.Ptr' (aka 'PointerType') cannot satisfy safe associated type 'Ptr'}}
|
||||
// expected-warning@-1{{conformance of 'HasAPointerType' to protocol 'Ptrable2' involves unsafe code; use '@unsafe' to indicate that the conformance is not memory-safe [Unsafe]}}{{28-28=@unsafe }}
|
||||
// expected-warning@-1{{conformance of 'HasAPointerType' to protocol 'Ptrable2' involves unsafe code; use '@unsafe' to indicate that the conformance is not memory-safe [StrictMemorySafety]}}{{28-28=@unsafe }}
|
||||
|
||||
struct UnsafeXP: @unsafe P {
|
||||
@unsafe func f() { }
|
||||
@@ -44,7 +44,7 @@ protocol MultiP {
|
||||
|
||||
struct ConformsToMultiP { }
|
||||
|
||||
// expected-warning@+1{{conformance of 'ConformsToMultiP' to protocol 'MultiP' involves unsafe code; use '@unsafe' to indicate that the conformance is not memory-safe [Unsafe]}}{{29-29=@unsafe }}
|
||||
// expected-warning@+1{{conformance of 'ConformsToMultiP' to protocol 'MultiP' involves unsafe code; use '@unsafe' to indicate that the conformance is not memory-safe [StrictMemorySafety]}}{{29-29=@unsafe }}
|
||||
extension ConformsToMultiP: MultiP {
|
||||
// expected-note@-1{{unsafe type 'UnsafeSuper' cannot satisfy safe associated type 'Ptr'}}
|
||||
@unsafe func f() -> UnsafeSuper {
|
||||
@@ -74,7 +74,7 @@ class Super {
|
||||
}
|
||||
|
||||
class Sub: Super { // expected-note{{make class 'Sub' @unsafe to allow unsafe overrides of safe superclass methods}}{{1-1=@unsafe }}
|
||||
@unsafe override func f() { } // expected-warning{{override of safe instance method with unsafe instance method [Unsafe]}}
|
||||
@unsafe override func f() { } // expected-warning{{override of safe instance method with unsafe instance method [StrictMemorySafety]}}
|
||||
@unsafe override func g() { }
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ class ExclusivityChecking {
|
||||
func f() { }
|
||||
};
|
||||
|
||||
// expected-warning@+1{{class 'UnsafeSub' has superclass involving unsafe type 'UnsafeSuper' [Unsafe]}}{{1-1=@unsafe }}
|
||||
// expected-warning@+1{{class 'UnsafeSub' has superclass involving unsafe type 'UnsafeSuper' [StrictMemorySafety]}}{{1-1=@unsafe }}
|
||||
class UnsafeSub: UnsafeSuper { }
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
@@ -129,13 +129,13 @@ struct BufferThingy<T> {
|
||||
}
|
||||
|
||||
func testConstruction() {
|
||||
let _ = BufferThingy<Int>(count: 17) // expected-warning{{expression uses unsafe constructs but is not marked with 'unsafe' [Unsafe]}}{{11-11=unsafe }}
|
||||
let _ = BufferThingy<Int>(count: 17) // expected-warning{{expression uses unsafe constructs but is not marked with 'unsafe' [StrictMemorySafety]}}{{11-11=unsafe }}
|
||||
// expected-note@-1{{reference to unsafe initializer 'init(count:)'}}
|
||||
}
|
||||
|
||||
func testRHS(b: Bool, x: Int) {
|
||||
@unsafe let limit = 17
|
||||
if b && x > limit { // expected-warning{{expression uses unsafe constructs but is not marked with 'unsafe' [Unsafe]}}{{6-6=unsafe }}
|
||||
if b && x > limit { // expected-warning{{expression uses unsafe constructs but is not marked with 'unsafe' [StrictMemorySafety]}}{{6-6=unsafe }}
|
||||
// expected-note@-1{{reference to unsafe let 'limit'}}
|
||||
}
|
||||
}
|
||||
@@ -171,7 +171,7 @@ typealias SuperUnsafe = UnsafeSuper
|
||||
|
||||
@unsafe typealias SuperUnsafe2 = UnsafeSuper
|
||||
|
||||
// expected-warning@+3{{enum 'HasUnsafeThings' has storage involving unsafe types [Unsafe]}}
|
||||
// expected-warning@+3{{enum 'HasUnsafeThings' has storage involving unsafe types [StrictMemorySafety]}}
|
||||
// expected-note@+2{{add '@unsafe' if this type is also unsafe to use}}{{1-1=@unsafe }}
|
||||
// expected-note@+1{{add '@safe' if this type encapsulates the unsafe storage in a safe interface}}{{1-1=@safe }}
|
||||
enum HasUnsafeThings {
|
||||
@@ -181,7 +181,7 @@ case one(UnsafeSuper) // expected-note{{enum case 'one' involves unsafe type 'Un
|
||||
case two(UnsafeSuper) // expected-note{{enum case 'two' involves unsafe type 'UnsafeSuper'}}
|
||||
}
|
||||
|
||||
// expected-warning@+3{{class 'ClassWithUnsafeStorage' has storage involving unsafe types [Unsafe]}}
|
||||
// expected-warning@+3{{class 'ClassWithUnsafeStorage' has storage involving unsafe types [StrictMemorySafety]}}
|
||||
// expected-note@+2{{add '@unsafe' if this type is also unsafe to use}}{{1-1=@unsafe }}
|
||||
// expected-note@+1{{add '@safe' if this type encapsulates the unsafe storage in a safe interface}}{{1-1=@safe }}
|
||||
class ClassWithUnsafeStorage {
|
||||
|
||||
Reference in New Issue
Block a user