aboutsummaryrefslogtreecommitdiff
path: root/tools/libclang/CXComment.cpp
diff options
context:
space:
mode:
authorDmitri Gribenko <gribozavr@gmail.com>2013-01-26 21:39:50 +0000
committerDmitri Gribenko <gribozavr@gmail.com>2013-01-26 21:39:50 +0000
commit337ee24785a784ba5418c2e78716d15b94fd57f0 (patch)
tree63257804b7dd9025f80dab07a9a271a881374915 /tools/libclang/CXComment.cpp
parente42e578ad8a36ad5bd06c8a3110cbd3119aaee36 (diff)
libclang: type safety for CXTranslationUnitImpl::FormatContext
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173589 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/libclang/CXComment.cpp')
-rw-r--r--tools/libclang/CXComment.cpp17
1 files changed, 7 insertions, 10 deletions
diff --git a/tools/libclang/CXComment.cpp b/tools/libclang/CXComment.cpp
index b14e1745d8..0fcd7c2166 100644
--- a/tools/libclang/CXComment.cpp
+++ b/tools/libclang/CXComment.cpp
@@ -1368,23 +1368,20 @@ CXString clang_FullComment_getAsXML(CXComment CXC) {
ASTContext &Context = FC->getDeclInfo()->CurrentDecl->getASTContext();
CXTranslationUnit TU = CXC.TranslationUnit;
SourceManager &SM = cxtu::getASTUnit(TU)->getSourceManager();
-
- SimpleFormatContext *SFC =
- static_cast<SimpleFormatContext*>(TU->FormatContext);
- if (!SFC) {
- SFC = new SimpleFormatContext(Context.getLangOpts());
- TU->FormatContext = SFC;
+
+ if (!TU->FormatContext) {
+ TU->FormatContext = new SimpleFormatContext(Context.getLangOpts());
} else if ((TU->FormatInMemoryUniqueId % 1000) == 0) {
// Delete after some number of iterators, so the buffers don't grow
// too large.
- delete SFC;
- SFC = new SimpleFormatContext(Context.getLangOpts());
- TU->FormatContext = SFC;
+ delete TU->FormatContext;
+ TU->FormatContext = new SimpleFormatContext(Context.getLangOpts());
}
SmallString<1024> XML;
CommentASTToXMLConverter Converter(FC, XML, getCommandTraits(CXC), SM,
- *SFC, TU->FormatInMemoryUniqueId++);
+ *TU->FormatContext,
+ TU->FormatInMemoryUniqueId++);
Converter.visit(FC);
return createCXString(XML.str(), /* DupString = */ true);
}