]> granicus.if.org Git - clang/commitdiff
[libclang] When annotating tokens, don't override a property annotation with a getter...
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Tue, 4 Jun 2013 18:24:30 +0000 (18:24 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Tue, 4 Jun 2013 18:24:30 +0000 (18:24 +0000)
rdar://13764549

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183242 91177308-0d34-0410-b5e6-96231b3b80d8

test/Index/annotate-tokens.m
tools/libclang/CIndex.cpp

index 40c66a18b8f0231e87e6f667c630f23d548eb294..9a7e28a666bf81b236bdddf2bede054b7c396a9f 100644 (file)
@@ -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
index dacd46e96fc42ac72ea78e093783d2e041100193..83b251968bc8c8ba234eda427fc682eb26dbd4f4 100644 (file)
@@ -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