[cfe-commits] r46287 - /cfe/trunk/Rewrite/Rewriter.cpp
Chris Lattner
sabre at nondot.org
Wed Jan 23 15:37:18 PST 2008
Author: lattner
Date: Wed Jan 23 17:37:15 2008
New Revision: 46287
URL: http://llvm.org/viewvc/llvm-project?rev=46287&view=rev
Log:
add some assertions so that the rewriter dies violently with a useful
error instead of subtly with a mysterious one.
Modified:
cfe/trunk/Rewrite/Rewriter.cpp
Modified: cfe/trunk/Rewrite/Rewriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Rewrite/Rewriter.cpp?rev=46287&r1=46286&r2=46287&view=diff
==============================================================================
--- cfe/trunk/Rewrite/Rewriter.cpp (original)
+++ cfe/trunk/Rewrite/Rewriter.cpp Wed Jan 23 17:37:15 2008
@@ -208,6 +208,7 @@
/// 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 @@
/// 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);
More information about the cfe-commits
mailing list