[clang] [Clang] [C++26] Implement P1306R5 Expansion Statements (PR #165195)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Oct 26 22:57:10 PDT 2025
================
@@ -2393,9 +2413,13 @@ ExprResult
TemplateInstantiator::TransformFunctionParmPackRefExpr(DeclRefExpr *E,
ValueDecl *PD) {
typedef LocalInstantiationScope::DeclArgumentPack DeclArgumentPack;
- llvm::PointerUnion<Decl *, DeclArgumentPack *> *Found
- = getSema().CurrentInstantiationScope->findInstantiationOf(PD);
- assert(Found && "no instantiation for parameter pack");
+ llvm::PointerUnion<Decl *, DeclArgumentPack *> *Found =
+ getSema().CurrentInstantiationScope->getInstantiationOfIfExists(PD);
+
+ // This can happen when instantiating an expansion statement that contains
+ // a pack (e.g. `template for (auto x : {{ts...}})`).
+ if (!Found)
+ return E;
----------------
Sirraide wrote:
There’s similar stuff elsewhere in the template code where I removed some assertions; as I understand it, the main reason is that with this patch we’re now doing template instantiation inside a function w/o instantiating the function itself, which is something what wasn’t possible before, hence why we’re asserting on not being able to find instantiations of things in a few places.
https://github.com/llvm/llvm-project/pull/165195
More information about the cfe-commits
mailing list