[PATCH] D136594: [clangd] Add support for semantic token type "operator"

Nathan Ridge via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 25 01:19:48 PST 2022


nridge added a comment.

In D136594#3940482 <https://reviews.llvm.org/D136594#3940482>, @sammccall wrote:

> An (IMO) useful distinction that can't be found by the lexer is the use of `*` as a declarator (`int *x`) vs an operator (`return *x`).

I failed to appreciate the implication of this the first time I read it: this is in fact a **semantic** distinction. Given `A * B`, the `*` could be a declarator or an operator depending on whether `A` resolves to a type name or a variable name; at the lexer level, it's just `tok::star` in both cases.

The current patch will produce an operator token in the operator case but not the declarator case, thereby achieving an effect that client-side highlighting couldn't. As such, I guess it **does** make sense for this to be a semantic token (i.e. produced even with with `augmentsSyntaxTokens=true`) even in the built-in case?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136594



More information about the cfe-commits mailing list