[all-commits] [llvm/llvm-project] 98aa06: [Syntax] Start to move trivial Node class definiti...

Sam McCall via All-commits all-commits at lists.llvm.org
Wed Nov 11 03:41:15 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 98aa067109ed482e428bc16e1321dbe756efc57c
      https://github.com/llvm/llvm-project/commit/98aa067109ed482e428bc16e1321dbe756efc57c
  Author: Sam McCall <sam.mccall at gmail.com>
  Date:   2020-11-11 (Wed, 11 Nov 2020)

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

  Log Message:
  -----------
  [Syntax] Start to move trivial Node class definitions to TableGen. NFC

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

Differential Revision: https://reviews.llvm.org/D90543




More information about the All-commits mailing list