Skip to content

Commit 16627a0

Browse files
authored
Merge pull request swiftlang#75703 from gottesmm/pr-12c964b902efd010879d6af6f3ccc0d59563908c
[region-isolation] Re-group diagnostics in header based on which diagnostic emitter they are used by.
2 parents 262ba2b + 18a6109 commit 16627a0

File tree

1 file changed

+86
-55
lines changed

1 file changed

+86
-55
lines changed

include/swift/AST/DiagnosticsSIL.def

Lines changed: 86 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -935,55 +935,39 @@ NOTE(sil_referencebinding_inout_binding_here, none,
935935
// MARK: Region Based Isolation Diagnostics
936936
//===----------------------------------------------------------------------===//
937937

938-
NOTE(regionbasedisolation_maybe_race, none,
939-
"access can happen concurrently", ())
940-
NOTE(regionbasedisolation_inout_sending_must_be_reinitialized, none,
941-
"'inout sending' parameter must be reinitialized before function exit with a non-actor isolated value",
942-
())
938+
// READ THIS: Please when adding diagnostics for region based isolation, keep
939+
// them ordered in sections depending on which emitter uses it. It makes it
940+
// easier for people unfamiliar with the code to quickly see which diagnostics
941+
// are used by which of the SendNonSendable emitters use.
942+
943+
//===
944+
// Misc
945+
943946
ERROR(regionbasedisolation_unknown_pattern, none,
944947
"pattern that the region based isolation checker does not understand how to check. Please file a bug",
945948
())
949+
NOTE(regionbasedisolation_maybe_race, none,
950+
"access can happen concurrently", ())
951+
NOTE(regionbasedisolation_type_is_non_sendable, none,
952+
"%0 is a non-Sendable type",
953+
(Type))
954+
955+
//===
956+
// Use After Send Emitter
946957

947958
ERROR(regionbasedisolation_named_transfer_yields_race, none,
948959
"sending %0 risks causing data races",
949960
(Identifier))
950-
NOTE(regionbasedisolation_type_is_non_sendable, none,
951-
"%0 is a non-Sendable type",
952-
(Type))
953961
ERROR(regionbasedisolation_type_transfer_yields_race, none,
954962
"sending value of non-Sendable type %0 risks causing data races",
955963
(Type))
956-
957964
NOTE(regionbasedisolation_type_use_after_transfer, none,
958965
"sending value of non-Sendable type %0 to %1 callee risks causing data races between %1 and local %2 uses",
959966
(Type, ActorIsolation, ActorIsolation))
960967
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))
966-
967-
ERROR(regionbasedisolation_inout_sending_cannot_be_actor_isolated, none,
968-
"'inout sending' parameter %0 cannot be %1at end of function",
969-
(Identifier, StringRef))
970-
NOTE(regionbasedisolation_inout_sending_cannot_be_actor_isolated_note, none,
971-
"%1%0 risks causing races in between %1uses and caller uses since caller assumes value is not actor isolated",
972-
(Identifier, StringRef))
973-
974-
ERROR(regionbasedisolation_out_sending_cannot_be_actor_isolated_type, none,
975-
"returning a %1 %0 value as a 'sending' result risks causing data races",
976-
(Type, StringRef))
977-
NOTE(regionbasedisolation_out_sending_cannot_be_actor_isolated_note_type, none,
978-
"returning a %1 %0 value risks causing races since the caller assumes the value can be safely sent to other isolation domains",
979-
(Type, StringRef))
980-
981-
ERROR(regionbasedisolation_out_sending_cannot_be_actor_isolated_named, none,
982-
"returning %1 %0 as a 'sending' result risks causing data races",
983-
(Identifier, StringRef))
984-
NOTE(regionbasedisolation_out_sending_cannot_be_actor_isolated_note_named, none,
985-
"returning %1 %0 risks causing data races since the caller assumes that %0 can be safely sent to other isolation domains",
986-
(Identifier, StringRef))
968+
"sending value of non-Sendable type %0 to %1 %2 %3 risks causing data "
969+
"races between %1 and local %4 uses",
970+
(Type, ActorIsolation, DescriptiveDeclKind, DeclName, ActorIsolation))
987971

