summaryrefslogtreecommitdiff
path: root/clang/test/Index/file-refs.c
blob: 23042ea06f694f27f7e3600c8df0b93ff381d0b3 (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
enum {
  VALUE = 3
};

extern int glob_x;

int f(int x) {
  return x+glob_x+VALUE; 
}

typedef struct {
  int x;
  int y;
} Vector;

int vector_get_x(Vector v) {
  int x = v.x;
  return x;
}

int f(int);
int f(int);

// RUN: c-index-test \

// RUN:  -file-refs-at=%s:2:5 \
// CHECK:      EnumConstantDecl=VALUE:2:3 (Definition)
// CHECK-NEXT: EnumConstantDecl=VALUE:2:3 (Definition) =[2:3 - 2:8]
// CHECK-NEXT: DeclRefExpr=VALUE:2:3 =[8:19 - 8:24]

// RUN:  -file-refs-at=%s:8:15 \
// CHECK-NEXT: DeclRefExpr=glob_x:5:12
// CHECK-NEXT: VarDecl=glob_x:5:12 =[5:12 - 5:18]
// CHECK-NEXT: DeclRefExpr=glob_x:5:12 =[8:12 - 8:18]

// RUN:  -file-refs-at=%s:8:10 \
// CHECK-NEXT: DeclRefExpr=x:7:11
// CHECK-NEXT: ParmDecl=x:7:11 (Definition) =[7:11 - 7:12]
// CHECK-NEXT: DeclRefExpr=x:7:11 =[8:10 - 8:11]

// RUN:  -file-refs-at=%s:12:7 \
// CHECK-NEXT: FieldDecl=x:12:7 (Definition)
// CHECK-NEXT: FieldDecl=x:12:7 (Definition) =[12:7 - 12:8]
// CHECK-NEXT: MemberRefExpr=x:12:7 {{.*}} =[17:13 - 17:14]

// RUN:  -file-refs-at=%s:16:21 \
// CHECK-NEXT: TypeRef=Vector:14:3
// CHECK-NEXT: TypedefDecl=Vector:14:3 (Definition) =[14:3 - 14:9]
// CHECK-NEXT: TypeRef=Vector:14:3 =[16:18 - 16:24]

// RUN:  -file-refs-at=%s:21:5 \
// CHECK-NEXT: FunctionDecl=f:21:5
// CHECK-NEXT: FunctionDecl=f:7:5 (Definition) =[7:5 - 7:6]
// CHECK-NEXT: FunctionDecl=f:21:5 =[21:5 - 21:6]
// CHECK-NEXT: FunctionDecl=f:22:5 =[22:5 - 22:6]

// RUN:   %s | FileCheck %s