aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-01-23 23:37:15 +0000
committerChris Lattner <sabre@nondot.org>2008-01-23 23:37:15 +0000
commitd3c25ddb599ca59f0fce4731521025307670ead8 (patch)
tree0f551e40431d5ea30216e9b9dc3560e783434db5
parent8cc09d5133c9f1a8257235bfef92c1d3abf5345d (diff)
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
-rw-r--r--Rewrite/Rewriter.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/Rewrite/Rewriter.cpp b/Rewrite/Rewriter.cpp
index 7744a0c4ff..62d0432f0a 100644
--- a/Rewrite/Rewriter.cpp
+++ b/Rewrite/Rewriter.cpp
@@ -208,6 +208,7 @@ RewriteBuffer &Rewriter::getEditBuffer(unsigned FileID) {
/// 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 @@ void Rewriter::InsertText(SourceLocation Loc,
/// 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);