blob: e251596c8002d27f01ed21d6ea76a901d713a01b [file] [log] [blame]
Douglas Gregorfc8ea232010-01-26 17:06:03 +00001typedef int T;
2struct X { int a, b; };
3void f(void *ptr) {
4 T* t_ptr = (T *)ptr;
5 (void)sizeof(T);
6 /* A comment */
7 struct X x = (struct X){1, 2};
8 void *xx = ptr ? : &x;
9 const char * hello = "Hello";
10}
11
Douglas Gregor648220e2010-08-10 15:02:34 +000012typedef int Int;
13void g(int i, ...) {
14 __builtin_va_list va;
15 (void)__builtin_va_arg(va, Int);
16 (void)__builtin_types_compatible_p(Int, Int);
17}
18
19// RUN: c-index-test -test-annotate-tokens=%s:4:1:17:1 %s | FileCheck %s
Daniel Dunbar8f0bf812010-02-14 08:32:51 +000020// CHECK: Identifier: "T" [4:3 - 4:4] TypeRef=T:1:13
Ted Kremenekfbd84ca2010-05-05 00:55:23 +000021// CHECK: Punctuation: "*" [4:4 - 4:5] VarDecl=t_ptr:4:6 (Definition)
Daniel Dunbar8f0bf812010-02-14 08:32:51 +000022// CHECK: Identifier: "t_ptr" [4:6 - 4:11] VarDecl=t_ptr:4:6 (Definition)
Ted Kremenekfbd84ca2010-05-05 00:55:23 +000023// CHECK: Punctuation: "=" [4:12 - 4:13] VarDecl=t_ptr:4:6 (Definition)
24// CHECK: Punctuation: "(" [4:14 - 4:15] UnexposedExpr=ptr:3:14
Daniel Dunbar8f0bf812010-02-14 08:32:51 +000025// CHECK: Identifier: "T" [4:15 - 4:16] TypeRef=T:1:13
Ted Kremenekfbd84ca2010-05-05 00:55:23 +000026// CHECK: Punctuation: "*" [4:17 - 4:18] UnexposedExpr=ptr:3:14
27// CHECK: Punctuation: ")" [4:18 - 4:19] UnexposedExpr=ptr:3:14
Daniel Dunbar8f0bf812010-02-14 08:32:51 +000028// CHECK: Identifier: "ptr" [4:19 - 4:22] DeclRefExpr=ptr:3:14
Ted Kremenekfbd84ca2010-05-05 00:55:23 +000029// CHECK: Punctuation: ";" [4:22 - 4:23] UnexposedStmt=
30// CHECK: Punctuation: "(" [5:3 - 5:4] UnexposedExpr=
31// CHECK: Keyword: "void" [5:4 - 5:8] UnexposedExpr=
32// CHECK: Punctuation: ")" [5:8 - 5:9] UnexposedExpr=
33// CHECK: Keyword: "sizeof" [5:9 - 5:15] UnexposedExpr=
34// CHECK: Punctuation: "(" [5:15 - 5:16] UnexposedExpr=
Daniel Dunbar8f0bf812010-02-14 08:32:51 +000035// CHECK: Identifier: "T" [5:16 - 5:17] TypeRef=T:1:13
Ted Kremenekfbd84ca2010-05-05 00:55:23 +000036// CHECK: Punctuation: ")" [5:17 - 5:18] UnexposedExpr=
37// CHECK: Punctuation: ";" [5:18 - 5:19] UnexposedStmt=
38// CHECK: Comment: "/* A comment */" [6:3 - 6:18] UnexposedStmt=
39// CHECK: Keyword: "struct" [7:3 - 7:9] UnexposedStmt=
Daniel Dunbar8f0bf812010-02-14 08:32:51 +000040// CHECK: Identifier: "X" [7:10 - 7:11] TypeRef=struct X:2:8
41// CHECK: Identifier: "x" [7:12 - 7:13] VarDecl=x:7:12 (Definition)
Ted Kremenekfbd84ca2010-05-05 00:55:23 +000042// CHECK: Punctuation: "=" [7:14 - 7:15] VarDecl=x:7:12 (Definition)
43// CHECK: Punctuation: "(" [7:16 - 7:17] UnexposedExpr=
44// CHECK: Keyword: "struct" [7:17 - 7:23] UnexposedExpr=
Daniel Dunbar8f0bf812010-02-14 08:32:51 +000045// CHECK: Identifier: "X" [7:24 - 7:25] TypeRef=struct X:2:8
Ted Kremenekfbd84ca2010-05-05 00:55:23 +000046// CHECK: Punctuation: ")" [7:25 - 7:26] UnexposedExpr=
47// CHECK: Punctuation: "{" [7:26 - 7:27] UnexposedExpr=
48// CHECK: Literal: "1" [7:27 - 7:28] UnexposedExpr=
49// CHECK: Punctuation: "," [7:28 - 7:29] UnexposedExpr=
50// CHECK: Literal: "2" [7:30 - 7:31] UnexposedExpr=
51// CHECK: Punctuation: "}" [7:31 - 7:32] UnexposedExpr=
52// CHECK: Punctuation: ";" [7:32 - 7:33] UnexposedStmt=
53// CHECK: Keyword: "void" [8:3 - 8:7] VarDecl=xx:8:9 (Definition)
54// CHECK: Punctuation: "*" [8:8 - 8:9] VarDecl=xx:8:9 (Definition)
Daniel Dunbar8f0bf812010-02-14 08:32:51 +000055// CHECK: Identifier: "xx" [8:9 - 8:11] VarDecl=xx:8:9 (Definition)
Ted Kremenekfbd84ca2010-05-05 00:55:23 +000056// CHECK: Punctuation: "=" [8:12 - 8:13] VarDecl=xx:8:9 (Definition)
Daniel Dunbar8f0bf812010-02-14 08:32:51 +000057// CHECK: Identifier: "ptr" [8:14 - 8:17] DeclRefExpr=ptr:3:14
Ted Kremenekfbd84ca2010-05-05 00:55:23 +000058// CHECK: Punctuation: "?" [8:18 - 8:19] UnexposedExpr=
59// CHECK: Punctuation: ":" [8:20 - 8:21] UnexposedExpr=
60// CHECK: Punctuation: "&" [8:22 - 8:23] UnexposedExpr=
Daniel Dunbar8f0bf812010-02-14 08:32:51 +000061// CHECK: Identifier: "x" [8:23 - 8:24] DeclRefExpr=x:7:12
Ted Kremenekfbd84ca2010-05-05 00:55:23 +000062// CHECK: Punctuation: ";" [8:24 - 8:25] UnexposedStmt=
63// CHECK: Keyword: "const" [9:3 - 9:8] UnexposedStmt=
64// CHECK: Keyword: "char" [9:9 - 9:13] VarDecl=hello:9:16 (Definition)
65// CHECK: Punctuation: "*" [9:14 - 9:15] VarDecl=hello:9:16 (Definition)
Daniel Dunbar8f0bf812010-02-14 08:32:51 +000066// CHECK: Identifier: "hello" [9:16 - 9:21] VarDecl=hello:9:16 (Definition)
Ted Kremenekfbd84ca2010-05-05 00:55:23 +000067// CHECK: Punctuation: "=" [9:22 - 9:23] VarDecl=hello:9:16 (Definition)
68// CHECK: Literal: ""Hello"" [9:24 - 9:31] UnexposedExpr=
69// CHECK: Punctuation: ";" [9:31 - 9:32] UnexposedStmt=
70// CHECK: Punctuation: "}" [10:1 - 10:2] UnexposedStmt=
Douglas Gregor648220e2010-08-10 15:02:34 +000071// CHECK: Keyword: "__builtin_va_arg" [15:9 - 15:25] UnexposedExpr=
72// CHECK: Identifier: "Int" [15:30 - 15:33] TypeRef=Int:12:13
73// CHECK: Keyword: "__builtin_types_compatible_p" [16:9 - 16:37] UnexposedExpr=
74// CHECK: Identifier: "Int" [16:38 - 16:41] TypeRef=Int:12:13
75// CHECK: Punctuation: "," [16:41 - 16:42] UnexposedExpr=
76// CHECK: Identifier: "Int" [16:43 - 16:46] TypeRef=Int:12:13
Douglas Gregord1eabfb2010-02-27 02:42:25 +000077// RUN: c-index-test -test-annotate-tokens=%s:4:1:165:32 %s | FileCheck %s
78// RUN: c-index-test -test-annotate-tokens=%s:4:1:165:38 %s | FileCheck %s