Skip to content

Commit fef1b5e

Browse files
committed
[region-isolation] Use VariableNameUtils to emit name diagnostics when possible.
A name diagnostic looks as follows: Some notes: 1. VariableNameUtils still doesn't pattern match all cases. In the cases where we fail to pattern match, I fall back to the old diagnostics. I am going to be adding tests/etc specific to VariableNameUtils in a later patch. 2. I took this as an opportunity to begin preparing to change the diagnostics into diags of the following form: a. The main diagnostic is changed to something short "transferring non-Sendable %0 could yield races with later accesses". b. I added a longer note at the same location that explains that our caller is in a specific isolation domain and our callee is isolated differently. c. I added a note on the definition location of the identified value.
1 parent a569160 commit fef1b5e

File tree

7 files changed

+226
-103
lines changed

7 files changed

+226
-103
lines changed

include/swift/AST/DiagnosticsSIL.def

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -894,8 +894,20 @@ NOTE(sil_referencebinding_inout_binding_here, none,
894894
"inout binding here",
895895
())
896896

897-
// Warnings arising from the flow-sensitive checking of Sendability of
898-
// non-Sendable values
897+
//===----------------------------------------------------------------------===//
898+
// MARK: Region Based Isolation Diagnostics
899+
//===----------------------------------------------------------------------===//
900+
901+
NOTE(regionbasedisolation_maybe_race, none,
902+
"access here could race", ())
903+
ERROR(regionbasedisolation_unknown_pattern, none,
904+
"pattern that the region based isolation checker does not understand how to check. Please file a bug",
905+
())
906+
907+
//===---
908+
// Old Transfer Non Sendable Diagnostics
909+
//
910+
899911
ERROR(regionbasedisolation_selforargtransferred, none,
900912
"call site passes `self` or a non-sendable argument of this function to another thread, potentially yielding a race with the caller", ())
901913
ERROR(regionbasedisolation_transfer_yields_race_no_isolation, none,
@@ -919,14 +931,28 @@ ERROR(regionbasedisolation_arg_transferred, none,
919931
ERROR(regionbasedisolation_arg_passed_to_strongly_transferred_param, none,
920932
"task isolated value of type %0 passed as a strongly transferred parameter; later accesses could race",
921933
(Type))
922-
NOTE(regionbasedisolation_maybe_race, none,
923-
"access here could race", ())
924934
NOTE(regionbasedisolation_isolated_since_in_same_region_basename, none,
925935
"value is %0 since it is in the same region as %1",
926936
(StringRef, DeclBaseName))
927-
ERROR(regionbasedisolation_unknown_pattern, none,
928-
"pattern that the region based isolation checker does not understand how to check. Please file a bug",
929-
())
937+
938+
//===---
939+
// New Transfer Non Sendable Diagnostics
940+
//
941+
942+
ERROR(regionbasedisolation_named_transfer_yields_race, none,
943+
"transferring non-Sendable binding %0 could yield races with later accesses",
944+
(Identifier))
945+
NOTE(regionbasedisolation_named_info_transfer_yields_race, none,
946+
"%0 is transferred from %1 caller to %2 callee. Later uses in caller could race with potential uses in callee",
947+
(Identifier, ActorIsolation, ActorIsolation))
948+
NOTE(regionbasedisolation_named_info_isolated_capture, none,
949+
"%1 binding %0 is captured by %2 closure. Later local uses could race",
950+
(Identifier, ActorIsolation, ActorIsolation))
951+
NOTE(regionbasedisolation_named_arg_info, none,
952+
"Transferring task isolated function argument %0 could yield races with caller uses",
953+
(Identifier))
954+
NOTE(regionbasedisolation_named_stronglytransferred_binding, none,
955+
"Cannot access a transferring parameter after the parameter has been transferred", ())
930956

931957
// TODO: print the name of the nominal type
932958
ERROR(deinit_not_visible, none,

0 commit comments

Comments
 (0)