[PATCH] D133664: [clangd] Fix hover on symbol introduced by using declaration

Kadir Cetinkaya via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 13 06:42:45 PDT 2022


kadircet added inline comments.


================
Comment at: clang-tools-extra/clangd/Hover.cpp:1091
+        // better, which in this example would be the actual declaration of foo.
+        auto *DeclToUse = Decls.begin();
+        while (llvm::isa<BaseUsingDecl>(*DeclToUse) &&
----------------
we actually want to show the using decl in certain cases, e.g:
```
namespace ns {
void foo(int); void foo(char);
}
using ns::foo;
template <typename T> void bar() { fo^o(T{}); }
```

so rather than this, can we have some logic that looks like:
```
- If we have more than two candidates, and there's exactly one `BaseUsingDecl`, prefer that.
- If we have two candidates, prefer the non-`BaseUsingDecl` one.
- Prefer the first. (we hit this case when there's a single candidate or there are `multiple or no` using decls. i think multiple using decls is not possible, but at least we preserve the existing behaviour in such cases).  
```

can you also export this logic to a helper function, probably called `pickDeclToUse`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133664



More information about the cfe-commits mailing list