From: Argyrios Kyrtzidis Date: Tue, 4 Jun 2013 18:24:30 +0000 (+0000) Subject: [libclang] When annotating tokens, don't override a property annotation with a getter... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=25cd4a284307ea5431f646087dee2e93dd4b3d7a;p=clang [libclang] When annotating tokens, don't override a property annotation with a getter/setter method annotation. rdar://13764549 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183242 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/Index/annotate-tokens.m b/test/Index/annotate-tokens.m index 40c66a18b8..9a7e28a666 100644 --- a/test/Index/annotate-tokens.m +++ b/test/Index/annotate-tokens.m @@ -142,6 +142,17 @@ static Rdar8595462_A * Rdar8595462_staticVar; } @end +@interface MyClass + @property int classProperty; +@end +@interface MyClass (abc) + @property int categoryProperty; +@end +@interface MyClass () + @property int extensionProperty; +@end + + // RUN: c-index-test -test-annotate-tokens=%s:1:1:118:1 %s -DIBOutlet='__attribute__((iboutlet))' -DIBAction='void)__attribute__((ibaction)' | FileCheck %s // CHECK: Punctuation: "@" [1:1 - 1:2] ObjCInterfaceDecl=Foo:1:12 // CHECK: Keyword: "interface" [1:2 - 1:11] ObjCInterfaceDecl=Foo:1:12 @@ -574,3 +585,14 @@ static Rdar8595462_A * Rdar8595462_staticVar; // CHECK-WITH-WEAK: Identifier: "foo" [141:15 - 141:18] ObjCIvarDecl=foo:141:15 (Definition) // CHECK-WITH-WEAK: Punctuation: ";" [141:18 - 141:19] ObjCInterfaceDecl=rdar9535717:140:12 // CHECK-WITH-WEAK: Punctuation: "}" [142:1 - 142:2] ObjCInterfaceDecl=rdar9535717:140:12 + +// RUN: c-index-test -test-annotate-tokens=%s:145:1:153:1 %s -DIBOutlet='__attribute__((iboutlet))' -DIBAction='void)__attribute__((ibaction)' -target x86_64-apple-macosx10.7.0 | FileCheck -check-prefix=CHECK-PROP %s +// CHECK-PROP: Keyword: "property" [146:4 - 146:12] ObjCPropertyDecl=classProperty:146:17 +// CHECK-PROP: Keyword: "int" [146:13 - 146:16] ObjCPropertyDecl=classProperty:146:17 +// CHECK-PROP: Identifier: "classProperty" [146:17 - 146:30] ObjCPropertyDecl=classProperty:146:17 +// CHECK-PROP: Keyword: "property" [149:4 - 149:12] ObjCPropertyDecl=categoryProperty:149:17 +// CHECK-PROP: Keyword: "int" [149:13 - 149:16] ObjCPropertyDecl=categoryProperty:149:17 +// CHECK-PROP: Identifier: "categoryProperty" [149:17 - 149:33] ObjCPropertyDecl=categoryProperty:149:17 +// CHECK-PROP: Keyword: "property" [152:4 - 152:12] ObjCPropertyDecl=extensionProperty:152:17 +// CHECK-PROP: Keyword: "int" [152:13 - 152:16] ObjCPropertyDecl=extensionProperty:152:17 +// CHECK-PROP: Identifier: "extensionProperty" [152:17 - 152:34] ObjCPropertyDecl=extensionProperty:152:17 diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index dacd46e96f..83b251968b 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -5179,6 +5179,11 @@ AnnotateTokensWorker::Visit(CXCursor cursor, CXCursor parent) { HasContextSensitiveKeywords = true; } } + + // Don't override a property annotation with its getter/setter method. + if (cursor.kind == CXCursor_ObjCInstanceMethodDecl && + parent.kind == CXCursor_ObjCPropertyDecl) + return CXChildVisit_Continue; if (clang_isPreprocessing(cursor.kind)) { // Items in the preprocessing record are kept separate from items in