[Exclusivity] Suggest Fix-Its to replace swap() with swapAt()

Extend the static diagnostics for exclusivity violations to suggest replacing

  swap(&collection[index1], &collection[index2]

with

  collection.swapAt(index1, index2).

when 'collection' is a MutableCollection.

To do so, repurpose some vestigial code that was previously used to suppress all
exclusivity diagnostics for calls to swap() and add some additional syntactic,
semantic,  and textual pattern matching.

rdar://problem/31916085
This commit is contained in:
Devin Coughlin
2017-05-17 14:35:43 -07:00
parent 130231456b
commit f239ae2ad7
6 changed files with 202 additions and 90 deletions

View File

@@ -1378,8 +1378,6 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
|= Args.hasArg(OPT_assume_parsing_unqualified_ownership_sil);
Opts.EnableMandatorySemanticARCOpts |=
!Args.hasArg(OPT_disable_mandatory_semantic_arc_opts);
Opts.SuppressStaticExclusivitySwap |=
Args.hasArg(OPT_suppress_static_exclusivity_swap);
if (Args.hasArg(OPT_debug_on_sil)) {
// Derive the name of the SIL file for debugging from