[PATCH] D130260: [clangd] Make forwarding parameter detection logic resilient
Kadir Cetinkaya via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 22 03:03:20 PDT 2022
kadircet added inline comments.
================
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;
----------------
upsj wrote:
> 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.
yeah that makes sense, added an extra check.
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