[PATCH] D73369: [clangd] Simplify "preferred" vs "definition" logic a bit in XRefs AST code.
Sam McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 25 15:44:09 PDT 2020
sammccall added inline comments.
================
Comment at: clang-tools-extra/clangd/XRefs.cpp:257
const NamedDecl *Def = getDefinition(D);
- const NamedDecl *Preferred = Def ? Def : D;
+ if (const NamedDecl *C = llvm::dyn_cast<NamedDecl>(D->getCanonicalDecl()))
+ D = C;
----------------
kadircet wrote:
> Is it possible for this check to ever fail? I think it is safe to just perform a `llvm::cast` instead of `dyn_cast`.
> also why not perform this before getting definition?
Done. (I thought there was such a case, but I was thinking about D vs OrigD in IndexDataConusmer, and this happens in one of the rare cases where D isn't the canonical decl of OrigD)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D73369/new/
https://reviews.llvm.org/D73369
More information about the cfe-commits
mailing list