@@ -200,24 +200,26 @@ TEST(WalkAST, VarTemplates) {
200
200
EXPECT_THAT (testWalk (R"cpp(
201
201
template <typename T> T $explicit^Foo = 0;)cpp" ,
202
202
" int z = ^Foo<int>;" ),
203
- ElementsAre (Decl::VarTemplate ));
203
+ ElementsAre (Decl::VarTemplateSpecialization ));
204
204
EXPECT_THAT (testWalk (R"cpp(
205
- template<typename T> T $explicit^ Foo = 0;
206
- template<> int Foo<int> = 1;)cpp" ,
205
+ template<typename T> T Foo = 0;
206
+ template<> int $explicit^ Foo<int> = 1;)cpp" ,
207
207
" int x = ^Foo<int>;" ),
208
- ElementsAre (Decl::VarTemplate ));
208
+ ElementsAre (Decl::VarTemplateSpecialization ));
209
209
// FIXME: This points at implicit specialization, instead we should point to
210
210
// explicit partial specializaiton pattern.
211
211
EXPECT_THAT (testWalk (R"cpp(
212
- template<typename T> T $explicit^ Foo = 0;
213
- template<typename T> T* Foo<T*> = nullptr;)cpp" ,
212
+ template<typename T> T Foo = 0;
213
+ template<typename T> T* $explicit^ Foo<T*> = nullptr;)cpp" ,
214
214
" int *x = ^Foo<int *>;" ),
215
- ElementsAre (Decl::VarTemplate));
215
+ ElementsAre (Decl::VarTemplateSpecialization));
216
+ // Implicit specializations through explicit instantiations has source
217
+ // locations pointing at the primary template.
216
218
EXPECT_THAT (testWalk (R"cpp(
217
219
template<typename T> T $explicit^Foo = 0;
218
220
template int Foo<int>;)cpp" ,
219
221
" int x = ^Foo<int>;" ),
220
- ElementsAre (Decl::VarTemplate ));
222
+ ElementsAre (Decl::VarTemplateSpecialization ));
221
223
}
222
224
TEST (WalkAST, FunctionTemplates) {
223
225
// Explicit instantiation and (partial) specialization references primary
@@ -239,18 +241,19 @@ TEST(WalkAST, FunctionTemplates) {
239
241
EXPECT_THAT (testWalk (R"cpp(
240
242
template <typename T> void $explicit^foo() {})cpp" ,
241
243
" auto x = []{ ^foo<int>(); };" ),
242
- ElementsAre (Decl::FunctionTemplate));
243
- // FIXME: DeclRefExpr points at primary template, not the specialization.
244
+ ElementsAre (Decl::Function));
244
245
EXPECT_THAT (testWalk (R"cpp(
245
- template<typename T> void $explicit^ foo() {}
246
- template<> void foo<int>(){})cpp" ,
246
+ template<typename T> void foo() {}
247
+ template<> void $explicit^ foo<int>(){})cpp" ,
247
248
" auto x = []{ ^foo<int>(); };" ),
248
- ElementsAre (Decl::FunctionTemplate));
249
+ ElementsAre (Decl::Function));
250
+ // The decl is actually the specialization, but explicit instantations point
251
+ // at the primary template.
249
252
EXPECT_THAT (testWalk (R"cpp(
250
253
template<typename T> void $explicit^foo() {};
251
254
template void foo<int>();)cpp" ,
252
255
" auto x = [] { ^foo<int>(); };" ),
253
- ElementsAre (Decl::FunctionTemplate ));
256
+ ElementsAre (Decl::Function ));
254
257
}
255
258
TEST (WalkAST, TemplateSpecializationsFromUsingDecl) {
256
259
// Class templates
@@ -548,7 +551,8 @@ TEST(WalkAST, Concepts) {
548
551
testWalk (Concept, " template<typename T> void func() requires ^Foo<T> {}" );
549
552
testWalk (Concept, " void func(^Foo auto x) {}" );
550
553
// FIXME: Foo should be explicitly referenced.
551
- testWalk (" template<typename T> concept Foo = true;" , " void func() { ^Foo auto x = 1; }" );
554
+ testWalk (" template<typename T> concept Foo = true;" ,
555
+ " void func() { ^Foo auto x = 1; }" );
552
556
}
553
557
554
558
TEST (WalkAST, FriendDecl) {
0 commit comments