nridge added inline comments.

================
Comment at: clang-tools-extra/clangd/XRefs.cpp:1150
+      if (llvm::isa<UsingDecl>(D) || llvm::isa<UnresolvedUsingValueDecl>(D)) {
+        Decls = getDeclAtPosition(AST, *CurLoc,
+                                  Relations | DeclRelation::Underlying);
----------------
hokein wrote:
> I think it should not happen in practice (Decls just have 1 element in most 
> cases), but the code feels hacky, we are throwing other decls if one of the 
> `Decls` is a using decl.
> 
> I suppose if we're using the same workaround as `locateASTReferent`, then we 
> should follow that way by only adjusting the UsingDecl/UnresolvedValueDecl 
> results and keeping others.
> 
> 
> In general, I think we probably need to remove this workaround (see the  
> `FIXME` in `locateASTReferent`) by refining TargetDecl API. The current 
> `DeclRelation::Underlying` enum is not enough to support our use case where 
> we only want underlying decls for *non-renaming* alias. One rough idea to fix 
> it is to split the `Underlying` to two `RenameAliasUnderlying` and 
> `RemainingUnderlying` -- this would need some API design work, so no need to 
> do it in this patch.
> 
> 
> 
I don't think we're actually throwing out the other results: by calling 
`getDeclAtPosition()` with `Relations | Underlying`, where `Relations` is the 
original flags, the call should find the other results again. If we only 
replaced the UsingDecl/UnresolvedValueDecl results, I think the other results 
would appear in duplicate.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87225

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

Reply via email to