[PATCH] D129359: [pseudo] Generate an enum type for identifying grammar rules.

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 15 07:07:50 PDT 2022


sammccall added inline comments.


================
Comment at: clang-tools-extra/pseudo/lib/grammar/Grammar.cpp:48
 
+std::string Grammar::mangleSymbol(SymbolID SID) const {
+  static const char *const TokNames[] = {
----------------
hokein wrote:
> sammccall wrote:
> > I'm not sure exposing these from `Grammar` is an improvement, i think even in principle we'd only want to use these for codegen.
> > 
> > The need for testing is real, but i guess you can add a test that uses the CXX generated grammar, assert the elements of Rule::whatever, and the name of Symbol::whatever?
> Yeah, these functions are only used in the codegen. I'm inlined to the put it into the `Grammar`(it also has a `symbolName` definition, I'd prefer to have all naming functions in a single place). 
That's exactly my point though: that symbolname is general purpose and should be used everywhere, which is why it belongs on grammar.

Vs the mangled name that literally nobody should be using for anything.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129359/new/

https://reviews.llvm.org/D129359



More information about the cfe-commits mailing list