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

    <tr>
        <th>Summary</th>
        <td>
            copy-paste error: `VarTemplateSpecializationDecl::getTypeAsWritten` makes no sense
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

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

    <tr>
      <th>Reporter</th>
      <td>
          zygoloid
      </td>
    </tr>
</table>

<pre>
    `VarTemplateSpecializationDecl::getTypeAsWritten` is copy-pasted from `ClassTemplateSpecializationDecl::getTypeAsWritten`. In the latter case, this function describes how the class template specialization was written. For example, here:

```
template<int N> class X {};
template class X<1 + 1>;
template<> class X<2 * 0>;
```

... the `getTypeAsWritten` carries the information about how the template arguments for `X<2>` and `X<0>` were written (the expressions `1 + 1` and `2 * 0`).

For `VarTemplateSpecializationDecl`, this data still exists, but is mostly not set -- the only call to `setTypeAsWritten` is [when instantiating a variable template partial specialization](https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp#L4292) and the "type" that it's set to is *not a valid type* --  it's a template specialization type whose "type template" is a variable template!

Also, the name of this function is highly misleading -- it sounds like it's determining the type of the variable, as written, but actually it's determining "what would the name of the variable, as written, be if it were a type template instead of a variable template?", which is nonsense.

We should store a list of template arguments as written on `VarTemplateSpecializationDecl` instead, and remove this.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJydVU1v4yAQ_TXOBdVycPN18CFtt1Kl1V5a7e51jCc2WwwW4Lrpr9-BxEnapt0PCYUAw7w3b2Zwaaptkcyz72AfsO0UeLzvUEhQ8gW8NPoGhUryNY0a_cO2w7X7YaX3qOkWk44J020vOnAeK7axpmW0f63Auf_wl7I7zXyDjO55tEyAw4Rf0xYBbXotggdWoRNWluhYY4ZoLgIe83tA5l4hsgEcG3YYKbs1luEzkGX03KDFQCe7SbLxd57tR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