diff --git a/clang/lib/Rewrite/RewriteRope.cpp b/clang/lib/Rewrite/RewriteRope.cpp index 9d5d7a741053..f1fd3f7ba971 100644 --- a/clang/lib/Rewrite/RewriteRope.cpp +++ b/clang/lib/Rewrite/RewriteRope.cpp @@ -578,7 +578,7 @@ void RopePieceBTreeInterior::erase(unsigned Offset, unsigned NumBytes) { NumBytes -= CurChild->size(); CurChild->Destroy(); --NumChildren; - if (i+1 != getNumChildren()) + if (i != getNumChildren()) memmove(&Children[i], &Children[i+1], (getNumChildren()-i)*sizeof(Children[0])); } diff --git a/clang/test/Rewriter/crash.m b/clang/test/Rewriter/crash.m new file mode 100644 index 000000000000..59f18f37c2c9 --- /dev/null +++ b/clang/test/Rewriter/crash.m @@ -0,0 +1,14 @@ +// RUN: clang -rewrite-objc -o - %s +// rdar://5950938 +@interface NSArray {} ++ (id)arrayWithObjects:(id)firstObj, ...; +@end + +@interface NSConstantString {} +@end + +int main() { + id foo = [NSArray arrayWithObjects:@"1", @"2", @"3", @"4", @"5", @"6", @"7", @"8", @"9", @"10", @"11", @"12", 0]; + return 0; +} +