Skip to content

Commit cf7fcf2

Browse files
committed
Fix test and improve dumper
1 parent 268d5cc commit cf7fcf2

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

lib/AST/AvailabilityContext.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,9 @@ void AvailabilityContext::print(llvm::raw_ostream &os) const {
241241

242242
if (isDeprecated())
243243
os << " deprecated";
244+
245+
if (allowsUnsafe())
246+
os << " allows_unsafe";
244247
}
245248

246249
void AvailabilityContext::dump() const { print(llvm::errs()); }

test/Interop/Cxx/class/safe-interop-mode.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,20 @@ struct MyContainer {
5555
import Test
5656
import CoreFoundation
5757

58+
// expected-note@+1{{mark the enclosing global function 'useUnsafeParam' '@unsafe' to allow it to use unsafe constructs}}{{1-1=@unsafe }}
5859
func useUnsafeParam(x: Unannotated) { // expected-warning{{reference to unsafe struct 'Unannotated'}}
5960
}
6061

62+
// expected-note@+2{{mark the enclosing global function 'useUnsafeParam2' '@unsafe' to allow it to use unsafe constructs}}{{10:1-1=@unsafe }}
6163
@available(SwiftStdlib 5.8, *)
6264
func useUnsafeParam2(x: UnsafeReference) { // expected-warning{{reference to unsafe class 'UnsafeReference'}}
6365
}
6466

67+
// expected-note@+1{{mark the enclosing global function 'useUnsafeParam3' '@unsafe' to allow it to use unsafe constructs}}{{1-1=@unsafe }}
6568
func useUnsafeParam3(x: UnknownEscapabilityAggregate) { // expected-warning{{reference to unsafe struct 'UnknownEscapabilityAggregate'}}
6669
}
6770

71+
// expected-note@+1{{mark the enclosing global function 'useSafeParams' '@unsafe' to allow it to use unsafe constructs}}{{1-1=@unsafe }}
6872
func useSafeParams(x: Owner, y: View, z: SafeEscapableAggregate, c: MyContainer) {
6973
let _ = c.__beginUnsafe() // expected-warning{{call to unsafe instance method '__beginUnsafe'}}
7074
}

0 commit comments

Comments
 (0)