Fix a reference count imbalance in RewriteRope::MakeRopeString().
This was causing a ton of memory to be leaked when using HTML
diagnostics with the static analyzer (on large files with many errors).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84601 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Rewrite/RewriteRope.cpp b/lib/Rewrite/RewriteRope.cpp
index 30bbcfa..bd99732 100644
--- a/lib/Rewrite/RewriteRope.cpp
+++ b/lib/Rewrite/RewriteRope.cpp
@@ -798,9 +798,8 @@
memcpy(AllocBuffer->Data, Start, Len);
AllocOffs = Len;
- // Start out the new allocation with a refcount of 1, since we have an
- // internal reference to it.
- AllocBuffer->addRef();
+ // Return a RopePiece that wraps 'AllocBuffer'. The constructor of RopePiece
+ // will increment the reference count of AllocBuffer.
return RopePiece(AllocBuffer, 0, Len);
}