summaryrefslogtreecommitdiff
path: root/clang/test/Index/annotate-literals.m
blob: 20bfd2c456429e9c09f165bff85d70f3de654bef (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
typedef unsigned char BOOL;

@interface NSNumber @end

@interface NSNumber (NSNumberCreation)
+ (NSNumber *)numberWithChar:(char)value;
+ (NSNumber *)numberWithUnsignedChar:(unsigned char)value;
+ (NSNumber *)numberWithShort:(short)value;
+ (NSNumber *)numberWithUnsignedShort:(unsigned short)value;
+ (NSNumber *)numberWithInt:(int)value;
+ (NSNumber *)numberWithUnsignedInt:(unsigned int)value;
+ (NSNumber *)numberWithLong:(long)value;
+ (NSNumber *)numberWithUnsignedLong:(unsigned long)value;
+ (NSNumber *)numberWithLongLong:(long long)value;
+ (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value;
+ (NSNumber *)numberWithFloat:(float)value;
+ (NSNumber *)numberWithDouble:(double)value;
+ (NSNumber *)numberWithBool:(BOOL)value;
@end

@interface NSArray
@end

@interface NSArray (NSArrayCreation)
+ (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt;
@end

@interface NSDictionary
+ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt;
@end

void test_literals(id k1, id o1, id k2, id o2, id k3) {
  id objects = @[ o1, o2 ];
  id dict = @{ k1 : o1,
               k2 : o2,
               k3 : @17 };
}


// RUN: c-index-test -test-annotate-tokens=%s:33:1:37:1 %s | FileCheck -check-prefix=CHECK-LITERALS %s

// CHECK-LITERALS: Identifier: "id" [33:3 - 33:5] TypeRef=id:0:0
// CHECK-LITERALS: Identifier: "objects" [33:6 - 33:13] VarDecl=objects:33:6 (Definition)
// CHECK-LITERALS: Punctuation: "=" [33:14 - 33:15] VarDecl=objects:33:6 (Definition)
// CHECK-LITERALS: Punctuation: "@" [33:16 - 33:17] UnexposedExpr=
// CHECK-LITERALS: Punctuation: "[" [33:17 - 33:18] UnexposedExpr=
// CHECK-LITERALS: Identifier: "o1" [33:19 - 33:21] DeclRefExpr=o1:32:30
// CHECK-LITERALS: Punctuation: "," [33:21 - 33:22] UnexposedExpr=
// CHECK-LITERALS: Identifier: "o2" [33:23 - 33:25] DeclRefExpr=o2:32:44
// CHECK-LITERALS: Punctuation: "]" [33:26 - 33:27] UnexposedExpr=
// CHECK-LITERALS: Punctuation: ";" [33:27 - 33:28] DeclStmt=
// CHECK-LITERALS: Identifier: "id" [34:3 - 34:5] TypeRef=id:0:0
// CHECK-LITERALS: Identifier: "dict" [34:6 - 34:10] VarDecl=dict:34:6 (Definition)
// CHECK-LITERALS: Punctuation: "=" [34:11 - 34:12] VarDecl=dict:34:6 (Definition)
// CHECK-LITERALS: Punctuation: "@" [34:13 - 34:14] UnexposedExpr=
// CHECK-LITERALS: Punctuation: "{" [34:14 - 34:15] UnexposedExpr=
// CHECK-LITERALS: Identifier: "k1" [34:16 - 34:18] DeclRefExpr=k1:32:23
// CHECK-LITERALS: Punctuation: ":" [34:19 - 34:20] UnexposedExpr=
// CHECK-LITERALS: Identifier: "o1" [34:21 - 34:23] DeclRefExpr=o1:32:30
// CHECK-LITERALS: Punctuation: "," [34:23 - 34:24] UnexposedExpr=
// CHECK-LITERALS: Identifier: "k2" [35:16 - 35:18] DeclRefExpr=k2:32:37
// CHECK-LITERALS: Punctuation: ":" [35:19 - 35:20] UnexposedExpr=
// CHECK-LITERALS: Identifier: "o2" [35:21 - 35:23] DeclRefExpr=o2:32:44
// CHECK-LITERALS: Punctuation: "," [35:23 - 35:24] UnexposedExpr=
// CHECK-LITERALS: Identifier: "k3" [36:16 - 36:18] DeclRefExpr=k3:32:51
// CHECK-LITERALS: Punctuation: ":" [36:19 - 36:20] UnexposedExpr=
// CHECK-LITERALS: Punctuation: "@" [36:21 - 36:22] UnexposedExpr=
// CHECK-LITERALS: Literal: "17" [36:22 - 36:24] IntegerLiteral=
// CHECK-LITERALS: Punctuation: "}" [36:25 - 36:26] UnexposedExpr=
// CHECK-LITERALS: Punctuation: ";" [36:26 - 36:27] DeclStmt=
// CHECK-LITERALS: Punctuation: "}" [37:1 - 37:2] CompoundStmt=