[cfe-commits] r50126 - in /cfe/trunk: include/clang/Rewrite/RewriteRope.h lib/Rewrite/RewriteRope.cpp
Chris Lattner
sabre at nondot.org
Tue Apr 22 20:21:51 PDT 2008
Author: lattner
Date: Tue Apr 22 22:21:50 2008
New Revision: 50126
URL: http://llvm.org/viewvc/llvm-project?rev=50126&view=rev
Log:
fix a rewriter crash on zero length files.
Modified:
cfe/trunk/include/clang/Rewrite/RewriteRope.h
cfe/trunk/lib/Rewrite/RewriteRope.cpp
Modified: cfe/trunk/include/clang/Rewrite/RewriteRope.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Rewrite/RewriteRope.h?rev=50126&r1=50125&r2=50126&view=diff
==============================================================================
--- cfe/trunk/include/clang/Rewrite/RewriteRope.h (original)
+++ cfe/trunk/include/clang/Rewrite/RewriteRope.h Tue Apr 22 22:21:50 2008
@@ -204,7 +204,8 @@
void assign(const char *Start, const char *End) {
clear();
- Chunks.insert(0, MakeRopeString(Start, End));
+ if (Start != End)
+ Chunks.insert(0, MakeRopeString(Start, End));
}
void insert(unsigned Offset, const char *Start, const char *End) {
Modified: cfe/trunk/lib/Rewrite/RewriteRope.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Rewrite/RewriteRope.cpp?rev=50126&r1=50125&r2=50126&view=diff
==============================================================================
--- cfe/trunk/lib/Rewrite/RewriteRope.cpp (original)
+++ cfe/trunk/lib/Rewrite/RewriteRope.cpp Tue Apr 22 22:21:50 2008
@@ -741,6 +741,7 @@
/// allocation instead of doing tons of tiny allocations.
RopePiece RewriteRope::MakeRopeString(const char *Start, const char *End) {
unsigned Len = End-Start;
+ assert(Len && "Zero length RopePiece is invalid!");
// If we have space for this string in the current alloc buffer, use it.
if (AllocOffs+Len <= AllocChunkSize) {
More information about the cfe-commits
mailing list