This is an archive of the discontinued LLVM Phabricator instance.

[clangd][c++20]Add missing semantic highlighing for concepts.
ClosedPublic

Authored by massberg on Jul 6 2023, 1:51 AM.

Diff Detail

Event Timeline

massberg created this revision.Jul 6 2023, 1:51 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 6 2023, 1:51 AM
massberg requested review of this revision.Jul 6 2023, 1:51 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 6 2023, 1:51 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
massberg retitled this revision from Add missing semantic highlighing for concepts. to [clangd][c++20]Add missing semantic highlighing for concepts..Jul 6 2023, 1:52 AM
sammccall added inline comments.Jul 6 2023, 2:12 AM
clang-tools-extra/clangd/SemanticHighlighting.cpp
966

if we add this logic it definitely needs a comment explaining that we're looking for the auto token (because we're not doing so directly) and why

969

getLocWithOffset(1) is just jumping one byte in the source code
why is this correct?

IIUC the intention here is to jump to the auto token, and the AutoTypeLoc doesn't actually expose this

I'd suggest:

  • for now just bailing out - this is not important enough to hack around (and the current hack doesn't seem robust)
  • if you have the appetite, adding this location to AutoTypeLoc seems like a good thing
massberg updated this revision to Diff 537642.Jul 6 2023, 2:46 AM

Set correct token for deduced auto types.

massberg updated this revision to Diff 537643.Jul 6 2023, 2:49 AM

Directly get correct source loc in case of deduced auto types.

massberg marked 2 inline comments as done.Jul 6 2023, 2:52 AM
massberg added inline comments.
clang-tools-extra/clangd/SemanticHighlighting.cpp
969

It seems that we can directly get the correct location, see above.
The test had been wrong before as the auto in auto in Fooable auto f = .. should have a class deduced token as it would have without the concept.
This is now fixed.

sammccall accepted this revision.Jul 6 2023, 5:56 AM

Nice! I forgot about the TypeLoc hierarchy, getNameLoc() isn't so obvious...

This revision is now accepted and ready to land.Jul 6 2023, 5:56 AM
This revision was automatically updated to reflect the committed changes.
massberg marked an inline comment as done.
nridge added a subscriber: nridge.Jul 6 2023, 6:19 PM