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 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits