aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-09-13 18:49:56 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-09-13 18:49:56 +0000
commit221d5a5005b3dbde50b8b0a40bb5c5e6da8c1173 (patch)
tree7a14aadbd3843ac6e21c80281cbb2d89427b6252
parent18aa2ff4641847d7f8866e8c5912d4d0ddb858ce (diff)
[libclang] Correct annotation and taking of cursor for objc class references
inside the IBOutletCollection attribute. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139621 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--test/Index/IBOutletCollection.m18
-rw-r--r--tools/libclang/CIndex.cpp10
2 files changed, 27 insertions, 1 deletions
diff --git a/test/Index/IBOutletCollection.m b/test/Index/IBOutletCollection.m
new file mode 100644
index 0000000000..a95df8694c
--- /dev/null
+++ b/test/Index/IBOutletCollection.m
@@ -0,0 +1,18 @@
+#define IBOutletCollection(ClassName) __attribute__((iboutletcollection(ClassName)))
+
+@interface Test {
+ IBOutletCollection(Test) Test *anOutletCollection;
+}
+@end
+
+// RUN: c-index-test -cursor-at=%s:4:24 %s | FileCheck -check-prefix=CHECK-CURSOR %s
+// CHECK-CURSOR: ObjCClassRef=Test:3:12
+
+// RUN: c-index-test -test-annotate-tokens=%s:4:1:5:1 %s | FileCheck -check-prefix=CHECK-TOK %s
+// CHECK-TOK: Identifier: "IBOutletCollection" [4:3 - 4:21] macro expansion=IBOutletCollection:1:9
+// CHECK-TOK: Punctuation: "(" [4:21 - 4:22] ObjCInterfaceDecl=Test:3:12
+// CHECK-TOK: Identifier: "Test" [4:22 - 4:26] ObjCClassRef=Test:3:12
+// CHECK-TOK: Punctuation: ")" [4:26 - 4:27] ObjCIvarDecl=anOutletCollection:4:34 (Definition)
+// CHECK-TOK: Identifier: "Test" [4:28 - 4:32] ObjCClassRef=Test:3:12
+// CHECK-TOK: Punctuation: "*" [4:33 - 4:34] ObjCIvarDecl=anOutletCollection:4:34 (Definition)
+// CHECK-TOK: Identifier: "anOutletCollection" [4:34 - 4:52] ObjCIvarDecl=anOutletCollection:4:34 (Definition)
diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp
index 40b21940af..2f8db5dfce 100644
--- a/tools/libclang/CIndex.cpp
+++ b/tools/libclang/CIndex.cpp
@@ -559,7 +559,15 @@ bool CursorVisitor::VisitChildren(CXCursor Cursor) {
}
}
}
-
+
+ if (Cursor.kind == CXCursor_IBOutletCollectionAttr) {
+ IBOutletCollectionAttr *A =
+ cast<IBOutletCollectionAttr>(cxcursor::getCursorAttr(Cursor));
+ if (const ObjCInterfaceType *InterT = A->getInterface()->getAs<ObjCInterfaceType>())
+ return Visit(cxcursor::MakeCursorObjCClassRef(InterT->getInterface(),
+ A->getInterfaceLoc(), TU));
+ }
+
// Nothing to visit at the moment.
return false;
}