xref: /minix3/external/bsd/llvm/dist/clang/test/Index/file-refs.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc namespace NS {
2*f4a2713aSLionel Sambuc   class C {
3*f4a2713aSLionel Sambuc   public:
C()4*f4a2713aSLionel Sambuc     C() { }
5*f4a2713aSLionel Sambuc     void m();
6*f4a2713aSLionel Sambuc   };
7*f4a2713aSLionel Sambuc }
8*f4a2713aSLionel Sambuc 
m()9*f4a2713aSLionel Sambuc void NS::C::m() {
10*f4a2713aSLionel Sambuc   C c;
11*f4a2713aSLionel Sambuc   c.m();
12*f4a2713aSLionel Sambuc }
13*f4a2713aSLionel Sambuc 
f()14*f4a2713aSLionel Sambuc void f() {
15*f4a2713aSLionel Sambuc   NS::C c1();
16*f4a2713aSLionel Sambuc   NS::C c2 = NS::C();
17*f4a2713aSLionel Sambuc }
18*f4a2713aSLionel Sambuc 
19*f4a2713aSLionel Sambuc void over(int);
20*f4a2713aSLionel Sambuc void over(float);
21*f4a2713aSLionel Sambuc 
test_over()22*f4a2713aSLionel Sambuc void test_over() {
23*f4a2713aSLionel Sambuc   over(0);
24*f4a2713aSLionel Sambuc   over(0.0f);
25*f4a2713aSLionel Sambuc }
26*f4a2713aSLionel Sambuc 
27*f4a2713aSLionel Sambuc template <typename T>
tf(T t)28*f4a2713aSLionel Sambuc T tf(T t) {
29*f4a2713aSLionel Sambuc   return t;
30*f4a2713aSLionel Sambuc }
31*f4a2713aSLionel Sambuc 
32*f4a2713aSLionel Sambuc namespace Test2 {
33*f4a2713aSLionel Sambuc 
34*f4a2713aSLionel Sambuc struct S {
35*f4a2713aSLionel Sambuc   S(int x, int y);
36*f4a2713aSLionel Sambuc   S();
37*f4a2713aSLionel Sambuc };
38*f4a2713aSLionel Sambuc 
39*f4a2713aSLionel Sambuc typedef S Cake;
40*f4a2713aSLionel Sambuc 
f()41*f4a2713aSLionel Sambuc void f() {
42*f4a2713aSLionel Sambuc   Cake p;
43*f4a2713aSLionel Sambuc   p = Test2::S(0,2);
44*f4a2713aSLionel Sambuc   p = Test2::Cake(0,2);
45*f4a2713aSLionel Sambuc }
46*f4a2713aSLionel Sambuc 
47*f4a2713aSLionel Sambuc }
48*f4a2713aSLionel Sambuc 
49*f4a2713aSLionel Sambuc // RUN: c-index-test \
50*f4a2713aSLionel Sambuc 
51*f4a2713aSLionel Sambuc // RUN:  -file-refs-at=%s:9:7 \
52*f4a2713aSLionel Sambuc // CHECK:      NamespaceRef=NS:1:11
53*f4a2713aSLionel Sambuc // CHECK-NEXT: Namespace=NS:1:11 (Definition) =[1:11 - 1:13]
54*f4a2713aSLionel Sambuc // CHECK-NEXT: NamespaceRef=NS:1:11 =[9:6 - 9:8]
55*f4a2713aSLionel Sambuc // CHECK-NEXT: NamespaceRef=NS:1:11 =[15:3 - 15:5]
56*f4a2713aSLionel Sambuc // CHECK-NEXT: NamespaceRef=NS:1:11 =[16:3 - 16:5]
57*f4a2713aSLionel Sambuc // CHECK-NEXT: NamespaceRef=NS:1:11 =[16:14 - 16:16]
58*f4a2713aSLionel Sambuc 
59*f4a2713aSLionel Sambuc // RUN:  -file-refs-at=%s:2:9 \
60*f4a2713aSLionel Sambuc // CHECK-NEXT: ClassDecl=C:2:9 (Definition)
61*f4a2713aSLionel Sambuc // CHECK-NEXT: ClassDecl=C:2:9 (Definition) =[2:9 - 2:10]
62*f4a2713aSLionel Sambuc // CHECK-NEXT: CXXConstructor=C:4:5 (Definition) =[4:5 - 4:6]
63*f4a2713aSLionel Sambuc // CHECK-NEXT: TypeRef=class NS::C:2:9 =[9:10 - 9:11]
64*f4a2713aSLionel Sambuc // CHECK-NEXT: TypeRef=class NS::C:2:9 =[10:3 - 10:4]
65*f4a2713aSLionel Sambuc // CHECK-NEXT: TypeRef=class NS::C:2:9 =[15:7 - 15:8]
66*f4a2713aSLionel Sambuc // CHECK-NEXT: TypeRef=class NS::C:2:9 =[16:7 - 16:8]
67*f4a2713aSLionel Sambuc // CHECK-NEXT: TypeRef=class NS::C:2:9 =[16:18 - 16:19]
68*f4a2713aSLionel Sambuc 
69*f4a2713aSLionel Sambuc // RUN:  -file-refs-at=%s:16:18 \
70*f4a2713aSLionel Sambuc // CHECK-NEXT: CallExpr=C:4:5
71*f4a2713aSLionel Sambuc // CHECK-NEXT: ClassDecl=C:2:9 (Definition) =[2:9 - 2:10]
72*f4a2713aSLionel Sambuc // CHECK-NEXT: CXXConstructor=C:4:5 (Definition) =[4:5 - 4:6]
73*f4a2713aSLionel Sambuc // CHECK-NEXT: TypeRef=class NS::C:2:9 =[9:10 - 9:11]
74*f4a2713aSLionel Sambuc // CHECK-NEXT: TypeRef=class NS::C:2:9 =[10:3 - 10:4]
75*f4a2713aSLionel Sambuc // CHECK-NEXT: TypeRef=class NS::C:2:9 =[15:7 - 15:8]
76*f4a2713aSLionel Sambuc // CHECK-NEXT: TypeRef=class NS::C:2:9 =[16:7 - 16:8]
77*f4a2713aSLionel Sambuc // CHECK-NEXT: TypeRef=class NS::C:2:9 =[16:18 - 16:19]
78*f4a2713aSLionel Sambuc 
79*f4a2713aSLionel Sambuc // RUN:  -file-refs-at=%s:20:8 \
80*f4a2713aSLionel Sambuc // CHECK-NEXT: FunctionDecl=over:20:6
81*f4a2713aSLionel Sambuc // CHECK-NEXT: FunctionDecl=over:20:6 =[20:6 - 20:10]
82*f4a2713aSLionel Sambuc // CHECK-NEXT: DeclRefExpr=over:20:6 =[24:3 - 24:7]
83*f4a2713aSLionel Sambuc 
84*f4a2713aSLionel Sambuc // RUN:  -file-refs-at=%s:28:1 \
85*f4a2713aSLionel Sambuc // CHECK-NEXT: TypeRef=T:27:20
86*f4a2713aSLionel Sambuc // FIXME: Missing TemplateTypeParameter=T:27:20 (Definition)
87*f4a2713aSLionel Sambuc // CHECK-NEXT: TypeRef=T:27:20 =[28:1 - 28:2]
88*f4a2713aSLionel Sambuc // CHECK-NEXT: TypeRef=T:27:20 =[28:6 - 28:7]
89*f4a2713aSLionel Sambuc 
90*f4a2713aSLionel Sambuc // RUN:  -file-refs-at=%s:43:14 \
91*f4a2713aSLionel Sambuc // CHECK-NEXT: CallExpr=S:35:3
92*f4a2713aSLionel Sambuc // CHECK-NEXT: StructDecl=S:34:8 (Definition) =[34:8 - 34:9]
93*f4a2713aSLionel Sambuc // CHECK-NEXT: CXXConstructor=S:35:3 =[35:3 - 35:4]
94*f4a2713aSLionel Sambuc // CHECK-NEXT: CXXConstructor=S:36:3 =[36:3 - 36:4]
95*f4a2713aSLionel Sambuc // CHECK-NEXT: TypeRef=struct Test2::S:34:8 =[39:9 - 39:10]
96*f4a2713aSLionel Sambuc // CHECK-NEXT: TypeRef=struct Test2::S:34:8 =[43:14 - 43:15]
97*f4a2713aSLionel Sambuc 
98*f4a2713aSLionel Sambuc // RUN:  -file-refs-at=%s:44:16 \
99*f4a2713aSLionel Sambuc // CHECK-NEXT: CallExpr=S:35:3
100*f4a2713aSLionel Sambuc // CHECK-NEXT: TypedefDecl=Cake:39:11 (Definition) =[39:11 - 39:15]
101*f4a2713aSLionel Sambuc // CHECK-NEXT: TypeRef=Cake:39:11 =[42:3 - 42:7]
102*f4a2713aSLionel Sambuc // CHECK-NEXT: TypeRef=Cake:39:11 =[44:14 - 44:18]
103*f4a2713aSLionel Sambuc 
104*f4a2713aSLionel Sambuc // RUN:   %s | FileCheck %s
105