From: Chris Lattner Date: Thu, 8 Nov 2007 04:09:59 +0000 (+0000) Subject: Fix a rewriter bug that fariborz hit, when an @interface was the very very very X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=116c08938409b23704b60dd1a78a9243e3621407;p=clang Fix a rewriter bug that fariborz hit, when an @interface was the very very very first thing in the file. The trick is that text replacement should go after the insert point, not before it, because it will be replacing text after the point, not before it. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43879 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/Rewrite/Rewriter.cpp b/Rewrite/Rewriter.cpp index a8bc99fe39..f068f68ae9 100644 --- a/Rewrite/Rewriter.cpp +++ b/Rewrite/Rewriter.cpp @@ -117,7 +117,7 @@ void RewriteBuffer::InsertText(unsigned OrigOffset, /// operation. void RewriteBuffer::ReplaceText(unsigned OrigOffset, unsigned OrigLength, const char *NewStr, unsigned NewLength) { - unsigned RealOffset = getMappedOffset(OrigOffset); + unsigned RealOffset = getMappedOffset(OrigOffset, true); assert(RealOffset+OrigLength <= Buffer.size() && "Invalid location"); // Overwrite the common piece.