libclang: type safety for CXTranslationUnitImpl::FormatContext


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173589 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/libclang/CXComment.cpp b/tools/libclang/CXComment.cpp
index b14e174..0fcd7c2 100644
--- a/tools/libclang/CXComment.cpp
+++ b/tools/libclang/CXComment.cpp
@@ -1368,23 +1368,20 @@
   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);
 }