Author: Haojian Wu Date: 2022-07-18T10:23:15+02:00 New Revision: b94ea8b3ebc16504b668fd7086de544637e0cd53
URL: https://github.com/llvm/llvm-project/commit/b94ea8b3ebc16504b668fd7086de544637e0cd53 DIFF: https://github.com/llvm/llvm-project/commit/b94ea8b3ebc16504b668fd7086de544637e0cd53.diff LOG: [pseudo] Add bracket recovery for function parameters. Added: clang-tools-extra/pseudo/test/cxx/recovery-func-parameters.cpp Modified: clang-tools-extra/pseudo/lib/cxx/cxx.bnf clang-tools-extra/pseudo/test/cxx/parameter-decl-clause.cpp Removed: ################################################################################ diff --git a/clang-tools-extra/pseudo/lib/cxx/cxx.bnf b/clang-tools-extra/pseudo/lib/cxx/cxx.bnf index 204b816632649..b80dfd928f2b4 100644 --- a/clang-tools-extra/pseudo/lib/cxx/cxx.bnf +++ b/clang-tools-extra/pseudo/lib/cxx/cxx.bnf @@ -412,7 +412,7 @@ noptr-declarator := declarator-id noptr-declarator := noptr-declarator parameters-and-qualifiers noptr-declarator := noptr-declarator [ constant-expression_opt ] noptr-declarator := ( ptr-declarator ) -parameters-and-qualifiers := ( parameter-declaration-clause_opt ) cv-qualifier-seq_opt ref-qualifier_opt noexcept-specifier_opt +parameters-and-qualifiers := ( parameter-declaration-clause_opt [recover=Brackets] ) cv-qualifier-seq_opt ref-qualifier_opt noexcept-specifier_opt trailing-return-type := -> type-id ptr-operator := * cv-qualifier-seq_opt ptr-operator := & diff --git a/clang-tools-extra/pseudo/test/cxx/parameter-decl-clause.cpp b/clang-tools-extra/pseudo/test/cxx/parameter-decl-clause.cpp index 18584ded9b5b4..1426f4e0a9bc0 100644 --- a/clang-tools-extra/pseudo/test/cxx/parameter-decl-clause.cpp +++ b/clang-tools-extra/pseudo/test/cxx/parameter-decl-clause.cpp @@ -4,7 +4,7 @@ void foo2(int, ...); // CHECK-NEXT: ├─decl-specifier-seq~VOID := // CHECK-NEXT: ├─init-declarator-list~noptr-declarator := noptr-declarator parameters-and-qualifiers // CHECK-NEXT: │ ├─noptr-declarator~IDENTIFIER := -// CHECK-NEXT: │ └─parameters-and-qualifiers := ( parameter-declaration-clause ) +// CHECK-NEXT: │ └─parameters-and-qualifiers := ( parameter-declaration-clause [recover=Brackets] ) // CHECK-NEXT: │ ├─( := // CHECK-NEXT: │ ├─parameter-declaration-clause := parameter-declaration-list , ... // CHECK-NEXT: │ │ ├─parameter-declaration-list~INT := diff --git a/clang-tools-extra/pseudo/test/cxx/recovery-func-parameters.cpp b/clang-tools-extra/pseudo/test/cxx/recovery-func-parameters.cpp new file mode 100644 index 0000000000000..d3007c3fb4bc6 --- /dev/null +++ b/clang-tools-extra/pseudo/test/cxx/recovery-func-parameters.cpp @@ -0,0 +1,13 @@ +// RUN: clang-pseudo -grammar=cxx -source=%s --print-forest | FileCheck %s +void foo(complete garbage???) {} +// CHECK: translation-unit~function-definition := decl-specifier-seq declarator function-body +// CHECK-NEXT: ├─decl-specifier-seq~VOID := tok[0] +// CHECK-NEXT: ├─declarator~noptr-declarator := noptr-declarator parameters-and-qualifiers +// CHECK-NEXT: │ ├─noptr-declarator~IDENTIFIER := tok[1] +// CHECK-NEXT: │ └─parameters-and-qualifiers := ( parameter-declaration-clause [recover=Brackets] ) +// CHECK-NEXT: │ ├─( := tok[2] +// CHECK-NEXT: │ ├─parameter-declaration-clause := <opaque> +// CHECK-NEXT: │ └─) := tok[8] +// CHECK-NEXT: └─function-body~compound-statement := { } +// CHECK-NEXT: ├─{ := tok[9] +// CHECK-NEXT: └─} := tok[10] _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits