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

    <tr>
        <th>Summary</th>
        <td>
            `-ast-dump=json` doesn't provide the contents of `clang::annotate`
        </td>
    </tr>

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

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

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

<pre>
    Consider this simple example:
```cpp
struct Class {
    [[clang::annotate("meow")]] int member;
};
```
If I do the normal `ast-dump`, you can see the type `Class`, with the member `int`, with the attached annotation `meow`:
```
$ clang -Xclang -ast-dump -fsyntax-only -c foo.cxx
TranslationUnitDecl 0x97518d8 <<invalid sloc>> <invalid sloc>
|-TypedefDecl 0x9752140 <<invalid sloc>> <invalid sloc> implicit __int128_t '__int128'
| `-BuiltinType 0x9751ea0 '__int128'
|-TypedefDecl 0x97521b0 <<invalid sloc>> <invalid sloc> implicit __uint128_t 'unsigned __int128'
| `-BuiltinType 0x9751ec0 'unsigned __int128'
|-TypedefDecl 0x9752528 <<invalid sloc>> <invalid sloc> implicit __NSConstantString '__NSConstantString_tag'
| `-RecordType 0x97522a0 '__NSConstantString_tag'
|   `-CXXRecord 0x9752208 '__NSConstantString_tag'
|-TypedefDecl 0x97525c0 <<invalid sloc>> <invalid sloc> implicit __builtin_ms_va_list 'char *'
| `-PointerType 0x9752580 'char *'
|   `-BuiltinType 0x9751980 'char'
|-TypedefDecl 0x9797948 <<invalid sloc>> <invalid sloc> implicit __builtin_va_list '__va_list_tag[1]'
| `-ConstantArrayType 0x97978f0 '__va_list_tag[1]' 1
|   `-RecordType 0x97526b0 '__va_list_tag'
|     `-CXXRecord 0x9752618 '__va_list_tag'
`-CXXRecordDecl 0x97979a0 <foo.cxx:1:1, line:3:1> line:1:8 struct Class definition
  |-DefinitionData pass_in_registers aggregate standard_layout trivially_copyable pod trivial literal
  | |-DefaultConstructor exists trivial needs_implicit
  | |-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param
  | |-MoveConstructor exists simple trivial needs_implicit
  | |-CopyAssignment simple trivial has_const_param needs_implicit implicit_has_const_param
  | |-MoveAssignment exists simple trivial needs_implicit
  | `-Destructor simple irrelevant trivial needs_implicit
  |-CXXRecordDecl 0x9797ab8 <col:1, col:8> col:8 implicit struct Class
  `-FieldDecl 0x9797c00 <line:2:33, col:37> col:37 member 'int'
    `-AnnotateAttr 0x9797c50 <col:7, col:29> "meow"
```
If I do `-ast-dump=json`, I get a json file that looks like this. It is 298 lines long, so I'll just snip the relevant part: what we get for `member`:
```json
          "name": "member",
 "type": {
            "qualType": "int"
          },
 "inner": [
            {
              "id": "0x9797c60",
 "kind": "AnnotateAttr",
              "range": {
 "begin": {
                  "offset": 21,
 "col": 7,
                  "tokLen": 5
                },
 "end": {
                  "offset": 43,
 "col": 29,
                  "tokLen": 1
                }
 }
            }
          ]
```
`meow` does not appear here. I just get the range of tokens with their contents. This is correct (the attribute is is col 7:29 - that's all of `clang::annotate("meow")`, and walking the tree up I can get that it's on line 2), but it'd be nicer if I additionally got the actual annotate contents: `"meow"`. 
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0V91u27gSfhr6ZmBDpixLuvCFYzdAgHMODrZZoHcCJY1lNjSpJSkn3qdfkPqx4ihJU2CLBpbImW---SE1w4zhlUTckOiORPsZa-xR6U2u8fw3l7NclZfNTknDS9Rgj9yA4adaIOALc78k3JJgT4ItWQft_6Ku2xVjdVNY2AlmDJD4rl0FAPC27grBZOX0wy2TUllmkdCEUHpC9UwoJTQl0Z5Ee-DSwglPOWoSdjAk3l-fe9Pt68MBHqBUYI8IUukTE0DWATN2Xjan2onRHVxUAwWTYBC9oL3U6MQ8207mmduj32xtu20u7e0ms5YVRyyhc4Ir6SS9E-vgbXy6V7oCHwCY_-h-e4YwP5iLtOxlrqS4wLyAg1KL4uWl1X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