1 typedef int T; 2 struct X { int a, b; }; 3 void f(int x) { 4 for (T y = x; T z = x; ++x) { 5 } 6 if (T *z2 = &x) { } 7 while (T *z3 = &x) { } 8 switch (T z4 = x) { 9 case 17: break; 10 } 11 } 12 13 // Test handling of C++ base specifiers. 14 class A { 15 void doA(); 16 }; 17 18 class B { 19 void doB(); 20 }; 21 22 class C : public A, private B { 23 void doC(); 24 }; 25 26 class D : virtual public C, virtual private A {}; 27 28 namespace std { 29 class type_info { }; 30 } 31 32 void test_exprs(C *c) { 33 int typeid_marker; 34 typeid(C); 35 typeid(c); 36 typedef int Integer; 37 Integer *int_ptr; 38 int_ptr->Integer::~Integer(); 39 } 40 41 namespace N { 42 int f(int); 43 float f(float); 44 45 template<typename T> T g(T); 46 template<typename T> T g(T*); 47 } 48 49 template<typename T> 50 void test_dependent_exprs(T t) { 51 N::f(t); 52 typedef T type; 53 N::g<type>(t); 54 type::template f<type*>(t); 55 t->type::template f<type*>(); 56 } 57 58 struct Y { 59 int f(int); 60 float f(float); 61 62 template<typename T> T g(T); 63 template<typename T> T g(T*); 64 }; 65 66 template<typename T> 67 void test_more_dependent_exprs(T t, Y y) { 68 y.Y::f(t); 69 typedef T type; 70 y.g<type>(t); 71 } 72 73 struct Pair { 74 Pair(int, int); 75 }; 76 77 void *operator new(__SIZE_TYPE__, void*) throw(); 78 79 void test_more_exprs(void *mem, int i, int j) { 80 new (mem) Pair(i, j); 81 typedef int Integer; 82 (void)Integer(i); 83 (Integer)i; 84 Integer(); 85 } 86 87 template<typename T> 88 void test_even_more_dependent_exprs(T t, Y y) { 89 typedef T type; 90 (void)type(t, y); 91 (void)__has_nothrow_assign(type); 92 } 93 94 // RUN: c-index-test -test-load-source all %s | FileCheck %s 95 // CHECK: load-stmts.cpp:1:13: TypedefDecl=T:1:13 (Definition) Extent=[1:13 - 1:14] 96 // CHECK: load-stmts.cpp:2:8: StructDecl=X:2:8 (Definition) Extent=[2:1 - 2:23] 97 // CHECK: load-stmts.cpp:2:16: FieldDecl=a:2:16 (Definition) Extent=[2:16 - 2:17] 98 // CHECK: load-stmts.cpp:2:19: FieldDecl=b:2:19 (Definition) Extent=[2:19 - 2:20] 99 // CHECK: load-stmts.cpp:3:6: FunctionDecl=f:3:6 (Definition) Extent=[3:6 - 11:2] 100 // CHECK: load-stmts.cpp:3:12: ParmDecl=x:3:12 (Definition) Extent=[3:8 - 3:13] 101 // CHECK: <invalid loc>:0:0: UnexposedStmt= Extent=[3:15 - 11:2] 102 // CHECK: <invalid loc>:0:0: UnexposedStmt= Extent=[4:3 - 5:4] 103 // CHECK: <invalid loc>:0:0: UnexposedStmt= Extent=[4:8 - 4:16] 104 // CHECK: load-stmts.cpp:4:10: VarDecl=y:4:10 (Definition) Extent=[4:8 - 4:15] 105 // CHECK: load-stmts.cpp:4:8: TypeRef=T:1:13 Extent=[4:8 - 4:9] 106 // CHECK: load-stmts.cpp:4:14: DeclRefExpr=x:3:12 Extent=[4:14 - 4:15] 107 // CHECK: load-stmts.cpp:4:19: VarDecl=z:4:19 (Definition) Extent=[4:17 - 4:24] 108 // CHECK: load-stmts.cpp:4:17: TypeRef=T:1:13 Extent=[4:17 - 4:18] 109 // CHECK: load-stmts.cpp:4:23: DeclRefExpr=x:3:12 Extent=[4:23 - 4:24] 110 // CHECK: load-stmts.cpp:4:19: UnexposedExpr=z:4:19 Extent=[4:19 - 4:20] 111 // CHECK: load-stmts.cpp:4:19: DeclRefExpr=z:4:19 Extent=[4:19 - 4:20] 112 // CHECK: load-stmts.cpp:4:26: UnexposedExpr= Extent=[4:26 - 4:29] 113 // CHECK: load-stmts.cpp:4:28: DeclRefExpr=x:3:12 Extent=[4:28 - 4:29] 114 // CHECK: <invalid loc>:0:0: UnexposedStmt= Extent=[4:31 - 5:4] 115 // CHECK: <invalid loc>:0:0: UnexposedStmt= Extent=[6:3 - 6:22] 116 // CHECK: load-stmts.cpp:6:10: VarDecl=z2:6:10 (Definition) Extent=[6:7 - 6:17] 117 // CHECK: load-stmts.cpp:6:7: TypeRef=T:1:13 Extent=[6:7 - 6:8] 118 // CHECK: load-stmts.cpp:6:15: UnexposedExpr= Extent=[6:15 - 6:17] 119 // CHECK: load-stmts.cpp:6:16: DeclRefExpr=x:3:12 Extent=[6:16 - 6:17] 120 // CHECK: load-stmts.cpp:6:10: UnexposedExpr=z2:6:10 Extent=[6:10 - 6:12] 121 // CHECK: load-stmts.cpp:6:10: DeclRefExpr=z2:6:10 Extent=[6:10 - 6:12] 122 // CHECK: <invalid loc>:0:0: UnexposedStmt= Extent=[6:19 - 6:22] 123 // CHECK: <invalid loc>:0:0: UnexposedStmt= Extent=[7:3 - 7:25] 124 // CHECK: load-stmts.cpp:7:13: VarDecl=z3:7:13 (Definition) Extent=[7:10 - 7:20] 125 // CHECK: load-stmts.cpp:7:10: TypeRef=T:1:13 Extent=[7:10 - 7:11] 126 // CHECK: load-stmts.cpp:7:18: UnexposedExpr= Extent=[7:18 - 7:20] 127 // CHECK: load-stmts.cpp:7:19: DeclRefExpr=x:3:12 Extent=[7:19 - 7:20] 128 // CHECK: load-stmts.cpp:7:13: UnexposedExpr=z3:7:13 Extent=[7:13 - 7:15] 129 // CHECK: load-stmts.cpp:7:13: DeclRefExpr=z3:7:13 Extent=[7:13 - 7:15] 130 // CHECK: <invalid loc>:0:0: UnexposedStmt= Extent=[7:22 - 7:25] 131 // CHECK: <invalid loc>:0:0: UnexposedStmt= Extent=[8:3 - 10:4] 132 // CHECK: load-stmts.cpp:8:13: VarDecl=z4:8:13 (Definition) Extent=[8:11 - 8:19] 133 // CHECK: load-stmts.cpp:8:11: TypeRef=T:1:13 Extent=[8:11 - 8:12] 134 // CHECK: load-stmts.cpp:8:18: DeclRefExpr=x:3:12 Extent=[8:18 - 8:19] 135 // CHECK: load-stmts.cpp:8:13: DeclRefExpr=z4:8:13 Extent=[8:13 - 8:15] 136 // CHECK: <invalid loc>:0:0: UnexposedStmt= Extent=[8:21 - 10:4] 137 // CHECK: <invalid loc>:0:0: UnexposedStmt= Extent=[9:3 - 9:17] 138 // CHECK: load-stmts.cpp:9:8: UnexposedExpr= Extent=[9:8 - 9:10] 139 // CHECK: <invalid loc>:0:0: UnexposedStmt= Extent=[9:12 - 9:17] 140 // CHECK: load-stmts.cpp:14:7: ClassDecl=A:14:7 (Definition) Extent=[14:1 - 16:2] 141 // CHECK: load-stmts.cpp:15:8: CXXMethod=doA:15:8 Extent=[15:8 - 15:13] 142 // CHECK: load-stmts.cpp:18:7: ClassDecl=B:18:7 (Definition) Extent=[18:1 - 20:2] 143 // CHECK: load-stmts.cpp:19:8: CXXMethod=doB:19:8 Extent=[19:8 - 19:13] 144 // CHECK: load-stmts.cpp:22:7: ClassDecl=C:22:7 (Definition) Extent=[22:1 - 24:2] 145 // CHECK: <invalid loc>:0:0: C++ base class specifier=class A:14:7 [access=public isVirtual=false] 146 // CHECK: <invalid loc>:0:0: C++ base class specifier=class B:18:7 [access=private isVirtual=false] 147 // CHECK: load-stmts.cpp:23:8: CXXMethod=doC:23:8 Extent=[23:8 - 23:13] 148 // CHECK: load-stmts.cpp:26:7: ClassDecl=D:26:7 (Definition) Extent=[26:1 - 26:49] 149 // CHECK: <invalid loc>:0:0: C++ base class specifier=class C:22:7 [access=public isVirtual=true] 150 // CHECK: <invalid loc>:0:0: C++ base class specifier=class A:14:7 [access=private isVirtual=true] 151 // CHECK: load-stmts.cpp:33:7: VarDecl=typeid_marker:33:7 (Definition) 152 // CHECK: load-stmts.cpp:34:10: TypeRef=class C:22:7 Extent=[34:10 - 34:11] 153 // CHECK: load-stmts.cpp:35:10: DeclRefExpr=c:32:20 Extent=[35:10 - 35:11] 154 // CHECK: load-stmts.cpp:37:12: VarDecl=int_ptr:37:12 (Definition) Extent=[37:3 - 37:19] 155 // CHECK: load-stmts.cpp:37:3: TypeRef=Integer:36:15 Extent=[37:3 - 37:10] 156 // CHECK: load-stmts.cpp:38:3: DeclRefExpr=int_ptr:37:12 Extent=[38:3 - 38:10] 157 // CHECK: load-stmts.cpp:38:12: TypeRef=Integer:36:15 Extent=[38:12 - 38:19] 158 // CHECK: load-stmts.cpp:38:22: TypeRef=Integer:36:15 Extent=[38:22 - 38:29] 159 // CHECK: load-stmts.cpp:50:6: FunctionTemplate=test_dependent_exprs:50:6 (Definition) 160 // CHECK: load-stmts.cpp:51:3: CallExpr= Extent=[51:3 - 51:10] 161 // CHECK: load-stmts.cpp:51:3: NamespaceRef=N:41:11 Extent=[51:3 - 51:4] 162 // CHECK: load-stmts.cpp:51:8: DeclRefExpr=t:50:29 Extent=[51:8 - 51:9] 163 // CHECK: load-stmts.cpp:52:13: TypedefDecl=type:52:13 (Definition) Extent=[52:13 - 52:17] 164 // CHECK: load-stmts.cpp:53:3: CallExpr= Extent=[53:3 - 53:16] 165 // CHECK: load-stmts.cpp:53:3: NamespaceRef=N:41:11 Extent=[53:3 - 53:4] 166 // CHECK: load-stmts.cpp:53:8: TypeRef=type:52:13 Extent=[53:8 - 53:12] 167 // CHECK: load-stmts.cpp:53:14: DeclRefExpr=t:50:29 Extent=[53:14 - 53:15] 168 // CHECK: load-stmts.cpp:54:3: CallExpr= Extent=[54:3 - 54:29] 169 // CHECK: load-stmts.cpp:54:3: TypeRef=type:52:13 Extent=[54:3 - 54:7] 170 // CHECK: load-stmts.cpp:54:20: TypeRef=type:52:13 Extent=[54:20 - 54:24] 171 // CHECK: load-stmts.cpp:54:27: DeclRefExpr=t:50:29 Extent=[54:27 - 54:28] 172 // CHECK: load-stmts.cpp:55:3: CallExpr= Extent=[55:3 - 55:31] 173 // CHECK: load-stmts.cpp:55:3: DeclRefExpr=t:50:29 Extent=[55:3 - 55:4] 174 // CHECK: load-stmts.cpp:55:23: TypeRef=type:52:13 Extent=[55:23 - 55:27] 175 // CHECK: load-stmts.cpp:67:6: FunctionTemplate=test_more_dependent_exprs:67:6 (Definition) 176 // CHECK: load-stmts.cpp:68:3: CallExpr= Extent=[68:3 - 68:12] 177 // CHECK: load-stmts.cpp:68:3: DeclRefExpr=y:67:39 Extent=[68:3 - 68:4] 178 // CHECK: load-stmts.cpp:68:5: TypeRef=struct Y:58:8 Extent=[68:5 - 68:6] 179 // CHECK: load-stmts.cpp:68:10: DeclRefExpr=t:67:34 Extent=[68:10 - 68:11] 180 // CHECK: load-stmts.cpp:70:3: CallExpr= Extent=[70:3 - 70:15] 181 // CHECK: load-stmts.cpp:70:3: DeclRefExpr=y:67:39 Extent=[70:3 - 70:4] 182 // CHECK: load-stmts.cpp:70:7: TypeRef=type:69:13 Extent=[70:7 - 70:11] 183 // CHECK: load-stmts.cpp:70:13: DeclRefExpr=t:67:34 Extent=[70:13 - 70:14] 184 // CHECK: load-stmts.cpp:79:6: FunctionDecl=test_more_exprs:79:6 (Definition) 185 // CHECK: load-stmts.cpp:80:8: DeclRefExpr=mem:79:28 Extent=[80:8 - 80:11] 186 // CHECK: load-stmts.cpp:80:13: TypeRef=struct Pair:73:8 Extent=[80:13 - 80:17] 187 // CHECK: load-stmts.cpp:80:18: DeclRefExpr=i:79:37 Extent=[80:18 - 80:19] 188 // CHECK: load-stmts.cpp:80:21: DeclRefExpr=j:79:44 Extent=[80:21 - 80:22] 189 // CHECK: load-stmts.cpp:82:9: TypeRef=Integer:81:15 Extent=[82:9 - 82:16] 190 // CHECK: load-stmts.cpp:82:17: DeclRefExpr=i:79:37 Extent=[82:17 - 82:18] 191 // CHECK: load-stmts.cpp:83:3: UnexposedExpr=i:79:37 Extent=[83:3 - 83:13] 192 // CHECK: load-stmts.cpp:83:4: TypeRef=Integer:81:15 Extent=[83:4 - 83:11] 193 // CHECK: load-stmts.cpp:83:12: DeclRefExpr=i:79:37 Extent=[83:12 - 83:13] 194 // CHECK: load-stmts.cpp:84:3: UnexposedExpr= Extent=[84:3 - 84:12] 195 // CHECK: load-stmts.cpp:84:3: TypeRef=Integer:81:15 Extent=[84:3 - 84:10] 196 // CHECK: load-stmts.cpp:90:9: TypeRef=type:89:13 Extent=[90:9 - 90:13] 197 // CHECK: load-stmts.cpp:90:14: DeclRefExpr=t:88:39 Extent=[90:14 - 90:15] 198 // CHECK: load-stmts.cpp:90:17: DeclRefExpr=y:88:44 Extent=[90:17 - 90:18] 199 // CHECK: load-stmts.cpp:91:9: UnexposedExpr= Extent=[91:9 - 91:35] 200 // CHECK: load-stmts.cpp:91:30: TypeRef=type:89:13 Extent=[91:30 - 91:34] 201