summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorFangrui Song <maskray@google.com>2018-11-20 08:00:00 +0000
committerFangrui Song <maskray@google.com>2018-11-20 08:00:00 +0000
commit9b9f33d2fa56d4637b1da517d34f65e512c578b1 (patch)
tree35ad16a8e75c31ac651324400e7d5ac0d0f36f96 /tools
parent6cbb68cec62ea09bd647263006dfae1c9d5b5587 (diff)
[libclang] Unify getCursorDecl and getCursorParentDecl
They do the same thing, thus the latter (which has only 2 call sites) can be deleted. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@347293 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r--tools/libclang/CIndex.cpp4
-rw-r--r--tools/libclang/CXCursor.cpp4
-rw-r--r--tools/libclang/CXCursor.h17
3 files changed, 10 insertions, 15 deletions
diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp
index eb3c9c34cd..e9bc393971 100644
--- a/tools/libclang/CIndex.cpp
+++ b/tools/libclang/CIndex.cpp
@@ -6940,7 +6940,7 @@ AnnotateTokensWorker::DetermineChildActions(CXCursor Cursor) const {
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 cursor, CXCursor parent) {
// 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() &&
diff --git a/tools/libclang/CXCursor.cpp b/tools/libclang/CXCursor.cpp
index 0fee9e20ef..7e14b5f893 100644
--- a/tools/libclang/CXCursor.cpp
+++ b/tools/libclang/CXCursor.cpp
@@ -1012,10 +1012,6 @@ const Attr *cxcursor::getCursorAttr(CXCursor Cursor) {
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();
}
diff --git a/tools/libclang/CXCursor.h b/tools/libclang/CXCursor.h
index a5d9fff2a5..312fb3ff25 100644
--- a/tools/libclang/CXCursor.h
+++ b/tools/libclang/CXCursor.h
@@ -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 *, SourceLocation> getCursorVariableRef(CXCursor C);
/// 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(TemplateName Template,
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 Cursor);
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 cursor);
bool getDeclCursorUSR(const Decl *D, SmallVectorImpl<char> &Buf);
bool operator==(CXCursor X, CXCursor Y);
-
+
inline bool operator!=(CXCursor X, CXCursor Y) {
return !(X == Y);
}