988972
NOTE(regionbasedisolation_named_info_transfer_yields_race, none,
989973
"sending %1%0 to %2 callee risks causing data races between %2 and local %3 uses",
@@ -992,57 +976,104 @@ NOTE(regionbasedisolation_named_info_transfer_yields_race_callee, none,
992976
"sending %1%0 to %2 %3 %4 risks causing data races between %2 and local %5 uses",
993977
(Identifier, StringRef, ActorIsolation, DescriptiveDeclKind, DeclName, ActorIsolation))
994978

979+
// Use after transfer closure.
980+
NOTE(regionbasedisolation_type_isolated_capture_yields_race, none,
981+
"sending value of non-Sendable type %0 to %1 closure due to closure capture risks causing races in between %1 and %2 uses",
982+
(Type, ActorIsolation, ActorIsolation))
983+
984+
// Value captured in async let and reused.
985+
NOTE(regionbasedisolation_named_nonisolated_asynclet_name, none,
986+
"sending %0 into async let risks causing data races between async let uses and local uses",
987+
(Identifier))
988+
989+
NOTE(regionbasedisolation_named_value_used_after_explicit_sending, none,
990+
"%0 used after being passed as a 'sending' parameter; Later uses could race",
991+
(Identifier))
992+
NOTE(regionbasedisolation_named_isolated_closure_yields_race, none,
993+
"%0%1 is captured by a %2 closure. %2 uses in closure may race against later %3 uses",
994+
(StringRef, Identifier, ActorIsolation, ActorIsolation))
995+
996+
NOTE(regionbasedisolation_typed_use_after_sending, none,
997+
"Passing value of non-Sendable type %0 as a 'sending' argument risks causing races in between local and caller code",
998+
(Type))
999+
NOTE(regionbasedisolation_typed_use_after_sending_callee, none,
1000+
"Passing value of non-Sendable type %0 as a 'sending' argument to %1 %2 risks causing races in between local and caller code",
1001+
(Type, DescriptiveDeclKind, DeclName))
1002+
1003+
//===
1004+
// Sending Never Sendable Emitter
1005+
9951006
NOTE(regionbasedisolation_named_transfer_non_transferrable, none,
9961007
"sending %1%0 to %2 callee risks causing data races between %2 and %3 uses",
9971008
(Identifier, StringRef, ActorIsolation, StringRef))
9981009
NOTE(regionbasedisolation_named_transfer_non_transferrable_callee, none,
9991010
"sending %1%0 to %2 %3 %4 risks causing data races between %2 and %5 uses",
10001011
(Identifier, StringRef, ActorIsolation, DescriptiveDeclKind, DeclName, StringRef))
1001-
NOTE(regionbasedisolation_named_nonisolated_asynclet_name, none,
1002-
"sending %0 into async let risks causing data races between async let uses and local uses",
1003-
(Identifier))
10041012

10051013
NOTE(regionbasedisolation_named_transfer_into_sending_param, none,
1006-
"%0%1 is passed as a 'sending' parameter; Uses in callee may race with later %0uses",
1014+
"%0%1 is passed as a 'sending' parameter; Uses in callee may race with "
1015+
"later %0uses",
10071016
(StringRef, Identifier))
10081017
NOTE(regionbasedisolation_named_notransfer_transfer_into_result, none,
10091018
"%0%1 cannot be a 'sending' result. %2 uses may race with caller uses",
10101019
(StringRef, Identifier, StringRef))
1011-
NOTE(regionbasedisolation_named_value_used_after_explicit_sending, none,
1012-
"%0 used after being passed as a 'sending' parameter; Later uses could race",
1013-
(Identifier))
1014-
NOTE(regionbasedisolation_named_isolated_closure_yields_race, none,
1015-
"%0%1 is captured by a %2 closure. %2 uses in closure may race against later %3 uses",
1016-
(StringRef, Identifier, ActorIsolation, ActorIsolation))
10171020
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",
1021+
"Passing %0 value of non-Sendable type %1 as a 'sending' parameter risks "
1022+
"causing races inbetween %0 uses and uses reachable from the callee",
10191023
(StringRef, Type))
1024+
10201025
NOTE(regionbasedisolation_typed_tns_passed_to_sending_callee, none,
10211026
"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",
10221027
(StringRef, Type, DescriptiveDeclKind, DeclName))
10231028

