<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/64842>64842</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang-tidy 15.0.7-18.0.0git: AllowedTypes can not be used with template specilization
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
davemilter
</td>
</tr>
</table>
<pre>
Here is simplified example:
```c++
#include <string>
template <typename S> struct Foo {
double x;
double y;
S s;
};
double my_super_func(Foo<std::string> v) { return v.x + v.y; }
```
clang-tidy (15.0.7 from distort and 18.0.0git build by hands) reports:
```
test.cpp:9:39: warning: the parameter 'v' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]
9 | double my_super_func(Foo<std::string> v) { return v.x + v.y; }
| ^
| const &
Suppressed 4 warnings (4 with check filters).
Found compiler error(s).
```
But I have such option in clang-tidy's config:
```
performance-unnecessary-value-param.AllowedTypes: 'Foo<std::basic_string<char>>;Foo<std::string>'
```
The problem looks like here https://github.com/llvm/llvm-project/blob/69e47deca97b9a7f7394e5472095ee32e46f1831/clang-tools-extra/clang-tidy/utils/Matchers.h#L111
`ND.getQualifiedNameAsString()` returns just `Foo`.
But if use for example such code:
```
std::string QualName;
llvm::raw_string_ostream OS(QualName);
ND.getNameForDiagnostic(OS, ND.getASTContext().getPrintingPolicy(), true);
```
then `QualName` == `Foo<std::basic_string<char>>`.
I suppose there is also way to get `Foo<std::string>`, because of `clang -Xclang -ast-dump` generates suitable infromation:
```
FunctionDecl 0x5645b2414700 <line:9:1, col:62> col:8 my_super_func 'double (Foo<std::string>)'
|-ParmVarDecl 0x5645b2414600 <col:22, col:39> col:39 used v 'Foo<std::string>':'Foo<std::basic_string<char>>' destroyed
```
The whole idea to specify that `std::optional<CertainType>` is ok to copy, but in general case is not ok,
so I can not use `std::optional` in AllowTypes.
</pre>
<img width="1px" height="1px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