xref: /minix3/external/bsd/llvm/dist/clang/test/Index/cursor-ref-names.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc template <typename T>
2*f4a2713aSLionel Sambuc struct Base {
3*f4a2713aSLionel Sambuc     void func();
4*f4a2713aSLionel Sambuc     int operator[](T);
5*f4a2713aSLionel Sambuc };
6*f4a2713aSLionel Sambuc 
7*f4a2713aSLionel Sambuc struct Sub: public Base<int> {
8*f4a2713aSLionel Sambuc     void func();
9*f4a2713aSLionel Sambuc };
10*f4a2713aSLionel Sambuc 
11*f4a2713aSLionel Sambuc template <typename T>
myMax(T a,T b)12*f4a2713aSLionel Sambuc inline T myMax(T a, T b)
13*f4a2713aSLionel Sambuc { return (a > b) ? a : b; }
14*f4a2713aSLionel Sambuc 
main()15*f4a2713aSLionel Sambuc int main()
16*f4a2713aSLionel Sambuc {
17*f4a2713aSLionel Sambuc     Sub inst;
18*f4a2713aSLionel Sambuc     inst.func();
19*f4a2713aSLionel Sambuc     inst[1];
20*f4a2713aSLionel Sambuc     inst.operator[](1);
21*f4a2713aSLionel Sambuc 
22*f4a2713aSLionel Sambuc     inst.Base<int>::operator[](1);
23*f4a2713aSLionel Sambuc     myMax<int>(1, 2);
24*f4a2713aSLionel Sambuc 
25*f4a2713aSLionel Sambuc     return 0;
26*f4a2713aSLionel Sambuc }
27*f4a2713aSLionel Sambuc 
28*f4a2713aSLionel Sambuc // RUN: c-index-test -test-load-source all %s | FileCheck %s
29*f4a2713aSLionel Sambuc // CHECK: cursor-ref-names.cpp:17:5: DeclStmt= Extent=[17:5 - 17:14]
30*f4a2713aSLionel Sambuc // CHECK: cursor-ref-names.cpp:17:9: VarDecl=inst:17:9 (Definition) Extent=[17:5 - 17:13]
31*f4a2713aSLionel Sambuc // CHECK: cursor-ref-names.cpp:17:5: TypeRef=struct Sub:7:8 Extent=[17:5 - 17:8]
32*f4a2713aSLionel Sambuc // CHECK: cursor-ref-names.cpp:17:9: CallExpr=Sub:7:8 Extent=[17:9 - 17:13]
33*f4a2713aSLionel Sambuc // CHECK: cursor-ref-names.cpp:18:5: CallExpr=func:8:10 Extent=[18:5 - 18:16]
34*f4a2713aSLionel Sambuc // CHECK: cursor-ref-names.cpp:18:10: MemberRefExpr=func:8:10 SingleRefName=[18:10 - 18:14] RefName=[18:10 - 18:14] Extent=[18:5 - 18:14]
35*f4a2713aSLionel Sambuc // CHECK: cursor-ref-names.cpp:18:5: DeclRefExpr=inst:17:9 Extent=[18:5 - 18:9]
36*f4a2713aSLionel Sambuc // CHECK: cursor-ref-names.cpp:19:5: CallExpr=operator[]:4:9 SingleRefName=[19:9 - 19:12] RefName=[19:9 - 19:10] RefName=[19:11 - 19:12] Extent=[19:5 - 19:12]
37*f4a2713aSLionel Sambuc // CHECK: cursor-ref-names.cpp:19:5: DeclRefExpr=inst:17:9 Extent=[19:5 - 19:9]
38*f4a2713aSLionel Sambuc // CHECK: cursor-ref-names.cpp:19:9: DeclRefExpr=operator[]:4:9 RefName=[19:9 - 19:10] RefName=[19:11 - 19:12] Extent=[19:9 - 19:12]
39*f4a2713aSLionel Sambuc // CHECK: cursor-ref-names.cpp:20:5: CallExpr=operator[]:4:9 Extent=[20:5 - 20:23]
40*f4a2713aSLionel Sambuc // CHECK: cursor-ref-names.cpp:20:10: MemberRefExpr=operator[]:4:9 SingleRefName=[20:10 - 20:20] RefName=[20:10 - 20:18] RefName=[20:18 - 20:19] RefName=[20:19 - 20:20] Extent=[20:5 - 20:20]
41*f4a2713aSLionel Sambuc // CHECK: cursor-ref-names.cpp:20:5: DeclRefExpr=inst:17:9 Extent=[20:5 - 20:9]
42*f4a2713aSLionel Sambuc // CHECK: cursor-ref-names.cpp:22:5: CallExpr=operator[]:4:9 Extent=[22:5 - 22:34]
43*f4a2713aSLionel Sambuc // CHECK: cursor-ref-names.cpp:22:21: MemberRefExpr=operator[]:4:9 SingleRefName=[22:10 - 22:31] RefName=[22:10 - 22:21] RefName=[22:21 - 22:29] RefName=[22:29 - 22:30] RefName=[22:30 - 22:31] Extent=[22:5 - 22:31]
44*f4a2713aSLionel Sambuc // CHECK: cursor-ref-names.cpp:22:5: DeclRefExpr=inst:17:9 Extent=[22:5 - 22:9]
45*f4a2713aSLionel Sambuc // CHECK: cursor-ref-names.cpp:22:10: TemplateRef=Base:2:8 Extent=[22:10 - 22:14]
46*f4a2713aSLionel Sambuc // CHECK: cursor-ref-names.cpp:23:5: CallExpr=myMax:12:10 Extent=[23:5 - 23:21]
47*f4a2713aSLionel Sambuc // CHECK: cursor-ref-names.cpp:23:5: DeclRefExpr=myMax:12:10 RefName=[23:5 - 23:10] RefName=[23:10 - 23:15] Extent=[23:5 - 23:15]
48