r347293 - [libclang] Unify getCursorDecl and getCursorParentDecl

Fangrui Song via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 20 00:00:00 PST 2018


Author: maskray
Date: Tue Nov 20 00:00:00 2018
New Revision: 347293

URL: http://llvm.org/viewvc/llvm-project?rev=347293&view=rev
Log:
[libclang] Unify getCursorDecl and getCursorParentDecl

They do the same thing, thus the latter (which has only 2 call sites) can be deleted.

Modified:
    cfe/trunk/tools/libclang/CIndex.cpp
    cfe/trunk/tools/libclang/CXCursor.cpp
    cfe/trunk/tools/libclang/CXCursor.h

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=347293&r1=347292&r2=347293&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Tue Nov 20 00:00:00 2018
@@ -6940,7 +6940,7 @@ AnnotateTokensWorker::DetermineChildActi
     if (const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Callee)) {
       const Expr *SubExpr = ICE->getSubExpr();
       if (const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(SubExpr)) {
-        const Decl *parentDecl = getCursorParentDecl(Cursor);
+        const Decl *parentDecl = getCursorDecl(Cursor);
         CXTranslationUnit TU = clang_Cursor_getTranslationUnit(Cursor);
 
         // Visit the DeclRefExpr as last.
@@ -7163,7 +7163,7 @@ AnnotateTokensWorker::Visit(CXCursor cur
   //  MyCXXClass foo; // Make sure we don't annotate 'foo' as a CallExpr cursor.
   if (clang_isExpression(cursorK) && MoreTokens()) {
     const Expr *E = getCursorExpr(cursor);
-    if (const Decl *D = getCursorParentDecl(cursor)) {
+    if (const Decl *D = getCursorDecl(cursor)) {
       const unsigned I = NextToken();
       if (E->getBeginLoc().isValid() && D->getLocation().isValid() &&
           E->getBeginLoc() == D->getLocation() &&

Modified: cfe/trunk/tools/libclang/CXCursor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXCursor.cpp?rev=347293&r1=347292&r2=347293&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CXCursor.cpp (original)
+++ cfe/trunk/tools/libclang/CXCursor.cpp Tue Nov 20 00:00:00 2018
@@ -1012,10 +1012,6 @@ const Attr *cxcursor::getCursorAttr(CXCu
   return static_cast<const Attr *>(Cursor.data[1]);
 }
 
-const Decl *cxcursor::getCursorParentDecl(CXCursor Cursor) {
-  return static_cast<const Decl *>(Cursor.data[0]);
-}
-
 ASTContext &cxcursor::getCursorContext(CXCursor Cursor) {
   return getCursorASTUnit(Cursor)->getASTContext();
 }

Modified: cfe/trunk/tools/libclang/CXCursor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXCursor.h?rev=347293&r1=347292&r2=347293&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CXCursor.h (original)
+++ cfe/trunk/tools/libclang/CXCursor.h Tue Nov 20 00:00:00 2018
@@ -43,11 +43,11 @@ class TemplateName;
 class TypeDecl;
 class VarDecl;
 class IdentifierInfo;
-  
+
 namespace cxcursor {
 
 CXCursor getCursor(CXTranslationUnit, SourceLocation);
-  
+
 CXCursor MakeCXCursor(const clang::Attr *A, const clang::Decl *Parent,
                       CXTranslationUnit TU);
 CXCursor MakeCXCursor(const clang::Decl *D, CXTranslationUnit TU,
@@ -125,7 +125,7 @@ std::pair<const VarDecl *, SourceLocatio
 /// Create a reference to a field at the given location.
 CXCursor MakeCursorMemberRef(const FieldDecl *Field, SourceLocation Loc, 
                              CXTranslationUnit TU);
-  
+
 /// Unpack a MemberRef cursor into the field it references and the 
 /// location where the reference occurred.
 std::pair<const FieldDecl *, SourceLocation> getCursorMemberRef(CXCursor C);
@@ -232,17 +232,16 @@ CXCursor MakeCursorOverloadedDeclRef(Tem
 typedef llvm::PointerUnion3<const OverloadExpr *, const Decl *,
                             OverloadedTemplateStorage *>
   OverloadedDeclRefStorage;
-  
+
 /// Unpack an overloaded declaration reference into an expression,
 /// declaration, or template name along with the source location.
 std::pair<OverloadedDeclRefStorage, SourceLocation>
   getCursorOverloadedDeclRef(CXCursor C);
-  
+
 const Decl *getCursorDecl(CXCursor Cursor);
 const Expr *getCursorExpr(CXCursor Cursor);
 const Stmt *getCursorStmt(CXCursor Cursor);
 const Attr *getCursorAttr(CXCursor Cursor);
-const Decl *getCursorParentDecl(CXCursor Cursor);
 
 ASTContext &getCursorContext(CXCursor Cursor);
 ASTUnit *getCursorASTUnit(CXCursor Cursor);
@@ -250,14 +249,14 @@ CXTranslationUnit getCursorTU(CXCursor C
 
 void getOverriddenCursors(CXCursor cursor,
                           SmallVectorImpl<CXCursor> &overridden);
-  
+
 /// Create an opaque pool used for fast generation of overridden
 /// CXCursor arrays.
 void *createOverridenCXCursorsPool();
 
 /// Dispose of the overridden CXCursors pool.
 void disposeOverridenCXCursorsPool(void *pool);
-  
+
 /// Returns a index/location pair for a selector identifier if the cursor
 /// points to one.
 std::pair<int, SourceLocation> getSelectorIdentifierIndexAndLoc(CXCursor);
@@ -285,7 +284,7 @@ CXCursor getTypeRefCursor(CXCursor curso
 bool getDeclCursorUSR(const Decl *D, SmallVectorImpl<char> &Buf);
 
 bool operator==(CXCursor X, CXCursor Y);
-  
+
 inline bool operator!=(CXCursor X, CXCursor Y) {
   return !(X == Y);
 }




More information about the cfe-commits mailing list