Skip to content

Commit 258c9d9

Browse files
committed
Merge remote-tracking branch 'origin/main' into rebranch
2 parents f7babf2 + 0081b28 commit 258c9d9

File tree

6 files changed

+41
-1
lines changed

6 files changed

+41
-1
lines changed

lib/AST/ASTWalker.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,6 +1461,10 @@ class Traversal : public ASTVisitor<Traversal, Expr*, Stmt*,
14611461
}
14621462

14631463
Expr *visitTypeValueExpr(TypeValueExpr *E) {
1464+
if (auto *TR = E->getRepr()) {
1465+
if (doIt(TR))
1466+
return nullptr;
1467+
}
14641468
return E;
14651469
}
14661470

lib/Sema/TypeCheckEffects.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3851,7 +3851,6 @@ class CheckEffectsCoverage : public EffectsHandlingWalker<CheckEffectsCoverage>
38513851
}
38523852

38533853
void preserveCoverageFromUnsafeOperand() {
3854-
OldFlags.mergeFrom(ContextFlags::HasAnyUnsafeSite, Self.Flags);
38553854
OldFlags.mergeFrom(ContextFlags::HasAnyUnsafe, Self.Flags);
38563855
OldFlags.mergeFrom(ContextFlags::asyncAwaitFlags(), Self.Flags);
38573856
OldFlags.mergeFrom(ContextFlags::throwFlags(), Self.Flags);

test/Index/index_generic_params.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,3 +165,16 @@ _ = C.Nested(value: 1)
165165
// CHECK-NEXT: [[@LINE+2]]:7 | struct/Swift | Nested | [[C_Nested_USR]] | Ref | rel: 0
166166
// CHECK-NEXT: [[@LINE+1]]:14 | constructor/Swift | init(value:) | [[C_Nested_init_USR]] | Ref,Call | rel: 0
167167
_ = C.Nested.init(value: 1)
168+
169+
// MARK: - Test value generic parameters
170+
171+
struct HasValueGenericParam<let Param: Int> {
172+
// CHECK: [[@LINE-1]]:33 | type-alias/generic-type-param/Swift | Param | s:14swift_ide_test20HasValueGenericParamV0G0xmfp | Def,RelChild | rel: 1
173+
// CHECK-NEXT: RelChild | struct/Swift | HasValueGenericParam
174+
func foo() {
175+
_ = Param
176+
// CHECK: [[@LINE-1]]:9 | type-alias/generic-type-param/Swift | Param | s:14swift_ide_test20HasValueGenericParamV0G0xmfp | Ref,RelCont | rel: 1
177+
// CHECK-NEXT: RelCont | instance-method/Swift | foo()
178+
}
179+
}
180+

test/SourceKit/CursorInfo/cursor_generics.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ public protocol Proto<Assoc> {
3434
associatedtype Assoc
3535
}
3636

37+
struct HasValueGenericParam<let Param: Int> {
38+
func foo() {
39+
_ = Param
40+
}
41+
}
42+
3743
// RUN: %sourcekitd-test -req=cursor -pos=1:10 %s -- %s | %FileCheck -check-prefix=CHECK1 %s
3844
// CHECK1: <Declaration>func testGenerics&lt;T&gt;(x: <Type usr="s:15cursor_generics12testGenerics1xyx_tlF1TL_xmfp">T</Type>)</Declaration>
3945

@@ -69,3 +75,7 @@ public protocol Proto<Assoc> {
6975
// CHECK_ASSOC_COMMON-NEXT: source.refactoring.kind.rename.global
7076
// CHECK_ASSOC_COMMON-NEXT: Global Rename
7177
// CHECK_ASSOC_COMMON-NEXT: ACTIONS END
78+
79+
// RUN: %sourcekitd-test -req=cursor -pos=39:9 %s -- %s | %FileCheck -check-prefix=CHECK_VALUE_GENERIC %s
80+
// CHECK_VALUE_GENERIC: source.lang.swift.ref.generic_type_param (37:33-37:38)
81+
// CHECK_VALUE_GENERIC: <Declaration>let Param : <Type usr="s:Si">Int</Type></Declaration>

test/Unsafe/safe.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,3 +384,10 @@ func testInterpolation(ptr: UnsafePointer<Int>) {
384384
// expected-note@-1{{reference to unsafe type 'UnsafePointer<Int>'}}
385385
// expected-note@-2{{argument #0 in call to instance method 'appendInterpolation' has unsafe type 'UnsafePointer<Int>'}}
386386
}
387+
388+
func superDuperUnsafe(_ bytes: UnsafeRawBufferPointer) {
389+
// expected-warning@+1{{no unsafe operations occur within 'unsafe' expression}}
390+
let byte = unsafe unsafe bytes.first ?? 0
391+
_ = byte
392+
_ = unsafe bytes.first ?? 0
393+
}

test/Unsafe/unsafe_nonstrict.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,10 @@ func testItAll(ut: UnsafeType, x: X, i: Int) {
1616
unsafe acceptP(x)
1717
_ = unsafe i // expected-warning{{no unsafe operations occur within 'unsafe' expression}}
1818
}
19+
20+
func superDuperUnsafe(_ bytes: UnsafeRawBufferPointer) {
21+
// expected-warning@+1{{no unsafe operations occur within 'unsafe' expression}}
22+
let byte = unsafe unsafe bytes.first ?? 0
23+
_ = byte
24+
_ = unsafe bytes.first ?? 0
25+
}

0 commit comments

Comments
 (0)