[PATCH] D130260: [clangd] Make forwarding parameter detection logic resilient
Tobias Ribizel via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 22 02:22:10 PDT 2022
upsj added a comment.
Your approach to handling implicit conversions is much nicer than mine, so I abandoned my revision. There is still one case (that might even occur in the code base I'm working on?) that this change would lead to incorrect hints on. WDYT about keeping the other changes, but using my pack detection logic?
================
Comment at: clang-tools-extra/clangd/AST.cpp:790
+ // Skip functions with less parameters, they can't be the target.
+ if (Callee->parameters().size() < Parameters.size())
+ return;
----------------
This is not a sufficient check, since the other parameters need not be from an expanded pack.
Example:
```
void foo(int a, int b);
int baz(int x, int y);
template <typename... Args>
void bar(Args... args) {
foo(baz(args, 1)...);
}
void foo() {
bar(1, 42);
}
```
Here we shouldn't print a hint at all, but we print `x:` and `y:`
The important distinction is between `Expr(args...)` and `Expr(args)...`, which can be decided in the instantiated case by the check I implemented in https://reviews.llvm.org/D130259 for all cases, except when `args` only consists of a single element.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D130260/new/
https://reviews.llvm.org/D130260
More information about the cfe-commits
mailing list