Page MenuHomePhabricator

[Syntax] Add minimal TableGen for syntax nodes. NFC
ClosedPublic

Authored by sammccall on Oct 31 2020, 1:10 PM.

Details

Summary

So far, only used to generate Kind and implement classof().

My plan is to have this general-purpose Nodes.inc in the style of AST
DeclNodes.inc etc, and additionally a special-purpose backend generating
the actual class definitions. But baby steps...

Diff Detail

Event Timeline

sammccall created this revision.Oct 31 2020, 1:10 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 31 2020, 1:10 PM
sammccall requested review of this revision.Oct 31 2020, 1:10 PM
sammccall added inline comments.Oct 31 2020, 1:15 PM
clang/lib/Tooling/Syntax/Tree.cpp
434

OK, this is not *quite* NFC:

  • before this patch, List::classof(DeclaratorList*) incorrectly returned false ,now it's true...
  • ...which uncovered these unhandled cases

I'll split these changes into another patch and land that first.

sammccall edited reviewers, added: gribozavr2; removed: gribozavr.Nov 3 2020, 4:43 AM
gribozavr2 accepted this revision.Nov 4 2020, 2:23 AM
gribozavr2 added inline comments.
clang/include/clang/Tooling/Syntax/Syntax.td
10
21

I'd suggest to add this point later if we decide to do it.

42

List is already defined in Nodes.td FWIW.

clang/utils/TableGen/ClangSyntaxEmitter.cpp
20

I personally usually avoid writing about plans in comments, but up to you.

This revision is now accepted and ready to land.Nov 4 2020, 2:23 AM
gribozavr2 added inline comments.Nov 4 2020, 2:30 AM
clang/include/clang/Tooling/Syntax/Syntax.td
32

"Records derived from NodeType correspond to syntax tree node types."

eduucaldas accepted this revision.Nov 4 2020, 2:55 AM
hokein accepted this revision.Nov 4 2020, 12:08 PM
hokein added inline comments.
clang/utils/TableGen/ClangSyntaxEmitter.cpp
108

By looking at the existing tablegen patterns, I think we should invoke emitSourceFileHeader to emit the head file comments for the generated .inc file.

This revision was landed with ongoing or failed builds.Nov 9 2020, 2:46 PM
This revision was automatically updated to reflect the committed changes.
sammccall marked 4 inline comments as done.