This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Expose more dependent-name detail via semanticTokens
ClosedPublic

Authored by sammccall on Jan 29 2021, 4:22 PM.

Details

Summary

This change makes dependentName a modifier, rather than a token type.
It can be combined with:

  • type (new, standard) - this combination replaces dependentType like T::typename Foo
  • unknown (new, nonstandard) - for general dependent names
  • Field, etc - when the name is dependent but we heuristically resolve it

While here, fix cases where template-template-parameter cases were
incorrectly flagged as type-dependent.
And the merging of modifiers when resolving conflicts accidentally
happens to work around a bug that showed up in a test.

The behavior observed through the pre-standard protocol should be mostly
unchanged (it'll see the bugfixes only). This is done in a somehat
fragile way but it's not expected to live long.

Diff Detail

Event Timeline

sammccall created this revision.Jan 29 2021, 4:22 PM
sammccall requested review of this revision.Jan 29 2021, 4:22 PM
nridge accepted this revision.Feb 2 2021, 11:01 PM

Looks great, thanks again for doing this!

clang-tools-extra/clangd/SemanticHighlighting.cpp
254

I like that this ends up with a concrete kind + dependent modifier, to give a hint that the concrete kind was determined heuristically :)

Maybe we could adjust the comment at the top of the function to call this behaviour out.

clang-tools-extra/clangd/SemanticHighlighting.h
78

Just Dependent might be enough

This revision is now accepted and ready to land.Feb 2 2021, 11:01 PM
sammccall marked an inline comment as done.Feb 9 2021, 9:24 AM
sammccall added inline comments.
clang-tools-extra/clangd/SemanticHighlighting.cpp
254

Right! I like this too but forgot do doc it. Done.

clang-tools-extra/clangd/SemanticHighlighting.h
78

AFAICS the current implementation is closer to "dependent name" than "dependent", I think.

For example, in the RHS of template <typename T> using Val = T::value_type, both "T" and "value_type" certainly refer to dependent types. But only value_type is a dependent name, and only value_type gets the old kinds/new modifier.


Or are you proposing we change the implementation too?

It's not intuitively which version would be more useful. FWIW I have the current DependentName kind highlighted in bold bright orange, and I find it really helpful :-) When there are errors and RecoveryExpr kicks in, it colors the resulting unresolved names, which I like surprisingly much.

nridge added inline comments.Feb 9 2021, 11:30 AM
clang-tools-extra/clangd/SemanticHighlighting.h
78

I like the current impl as well, was not proposing a change to it. I was just quibbling about the name. Please feel free to ignore, it makes sense to be consistent with clang's terminology.

This revision was landed with ongoing or failed builds.Feb 9 2021, 11:41 AM
This revision was automatically updated to reflect the committed changes.
sammccall marked an inline comment as done.