[PATCH] D126996: [pseudo] Handle the language predefined identifier __func__
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 3 12:52:14 PDT 2022
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added a project: All.
hokein requested review of this revision.
Herald added a subscriber: alextsao1999.
Herald added a project: clang-tools-extra.
The clang lexer lexes it as a dedicated token kind (rather than
identifier), we extend the grammar to handle it.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D126996
Files:
clang-tools-extra/pseudo/lib/cxx.bnf
clang-tools-extra/pseudo/test/cxx/predefined-identifier.cpp
Index: clang-tools-extra/pseudo/test/cxx/predefined-identifier.cpp
===================================================================
--- /dev/null
+++ clang-tools-extra/pseudo/test/cxx/predefined-identifier.cpp
@@ -0,0 +1,5 @@
+// RUN: clang-pseudo -grammar=%cxx-bnf-file -source=%s --print-forest | FileCheck %s
+void s() {
+ __func__;
+ // CHECK: expression~__FUNC__ := tok[5]
+}
Index: clang-tools-extra/pseudo/lib/cxx.bnf
===================================================================
--- clang-tools-extra/pseudo/lib/cxx.bnf
+++ clang-tools-extra/pseudo/lib/cxx.bnf
@@ -750,3 +750,8 @@
#! split it into two tokens to make the GLR parser aware of the nested-template
#! case.
greatergreater := > >
+
+#! C++ predefined identifier, __func__ [dcl.fct.def.general] p8
+#! FIXME: add other (MSVC, GNU extension) predefined identifiers.
+primary-expression := predefined-expression
+predefined-expression := __FUNC__
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126996.434115.patch
Type: text/x-patch
Size: 928 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220603/8378d65a/attachment.bin>
More information about the cfe-commits
mailing list