annotate-tokens.m revision bcbdd8e4e9d28c543c177955c0cecfad2132f413
1@interface Foo 2- (int)compare:(Foo*)other; 3@end 4 5@implementation Foo 6- (int)compare:(Foo*)other { 7 return 0; 8 (void)@encode(Foo); 9} 10@end 11 12// From <rdar://problem/7971430>, the 'barType' referenced in the ivar 13// declarations should be annotated as TypeRefs. 14typedef int * barType; 15@interface Bar 16{ 17 barType iVar; 18 barType iVar1, iVar2; 19} 20@end 21@implementation Bar 22- (void) method 23{ 24 barType local = iVar; 25} 26@end 27 28// From <rdar://problem/7967123>. The ranges for attributes are not 29// currently stored, causing most of the tokens to be falsely annotated. 30// Since there are no source ranges for attributes, we currently don't 31// annotate them. 32@interface IBActionTests 33- (IBAction) actionMethod:(id)arg; 34- (void)foo:(int)x; 35@end 36extern int ibaction_test(void); 37@implementation IBActionTests 38- (IBAction) actionMethod:(id)arg 39{ 40 ibaction_test(); 41 [self foo:0]; 42} 43- (void) foo:(int)x 44{ 45 (void) x; 46} 47@end 48 49// From <rdar://problem/7961995>. Essentially the same issue as 7967123, 50// but impacting code marked as IBOutlets. 51@interface IBOutletTests 52{ 53 IBOutlet char * anOutlet; 54} 55- (IBAction) actionMethod:(id)arg; 56@property IBOutlet int * aPropOutlet; 57@end 58 59// RUN: c-index-test -test-annotate-tokens=%s:1:1:58:1 %s -DIBOutlet='__attribute__((iboutlet))' -DIBAction='void)__attribute__((ibaction)' | FileCheck %s 60// CHECK: Punctuation: "@" [1:1 - 1:2] ObjCInterfaceDecl=Foo:1:12 61// CHECK: Keyword: "interface" [1:2 - 1:11] ObjCInterfaceDecl=Foo:1:12 62// CHECK: Identifier: "Foo" [1:12 - 1:15] ObjCInterfaceDecl=Foo:1:12 63// CHECK: Punctuation: "-" [2:1 - 2:2] ObjCInstanceMethodDecl=compare::2:1 64// CHECK: Punctuation: "(" [2:3 - 2:4] ObjCInstanceMethodDecl=compare::2:1 65// CHECK: Keyword: "int" [2:4 - 2:7] ObjCInstanceMethodDecl=compare::2:1 66// CHECK: Punctuation: ")" [2:7 - 2:8] ObjCInstanceMethodDecl=compare::2:1 67// CHECK: Identifier: "compare" [2:8 - 2:15] ObjCInstanceMethodDecl=compare::2:1 68// CHECK: Punctuation: ":" [2:15 - 2:16] ObjCInstanceMethodDecl=compare::2:1 69// CHECK: Punctuation: "(" [2:16 - 2:17] ObjCInstanceMethodDecl=compare::2:1 70// CHECK: Identifier: "Foo" [2:17 - 2:20] ObjCClassRef=Foo:1:12 71// CHECK: Punctuation: "*" [2:20 - 2:21] ParmDecl=other:2:22 (Definition) 72// CHECK: Punctuation: ")" [2:21 - 2:22] ParmDecl=other:2:22 (Definition) 73// CHECK: Identifier: "other" [2:22 - 2:27] ParmDecl=other:2:22 (Definition) 74// CHECK: Punctuation: ";" [2:27 - 2:28] ObjCInstanceMethodDecl=compare::2:1 75// CHECK: Punctuation: "@" [3:1 - 3:2] ObjCInterfaceDecl=Foo:1:12 76// CHECK: Keyword: "end" [3:2 - 3:5] ObjCInterfaceDecl=Foo:1:12 77// CHECK: Punctuation: "@" [5:1 - 5:2] ObjCImplementationDecl=Foo:5:1 (Definition) 78// CHECK: Keyword: "implementation" [5:2 - 5:16] ObjCImplementationDecl=Foo:5:1 (Definition) 79// CHECK: Identifier: "Foo" [5:17 - 5:20] ObjCImplementationDecl=Foo:5:1 (Definition) 80// CHECK: Punctuation: "-" [6:1 - 6:2] ObjCInstanceMethodDecl=compare::6:1 (Definition) 81// CHECK: Punctuation: "(" [6:3 - 6:4] ObjCInstanceMethodDecl=compare::6:1 (Definition) 82// CHECK: Keyword: "int" [6:4 - 6:7] ObjCInstanceMethodDecl=compare::6:1 (Definition) 83// CHECK: Punctuation: ")" [6:7 - 6:8] ObjCInstanceMethodDecl=compare::6:1 (Definition) 84// CHECK: Identifier: "compare" [6:8 - 6:15] ObjCInstanceMethodDecl=compare::6:1 (Definition) 85// CHECK: Punctuation: ":" [6:15 - 6:16] ObjCInstanceMethodDecl=compare::6:1 (Definition) 86// CHECK: Punctuation: "(" [6:16 - 6:17] ObjCInstanceMethodDecl=compare::6:1 (Definition) 87// CHECK: Identifier: "Foo" [6:17 - 6:20] ObjCClassRef=Foo:1:12 88// CHECK: Punctuation: "*" [6:20 - 6:21] ParmDecl=other:6:22 (Definition) 89// CHECK: Punctuation: ")" [6:21 - 6:22] ParmDecl=other:6:22 (Definition) 90// CHECK: Identifier: "other" [6:22 - 6:27] ParmDecl=other:6:22 (Definition) 91// CHECK: Punctuation: "{" [6:28 - 6:29] UnexposedStmt= 92// CHECK: Keyword: "return" [7:3 - 7:9] UnexposedStmt= 93// CHECK: Literal: "0" [7:10 - 7:11] UnexposedExpr= 94// CHECK: Punctuation: ";" [7:11 - 7:12] UnexposedStmt= 95// CHECK: Punctuation: "(" [8:3 - 8:4] UnexposedExpr= 96// CHECK: Keyword: "void" [8:4 - 8:8] UnexposedExpr= 97// CHECK: Punctuation: ")" [8:8 - 8:9] UnexposedExpr= 98// CHECK: Punctuation: "@" [8:9 - 8:10] UnexposedExpr= 99// CHECK: Keyword: "encode" [8:10 - 8:16] UnexposedExpr= 100// CHECK: Punctuation: "(" [8:16 - 8:17] UnexposedExpr= 101// CHECK: Identifier: "Foo" [8:17 - 8:20] ObjCClassRef=Foo:1:12 102// CHECK: Punctuation: ")" [8:20 - 8:21] UnexposedExpr= 103// CHECK: Punctuation: ";" [8:21 - 8:22] UnexposedStmt= 104// CHECK: Punctuation: "}" [9:1 - 9:2] UnexposedStmt= 105// CHECK: Punctuation: "@" [10:1 - 10:2] ObjCImplementationDecl=Foo:5:1 (Definition) 106// CHECK: Keyword: "end" [10:2 - 10:5] 107// CHECK: Keyword: "typedef" [14:1 - 14:8] 108// CHECK: Keyword: "int" [14:9 - 14:12] 109// CHECK: Punctuation: "*" [14:13 - 14:14] 110// CHECK: Identifier: "barType" [14:15 - 14:22] TypedefDecl=barType:14:15 (Definition) 111// CHECK: Punctuation: ";" [14:22 - 14:23] 112// CHECK: Punctuation: "@" [15:1 - 15:2] ObjCInterfaceDecl=Bar:15:12 113// CHECK: Keyword: "interface" [15:2 - 15:11] ObjCInterfaceDecl=Bar:15:12 114// CHECK: Identifier: "Bar" [15:12 - 15:15] ObjCInterfaceDecl=Bar:15:12 115// CHECK: Punctuation: "{" [16:1 - 16:2] ObjCInterfaceDecl=Bar:15:12 116// CHECK: Identifier: "barType" [17:5 - 17:12] TypeRef=barType:14:15 117// CHECK: Identifier: "iVar" [17:13 - 17:17] ObjCIvarDecl=iVar:17:13 (Definition) 118// CHECK: Punctuation: ";" [17:17 - 17:18] ObjCInterfaceDecl=Bar:15:12 119// CHECK: Identifier: "barType" [18:5 - 18:12] TypeRef=barType:14:15 120// CHECK: Identifier: "iVar1" [18:13 - 18:18] ObjCIvarDecl=iVar1:18:13 (Definition) 121// CHECK: Punctuation: "," [18:18 - 18:19] ObjCIvarDecl=iVar2:18:20 (Definition) 122// CHECK: Identifier: "iVar2" [18:20 - 18:25] ObjCIvarDecl=iVar2:18:20 (Definition) 123// CHECK: Punctuation: ";" [18:25 - 18:26] ObjCInterfaceDecl=Bar:15:12 124// CHECK: Punctuation: "}" [19:1 - 19:2] ObjCInterfaceDecl=Bar:15:12 125// CHECK: Punctuation: "@" [20:1 - 20:2] ObjCInterfaceDecl=Bar:15:12 126// CHECK: Keyword: "end" [20:2 - 20:5] ObjCInterfaceDecl=Bar:15:12 127// CHECK: Punctuation: "@" [21:1 - 21:2] ObjCImplementationDecl=Bar:21:1 (Definition) 128// CHECK: Keyword: "implementation" [21:2 - 21:16] ObjCImplementationDecl=Bar:21:1 (Definition) 129// CHECK: Identifier: "Bar" [21:17 - 21:20] ObjCImplementationDecl=Bar:21:1 (Definition) 130// CHECK: Punctuation: "-" [22:1 - 22:2] ObjCInstanceMethodDecl=method:22:1 (Definition) 131// CHECK: Punctuation: "(" [22:3 - 22:4] ObjCInstanceMethodDecl=method:22:1 (Definition) 132// CHECK: Keyword: "void" [22:4 - 22:8] ObjCInstanceMethodDecl=method:22:1 (Definition) 133// CHECK: Punctuation: ")" [22:8 - 22:9] ObjCInstanceMethodDecl=method:22:1 (Definition) 134// CHECK: Identifier: "method" [22:10 - 22:16] ObjCInstanceMethodDecl=method:22:1 (Definition) 135// CHECK: Punctuation: "{" [23:1 - 23:2] UnexposedStmt= 136// CHECK: Identifier: "barType" [24:5 - 24:12] TypeRef=barType:14:15 137// CHECK: Identifier: "local" [24:13 - 24:18] VarDecl=local:24:13 (Definition) 138// CHECK: Punctuation: "=" [24:19 - 24:20] VarDecl=local:24:13 (Definition) 139// CHECK: Identifier: "iVar" [24:21 - 24:25] MemberRefExpr=iVar:17:13 140// CHECK: Punctuation: ";" [24:25 - 24:26] UnexposedStmt= 141// CHECK: Punctuation: "}" [25:1 - 25:2] UnexposedStmt= 142// CHECK: Punctuation: "@" [26:1 - 26:2] ObjCImplementationDecl=Bar:21:1 (Definition) 143// CHECK: Keyword: "end" [26:2 - 26:5] 144// CHECK: Punctuation: "@" [32:1 - 32:2] ObjCInterfaceDecl=IBActionTests:32:12 145// CHECK: Keyword: "interface" [32:2 - 32:11] ObjCInterfaceDecl=IBActionTests:32:12 146// CHECK: Identifier: "IBActionTests" [32:12 - 32:25] ObjCInterfaceDecl=IBActionTests:32:12 147// CHECK: Punctuation: "-" [33:1 - 33:2] ObjCInstanceMethodDecl=actionMethod::33:1 148// CHECK: Punctuation: "(" [33:3 - 33:4] ObjCInstanceMethodDecl=actionMethod::33:1 149// CHECK: Identifier: "IBAction" [33:4 - 33:12] macro instantiation=IBAction 150// CHECK: Punctuation: ")" [33:12 - 33:13] ObjCInstanceMethodDecl=actionMethod::33:1 151// CHECK: Identifier: "actionMethod" [33:14 - 33:26] ObjCInstanceMethodDecl=actionMethod::33:1 152// CHECK: Punctuation: ":" [33:26 - 33:27] ObjCInstanceMethodDecl=actionMethod::33:1 153// CHECK: Punctuation: "(" [33:27 - 33:28] ObjCInstanceMethodDecl=actionMethod::33:1 154// CHECK: Identifier: "id" [33:28 - 33:30] TypeRef=id:0:0 155// CHECK: Punctuation: ")" [33:30 - 33:31] ParmDecl=arg:33:31 (Definition) 156// CHECK: Identifier: "arg" [33:31 - 33:34] ParmDecl=arg:33:31 (Definition) 157// CHECK: Punctuation: ";" [33:34 - 33:35] ObjCInstanceMethodDecl=actionMethod::33:1 158// CHECK: Punctuation: "-" [34:1 - 34:2] ObjCInstanceMethodDecl=foo::34:1 159// CHECK: Punctuation: "(" [34:3 - 34:4] ObjCInstanceMethodDecl=foo::34:1 160// CHECK: Keyword: "void" [34:4 - 34:8] ObjCInstanceMethodDecl=foo::34:1 161// CHECK: Punctuation: ")" [34:8 - 34:9] ObjCInstanceMethodDecl=foo::34:1 162// CHECK: Identifier: "foo" [34:9 - 34:12] ObjCInstanceMethodDecl=foo::34:1 163// CHECK: Punctuation: ":" [34:12 - 34:13] ObjCInstanceMethodDecl=foo::34:1 164// CHECK: Punctuation: "(" [34:13 - 34:14] ObjCInstanceMethodDecl=foo::34:1 165// CHECK: Keyword: "int" [34:14 - 34:17] ParmDecl=x:34:18 (Definition) 166// CHECK: Punctuation: ")" [34:17 - 34:18] ParmDecl=x:34:18 (Definition) 167// CHECK: Identifier: "x" [34:18 - 34:19] ParmDecl=x:34:18 (Definition) 168// CHECK: Punctuation: ";" [34:19 - 34:20] ObjCInstanceMethodDecl=foo::34:1 169// CHECK: Punctuation: "@" [35:1 - 35:2] ObjCInterfaceDecl=IBActionTests:32:12 170// CHECK: Keyword: "end" [35:2 - 35:5] ObjCInterfaceDecl=IBActionTests:32:12 171// CHECK: Keyword: "extern" [36:1 - 36:7] 172// CHECK: Keyword: "int" [36:8 - 36:11] FunctionDecl=ibaction_test:36:12 173// CHECK: Identifier: "ibaction_test" [36:12 - 36:25] FunctionDecl=ibaction_test:36:12 174// CHECK: Punctuation: "(" [36:25 - 36:26] FunctionDecl=ibaction_test:36:12 175// CHECK: Keyword: "void" [36:26 - 36:30] FunctionDecl=ibaction_test:36:12 176// CHECK: Punctuation: ")" [36:30 - 36:31] FunctionDecl=ibaction_test:36:12 177// CHECK: Punctuation: ";" [36:31 - 36:32] 178// CHECK: Punctuation: "@" [37:1 - 37:2] ObjCImplementationDecl=IBActionTests:37:1 (Definition) 179// CHECK: Keyword: "implementation" [37:2 - 37:16] ObjCImplementationDecl=IBActionTests:37:1 (Definition) 180// CHECK: Identifier: "IBActionTests" [37:17 - 37:30] ObjCImplementationDecl=IBActionTests:37:1 (Definition) 181// CHECK: Punctuation: "-" [38:1 - 38:2] ObjCInstanceMethodDecl=actionMethod::38:1 (Definition) 182// CHECK: Punctuation: "(" [38:3 - 38:4] ObjCInstanceMethodDecl=actionMethod::38:1 (Definition) 183// CHECK: Identifier: "IBAction" [38:4 - 38:12] macro instantiation=IBAction 184// CHECK: Punctuation: ")" [38:12 - 38:13] ObjCInstanceMethodDecl=actionMethod::38:1 (Definition) 185// CHECK: Identifier: "actionMethod" [38:14 - 38:26] ObjCInstanceMethodDecl=actionMethod::38:1 (Definition) 186// CHECK: Punctuation: ":" [38:26 - 38:27] ObjCInstanceMethodDecl=actionMethod::38:1 (Definition) 187// CHECK: Punctuation: "(" [38:27 - 38:28] ObjCInstanceMethodDecl=actionMethod::38:1 (Definition) 188// CHECK: Identifier: "id" [38:28 - 38:30] TypeRef=id:0:0 189// CHECK: Punctuation: ")" [38:30 - 38:31] ParmDecl=arg:38:31 (Definition) 190// CHECK: Identifier: "arg" [38:31 - 38:34] ParmDecl=arg:38:31 (Definition) 191// CHECK: Punctuation: "{" [39:1 - 39:2] UnexposedStmt= 192// CHECK: Identifier: "ibaction_test" [40:5 - 40:18] DeclRefExpr=ibaction_test:36:12 193// CHECK: Punctuation: "(" [40:18 - 40:19] CallExpr=ibaction_test:36:12 194// CHECK: Punctuation: ")" [40:19 - 40:20] CallExpr=ibaction_test:36:12 195// CHECK: Punctuation: ";" [40:20 - 40:21] UnexposedStmt= 196// CHECK: Punctuation: "[" [41:5 - 41:6] ObjCMessageExpr=foo::34:1 197// CHECK: Identifier: "self" [41:6 - 41:10] DeclRefExpr=self:0:0 198// CHECK: Identifier: "foo" [41:11 - 41:14] ObjCMessageExpr=foo::34:1 199// CHECK: Punctuation: ":" [41:14 - 41:15] ObjCMessageExpr=foo::34:1 200// CHECK: Literal: "0" [41:15 - 41:16] UnexposedExpr= 201// CHECK: Punctuation: "]" [41:16 - 41:17] ObjCMessageExpr=foo::34:1 202// CHECK: Punctuation: ";" [41:17 - 41:18] UnexposedStmt= 203// CHECK: Punctuation: "}" [42:1 - 42:2] UnexposedStmt= 204// CHECK: Punctuation: "-" [43:1 - 43:2] ObjCInstanceMethodDecl=foo::43:1 (Definition) 205// CHECK: Punctuation: "(" [43:3 - 43:4] ObjCInstanceMethodDecl=foo::43:1 (Definition) 206// CHECK: Keyword: "void" [43:4 - 43:8] ObjCInstanceMethodDecl=foo::43:1 (Definition) 207// CHECK: Punctuation: ")" [43:8 - 43:9] ObjCInstanceMethodDecl=foo::43:1 (Definition) 208// CHECK: Identifier: "foo" [43:10 - 43:13] ObjCInstanceMethodDecl=foo::43:1 (Definition) 209// CHECK: Punctuation: ":" [43:13 - 43:14] ObjCInstanceMethodDecl=foo::43:1 (Definition) 210// CHECK: Punctuation: "(" [43:14 - 43:15] ObjCInstanceMethodDecl=foo::43:1 (Definition) 211// CHECK: Keyword: "int" [43:15 - 43:18] ParmDecl=x:43:19 (Definition) 212// CHECK: Punctuation: ")" [43:18 - 43:19] ParmDecl=x:43:19 (Definition) 213// CHECK: Identifier: "x" [43:19 - 43:20] ParmDecl=x:43:19 (Definition) 214// CHECK: Punctuation: "{" [44:1 - 44:2] UnexposedStmt= 215// CHECK: Punctuation: "(" [45:3 - 45:4] UnexposedExpr=x:43:19 216// CHECK: Keyword: "void" [45:4 - 45:8] UnexposedExpr=x:43:19 217// CHECK: Punctuation: ")" [45:8 - 45:9] UnexposedExpr=x:43:19 218// CHECK: Identifier: "x" [45:10 - 45:11] DeclRefExpr=x:43:19 219// CHECK: Punctuation: ";" [45:11 - 45:12] UnexposedStmt= 220// CHECK: Punctuation: "}" [46:1 - 46:2] UnexposedStmt= 221// CHECK: Punctuation: "@" [47:1 - 47:2] ObjCImplementationDecl=IBActionTests:37:1 (Definition) 222// CHECK: Keyword: "end" [47:2 - 47:5] 223// CHECK: Punctuation: "@" [51:1 - 51:2] ObjCInterfaceDecl=IBOutletTests:51:12 224// CHECK: Keyword: "interface" [51:2 - 51:11] ObjCInterfaceDecl=IBOutletTests:51:12 225// CHECK: Identifier: "IBOutletTests" [51:12 - 51:25] ObjCInterfaceDecl=IBOutletTests:51:12 226// CHECK: Punctuation: "{" [52:1 - 52:2] ObjCInterfaceDecl=IBOutletTests:51:12 227// CHECK: Identifier: "IBOutlet" [53:5 - 53:13] macro instantiation=IBOutlet:132:9 228// CHECK: Keyword: "char" [53:14 - 53:18] ObjCIvarDecl=anOutlet:53:21 (Definition) 229// CHECK: Punctuation: "*" [53:19 - 53:20] ObjCIvarDecl=anOutlet:53:21 (Definition) 230// CHECK: Identifier: "anOutlet" [53:21 - 53:29] ObjCIvarDecl=anOutlet:53:21 (Definition) 231// CHECK: Punctuation: ";" [53:29 - 53:30] ObjCInterfaceDecl=IBOutletTests:51:12 232// CHECK: Punctuation: "}" [54:1 - 54:2] ObjCInterfaceDecl=IBOutletTests:51:12 233// CHECK: Punctuation: "-" [55:1 - 55:2] ObjCInterfaceDecl=IBOutletTests:51:12 234// CHECK: Punctuation: "(" [55:3 - 55:4] ObjCInterfaceDecl=IBOutletTests:51:12 235// CHECK: Identifier: "IBAction" [55:4 - 55:12] macro instantiation=IBAction 236// CHECK: Punctuation: ")" [55:12 - 55:13] ObjCInterfaceDecl=IBOutletTests:51:12 237// CHECK: Identifier: "actionMethod" [55:14 - 55:26] ObjCInterfaceDecl=IBOutletTests:51:12 238// CHECK: Punctuation: ":" [55:26 - 55:27] ObjCInterfaceDecl=IBOutletTests:51:12 239// CHECK: Punctuation: "(" [55:27 - 55:28] ObjCInterfaceDecl=IBOutletTests:51:12 240// CHECK: Identifier: "id" [55:28 - 55:30] ObjCInterfaceDecl=IBOutletTests:51:12 241// CHECK: Punctuation: ")" [55:30 - 55:31] ObjCInterfaceDecl=IBOutletTests:51:12 242// CHECK: Identifier: "arg" [55:31 - 55:34] ObjCInterfaceDecl=IBOutletTests:51:12 243// CHECK: Punctuation: ";" [55:34 - 55:35] ObjCInterfaceDecl=IBOutletTests:51:12 244// CHECK: Punctuation: "@" [56:1 - 56:2] ObjCInterfaceDecl=IBOutletTests:51:12 245// CHECK: Keyword: "property" [56:2 - 56:10] ObjCInterfaceDecl=IBOutletTests:51:12 246// CHECK: Identifier: "IBOutlet" [56:11 - 56:19] macro instantiation=IBOutlet:132:9 247// CHECK: Keyword: "int" [56:20 - 56:23] ObjCInterfaceDecl=IBOutletTests:51:12 248// CHECK: Punctuation: "*" [56:24 - 56:25] ObjCInterfaceDecl=IBOutletTests:51:12 249// CHECK: Identifier: "aPropOutlet" [56:26 - 56:37] ObjCPropertyDecl=aPropOutlet:56:26 250// CHECK: Punctuation: ";" [56:37 - 56:38] ObjCInterfaceDecl=IBOutletTests:51:12 251// CHECK: Punctuation: "@" [57:1 - 57:2] ObjCInterfaceDecl=IBOutletTests:51:12 252// CHECK: Keyword: "end" [57:2 - 57:5] ObjCInterfaceDecl=IBOutletTests:51:12 253 254