From: Chris Lattner Date: Fri, 23 May 2008 23:10:58 +0000 (+0000) Subject: add some assertions to catch bad things before they die X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0d3ab3f121ff6c2a38acde4e93a28980b824d045;p=clang add some assertions to catch bad things before they die somewhere deep in rewrite rope. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51515 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Rewrite/RewriteRope.h b/include/clang/Rewrite/RewriteRope.h index 963c0715d9..c62f684a09 100644 --- a/include/clang/Rewrite/RewriteRope.h +++ b/include/clang/Rewrite/RewriteRope.h @@ -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); }