]> granicus.if.org Git - clang/commitdiff
add some assertions so that the rewriter dies violently with a useful
authorChris Lattner <sabre@nondot.org>
Wed, 23 Jan 2008 23:37:15 +0000 (23:37 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 23 Jan 2008 23:37:15 +0000 (23:37 +0000)
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

Rewrite/Rewriter.cpp

index 7744a0c4ff7289c0f149974dcd5d5d700ebdead2..62d0432f0a63164b81eee598f5be38c6d2a41d5c 100644 (file)
@@ -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);