summaryrefslogtreecommitdiff
path: root/clang-tools-extra/pseudo
diff options
context:
space:
mode:
authorHaojian Wu <hokein.wu@gmail.com>2022-08-10 15:41:36 +0200
committerHaojian Wu <hokein.wu@gmail.com>2022-08-12 13:49:01 +0200
commit1828c75d5f4ff657cf977476091fa224c8193e1d (patch)
tree47189c019dc0939a90ce8ae2408d67719e3e5c88 /clang-tools-extra/pseudo
parenta1a1a78ac8cf837e4c05152c9715f399b33bfb59 (diff)
downloadllvm-1828c75d5f4ff657cf977476091fa224c8193e1d.tar.gz
[pseudo] Apply the function-declarator to member functions.
A followup patch of d489b3807f096584175c321ce7f20e9dcd49b1da, but for member functions, this will eliminate a false parse of member declaration. Differential Revision: https://reviews.llvm.org/D131720
Diffstat (limited to 'clang-tools-extra/pseudo')
-rw-r--r--clang-tools-extra/pseudo/lib/cxx/cxx.bnf6
-rw-r--r--clang-tools-extra/pseudo/test/cxx/declator-member-function.cpp9
2 files changed, 12 insertions, 3 deletions
diff --git a/clang-tools-extra/pseudo/lib/cxx/cxx.bnf b/clang-tools-extra/pseudo/lib/cxx/cxx.bnf
index d5cc0a9d2c85..697e79d609aa 100644
--- a/clang-tools-extra/pseudo/lib/cxx/cxx.bnf
+++ b/clang-tools-extra/pseudo/lib/cxx/cxx.bnf
@@ -571,9 +571,9 @@ member-declaration := opaque-enum-declaration
member-declaration := empty-declaration
member-declarator-list := member-declarator
member-declarator-list := member-declarator-list , member-declarator
-member-declarator := declarator virt-specifier-seq_opt pure-specifier_opt
-member-declarator := declarator requires-clause
-member-declarator := declarator brace-or-equal-initializer
+member-declarator := function-declarator virt-specifier-seq_opt pure-specifier_opt
+member-declarator := function-declarator requires-clause
+member-declarator := non-function-declarator brace-or-equal-initializer_opt
member-declarator := IDENTIFIER_opt : constant-expression brace-or-equal-initializer_opt
virt-specifier-seq := virt-specifier
virt-specifier-seq := virt-specifier-seq virt-specifier
diff --git a/clang-tools-extra/pseudo/test/cxx/declator-member-function.cpp b/clang-tools-extra/pseudo/test/cxx/declator-member-function.cpp
new file mode 100644
index 000000000000..58d0ff4ccae9
--- /dev/null
+++ b/clang-tools-extra/pseudo/test/cxx/declator-member-function.cpp
@@ -0,0 +1,9 @@
+// RUN: clang-pseudo -grammar=cxx -source=%s --print-forest | FileCheck %s
+
+// Similiar to declarator-function.cpp, but for member functions.
+class Foo {
+ void foo() {};
+// CHECK-NOT: member-declarator := declarator brace-or-equal-initializer
+// CHECK: member-declaration~function-definition := decl-specifier-seq function-declarator function-body
+// CHECK-NOT: member-declarator := declarator brace-or-equal-initializer
+};