[cfe-commits] r172241 - in /cfe/trunk/tools/libclang: CIndex.cpp CIndexCXX.cpp CXCursor.cpp CXType.cpp

Dmitri Gribenko gribozavr at gmail.com
Fri Jan 11 11:28:44 PST 2013


Author: gribozavr
Date: Fri Jan 11 13:28:44 2013
New Revision: 172241

URL: http://llvm.org/viewvc/llvm-project?rev=172241&view=rev
Log:
libclang: use getCursorTU and getCursorASTUnit instead of explicit casts

Modified:
    cfe/trunk/tools/libclang/CIndex.cpp
    cfe/trunk/tools/libclang/CIndexCXX.cpp
    cfe/trunk/tools/libclang/CXCursor.cpp
    cfe/trunk/tools/libclang/CXType.cpp

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=172241&r1=172240&r2=172241&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Fri Jan 11 13:28:44 2013
@@ -3118,8 +3118,7 @@
 
 CXString clang_getCursorSpelling(CXCursor C) {
   if (clang_isTranslationUnit(C.kind))
-    return clang_getTranslationUnitSpelling(
-                            static_cast<CXTranslationUnit>(C.data[2]));
+    return clang_getTranslationUnitSpelling(getCursorTU(C));
 
   if (clang_isReference(C.kind)) {
     switch (C.kind) {

Modified: cfe/trunk/tools/libclang/CIndexCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndexCXX.cpp?rev=172241&r1=172240&r2=172241&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndexCXX.cpp (original)
+++ cfe/trunk/tools/libclang/CIndexCXX.cpp Fri Jan 11 13:28:44 2013
@@ -58,8 +58,7 @@
   case CXCursor_FunctionTemplate:
     if (TemplateDecl *Template
                            = dyn_cast_or_null<TemplateDecl>(getCursorDecl(C)))
-      return MakeCXCursor(Template->getTemplatedDecl(), 
-                          static_cast<CXTranslationUnit>(C.data[2])).kind;
+      return MakeCXCursor(Template->getTemplatedDecl(), getCursorTU(C)).kind;
     break;
       
   case CXCursor_ClassTemplatePartialSpecialization:
@@ -122,7 +121,7 @@
   if (!Template)
     return clang_getNullCursor();
   
-  return MakeCXCursor(Template, static_cast<CXTranslationUnit>(C.data[2]));
+  return MakeCXCursor(Template, getCursorTU(C));
 }
   
 } // end extern "C"

Modified: cfe/trunk/tools/libclang/CXCursor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXCursor.cpp?rev=172241&r1=172240&r2=172241&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CXCursor.cpp (original)
+++ cfe/trunk/tools/libclang/CXCursor.cpp Fri Jan 11 13:28:44 2013
@@ -805,7 +805,7 @@
 }
 
 ASTUnit *cxcursor::getCursorASTUnit(CXCursor Cursor) {
-  CXTranslationUnit TU = static_cast<CXTranslationUnit>(Cursor.data[2]);
+  CXTranslationUnit TU = getCursorTU(Cursor);
   if (!TU)
     return 0;
   return static_cast<ASTUnit *>(TU->TUData);

Modified: cfe/trunk/tools/libclang/CXType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXType.cpp?rev=172241&r1=172240&r2=172241&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CXType.cpp (original)
+++ cfe/trunk/tools/libclang/CXType.cpp Fri Jan 11 13:28:44 2013
@@ -636,8 +636,7 @@
     return cxstring::createCXString("");
 
   Decl *D = static_cast<Decl*>(C.data[0]);
-  CXTranslationUnit TU = static_cast<CXTranslationUnit>(C.data[2]);
-  ASTUnit *AU = static_cast<ASTUnit*>(TU->TUData);
+  ASTUnit *AU = cxcursor::getCursorASTUnit(C);
   ASTContext &Ctx = AU->getASTContext();
   std::string encoding;
 





More information about the cfe-commits mailing list