This is an archive of the discontinued LLVM Phabricator instance.

When replacements have the same offset, make replacements with smaller length order first in the set.
ClosedPublic

Authored by ioeric on Sep 16 2016, 6:30 AM.

Details

Summary

No behavioral change intended. The change makes iterating the replacements set more intuitive in Replacements class implementation. Previously, insertion is ordered before an deletion/replacement with the same offset, which is counter-intuitive for implementation, especially for a followup patch to support adding insertions around replacements.

With the current ordering, we only need to make applyAllReplacements iterate the replacements set reversely when applying them so that deletion/replacement is still applied before insertion with the same offset.

Diff Detail

Event Timeline

ioeric updated this revision to Diff 71632.Sep 16 2016, 6:30 AM
ioeric retitled this revision from to When replacements have the same offset, make replacements with smaller length order first in the set..
ioeric updated this object.
ioeric added a reviewer: djasper.
ioeric added a subscriber: cfe-commits.
klimek edited edge metadata.Sep 16 2016, 9:53 AM

Test? Why are we doing this (should go into the CL description)?

ioeric updated this object.Sep 16 2016, 12:31 PM
ioeric edited edge metadata.

Test? Why are we doing this (should go into the CL description)?

There is no behavioral change intended, and the goal here is not to break any test. A test for this change can be having an insertion and a deletion at the same offset, but this is not supported yet and will a followup patch.

djasper accepted this revision.Sep 17 2016, 5:22 AM
djasper edited edge metadata.

Looks good.

lib/Tooling/Core/Replacement.cpp
406–407

Maybe use auto?

This revision is now accepted and ready to land.Sep 17 2016, 5:22 AM
ioeric updated this revision to Diff 71729.Sep 17 2016, 5:27 AM
ioeric marked an inline comment as done.
ioeric edited edge metadata.
  • Use auto.
ioeric updated this revision to Diff 71730.Sep 17 2016, 5:29 AM
  • Format code properly.
This revision was automatically updated to reflect the committed changes.