Skip to content

Commit 9c4da1f

Browse files
authored
Merge pull request #75597 from gottesmm/incremental-diagnostics
[region-isolation] Incremental diagnostic updates
2 parents 36c8af8 + 0f61f29 commit 9c4da1f

23 files changed

+475
-171
lines changed

include/swift/AST/DiagnosticsSIL.def

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -944,39 +944,25 @@ ERROR(regionbasedisolation_unknown_pattern, none,
944944
"pattern that the region based isolation checker does not understand how to check. Please file a bug",
945945
())
946946

947-
//===---
948-
// Old Transfer Non Sendable Diagnostics
949-
//
950-
951-
ERROR(regionbasedisolation_transfer_yields_race_no_isolation, none,
952-
"sending value of non-Sendable type %0 with later accesses risks causing data races",
953-
(Type))
954-
ERROR(regionbasedisolation_transfer_yields_race_with_isolation, none,
955-
"sending value of non-Sendable type %0 with later accesses from %1 context to %2 context risks causing data races",
956-
(Type, ActorIsolation, ActorIsolation))
957-
ERROR(regionbasedisolation_isolated_capture_yields_race, none,
958-
"%1 closure captures value of non-Sendable type %0 from %2 context; later accesses to value could race",
959-
(Type, ActorIsolation, ActorIsolation))
960-
ERROR(regionbasedisolation_transfer_yields_race_stronglytransferred_binding, none,
961-
"value of non-Sendable type %0 accessed after being transferred; later accesses could race",
962-
(Type))
963-
ERROR(regionbasedisolation_arg_transferred, none,
964-
"sending %0 value of type %1 with later accesses to %2 context risks causing data races",
965-
(StringRef, Type, ActorIsolation))
966-
ERROR(regionbasedisolation_arg_passed_to_strongly_transferred_param, none,
967-
"%0 value of type %1 passed as a strongly transferred parameter; later accesses could race",
968-
(StringRef, Type))
969-
970-
//===---
971-
// New Transfer Non Sendable Diagnostics
972-
//
973-
974947
ERROR(regionbasedisolation_named_transfer_yields_race, none,
975948
"sending %0 risks causing data races",
976949
(Identifier))
977950
NOTE(regionbasedisolation_type_is_non_sendable, none,
978951
"%0 is a non-Sendable type",
979952
(Type))
953+
ERROR(regionbasedisolation_type_transfer_yields_race, none,
954+
"sending value of non-Sendable type %0 risks causing data races",
955+
(Type))
956+
957+
NOTE(regionbasedisolation_type_use_after_transfer, none,
958+
"sending value of non-Sendable type %0 to %1 callee risks causing data races between %1 and local %2 uses",
959+
(Type, ActorIsolation, ActorIsolation))
960+
NOTE(regionbasedisolation_type_use_after_transfer_callee, none,
961+
"sending value of non-Sendable type %0 to %1 %2 %3 risks causing data races between %1 and local %4 uses",
962+
(Type, ActorIsolation, DescriptiveDeclKind, DeclName, ActorIsolation))
963+
NOTE(regionbasedisolation_type_isolated_capture_yields_race, none,
964+
"sending value of non-Sendable type %0 to %1 closure due to closure capture risks causing races in between %1 and %2 uses",
965+
(Type, ActorIsolation, ActorIsolation))
980966

