diff options
| author | Dmitri Gribenko <gribozavr@gmail.com> | 2014-04-24 07:52:31 +0000 |
|---|---|---|
| committer | Dmitri Gribenko <gribozavr@gmail.com> | 2014-04-24 07:52:31 +0000 |
| commit | b4e01ab54a3dfcddb845f241239b2f5efffed8ba (patch) | |
| tree | f3f345f26d0738779fcf651fd5f6558b71de06a5 /lib/Index/CommentToXML.cpp | |
| parent | 9b7ce5b7bd7f45efc4abf36c6456742d2fc8ec5b (diff) | |
| download | clang-b4e01ab54a3dfcddb845f241239b2f5efffed8ba.tar.gz clang-b4e01ab54a3dfcddb845f241239b2f5efffed8ba.tar.bz2 clang-b4e01ab54a3dfcddb845f241239b2f5efffed8ba.tar.xz | |
Comment to XML conversion: use unique_ptr for SimpleFormatContext
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@207087 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Index/CommentToXML.cpp')
| -rw-r--r-- | lib/Index/CommentToXML.cpp | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/lib/Index/CommentToXML.cpp b/lib/Index/CommentToXML.cpp index 54087bd87d..a668c5676b 100644 --- a/lib/Index/CommentToXML.cpp +++ b/lib/Index/CommentToXML.cpp @@ -1136,9 +1136,8 @@ void CommentASTToXMLConverter::appendToResultWithCDATAEscaping(StringRef S) { Result << "]]>"; } -CommentToXMLConverter::~CommentToXMLConverter() { - delete FormatContext; -} +CommentToXMLConverter::CommentToXMLConverter() : FormatInMemoryUniqueId(0) {} +CommentToXMLConverter::~CommentToXMLConverter() = default; void CommentToXMLConverter::convertCommentToHTML(const FullComment *FC, SmallVectorImpl<char> &HTML, @@ -1159,13 +1158,10 @@ void CommentToXMLConverter::convertHTMLTagNodeToText( void CommentToXMLConverter::convertCommentToXML(const FullComment *FC, SmallVectorImpl<char> &XML, const ASTContext &Context) { - if (!FormatContext) { - FormatContext = new SimpleFormatContext(Context.getLangOpts()); - } else if ((FormatInMemoryUniqueId % 1000) == 0) { - // Delete after some number of iterations, so the buffers don't grow - // too large. - delete FormatContext; - FormatContext = new SimpleFormatContext(Context.getLangOpts()); + if (!FormatContext || (FormatInMemoryUniqueId % 1000) == 0) { + // Create a new format context, or re-create it after some number of + // iterations, so the buffers don't grow too large. + FormatContext.reset(new SimpleFormatContext(Context.getLangOpts())); } CommentASTToXMLConverter Converter(FC, XML, Context.getCommentCommandTraits(), |
