[PATCH] D128411: [syntax] Introduce a BaseToken class.

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 23 06:44:36 PDT 2022


sammccall added a comment.

As discussed offline this has some problems:

- putting virtual methods on BaseToken gives it a vtable, which makes it (and syntax::Token) large
- being able to use ArrayRef<syntax::Token> but not ArrayRef<BaseToken> is a bit weird
- unusual uses of inheritance can be hard to reason about

We suggested rather having Leaf store an opaque ID.
Callers who know what kind of tokens are in use can use this to associate with the original token.
For generic use (e.g dump()), we can have a TokenManager interface which provides the common operations (like getText()). This generalizes where SourceManager is needed today.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128411



More information about the cfe-commits mailing list