-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[Clang] enhance error recovery with RecoveryExpr for trailing commas in call arguments #114684
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…in call arguments
@llvm/pr-subscribers-clang Author: Oleksandr T. (a-tarasyuk) ChangesFixes #100921 Full diff: https://github.com/llvm/llvm-project/pull/114684.diff 2 Files Affected:
diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index 4570a18bc0d5e5..5fccd2ae106015 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -3705,6 +3705,9 @@ bool Parser::ParseExpressionList(SmallVectorImpl<Expr *> &Exprs,
Token Comma = Tok;
ConsumeToken();
checkPotentialAngleBracketDelimiter(Comma);
+
+ if (Tok.is(tok::r_paren))
+ break;
}
if (SawError) {
// Ensure typos get diagnosed when errors were encountered while parsing the
diff --git a/clang/test/AST/ast-dump-recovery.cpp b/clang/test/AST/ast-dump-recovery.cpp
index a88dff471d9f04..1876f4ace32a5a 100644
--- a/clang/test/AST/ast-dump-recovery.cpp
+++ b/clang/test/AST/ast-dump-recovery.cpp
@@ -9,7 +9,7 @@ int some_func(int *);
// CHECK-NEXT: `-IntegerLiteral {{.*}} 123
// DISABLED-NOT: -RecoveryExpr {{.*}} contains-errors
int invalid_call = some_func(123);
-void test_invalid_call(int s) {
+void test_invalid_call_1(int s) {
// CHECK: CallExpr {{.*}} '<dependent type>' contains-errors
// CHECK-NEXT: |-UnresolvedLookupExpr {{.*}} 'some_func'
// CHECK-NEXT: |-RecoveryExpr {{.*}} <col:13>
@@ -32,6 +32,21 @@ void test_invalid_call(int s) {
int var = some_func(undef1);
}
+int some_func2(int a, int b);
+void test_invalid_call_2() {
+ // CHECK: `-RecoveryExpr {{.*}} 'int' contains-errors
+ // CHECK-NEXT: |-UnresolvedLookupExpr {{.*}} '<overloaded function type>' lvalue (ADL) = 'some_func2'
+ // CHECK-NEXT: `-IntegerLiteral {{.*}} 'int' 1
+ some_func2(1, );
+}
+
+void test_invalid_call_3() {
+ // CHECK: `-RecoveryExpr {{.*}} 'int' contains-errors
+ // CHECK-NEXT: |-UnresolvedLookupExpr {{.*}} '<overloaded function type>' lvalue (ADL) = 'some_func2'
+ // CHECK-NEXT: `-IntegerLiteral {{.*}} 'int' 1
+ some_func2(1);
+}
+
int ambig_func(double);
int ambig_func(float);
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this is nice.
Can you also add a release note?
…oper processing of prior erroneous expressions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, looks good.
This PR is linked to the following regression: #125225 |
@shafik thanks for pointing that out! I'll check it ASAP |
I have a fix for it #125232 |
…. (#125232) This patch fixes a regression caused by llvm/llvm-project#114684 where clang accepts trailing commas for function calls. Fixes #125225
) This patch fixes a regression caused by llvm#114684 where clang accepts trailing commas for function calls. Fixes llvm#125225
) This patch fixes a regression caused by llvm#114684 where clang accepts trailing commas for function calls. Fixes llvm#125225 (cherry picked from commit 922f339)
…. (#125232) This patch fixes a regression caused by llvm/llvm-project#114684 where clang accepts trailing commas for function calls. Fixes #125225 (cherry picked from commit 922f339)
) This patch fixes a regression caused by llvm#114684 where clang accepts trailing commas for function calls. Fixes llvm#125225
Fixes #100921