[cfe-commits] r137248 - in /cfe/trunk: test/Index/get-cursor.m tools/libclang/CIndex.cpp
Argyrios Kyrtzidis
akyrtzi at gmail.com
Wed Aug 10 14:12:04 PDT 2011
Author: akirtzidis
Date: Wed Aug 10 16:12:04 2011
New Revision: 137248
URL: http://llvm.org/viewvc/llvm-project?rev=137248&view=rev
Log:
[libclang] When pointing at an objc property don't return a cursor that points at the
synthesized method for the property. rdar://9771715
Added:
cfe/trunk/test/Index/get-cursor.m
Modified:
cfe/trunk/tools/libclang/CIndex.cpp
Added: cfe/trunk/test/Index/get-cursor.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/get-cursor.m?rev=137248&view=auto
==============================================================================
--- cfe/trunk/test/Index/get-cursor.m (added)
+++ cfe/trunk/test/Index/get-cursor.m Wed Aug 10 16:12:04 2011
@@ -0,0 +1,11 @@
+// Test is line- and column-sensitive. Run lines are below.
+
+ at interface rdar9771715
+ at property (readonly) int foo1;
+ at property (readwrite) int foo2;
+ at 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
Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=137248&r1=137247&r2=137248&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Wed Aug 10 16:12:04 2011
@@ -3471,6 +3471,13 @@
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)) {
More information about the cfe-commits
mailing list