[PATCH] D90543: [Syntax] Start to move trivial Node class definitions to TableGen. NFC

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Oct 31 17:05:20 PDT 2020


sammccall created this revision.
sammccall added reviewers: gribozavr2, hokein.
Herald added subscribers: cfe-commits, mgorny.
Herald added a project: clang.
sammccall requested review of this revision.

This defines two node archetypes with trivial class definitions:

- Alternatives: the generated abstract classes are trivial as all functionality is via LLVM RTTI
- Unconstrained: this is a placeholder, I think all of these are going to be Lists but today they have no special accessors etc, so we just say "could contain anything", and migrate them one-by-one to Sequence later.

Compared to Dmitri's prototype, Nodes.td looks more like a class hierarchy and
less like a grammar. (E.g. variants list the Alternatives parent rather than
vice versa).
The main reasons for this:

- the hierarchy is an important part of the API we want direct control over.
  - e.g. we may introduce abstract bases like "loop" that the grammar doesn't care about in order to model is-a concepts that might make refactorings more expressive. This is less natural in a grammar-like idiom.
  - e.g. we're likely to have to model some alternatives as variants and others as class hierarchies, the choice will probably be based on natural is-a relationships.
- it reduces the cognitive load of switching from editing *.td to working with code that uses the generated classes


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90543

Files:
  clang/include/clang/Tooling/Syntax/CMakeLists.txt
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/include/clang/Tooling/Syntax/Nodes.td
  clang/include/clang/Tooling/Syntax/Syntax.td
  clang/utils/TableGen/ClangSyntaxEmitter.cpp
  clang/utils/TableGen/TableGen.cpp
  clang/utils/TableGen/TableGenBackends.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90543.302116.patch
Type: text/x-patch
Size: 14898 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201101/9193de7e/attachment-0001.bin>


More information about the cfe-commits mailing list