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

    <tr>
        <th>Summary</th>
        <td>
            DeclPrinter prints 'final' twice
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    @tom-anders @sam-mccall 

IWYU's hacky forward-declare printer broke yesterday when 9f57b65a272817752aa00e2fb94154e6eed1d0ec landed.

For the following declaration:
```
template <typename T>
class FinalTemplate final {};
```
`decl->print()` generates:
```
template <typename T> class final FinalTemplate final {\n}
```

So while it's nice that `final` ends up in the right place, it's a little annoying that it's printed both before and after the decl name.

The reason for that is [`DeclPrinter::prettyPrintAttributes`](https://github.com/llvm/llvm-project/blob/main/clang/lib/AST/DeclPrinter.cpp#L235), which emits all decl attributes, and is called before the new `final` code in [`DeclPrinter::VisitCXXRecordDecl`](https://github.com/llvm/llvm-project/blob/main/clang/lib/AST/DeclPrinter.cpp#L993).

There's a bunch of things wrong with our current parsing and rewriting of the `decl->print()` output, so I'll look into hardening that, but I figured this might hit someone else.

Not sure why it doesn't show up in your tests. Does the Hover code do any additional cleanup?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy9VcGO2zYQ_Rr5MrAhU5ZlHXTYXcfoAkURJJs2PVLkWGKXIgWSiqC_z5DytrtF9pBLAIESyeHMmzdvqNbKpckOebDDlhuJzgPNPB-2gxBca8jyc5bfrePjX39_yVjloefieYGrdTN3citRaO4QRqdMQAets88IC3qaSL7A3KOB-lpW7bHkrGKnfVWVjPM8R3Zt68O-POARUe5ljgJ0hCF3r-NerIPQIwXU2s7KdLCG5EFZkxU3q-yY3540DTiMmgeErHgIy4iGDwhPWfFh3abz3sNFGa6fXiyvcQZZdZ9V56y4_6Fb-ojBt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