[PATCH] D107503: [clang][Rewriter] patch to fix bug with ReplaceText erasing too many characters when text has been inserted before the replace location.

Joel E. Denny via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 17 19:48:58 PDT 2021


jdenny added inline comments.


================
Comment at: clang/lib/Rewrite/Rewriter.cpp:136
   if (OrigLength != NewStr.size())
     AddReplaceDelta(OrigOffset, NewStr.size() - OrigLength);
 }
----------------
I think this needs to be fixed too.  That is, the removal of the inserts requires updating the insert delta separately from the replace delta.  Otherwise, a future `getRewrittenText` ending at `OrigOffset` will include extra characters.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107503/new/

https://reviews.llvm.org/D107503



More information about the cfe-commits mailing list