981967
ERROR(regionbasedisolation_inout_sending_cannot_be_actor_isolated, none,
982968
"'inout sending' parameter %0 cannot be %1at end of function",
@@ -1028,11 +1014,31 @@ NOTE(regionbasedisolation_named_value_used_after_explicit_sending, none,
10281014
NOTE(regionbasedisolation_named_isolated_closure_yields_race, none,
10291015
"%0%1 is captured by a %2 closure. %2 uses in closure may race against later %3 uses",
10301016
(StringRef, Identifier, ActorIsolation, ActorIsolation))
1017+
NOTE(regionbasedisolation_typed_tns_passed_to_sending, none,
1018+
"Passing %0 value of non-Sendable type %1 as a 'sending' parameter risks causing races inbetween %0 uses and uses reachable from the callee",
1019+
(StringRef, Type))
1020+
NOTE(regionbasedisolation_typed_tns_passed_to_sending_callee, none,
1021+
"Passing %0 value of non-Sendable type %1 as a 'sending' parameter to %2 %3 risks causing races inbetween %0 uses and uses reachable from %3",
1022+
(StringRef, Type, DescriptiveDeclKind, DeclName))
10311023

10321024
NOTE(regionbasedisolation_named_transfer_nt_asynclet_capture, none,
10331025
"sending %1 %0 into async let risks causing data races between nonisolated and %1 uses",
10341026
(Identifier, StringRef))
10351027

1028+
NOTE(regionbasedisolation_typed_use_after_sending, none,
1029+
"Passing value of non-Sendable type %0 as a 'sending' argument risks causing races in between local and caller code",
1030+
(Type))
1031+
NOTE(regionbasedisolation_typed_use_after_sending_callee, none,
1032+
"Passing value of non-Sendable type %0 as a 'sending' argument to %1 %2 risks causing races in between local and caller code",
1033+
(Type, DescriptiveDeclKind, DeclName))
1034+
1035+
NOTE(regionbasedisolation_typed_transferneversendable_via_arg, none,
1036+
"sending %0 value of non-Sendable type %1 to %2 callee risks causing races in between %0 and %2 uses",
1037+
(StringRef, Type, ActorIsolation))
1038+
NOTE(regionbasedisolation_typed_transferneversendable_via_arg_callee, none,
1039+
"sending %0 value of non-Sendable type %1 to %2 %3 %4 risks causing races in between %0 and %2 uses",
1040+
(StringRef, Type, ActorIsolation, DescriptiveDeclKind, DeclName))
1041+
10361042
// Misc Error.
10371043
ERROR(regionbasedisolation_task_or_actor_isolated_transferred, none,
10381044
"task or actor isolated value cannot be sent", ())

include/swift/SILOptimizer/Utils/SILIsolationInfo.h

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -346,18 +346,6 @@ class SILIsolationInfo {
346346
Flag::UnappliedIsolatedAnyParameter};
347347
}
348348

349-
/// Only use this as a fallback if we cannot find better information.
350-
static SILIsolationInfo
351-
getWithIsolationCrossing(ApplyIsolationCrossing crossing) {
352-
if (crossing.getCalleeIsolation().isActorIsolated()) {
353-
// SIL level, just let it through
354-
return SILIsolationInfo(SILValue(), SILValue(),
355-
crossing.getCalleeIsolation());
356-
}
357-
358-
return {};
359-
}
360-
361349
static SILIsolationInfo getActorInstanceIsolated(SILValue isolatedValue,
362350
SILValue actorInstance,
363351
NominalTypeDecl *typeDecl) {
@@ -463,6 +451,20 @@ class SILIsolationInfo {
463451

464452
private:
465453
void printOptions(llvm::raw_ostream &os) const;
454+
455+
/// This is used only to let through apply isolation crossings that we define
456+
/// in SIL just for testing. Do not use this in any other contexts!
457+
static SILIsolationInfo
458+
getWithIsolationCrossing(ApplyIsolationCrossing crossing) {
459+
if (!crossing.getCalleeIsolation().isActorIsolated())
460+
return {};
461+
462+
// SIL level, just let it through without an actor instance. We assume since
463+
// we are using this for SIL tests that we do not need to worry about having
464+
// a null actor instance.
465+
return SILIsolationInfo(SILValue(), SILValue(),
466+
crossing.getCalleeIsolation());
467+
}
466468
};
467469

468470
/// A SILIsolationInfo that has gone through merging and represents the dynamic

0 commit comments

Comments
 (0)