diff options
author | Dmitri Gribenko <gribozavr@gmail.com> | 2013-01-26 21:39:50 +0000 |
---|---|---|
committer | Dmitri Gribenko <gribozavr@gmail.com> | 2013-01-26 21:39:50 +0000 |
commit | 337ee24785a784ba5418c2e78716d15b94fd57f0 (patch) | |
tree | 63257804b7dd9025f80dab07a9a271a881374915 /tools/libclang/CXComment.cpp | |
parent | e42e578ad8a36ad5bd06c8a3110cbd3119aaee36 (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.cpp | 17 |
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); } |