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

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 10 03:43:59 PDT 2020


sammccall added a comment.

Yeah SelectionTree is the right place to solve this but it's a harder problem there.

In general we *don't* only want to trigger on the single token returned by getLocation().
The strategy SelectionTree uses is to attribute tokens to an outer node unless they're associated with an inner node or ignored.

Your test cases show two problems with this strategy:

- we ignore comments and semicolons, but not preprocessor directives (or disabled preprocessor regions). I think we can fix this by asking TokenBuffer if a spelled token is part of a region that maps to no (PP-)expanded tokens.
- in the case of syntax errors, tokens are emitted by the preprocessor but then no AST node is built from them, and we associate them with the parent by default. Maybe we don't need to fix this case?


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