This is an archive of the discontinued LLVM Phabricator instance.

Supports adding insertion around non-insertion replacements.
ClosedPublic

Authored by ioeric on Sep 13 2016, 10:08 AM.

Details

Summary

Extend tooling::Replacements::add() to support adding order-independent replacements.

Two replacements are considered order-independent if one of the following conditions is true:

  • They do not overlap. (This is already supported.)
  • One replacement is insertion, and the other is a replacement with length > 0, and the insertion is adjecent to but not contained in the other replacement. In this case, the replacement should always change the original code instead of the inserted text.

Diff Detail

Repository
rL LLVM

Event Timeline

ioeric updated this revision to Diff 71192.Sep 13 2016, 10:08 AM
ioeric retitled this revision from to Supports adding insertion around non-insertion replacements..
ioeric updated this object.
ioeric added reviewers: djasper, klimek.
ioeric added a subscriber: cfe-commits.
djasper added inline comments.Sep 14 2016, 5:57 AM
include/clang/Tooling/Core/Replacement.h
172 ↗(On Diff #71192)

I think technically this is also not an overlap and so the first condition would hold. How about phrasing this the other way, i.e.:

Two replacements are considered order independent if they:

  • they don't overlap (being directly adjacent is fine) and
  • aren't both inserts at the same code location
ioeric updated this revision to Diff 71332.Sep 14 2016, 6:01 AM
ioeric marked an inline comment as done.
  • Addressed comment.
djasper accepted this revision.Sep 14 2016, 6:06 AM
djasper edited edge metadata.

Looks good.

include/clang/Tooling/Core/Replacement.h
172 ↗(On Diff #71332)

Remove the Note line and just add "(would be order-dependent)" to the line above.

This revision is now accepted and ready to land.Sep 14 2016, 6:06 AM
ioeric updated this revision to Diff 71335.Sep 14 2016, 6:09 AM
ioeric edited edge metadata.
  • Updated comment.
This revision was automatically updated to reflect the committed changes.