See https://llvm.discourse.group/t/possible-bug-in-clang-rewriter-clang-rewritebuffer-and-or-clang-rewriterope/3970 for initial explanation of bug.
[clang][Rewriter] split test for replace after insert to be more understandable and also a fix to make the test correct
I think this might fix the bug, but I haven't tested thoroughly.
One problem is ensuring backward compatibility here and in callers while keeping a consistent interface. That is, the previous default here was IncludeInsertsAtBeginOfRange=false, but it seems the intended default elsewhere is meant to be the opposite.