kadircet 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;
----------------
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?


================
Comment at: clang-tools-extra/clangd/XRefs.cpp:278
     Result.back().PreferredDeclaration = *Loc;
-    // Preferred is always a definition if possible, so this check works.
-    if (Def == Preferred)
-      Result.back().Definition = *Loc;
+    if (Def)
+      Result.back().Definition = makeLocation(
----------------
maybe inline `getDefinition` to here


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73369



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to