[clang] [Clang][NFCI] Slightly refactor getTemplateInstantiationArgs() (PR #102922)

Younan Zhang via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 13 18:56:13 PDT 2024


zyn0217 wrote:

> I think I'd need to see how you would use it, to say if this would be the best approach.

(I thought I have explained somewhere, but it seems not. Sorry!)

So the basic idea of CWG2369 is to swap the order of the function template substitution and its constraint checking. We previously relied on the substituted function to collect the entire template argument lists for the constraint evaluation to work, while this is no longer the case because we're now required to check the constraint before the function declaration substitution.

The situation is then slightly subtle since we don't have a complete function specialization to collect the complete arguments in one go. So it would end up with two pieces: one is the instantiating template arguments that we have (`CanonicalBuilder` / `SugaredBuilder`) for the current function template; the other part consisted of the template arguments of the parent `DeclContext`s. My idea is to splice these template arguments together through the parameter `Innermost` of the `getTemplateInstantiationArgs()`, and in that case we have to switch the next DC to its lexical declaration context, similar to what we're going to visit after a `FunctionTemplateDecl` in `HandleFunctionTemplateDecl()`.

https://github.com/llvm/llvm-project/pull/102922


More information about the cfe-commits mailing list