summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorDmitri Gribenko <gribozavr@gmail.com>2014-04-24 07:52:31 +0000
committerDmitri Gribenko <gribozavr@gmail.com>2014-04-24 07:52:31 +0000
commit4f4dd17d056b02eaa64adf1cad99e14eceabde1b (patch)
treee490dbc186cfd1851244307a8f1a525d07f39540 /clang
parent944b9acddd533bc078578803f73320103e183dd6 (diff)
downloadbcm5719-llvm-4f4dd17d056b02eaa64adf1cad99e14eceabde1b.tar.gz
bcm5719-llvm-4f4dd17d056b02eaa64adf1cad99e14eceabde1b.zip
Comment to XML conversion: use unique_ptr for SimpleFormatContext
llvm-svn: 207087
Diffstat (limited to 'clang')
-rw-r--r--clang/include/clang/Index/CommentToXML.h5
-rw-r--r--clang/lib/Index/CommentToXML.cpp16
2 files changed, 9 insertions, 12 deletions
diff --git a/clang/include/clang/Index/CommentToXML.h b/clang/include/clang/Index/CommentToXML.h
index c68d7a47d51..bb7b71ad411 100644
--- a/clang/include/clang/Index/CommentToXML.h
+++ b/clang/include/clang/Index/CommentToXML.h
@@ -11,6 +11,7 @@
#define LLVM_CLANG_INDEX_COMMENTTOXML_H
#include "clang/Basic/LLVM.h"
+#include <memory>
namespace clang {
class ASTContext;
@@ -24,11 +25,11 @@ namespace index {
class SimpleFormatContext;
class CommentToXMLConverter {
- SimpleFormatContext *FormatContext;
+ std::unique_ptr<SimpleFormatContext> FormatContext;
unsigned FormatInMemoryUniqueId;
public:
- CommentToXMLConverter() : FormatContext(0), FormatInMemoryUniqueId(0) {}
+ CommentToXMLConverter();
~CommentToXMLConverter();
void convertCommentToHTML(const comments::FullComment *FC,
diff --git a/clang/lib/Index/CommentToXML.cpp b/clang/lib/Index/CommentToXML.cpp
index 54087bd87d7..a668c5676b3 100644
--- a/clang/lib/Index/CommentToXML.cpp
+++ b/clang/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(),
OpenPOWER on IntegriCloud