From: Chris Lattner Date: Wed, 23 Jan 2008 23:37:15 +0000 (+0000) Subject: add some assertions so that the rewriter dies violently with a useful X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d3c25ddb599ca59f0fce4731521025307670ead8;p=clang 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 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);