[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 May 26 11:20:29 PDT 2022


upsj added a comment.

I've hit a roadblock I'm not sure how to proceed with. It seems that in some cases, a `ParmVarDecl` of an instantiated function template indeed doesn't preserve the `SubstTemplateTypeParmType` type sugar allowing me to check which template parameter it was instantiated from. This might be related to reference collapsing on type deduction, since `Args...` preserves the sugar, but `Args&&...` doesn't. Without this ability to distinguish between expanded packs and normal parameters, I risk recursing into other functions and pulling up unrelated type names. Any ideas how to proceed here? Essentially, it's the same issue that @nridge already provided a partial solution for by not using `getNonReferenceType()`, but more complex. I would really like to avoid having to reconstruct parameter indices from arbitrarily many levels of template parameters packs from surrounding scopes.

Example where this pops up:

  cpp
      namespace std { template <typename T> T&& forward(T&); }
      struct S { S(int a); };
      template <typename T, typename... Args>
      T bar(Args&&... args) { return T{std::forward<Args>($fwd[[args]])...}; }
      void baz() {
        int b;
        bar<S>($param[[b]]);
      }


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