]> granicus.if.org Git - clang/commitdiff
The size returned by Rewriter::getRangeSize should include
authorChris Lattner <sabre@nondot.org>
Wed, 17 Oct 2007 21:23:07 +0000 (21:23 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 17 Oct 2007 21:23:07 +0000 (21:23 +0000)
the size of the last token.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43092 91177308-0d34-0410-b5e6-96231b3b80d8

Rewrite/Rewriter.cpp

index 87a5deaf1a9862a978facb5d7996bf4e677c4654..514b82235a47605a64abf1eb23ff16726c4a9246 100644 (file)
@@ -13,6 +13,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "clang/Rewrite/Rewriter.h"
+#include "clang/Lex/Lexer.h"
 #include "clang/Basic/SourceManager.h"
 using namespace clang;
 
@@ -156,6 +157,10 @@ int Rewriter::getRangeSize(SourceRange Range) const {
   if (StartFileID != EndFileID)
     return -1;
   
+  // Adjust the end offset to the end of the last token, instead of being the
+  // start of the last token.
+  EndOff += Lexer::MeasureTokenLength(Range.getEnd(), *SourceMgr);
+  
   return EndOff-StartOff;
 }