[PATCH] D124690: [clangd] add inlay hints for std::forward-ed parameter packs
Tobias Ribizel via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 16 05:09:32 PDT 2022
upsj added inline comments.
================
Comment at: clang-tools-extra/clangd/AST.cpp:682
+ if (const auto *TTPD =
+ dyn_cast<TemplateTypeParmDecl>(TemplateParams.back())) {
+ const auto *TTPT =
----------------
nridge wrote:
> upsj wrote:
> > nridge wrote:
> > > I don't think there is any requirement that a pack be a trailing **template** parameter. For example, the following is valid:
> > >
> > > ```
> > > template <typename... B, typename A>
> > > void foo(A, B...);
> > >
> > > void bar() {
> > > foo(1, 2, 3);
> > > }
> > > ```
> > Do you have a suggestion for how to find this pack in general? I would like to keep this function as efficient as possible, since it's used everywhere
> > Do you have a suggestion for how to find this pack in general?
>
> Just iterate backwards through `TemplateParams` rather than only considering `TemplateParams.back()`, I suppose.
>
> > I would like to keep this function as efficient as possible, since it's used everywhere
>
> The `ParmVarDecl*` overload of `getPackTemplateParameter()` is called a lot via the `IsExpandedPack` lambdas, but this overload is only called once per depth level.
Ah thanks, of course! I got tricked by my own overloads.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D124690/new/
https://reviews.llvm.org/D124690
More information about the cfe-commits
mailing list