The size returned by Rewriter::getRangeSize should include
the size of the last token.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43092 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Rewrite/Rewriter.cpp b/Rewrite/Rewriter.cpp
index 87a5dea..514b822 100644
--- a/Rewrite/Rewriter.cpp
+++ b/Rewrite/Rewriter.cpp
@@ -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 @@
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;
}