This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Fix early selection for non-vardecl declarators
ClosedPublic

Authored by kadircet on Feb 25 2020, 1:02 AM.

Details

Summary

Selection tree was performing an early claim only for VarDecls, but
there are other cases where we can have declarators, e.g. FieldDecls. This patch
extends the early claim logic to all types of declarators.

Fixes https://github.com/clangd/clangd/issues/292

Diff Detail

Event Timeline

kadircet created this revision.Feb 25 2020, 1:02 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 25 2020, 1:02 AM
sammccall added inline comments.Feb 25 2020, 1:45 AM
clang-tools-extra/clangd/Selection.cpp
613

I think we can combine these two cases.
The weird cases handled by FunctionDecl are actually a bit wrong at the moment (early claiming types).

  • conversion operator: we should probably be claiming operator only, which hapepns to be getLocation()
  • destructor: we should be claiming ~ only, which is also getLocation()
  • constructor: we shouldn't be claiming anything, need to blacklist
  • all the others seem fine to be handled by the DeclaratorDecl case

This changes more behaviour (and the changes are likely to be seen as regressions in some cases, though more consistent) so we could also consider just landing this as-is.

clang-tools-extra/clangd/unittests/SelectionTests.cpp
374

I'd suggest using digraphs instead, if it works:

int hash<:32:>

kadircet updated this revision to Diff 246405.Feb 25 2020, 3:08 AM
kadircet marked 2 inline comments as done.
  • Address comments
sammccall added inline comments.Feb 25 2020, 3:46 AM
clang-tools-extra/clangd/Selection.cpp
612

we may have to blacklist deduction guides too?

clang-tools-extra/clangd/unittests/SelectionTests.cpp
372

can you add the other special cases we discussed offline? conversion operations should be triggered by operator, destructors by ~.

kadircet updated this revision to Diff 246635.Feb 25 2020, 11:43 PM
kadircet marked 2 inline comments as done.
  • Address comments
sammccall accepted this revision.Mar 4 2020, 1:23 AM
sammccall added inline comments.
clang-tools-extra/clangd/Selection.cpp
609

can you check this at HEAD?
IIRC this was related to the reason kythe was failing to report constructors as references to the class, which is now fixed. But I don't know if they fixed the AST or worked around it.

clang-tools-extra/clangd/unittests/HoverTests.cpp
342 ↗(On Diff #246635)

want to keep the conversion operator test too? (by pointing at operator)

This revision is now accepted and ready to land.Mar 4 2020, 1:23 AM
kadircet updated this revision to Diff 248123.Mar 4 2020, 1:41 AM
kadircet marked 2 inline comments as done.
  • Add the old test for hover over operator back.
clang-tools-extra/clangd/Selection.cpp
609

nope, seems like still broken.

This revision was automatically updated to reflect the committed changes.