<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/59147>59147</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            IncludeCleaner's filtering of UsingShadows is too aggressive with templates
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang-include-cleaner
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          sam-mccall
      </td>
    </tr>
</table>

<pre>
    ```
// foo.cpp
using std::vector;
vector<int> x;
```

The using-decl should be marked as a reference to either `vector<T>` or `vector<int>`, but is not.

The reason is that (in an implementation file) we iterate over the UsingShadowDecls and drop those whose targets are not `Used` or `Referenced`. In this case the UsingShadowDecl points at the primary template `vector<T>` but only the specialization `vector<int>` is marked as used.

Possible fixes:
 - change the AST to also mark the primary template as referenced/used
 - change the logic to query all template specializations when the target is a templatedecl
 - drop this filtering approach to UsingDecls (we already don't use it for headers)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxtU81y2yAQfhrpsmOPhGzFOuiQn2Ymt06TPACClUSLQQXkxH36Lqi2k9QzjDSw7O73s3RWHtusLv6t4iErbjP2SAt6a9dimpaz2SszgA8yq25pHVAE67LqbometvfKhKz6Bu_nyNfS6fsyIqSCK4lCgx_trCV0CHvufqEE7oGDwx4dGoEQLKAKIzqgOudWL9SI9mA_Hy8IYkN2D90cQHkwNqy_9nfIvTUxGkYeIGM7ZYDTwX7SuEcTeFAU75XGjDXwhqACOh4Q7IGQEBx4jRSeRy7t2wPxINBGgnR2oqj1CG_pG7gbMFDQYQQSwb56lBfoP05E49kangylEyzBY_L_bWCyxJHqhRSdnCLVjhCQgEd41zSKOlijjynDTygU1-rPwvCqeFGXixkz4f0k4Hfrveo0kjzv6ONIpGNYgRi5GRbct88v0TquvU21rsOl8u4iAHuMva5V03ZQItb7PSPlc60vNT4z8iQ8mpS0aB_J8PPtOHLnBv_cogtkNPkbh5xPk7NcjLFZ0n4xlyaEhoBrGhx5BGlNxm5ClIYGg96Kg5EC6DxNS45tWddN2dzUdZXLtpJN1fA8qKCxfTJCzxLvNXKDjop87G37j3b7NJ6WNBwGhyT5gYaKXsKZi89np9sxhCmZkN7tQBfmbi3snjZaH06_FbH6SUbTVnk_k23scduUm5t8bOtabqtu29fYbypebppyV1co6mKLvGd1mWveofZttr3LGBOaXFmphcdKnIiwbPuQq5YVjJUlq8qioLWud53c9YJ3VbMrtpXMNgXuudLriGlt3ZC7NsHr5sFTUCsf_CXIifVgEFNrqs9neluu9Xy_2gtBU5AnMm1i8hfADpR4">