summaryrefslogtreecommitdiffstats
path: root/clang/tools/CIndex/CXCursor.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-01-16 17:14:40 +0000
committerDouglas Gregor <dgregor@apple.com>2010-01-16 17:14:40 +0000
commit46d66143886be0c4b486f8112def441c90e5468a (patch)
treeca96e2e750af872c589968db67835465b00c8bf1 /clang/tools/CIndex/CXCursor.cpp
parent071676f42240cc06cb404f53d8f53c90b45fbc66 (diff)
downloadbcm5719-llvm-46d66143886be0c4b486f8112def441c90e5468a.tar.gz
bcm5719-llvm-46d66143886be0c4b486f8112def441c90e5468a.zip
Give ObjCClassRef cursors a sane representation, which is encapsulated
in CXCursor.cpp. With this sane representation, fix the class reference that is part of Objective-C category declarations so that the cursor's location matches up with the reference, not the class being referred to. llvm-svn: 93640
Diffstat (limited to 'clang/tools/CIndex/CXCursor.cpp')
-rw-r--r--clang/tools/CIndex/CXCursor.cpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/clang/tools/CIndex/CXCursor.cpp b/clang/tools/CIndex/CXCursor.cpp
index 01d809a8db8..8211cb00889 100644
--- a/clang/tools/CIndex/CXCursor.cpp
+++ b/clang/tools/CIndex/CXCursor.cpp
@@ -105,6 +105,21 @@ cxcursor::getCursorObjCProtocolRef(CXCursor C) {
reinterpret_cast<uintptr_t>(C.data[1])));
}
+CXCursor cxcursor::MakeCursorObjCClassRef(ObjCInterfaceDecl *Class,
+ SourceLocation Loc) {
+ void *RawLoc = reinterpret_cast<void *>(Loc.getRawEncoding());
+ CXCursor C = { CXCursor_ObjCClassRef, { Class, RawLoc, 0 } };
+ return C;
+}
+
+std::pair<ObjCInterfaceDecl *, SourceLocation>
+cxcursor::getCursorObjCClassRef(CXCursor C) {
+ assert(C.kind == CXCursor_ObjCClassRef);
+ return std::make_pair(static_cast<ObjCInterfaceDecl *>(C.data[0]),
+ SourceLocation::getFromRawEncoding(
+ reinterpret_cast<uintptr_t>(C.data[1])));
+}
+
Decl *cxcursor::getCursorDecl(CXCursor Cursor) {
return (Decl *)Cursor.data[0];
}
@@ -115,7 +130,8 @@ Expr *cxcursor::getCursorExpr(CXCursor Cursor) {
Stmt *cxcursor::getCursorStmt(CXCursor Cursor) {
if (Cursor.kind == CXCursor_ObjCSuperClassRef ||
- Cursor.kind == CXCursor_ObjCProtocolRef)
+ Cursor.kind == CXCursor_ObjCProtocolRef ||
+ Cursor.kind == CXCursor_ObjCClassRef)
return 0;
return (Stmt *)Cursor.data[1];
@@ -125,13 +141,6 @@ 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];
OpenPOWER on IntegriCloud