aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/Index/get-cursor.m11
-rw-r--r--tools/libclang/CIndex.cpp7
2 files changed, 18 insertions, 0 deletions
diff --git a/test/Index/get-cursor.m b/test/Index/get-cursor.m
new file mode 100644
index 0000000000..9932605647
--- /dev/null
+++ b/test/Index/get-cursor.m
@@ -0,0 +1,11 @@
+// Test is line- and column-sensitive. Run lines are below.
+
+@interface rdar9771715
+@property (readonly) int foo1;
+@property (readwrite) int foo2;
+@end
+
+// RUN: c-index-test -cursor-at=%s:4:28 %s | FileCheck -check-prefix=CHECK-PROP1 %s
+// RUN: c-index-test -cursor-at=%s:5:28 %s | FileCheck -check-prefix=CHECK-PROP2 %s
+// CHECK-PROP1: ObjCPropertyDecl=foo1:4:26
+// CHECK-PROP2: ObjCPropertyDecl=foo2:5:27
diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp
index 829649a779..875cb47a99 100644
--- a/tools/libclang/CIndex.cpp
+++ b/tools/libclang/CIndex.cpp
@@ -3471,6 +3471,13 @@ enum CXChildVisitResult GetCursorVisitor(CXCursor cursor,
CXClientData client_data) {
GetCursorData *Data = static_cast<GetCursorData *>(client_data);
CXCursor *BestCursor = &Data->BestCursor;
+
+ if (clang_isDeclaration(cursor.kind)) {
+ // Avoid having the synthesized methods override the property decls.
+ if (ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(getCursorDecl(cursor)))
+ if (MD->isSynthesized())
+ return CXChildVisit_Break;
+ }
if (clang_isExpression(cursor.kind) &&
clang_isDeclaration(BestCursor->kind)) {