• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 namespace NS {
3   extern int gx;
4   typedef int MyInt;
5 }
6 
7 enum {
8   EnumVal = 1
9 };
10 
11 NS::MyInt NS::gx = EnumVal;
12 
foo()13 void foo() {
14   NS::MyInt x;
15 }
16 
17 enum {
18   SecondVal = EnumVal
19 };
20 
21 struct S {
22   S& operator++();
23   int operator*();
24   S& operator=(int x);
25   S& operator!=(int x);
26   S& operator()(int x);
27 };
28 
foo2(S & s)29 void foo2(S &s) {
30   (void)++s;
31   (void)*s;
32   s = 3;
33   (void)(s != 3);
34   s(3);
35 }
36 
37 namespace NS {
38   namespace Inn {}
39   typedef int Foo;
40 }
41 
42 using namespace NS;
43 using namespace NS::Inn;
44 using NS::Foo;
45 
46 template <typename T1, typename T2>
47 struct TS { };
48 
49 template <typename T>
50 struct TS<T, int> {
51   typedef int MyInt;
52 };
53 
foo3()54 void foo3() {
55   TS<int, int> s;
56 }
57 
58 const int array_size = 3;
59 typedef int some_arr[array_size];
60 
61 const int default_param = 3;
62 void foo4(int p = default_param);
63 
64 struct S2 {
65   int x,y;
66 };
67 
foo5()68 void foo5() {
69   struct S2 s = { .y = 1, .x = 4};
70 }
71 
72 int ginitlist[] = {EnumVal};
73 
74 // RUN: c-index-test -index-file %s | FileCheck %s
75 // CHECK:      [indexDeclaration]: kind: namespace | name: NS
76 // CHECK-NEXT: [indexDeclaration]: kind: variable | name: gx
77 // CHECK-NEXT: [indexDeclaration]: kind: typedef | name: MyInt
78 // CHECK-NEXT: [indexDeclaration]: kind: enum
79 // CHECK-NEXT: [indexDeclaration]: kind: enumerator | name: EnumVal
80 // CHECK-NEXT: [indexDeclaration]: kind: variable | name: gx
81 // CHECK-NEXT: [indexEntityReference]: kind: namespace | name: NS
82 // CHECK-NEXT: [indexEntityReference]: kind: typedef | name: MyInt
83 // CHECK-NEXT: [indexEntityReference]: kind: namespace | name: NS
84 // CHECK-NEXT: [indexEntityReference]: kind: enumerator | name: EnumVal
85 // CHECK-NEXT: [indexDeclaration]: kind: function | name: foo
86 // CHECK-NEXT: [indexEntityReference]: kind: namespace | name: NS
87 // CHECK-NEXT: [indexEntityReference]: kind: typedef | name: MyInt
88 // CHECK-NEXT: [indexDeclaration]: kind: enum
89 // CHECK-NEXT: [indexDeclaration]: kind: enumerator | name: SecondVal
90 // CHECK-NEXT: [indexEntityReference]: kind: enumerator | name: EnumVal
91 
92 // CHECK:      [indexDeclaration]: kind: function | name: foo2
93 // CHECK:      [indexEntityReference]: kind: c++-instance-method | name: operator++
94 // CHECK-NEXT: [indexEntityReference]: kind: c++-instance-method | name: operator*
95 // CHECK-NEXT: [indexEntityReference]: kind: c++-instance-method | name: operator=
96 // CHECK-NEXT: [indexEntityReference]: kind: c++-instance-method | name: operator!=
97 // CHECK-NEXT: [indexEntityReference]: kind: c++-instance-method | name: operator()
98 
99 // CHECK:      [indexEntityReference]: kind: namespace | name: NS | {{.*}} | loc: 42:17
100 // CHECK-NEXT: [indexEntityReference]: kind: namespace | name: NS | {{.*}} | loc: 43:17
101 // CHECK-NEXT: [indexEntityReference]: kind: namespace | name: Inn | {{.*}} | loc: 43:21
102 // CHECK-NEXT: [indexEntityReference]: kind: namespace | name: NS | {{.*}} | loc: 44:7
103 // CHECK-NEXT: [indexEntityReference]: kind: typedef | name: Foo | {{.*}} | loc: 44:11
104 
105 // CHECK:      [indexDeclaration]: kind: c++-class-template | name: TS | {{.*}} | loc: 47:8
106 // CHECK-NEXT: [indexDeclaration]: kind: struct-template-partial-spec | name: TS | USR: c:@SP>1#T@TS>#t0.0#I | {{.*}} | loc: 50:8
107 // CHECK-NEXT: [indexDeclaration]: kind: typedef | name: MyInt | USR: c:index-refs.cpp@SP>1#T@TS>#t0.0#I@T@MyInt | {{.*}} | loc: 51:15 | semantic-container: [TS:50:8] | lexical-container: [TS:50:8]
108 /* when indexing implicit instantiations
109   [indexDeclaration]: kind: struct-template-spec | name: TS | USR: c:@S@TS>#I | {{.*}} | loc: 50:8
110   [indexDeclaration]: kind: typedef | name: MyInt | USR: c:index-refs.cpp@593@S@TS>#I@T@MyInt | {{.*}} | loc: 51:15 | semantic-container: [TS:50:8] | lexical-container: [TS:50:8]
111  */
112 // CHECK-NEXT: [indexDeclaration]: kind: function | name: foo3
113 /* when indexing implicit instantiations
114   [indexEntityReference]: kind: struct-template-spec | name: TS | USR: c:@S@TS>#I | {{.*}} | loc: 55:3
115 */
116 // CHECK-NEXT: [indexEntityReference]: kind: c++-class-template | name: TS | USR: c:@ST>2#T#T@TS | {{.*}} | loc: 55:3
117 
118 // CHECK:      [indexEntityReference]: kind: variable | name: array_size | {{.*}} | loc: 59:22
119 // CHECK:      [indexEntityReference]: kind: variable | name: default_param | {{.*}} | loc: 62:19
120 // CHECK-NOT:  [indexEntityReference]: kind: variable | name: default_param | {{.*}} | loc: 62:19
121 
122 // CHECK:      [indexEntityReference]: kind: field | name: y | {{.*}} | loc: 69:20
123 // CHECK-NEXT: [indexEntityReference]: kind: field | name: x | {{.*}} | loc: 69:28
124 // CHECK-NOT:  [indexEntityReference]: kind: field | name: y | {{.*}} | loc: 69:20
125 // CHECK-NOT:  [indexEntityReference]: kind: field | name: x | {{.*}} | loc: 69:28
126 
127 // CHECK:      [indexDeclaration]: kind: variable | name: ginitlist |
128 // CHECK:      [indexEntityReference]: kind: enumerator | name: EnumVal | {{.*}} | loc: 72:20
129 // CHECK-NOT:  [indexEntityReference]: kind: enumerator | name: EnumVal | {{.*}} | loc: 72:20
130