Why "Invalid region to erase" when replace or remove the whole VarDecl text?

Hi,

I want to remove certain VarDecl, using this:

rewrite.RemoveText(decl->getRange());

Then I got :
Assertion failed: (RealOffset+Size < Buffer.size() && “Invalid location”), function RemoveText, file /usr/local/src/llvm/tools/clang/lib/Rewrite/Core/Rewriter.cpp

The same satuation happens when I try to :
rewrite.ReplaceText(decl->getRange(), " ");

Could anyone tell me how to Remove the text of certain VarDecl…?

I really appreciate that!

Best Regards,
Shuai