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

    <tr>
        <th>Summary</th>
        <td>
            [clang] AST doesn't track source locations for where the attribute list appears
        </td>
    </tr>

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

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

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

<pre>
    When I tried to implement inserting a fix-it into the end of a `VarDecl`, I ran into a problem in the following case:

```cpp
const int var [[clang::annotate("")]];
// ^ insert fix-it here
```

Because I have no way to figure out where the attribute list ends.

Here's the reply from @AaronBallman

> We keep all of the attribute AST nodes with the declaration, and each attribute knows its own source range, but we *don't* keep the source locations for where the full attribute list appears. e.g.,
> ```cpp
> __attribute__((foo)) const int var [[bar, baz]];
> ```
> `var` will have three attributes associated with it, but the only source location information you have access to is for the `foo`, `bar`, and `baz` tokens. Each of those attributes also keeps track of what syntax was used, so you could tell that `foo` was a GNU-style attribute while `bar` and `baz` were C++. But we don't keep enough information about `bar` and `baz` being part of the same attribute list or whether that attribute list is leading or trailing. You have to calculate all of this yourself and some of it might not even be possible to calculate (for example, the user could have done `__attribute__((foo)) const int var [[bar]] [[baz]];` and the AST would come out the same as the previous example).

The original discussion lies in https://reviews.llvm.org/D139705
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVU1v4zYQ_TX0ZRBDpixldfDBjuM2l1667aKnYCSNJDYUKXAoK95fX5CyE9u7RYEChD_4MfPmvcchMqvWEG1EthPZfoGj76zbHFemW3E3mtadFqWtT5tvHRl4Ae8U1eAtqH7Q1JPxoAyT88q0gNCo9wcVprwF3xGQqcE2gCDy5E90e6q0yBMhn-AFHJp5I8LgbKmpB2XiqcZqbacQsUImkW5FshfJ5TNP5lENwzxTWcMxJxzRQSxkV2k0bTiZbtEY69GTkF-ElHEUItu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