Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[clang] Do not substitute parameter pack while retaining the pack exp…
…ansion (#108197) (In reference to 5901d82) Consider when `Input[I]` is a `VarDecl` with parameter pack. We would have already expanded the pack before the code change in the loop`for (unsigned I = 0; I != *NumExpansions; ++I) {`. Now in `if (RetainExpansion) {`, without this change, we continue to substitute the pack in the pattern even when we do not have meaningful `ArgumentPackSubstitutionIndex` set. This leads to use of an invalid pack substitution index in `TemplateInstantiator::TransformFunctionParmPackRefExpr` in `TransformedDecl = (*Pack)[getSema().ArgumentPackSubstitutionIndex];` This change sets `ArgumentPackSubstitutionIndex` to `-1` while retaining expansion to instruct `TransformFunctionParmPackRefExpr` to build `FunctionParmPackExpr` instead of substituting the param pack. --- There are other instances of `RetainExpansion` and IIUC, they should also unset the `ArgumentPackSubstitutionIndex`. It would be great if someone can verify my understanding. If this is correct then we could instead have a `ArgumentPackSubstitutionIndexRAII` as part of `ForgetPartiallySubstitutedPackRAII`. EDIT: I have moved this to `ForgetPartiallySubstitutedPackRAII`. Fixes #63819 Fixes #107560
- Loading branch information