add some assertions so that the rewriter dies violently with a useful
error instead of subtly with a mysterious one.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46287 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Rewrite/Rewriter.cpp b/Rewrite/Rewriter.cpp
index 7744a0c..62d0432 100644
--- a/Rewrite/Rewriter.cpp
+++ b/Rewrite/Rewriter.cpp
@@ -208,6 +208,7 @@
/// locations.
void Rewriter::InsertText(SourceLocation Loc,
const char *StrData, unsigned StrLen) {
+ assert(isRewritable(Loc) && "Not a rewritable location!");
unsigned FileID;
unsigned StartOffs = getLocationOffsetAndFileID(Loc, FileID);
getEditBuffer(FileID).InsertText(StartOffs, StrData, StrLen);
@@ -216,6 +217,7 @@
/// RemoveText - Remove the specified text region. This method is only valid
/// on a rewritable source location.
void Rewriter::RemoveText(SourceLocation Start, unsigned Length) {
+ assert(isRewritable(Start) && "Not a rewritable location!");
unsigned FileID;
unsigned StartOffs = getLocationOffsetAndFileID(Start, FileID);
getEditBuffer(FileID).RemoveText(StartOffs, Length);