aboutsummaryrefslogtreecommitdiff
path: root/tools/CIndex/CXCursor.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-01-15 21:56:13 +0000
committerDouglas Gregor <dgregor@apple.com>2010-01-15 21:56:13 +0000
commit283cae37b03047c14ef918503bc46b08405c3b69 (patch)
tree1d457df91193892ad91a9af884a20c027c267725 /tools/CIndex/CXCursor.cpp
parentdc5c78639f4e64d790c08e7b6494ae86ceea4ff1 (diff)
Make CXCursor's data opaque.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93561 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/CIndex/CXCursor.cpp')
-rw-r--r--tools/CIndex/CXCursor.cpp33
1 files changed, 31 insertions, 2 deletions
diff --git a/tools/CIndex/CXCursor.cpp b/tools/CIndex/CXCursor.cpp
index a7a7dfca65..0c72e96900 100644
--- a/tools/CIndex/CXCursor.cpp
+++ b/tools/CIndex/CXCursor.cpp
@@ -13,17 +13,46 @@
#include "CXCursor.h"
#include "clang/AST/Decl.h"
+#include "clang/AST/DeclObjC.h"
+#include "clang/AST/Expr.h"
using namespace clang;
CXCursor cxcursor::MakeCXCursor(CXCursorKind K, Decl *D) {
- CXCursor C = { K, D, 0, 0 };
+ CXCursor C = { K, { D, 0, 0 } };
return C;
}
CXCursor cxcursor::MakeCXCursor(CXCursorKind K, Decl *D, Stmt *S) {
assert(clang_isReference(K));
- CXCursor C = { K, D, S, 0 };
+ CXCursor C = { K, { D, S, 0 } };
return C;
}
+Decl *cxcursor::getCursorDecl(CXCursor Cursor) {
+ return (Decl *)Cursor.data[0];
+}
+
+Expr *cxcursor::getCursorExpr(CXCursor Cursor) {
+ return dyn_cast_or_null<Expr>(getCursorStmt(Cursor));
+}
+
+Stmt *cxcursor::getCursorStmt(CXCursor Cursor) {
+ return (Stmt *)Cursor.data[1];
+}
+
+Decl *cxcursor::getCursorReferringDecl(CXCursor Cursor) {
+ return (Decl *)Cursor.data[2];
+}
+
+NamedDecl *cxcursor::getCursorInterfaceParent(CXCursor Cursor) {
+ assert(Cursor.kind == CXCursor_ObjCClassRef);
+ assert(isa<ObjCInterfaceDecl>(getCursorDecl(Cursor)));
+ // FIXME: This is a hack (storing the parent decl in the stmt slot).
+ return static_cast<NamedDecl *>(Cursor.data[1]);
+}
+
+bool cxcursor::operator==(CXCursor X, CXCursor Y) {
+ return X.kind == Y.kind && X.data[0] == Y.data[0] && X.data[1] == Y.data[1] &&
+ X.data[2] == Y.data[2];
+} \ No newline at end of file