[PATCH] D127403: [clangd] Implement semantic token modifier "definition"

Christian Kandeler via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 12 02:14:02 PDT 2022


ckandeler added inline comments.


================
Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:863
+              Tok.addModifier(HighlightingModifier::Declaration);
+            if (const auto Func = dyn_cast<FunctionDecl>(Decl)) {
+              if (Func->isThisDeclarationADefinition())
----------------
dgoldman wrote:
> Instead of doing it like this, I wonder if would make more sense to call getDefinition from https://cs.github.com/llvm/llvm-project/blob/ae071a59bc6cc09e0e0043e0ef1d9725853f1681/clang-tools-extra/clangd/XRefs.cpp#L76 and if it matches Decl, add the Definition modifier?
Won't that incur an additional look-up or some other type of work? I'm not deeply familiar with the implementation, but a cursory glance seems to suggests that isThisDeclarationADefinition() is just an accessor, while getDefinition() "does things".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127403



More information about the cfe-commits mailing list