Skip to content

Commit e5a10a3

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`. (cherry picked from commit f4e49d5)
1 parent 5889371 commit e5a10a3

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
@@ -8634,23 +8634,23 @@ GROUPED_WARNING(
86348634
attr_execution_nonisolated_behavior_will_change_decl, NonisolatedNonsendingByDefault,
86358635
none,
86368636
"feature '%0' will cause nonisolated async %kindbase1 to run on the "
8637-
"caller's actor; use %2 to preserve behavior",
8638-
(StringRef, const AbstractFunctionDecl *, DeclAttribute))
8637+
"caller's actor; use '@concurrent' to preserve behavior",
8638+
(StringRef, const AbstractFunctionDecl *))
86398639
86408640
GROUPED_WARNING(
86418641
attr_execution_nonisolated_behavior_will_change_closure,
86428642
NonisolatedNonsendingByDefault, none,
86438643
"feature '%0' will cause nonisolated async closure to run on the caller's "
8644-
"actor; use %1 to preserve behavior",
8645-
(StringRef, DeclAttribute))
8644+
"actor; use '@concurrent' to preserve behavior",
8645+
(StringRef))
86468646
86478647
GROUPED_WARNING(
86488648
attr_execution_nonisolated_behavior_will_change_typerepr,
86498649
NonisolatedNonsendingByDefault, none,
86508650
"feature '%0' will cause nonisolated async function type to be treated as "
8651-
"specified to run on the caller's actor; use %1 to preserve "
8651+
"specified to run on the caller's actor; use '@concurrent' to preserve "
86528652
"behavior",
8653-
(StringRef, DeclAttribute))
8653+
(StringRef))
86548654
86558655
#define UNDEFINE_DIAGNOSTIC_MACROS
86568656
#include "DefineDiagnosticMacros.h"

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)