[PATCH] D83508: [clangd][Hover] Don't use Decl if it is not related with tokens under cursor.

Kadir Cetinkaya via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 10 02:13:38 PDT 2020


kadircet added a comment.

thanks for doing this! but i believe these look like bugs that should be addressed in other components, rather than worked around in hover.

the first example is likely a bug in selection tree, file location corresponds to a macro body that's never expanded, which resides inside a namespace (who's declaration contains everything within it's braces), hence selection tree attributes the selection to the namespace because there's no fine-grained children around the cursor.

the second one is likely a bug in ast-traversal logic, i suppose the function doesn't get a `TypeSourceInfo` when it is `invalid`, hence we don't get to traverse its parameters(children) and therefore assume all the declaration belongs to function itself.

---

As for your workaround in hover, it is surprising that no other tests has regressed, but in theory `D->getLocation` only corresponds to the main token in a declaration (e.g. name of a function), and hover can refer to declarations whose names are away from the cursor, e.g. if you are on (closing) parens of a function/ctor call.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83508





More information about the cfe-commits mailing list