[cfe-commits] r173589 - libclang: type safety for CXTranslationUnitImpl::FormatContext

Dmitri Gribenko gribozavr at gmail.com
Sat Jan 26 13:39:50 PST 2013


Author: gribozavr
Date: Sat Jan 26 15:39:50 2013
New Revision: 173589

URL: http://llvm.org/viewvc/llvm-project?rev=173589&view=rev
Log:
libclang: type safety for CXTranslationUnitImpl::FormatContext

Modified:
    cfe/trunk/tools/libclang/CIndex.cpp
    cfe/trunk/tools/libclang/CXComment.cpp
    cfe/trunk/tools/libclang/CXTranslationUnit.h

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=173589&r1=173588&r2=173589&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Sat Jan 26 15:39:50 2013
@@ -2823,7 +2823,7 @@ void clang_disposeTranslationUnit(CXTran
     disposeCXStringPool(CTUnit->StringPool);
     delete static_cast<CXDiagnosticSetImpl *>(CTUnit->Diagnostics);
     disposeOverridenCXCursorsPool(CTUnit->OverridenCursorsPool);
-    delete static_cast<SimpleFormatContext*>(CTUnit->FormatContext);
+    delete CTUnit->FormatContext;
     delete CTUnit;
   }
 }

Modified: cfe/trunk/tools/libclang/CXComment.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXComment.cpp?rev=173589&r1=173588&r2=173589&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CXComment.cpp (original)
+++ cfe/trunk/tools/libclang/CXComment.cpp Sat Jan 26 15:39:50 2013
@@ -1368,23 +1368,20 @@ CXString clang_FullComment_getAsXML(CXCo
   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);
 }

Modified: cfe/trunk/tools/libclang/CXTranslationUnit.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXTranslationUnit.h?rev=173589&r1=173588&r2=173589&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CXTranslationUnit.h (original)
+++ cfe/trunk/tools/libclang/CXTranslationUnit.h Sat Jan 26 15:39:50 2013
@@ -19,6 +19,7 @@
 namespace clang {
   class ASTUnit;
   class CIndexer;
+  class SimpleFormatContext;
 } // namespace clang
 
 struct CXTranslationUnitImpl {
@@ -27,14 +28,11 @@ struct CXTranslationUnitImpl {
   void *StringPool;
   void *Diagnostics;
   void *OverridenCursorsPool;
-  void *FormatContext;
+  clang::SimpleFormatContext *FormatContext;
   unsigned FormatInMemoryUniqueId;
 };
 
 namespace clang {
-  class ASTUnit;
-  class CIndexer;
-
 namespace cxtu {
 
 CXTranslationUnitImpl *MakeCXTranslationUnit(CIndexer *CIdx, ASTUnit *AU);





More information about the cfe-commits mailing list