xref: /minix3/external/bsd/llvm/dist/clang/test/Index/file-refs.c (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc enum {
2*f4a2713aSLionel Sambuc   VALUE = 3
3*f4a2713aSLionel Sambuc };
4*f4a2713aSLionel Sambuc 
5*f4a2713aSLionel Sambuc extern int glob_x;
6*f4a2713aSLionel Sambuc 
f(int x)7*f4a2713aSLionel Sambuc int f(int x) {
8*f4a2713aSLionel Sambuc   return x+glob_x+VALUE;
9*f4a2713aSLionel Sambuc }
10*f4a2713aSLionel Sambuc 
11*f4a2713aSLionel Sambuc typedef struct {
12*f4a2713aSLionel Sambuc   int x;
13*f4a2713aSLionel Sambuc   int y;
14*f4a2713aSLionel Sambuc } Vector;
15*f4a2713aSLionel Sambuc 
vector_get_x(Vector v)16*f4a2713aSLionel Sambuc int vector_get_x(Vector v) {
17*f4a2713aSLionel Sambuc   int x = v.x;
18*f4a2713aSLionel Sambuc   return x;
19*f4a2713aSLionel Sambuc }
20*f4a2713aSLionel Sambuc 
21*f4a2713aSLionel Sambuc int f(int);
22*f4a2713aSLionel Sambuc int f(int);
23*f4a2713aSLionel Sambuc 
24*f4a2713aSLionel Sambuc // RUN: c-index-test \
25*f4a2713aSLionel Sambuc 
26*f4a2713aSLionel Sambuc // RUN:  -file-refs-at=%s:2:5 \
27*f4a2713aSLionel Sambuc // CHECK:      EnumConstantDecl=VALUE:2:3 (Definition)
28*f4a2713aSLionel Sambuc // CHECK-NEXT: EnumConstantDecl=VALUE:2:3 (Definition) =[2:3 - 2:8]
29*f4a2713aSLionel Sambuc // CHECK-NEXT: DeclRefExpr=VALUE:2:3 =[8:19 - 8:24]
30*f4a2713aSLionel Sambuc 
31*f4a2713aSLionel Sambuc // RUN:  -file-refs-at=%s:8:15 \
32*f4a2713aSLionel Sambuc // CHECK-NEXT: DeclRefExpr=glob_x:5:12
33*f4a2713aSLionel Sambuc // CHECK-NEXT: VarDecl=glob_x:5:12 =[5:12 - 5:18]
34*f4a2713aSLionel Sambuc // CHECK-NEXT: DeclRefExpr=glob_x:5:12 =[8:12 - 8:18]
35*f4a2713aSLionel Sambuc 
36*f4a2713aSLionel Sambuc // RUN:  -file-refs-at=%s:8:10 \
37*f4a2713aSLionel Sambuc // CHECK-NEXT: DeclRefExpr=x:7:11
38*f4a2713aSLionel Sambuc // CHECK-NEXT: ParmDecl=x:7:11 (Definition) =[7:11 - 7:12]
39*f4a2713aSLionel Sambuc // CHECK-NEXT: DeclRefExpr=x:7:11 =[8:10 - 8:11]
40*f4a2713aSLionel Sambuc 
41*f4a2713aSLionel Sambuc // RUN:  -file-refs-at=%s:12:7 \
42*f4a2713aSLionel Sambuc // CHECK-NEXT: FieldDecl=x:12:7 (Definition)
43*f4a2713aSLionel Sambuc // CHECK-NEXT: FieldDecl=x:12:7 (Definition) =[12:7 - 12:8]
44*f4a2713aSLionel Sambuc // CHECK-NEXT: MemberRefExpr=x:12:7 {{.*}} =[17:13 - 17:14]
45*f4a2713aSLionel Sambuc 
46*f4a2713aSLionel Sambuc // RUN:  -file-refs-at=%s:16:21 \
47*f4a2713aSLionel Sambuc // CHECK-NEXT: TypeRef=Vector:14:3
48*f4a2713aSLionel Sambuc // CHECK-NEXT: TypedefDecl=Vector:14:3 (Definition) =[14:3 - 14:9]
49*f4a2713aSLionel Sambuc // CHECK-NEXT: TypeRef=Vector:14:3 =[16:18 - 16:24]
50*f4a2713aSLionel Sambuc 
51*f4a2713aSLionel Sambuc // RUN:  -file-refs-at=%s:21:5 \
52*f4a2713aSLionel Sambuc // CHECK-NEXT: FunctionDecl=f:21:5
53*f4a2713aSLionel Sambuc // CHECK-NEXT: FunctionDecl=f:7:5 (Definition) =[7:5 - 7:6]
54*f4a2713aSLionel Sambuc // CHECK-NEXT: FunctionDecl=f:21:5 =[21:5 - 21:6]
55*f4a2713aSLionel Sambuc // CHECK-NEXT: FunctionDecl=f:22:5 =[22:5 - 22:6]
56*f4a2713aSLionel Sambuc 
57*f4a2713aSLionel Sambuc // RUN:   %s | FileCheck %s
58