<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/57607>57607</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
classTemplateSpecializationDecl does not work as described
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
florianschanda-bmw
</td>
</tr>
</table>
<pre>
Hi,
I am trying to write a clang-tidy check and I have done this:
```
void PotatoCheck::registerMatchers(MatchFinder *Finder) {
Finder->addMatcher(classTemplateSpecializationDecl().bind("x"), this);
}
void PotatoCheck::check(const MatchFinder::MatchResult &Result) {
const auto *MatchedDecl = Result.Nodes.getNodeAs<Decl>("x");
diag(MatchedDecl->getLocation(), "instantiation");
}
```
The documentation for classTemplateSpecializationDecl says:
```
Given
template<typename T> class A {};
template<> class A<double> {};
A<int> a;
classTemplateSpecializationDecl()
matches the specializations A<int> and A<double>
```
But it doesn't. It matches the first two, not the last two:
```
foo.cpp:1:30: warning: instantiation [misc-Potato]
template<typename T> class A {};
^
foo.cpp:2:20: warning: instantiation [misc-Potato]
template<> class A<double> {};
^
```
(foo.cpp contains precisely the three lines copied from the documentation.)
I am assuming I did something obviously wrong with the way I have set up the matcher? In which case I apologize for the noise.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJylVduS4jYQ_Rr7pQuXsbGBBz8ww5BQlaRSyfyALDW2EltySTIO-_VpyTALuzO7WwmFjdStbp0-faHW4lL9LKPsOUr3Ubqb30dgPThzkaoBp2Ey0iEw4B1TzcJJcQHeIv8bmBJwhJadEYRWCK6VNsqvTqIyvX7D9qylgN-1Y04_e2N_Lt8ZbKR1aH5ljlwaG2WbsDxIJdBAlO3mVZRtIVo_za4AZuEiyl-YEFdbMiWA1r5iP3TM4Z8Dcsk6-Yk5qdUeeUcnyE9Sk3FYZv_QQxKKfoZOy_x6R7Te3zPyPvrAgr9XK-vgDvisDo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