[clang-tools-extra] ecd7ff5 - [pseudo] Fix the type-parameter rule.

Haojian Wu via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 7 01:38:07 PDT 2022


Author: Haojian Wu
Date: 2022-06-07T10:36:45+02:00
New Revision: ecd7ff53b53368d84767ceeda6b238ef467b4625

URL: https://github.com/llvm/llvm-project/commit/ecd7ff53b53368d84767ceeda6b238ef467b4625
DIFF: https://github.com/llvm/llvm-project/commit/ecd7ff53b53368d84767ceeda6b238ef467b4625.diff

LOG: [pseudo] Fix the type-parameter rule.

The IDENTIFIER should be optional.

Differential Revision: https://reviews.llvm.org/D126998

Added: 
    clang-tools-extra/pseudo/test/cxx/template-empty-type-parameter.cpp

Modified: 
    clang-tools-extra/pseudo/lib/cxx.bnf

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/pseudo/lib/cxx.bnf b/clang-tools-extra/pseudo/lib/cxx.bnf
index f0d666d5b54e..707844d88239 100644
--- a/clang-tools-extra/pseudo/lib/cxx.bnf
+++ b/clang-tools-extra/pseudo/lib/cxx.bnf
@@ -645,7 +645,7 @@ constraint-logical-and-expression := primary-expression
 constraint-logical-and-expression := constraint-logical-and-expression && primary-expression
 template-parameter := type-parameter
 template-parameter := parameter-declaration
-type-parameter := type-parameter-key ..._opt IDENTIFIER
+type-parameter := type-parameter-key ..._opt IDENTIFIER_opt
 type-parameter := type-parameter-key IDENTIFIER_opt = type-id
 type-parameter := type-constraint ..._opt IDENTIFIER_opt
 type-parameter := type-constraint IDENTIFIER_opt = type-id

diff  --git a/clang-tools-extra/pseudo/test/cxx/template-empty-type-parameter.cpp b/clang-tools-extra/pseudo/test/cxx/template-empty-type-parameter.cpp
new file mode 100644
index 000000000000..e8f48c64d79f
--- /dev/null
+++ b/clang-tools-extra/pseudo/test/cxx/template-empty-type-parameter.cpp
@@ -0,0 +1,3 @@
+// RUN: clang-pseudo -grammar=%cxx-bnf-file -source=%s --print-forest | FileCheck %s
+template <typename> struct MatchParents;
+// CHECK: template-parameter-list~TYPENAME := tok[2]


        


More information about the cfe-commits mailing list