Skip to content

Commit edf41ce

Browse files
committed
[DiagnoseStaticExclusivity] Fix this assertion.
This function is called in one place in an assertion. It asserts that the function in question is the stdlib's swap. In language mode 6, the called value may be wrapped in a `function_conversion_expr` for `@Sendable`. That's irrelevant for the purposes of this assertion, so look through such conversions. rdar://160692694
1 parent 92352b8 commit edf41ce

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lib/SILOptimizer/Mandatory/DiagnoseStaticExclusivity.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ static StringRef extractExprText(const Expr *E, SourceManager &SM) {
336336
/// it is in the ifndef.
337337
#ifndef NDEBUG
338338
static bool isCallToStandardLibrarySwap(CallExpr *CE, ASTContext &Ctx) {
339-
if (CE->getCalledValue() == Ctx.getSwap())
339+
if (CE->getCalledValue(/*skipFunctionConversions=*/true) == Ctx.getSwap())
340340
return true;
341341

342342
// Is the call module qualified, i.e. Swift.swap(&a[i], &[j)?
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %target-swift-frontend \
2+
// RUN: -c \
3+
// RUN: -verify \
4+
// RUN: -disable-availability-checking \
5+
// RUN: -swift-version 6 \
6+
// RUN: %s
7+
8+
typealias A = InlineArray<2, UInt64>
9+
func mix(_ a: inout A) {
10+
swap(&a[0], &a[1]) // expected-error{{overlapping accesses}}
11+
// expected-note@-1{{conflicting access}}
12+
}

0 commit comments

Comments
 (0)