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

    <tr>
        <th>Summary</th>
        <td>
            Build a RecoveryExpr for a call expression with a trailing command in the argument list
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang:frontend
      </td>
    </tr>

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

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

<pre>
    For the following code:

```c++
void func(int a, int b);

int main() {
  f(1,);
}
```

the AST contains no descendants for the `CompoundStmt` of main:

```
`-FunctionDecl 0x555de3b98098 <line:3:1, line:5:1> line:3:5 main 'int ()'
  `-CompoundStmt 0x555de3b981d0 <col:12, line:5:1>
```

It would be nice if the parser could recover from this and build an AST similar to the one that would be built if the trailing comma was not present:

```c++
void func(int a, int b);

int main() {
  f(1);
}
```

Here the number of arguments is still incorrect, but a `RecoveryExpr` is successfully built:

```
`-FunctionDecl 0x5589d407d098 <line:3:1, line:5:1> line:3:5 main 'int ()'
  `-CompoundStmt 0x5589d407d248 <col:12, line:5:1>
    `-RecoveryExpr 0x5589d407d218 <line:4:3, col:6> '<dependent type>' contains-errors lvalue
      |-UnresolvedLookupExpr 0x5589d407d170 <col:3> '<overloaded function type>' lvalue (ADL) = 'f' empty
 `-IntegerLiteral 0x5589d407d1b0 <col:5> 'int' 1
```

The `RecoveryExpr` is important because it allows e.g. go-to-definition in clangd to work on the function name.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8VV-PmzgQ_zTOyygRGAjwwMNu0qiV9una-wDGHoivxka2STbf_jSQdNlVr6ruoRLaDRjP7w-_GYsQdG8RG1Y8s-K4EVM8O9981v354IZBWIU-37RO3ZqT8xDPCJ0zxl217UE6hSx7YsmRJY-_-2S5JOPPdM1PL04r6CYrGa-0jSAYPwD9aBmvWfa8rkCPB6Et4xXjNbDyvgrQMV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