10241029
NOTE(regionbasedisolation_named_transfer_nt_asynclet_capture, none,
10251030
"sending %1 %0 into async let risks causing data races between nonisolated and %1 uses",
10261031
(Identifier, StringRef))
1027-
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-
10351032
NOTE(regionbasedisolation_typed_transferneversendable_via_arg, none,
10361033
"sending %0 value of non-Sendable type %1 to %2 callee risks causing races in between %0 and %2 uses",
10371034
(StringRef, Type, ActorIsolation))
10381035
NOTE(regionbasedisolation_typed_transferneversendable_via_arg_callee, none,
10391036
"sending %0 value of non-Sendable type %1 to %2 %3 %4 risks causing races in between %0 and %2 uses",
10401037
(StringRef, Type, ActorIsolation, DescriptiveDeclKind, DeclName))
10411038

1042-
// Misc Error.
1039+
// Error that is only used when the send non sendable emitter cannot discover any
1040+
// information to give a better diagnostic.
10431041
ERROR(regionbasedisolation_task_or_actor_isolated_transferred, none,
10441042
"task or actor isolated value cannot be sent", ())
10451043

1044+
//===
1045+
// InOut Sending Emitter
1046+
1047+
NOTE(regionbasedisolation_inout_sending_must_be_reinitialized, none,
1048+
"'inout sending' parameter must be reinitialized before function exit with a non-actor isolated value",
1049+
())
1050+
ERROR(regionbasedisolation_inout_sending_cannot_be_actor_isolated, none,
1051+
"'inout sending' parameter %0 cannot be %1at end of function",
1052+
(Identifier, StringRef))
1053+
NOTE(regionbasedisolation_inout_sending_cannot_be_actor_isolated_note, none,
1054+
"%1%0 risks causing races in between %1uses and caller uses since caller assumes value is not actor isolated",
1055+
(Identifier, StringRef))
1056+
1057+
//===
1058+
// Out Sending
1059+
1060+
ERROR(regionbasedisolation_out_sending_cannot_be_actor_isolated_type, none,
1061+
"returning a %1 %0 value as a 'sending' result risks causing data races",
1062+
(Type, StringRef))
1063+
NOTE(regionbasedisolation_out_sending_cannot_be_actor_isolated_note_type, none,
1064+
"returning a %1 %0 value risks causing races since the caller assumes the value can be safely sent to other isolation domains",
1065+
(Type, StringRef))
1066+
ERROR(regionbasedisolation_out_sending_cannot_be_actor_isolated_named, none,
1067+
"returning %1 %0 as a 'sending' result risks causing data races",
1068+
(Identifier, StringRef))
1069+
NOTE(regionbasedisolation_out_sending_cannot_be_actor_isolated_note_named, none,
1070+
"returning %1 %0 risks causing data races since the caller assumes that %0 can be safely sent to other isolation domains",
1071+
(Identifier, StringRef))
1072+
1073+
//===----------------------------------------------------------------------===//
1074+
// MARK: Misc Diagnostics
1075+
//===----------------------------------------------------------------------===//
1076+
10461077
// TODO: print the name of the nominal type
10471078
ERROR(deinit_not_visible, none,
10481079
"deinit of non-copyable type not visible in the current module", ())

0 commit comments

Comments
 (0)