[PATCH] cp11-migrate: Integration with LibFormat.

Edwin Vane edwin.vane at intel.com
Mon Jul 22 13:21:19 PDT 2013


Comment at: cpp11-migrate/Core/FileOverrides.cpp:207
@@ +206,3 @@
+    // replacement inside range -> resize the range
+    if (Range.contains(Replace)) {
+      int Difference = ReplaceNewSize - Replace.getLength();
Guillaume Papin wrote:
> Edwin Vane wrote:
> > Why change the range at all? If a replacement is completely within an existing range, the part of the range outside of the replacement is still something that has changed right?
> Yes you are right it is changed. What I'm doing here is resizing the range so it takes the replacement into account.
> Let's say we have a range: `Range(/*offset=*/0, /*length=*/5)`
> And a replacement: `Replacement(/*offset=*/2, /*length=*/1, /*replacement-text=*/"~~~")`
> The replacement deletes 1 character but adds 3 new characters, a difference of +2 characters.
> That's why I'm resizing the range to take the new characters into account, final range is `Range(0, 7)`.
Ah yes. of course.




More information about the cfe-commits mailing list