Issue 100921
Summary Build a RecoveryExpr for a call _expression_ with a trailing command in the argument list
Labels clang:frontend
Assignees
Reporter HighCommander4
    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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to