[PATCH] D84975: [clangd][WIP] Make use of SyntaxTrees for SemanticSelection
Dmitri Gribenko via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 30 13:46:19 PDT 2020
gribozavr2 added inline comments.
================
Comment at: clang-tools-extra/clangd/SemanticSelection.cpp:51
+syntax::Leaf *leafContaining(const syntax::Token *Tok, syntax::Tree *Root,
+ syntax::Arena &A, const SourceManager &SM) {
+ if (!Tok)
----------------
It would be nice to make it into a method on syntax::Node itself, or otherwise put it into a shared location, `include/clang/Tooling/Syntax/???.h`.
================
Comment at: clang-tools-extra/clangd/SemanticSelection.cpp:60
+ } else if (auto *T = llvm::dyn_cast<syntax::Tree>(C)) {
+ if (T->firstLeaf()->token() <= Tok && Tok <= T->lastLeaf()->token())
+ return leafContaining(Tok, T, A, SM);
----------------
lastLeaf() is traversing all children. Instead, you could compare against the location of C->nextSibling()->firstLeaf().
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D84975/new/
https://reviews.llvm.org/D84975
More information about the cfe-commits
mailing list