]> granicus.if.org Git - clang/commitdiff
add some assertions to catch bad things before they die
authorChris Lattner <sabre@nondot.org>
Fri, 23 May 2008 23:10:58 +0000 (23:10 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 23 May 2008 23:10:58 +0000 (23:10 +0000)
somewhere deep in rewrite rope.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51515 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Rewrite/RewriteRope.h

index 963c0715d905d5e5bdfdc6eeb998164343274888..c62f684a097a1d87d488ffbaa2bf26dff58de119 100644 (file)
@@ -209,11 +209,13 @@ public:
   }
   
   void insert(unsigned Offset, const char *Start, const char *End) {
+    assert(Offset <= size() && "Invalid position to insert!");
     if (Start == End) return;
     Chunks.insert(Offset, MakeRopeString(Start, End));
   }
 
   void erase(unsigned Offset, unsigned NumBytes) {
+    assert(Offset+NumBytes <= size() && "Invalid region to erase!");
     if (NumBytes == 0) return;
     Chunks.erase(Offset, NumBytes);
   }