Commit Graph

5 Commits

Author SHA1 Message Date
Devin Coughlin
6dcc8ce9b2 [Exclusivity] Don't suggest copying to a local when swapAt() is appropriate
Update static exclusivity diagnostics to not suggest copying to a local
when a call to swapAt() should be used instead. We already emit a FixIt in
this case, so don't suggest an an helpful fix in the diagnostic.

rdar://problem/32296784
2017-07-16 13:48:52 -07:00
Devin Coughlin
f6df5c79b2 [Exclusivity] Update static diagnostic text for "simultaneous" accesses
Remove the descriptive decl kind (since with subpaths it is not correct and
cannot represent a tuple element) and change "simultaneous" to "overlapping"
in order to lower the register slightly and avoid connoting threading.

For example, for the following:

   takesTwoInouts(&x.f, &x.f)

the diagnostic will change from

"simultaneous accesses to var 'x.f', but modification requires exclusive access;
consider copying to a local variable"

to

"overlapping accesses to 'x.f', but modification requires exclusive access;
consider copying to a local variable"
2017-06-13 20:08:48 -07:00
Devin Coughlin
d76ec6a8ff [Exclusivity] Relax enforcement for separate struct stored properties
Relax the static enforcement of exclusive access so that we no longer diagnose
on accesses to separate stored structs of the same property:

takesInout(&s.f1, &s.f2) // no-warning

And perform the analogous relaxation for tuple elements.

To do this, track for each begin_access the projection path from that
access and record the read and write-like modifications on a per-subpath
basis.

We still warn if the there are conflicting accesses on subpaths where one is
the prefix of another.

This commit leaves the diagnostic text in a not-so-good shape since we refer
to the DescriptiveDeclKind of the access even describing a subpath.

I'll fix that up in a later commit that changes only diagnostic text.

https://bugs.swift.org/browse/SR-5119
rdar://problem/31909639
2017-06-13 19:15:38 -07:00
Devin Coughlin
cedfa6d37c [Exclusivity] Update static diagnostic to suggest adding a local
Update the static diagnostics when enforcing exclusive access to suggest adding
a local variable. The new diagnostic text is:

  "simultaneous accesses to var 'a', but modification requires exclusive
  access; consider copying to a local variable"
2017-05-09 16:09:10 -07:00
Devin Coughlin
0777cccb71 [Exclusivity] Make static access conflict an error in Swift 4 mode.
When static enforcement of exclusive access is enabled, make access conflicts an
error in Swift 4 mode. They will remain a warning in Swift 3 mode.
2017-05-06 19:13:53 -07:00