fix a nasty off-by-one error.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51519 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Rewrite/RewriteRope.cpp b/lib/Rewrite/RewriteRope.cpp
index 9d5d7a7..f1fd3f7 100644
--- a/lib/Rewrite/RewriteRope.cpp
+++ b/lib/Rewrite/RewriteRope.cpp
@@ -578,7 +578,7 @@
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/test/Rewriter/crash.m b/test/Rewriter/crash.m
new file mode 100644
index 0000000..59f18f3
--- /dev/null
+++ b/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;
+}
+