This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Get rid of getBeginningOfIdentifier helper
ClosedPublic

Authored by kadircet on Feb 26 2020, 6:50 AM.

Diff Detail

Event Timeline

kadircet created this revision.Feb 26 2020, 6:50 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 26 2020, 6:50 AM

Hooray!

clang-tools-extra/clangd/Hover.cpp
538

first -> last I think, better explained as rightmost. See SelectionTree::create().

538

actually, if this is really only used for macros and auto, you could pull out those specific cases (define AutoLoc and IdentifierLoc and initialize them by looping over the touching tokens). Seems a bit simpler/more direct/less risk of reuse for other things?

541

This deserves a comment, it's a different strategy than SelectionTree that should yield the same result.

("In general we prefer the touching token that works over the one that doesn't, see SelectionTree::create(). This location is used only for triggering on macros and auto, so simply choosing the lone identifier-or-keyword token is equivalent")

541

you also need to check for keyword (or specifically kw auto)

kadircet updated this revision to Diff 246729.Feb 26 2020, 7:47 AM
kadircet marked 4 inline comments as done.
  • Only use special locations for deducedtype and macros.
sammccall accepted this revision.Feb 26 2020, 11:14 AM

Did you want to delete the lexer check in getDeducedType or is that another patch?

clang-tools-extra/clangd/Hover.cpp
533

again, I'd stick with "touching" to match syntax::tokens

542

nit: we don't tend to use SLoc to refer to SourceLocations outside SourceManager, or ID to refer to identifiers.
IdentLoc, AutoLoc?

This revision is now accepted and ready to land.Feb 26 2020, 11:14 AM
This revision was automatically updated to reflect the committed changes.
kadircet marked 2 inline comments as done.