Skip to content

Commit f4e49d5

Browse files
committed
Sema: Fix UB in NonisolatedNonsendingByDefault migration diagnosis
The diagnostic can outlive the locally constructed attribute, which was passed by pointer, if there is an active `DiagnosticTransaction`.
1 parent f57e2d7 commit f4e49d5

File tree

3 files changed

+51
-51
lines changed

3 files changed

+51
-51
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8698,23 +8698,23 @@ GROUPED_WARNING(
86988698
attr_execution_nonisolated_behavior_will_change_decl, NonisolatedNonsendingByDefault,
86998699
none,
87008700
"feature '%0' will cause nonisolated async %kindbase1 to run on the "
8701-
"caller's actor; use %2 to preserve behavior",
8702-
(StringRef, const AbstractFunctionDecl *, DeclAttribute))
8701+
"caller's actor; use '@concurrent' to preserve behavior",
8702+
(StringRef, const AbstractFunctionDecl *))
87038703

87048704
GROUPED_WARNING(
87058705
attr_execution_nonisolated_behavior_will_change_closure,
87068706
NonisolatedNonsendingByDefault, none,
87078707
"feature '%0' will cause nonisolated async closure to run on the caller's "
8708-
"actor; use %1 to preserve behavior",
8709-
(StringRef, DeclAttribute))
8708+
"actor; use '@concurrent' to preserve behavior",
8709+
(StringRef))
87108710

87118711
GROUPED_WARNING(
87128712
attr_execution_nonisolated_behavior_will_change_typerepr,
87138713
NonisolatedNonsendingByDefault, none,
87148714
"feature '%0' will cause nonisolated async function type to be treated as "
8715-
"specified to run on the caller's actor; use %1 to preserve "
8715+
"specified to run on the caller's actor; use '@concurrent' to preserve "
87168716
"behavior",
8717-
(StringRef, DeclAttribute))
8717+
(StringRef))
87188718

87198719
//===----------------------------------------------------------------------===//
87208720
// MARK: @extensible and @preEnumExtensibility Attributes

lib/Sema/NonisolatedNonsendingByDefaultMigration.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,21 +168,21 @@ void NonisolatedNonsendingByDefaultMigrationTarget::diagnose() const {
168168
ctx.Diags
169169
.diagnose(functionDecl->getLoc(),
170170
diag::attr_execution_nonisolated_behavior_will_change_decl,
171-
featureName, functionDecl, &attr)
171+
featureName, functionDecl)
172172
.fixItInsertAttribute(
173173
decl->getAttributeInsertionLoc(/*forModifier=*/false), &attr);
174174
} else if (closure) {
175175
ctx.Diags
176176
.diagnose(closure->getLoc(),
177177
diag::attr_execution_nonisolated_behavior_will_change_closure,
178-
featureName, &attr)
178+
featureName)
179179
.fixItAddAttribute(&attr, closure);
180180
} else {
181181
ctx.Diags
182182
.diagnose(
183183
functionRepr->getStartLoc(),
184184
diag::attr_execution_nonisolated_behavior_will_change_typerepr,
185-
featureName, &attr)
185+
featureName)
186186
.fixItInsertAttribute(functionRepr->getStartLoc(), &attr);
187187
}
188188
}

0 commit comments

Comments
 (0)