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__
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__
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits