================ @@ -4213,8 +4226,35 @@ class DecompositionDecl final static DecompositionDecl *CreateDeserialized(ASTContext &C, GlobalDeclID ID, unsigned NumBindings); - ArrayRef<BindingDecl *> bindings() const { - return llvm::ArrayRef(getTrailingObjects<BindingDecl *>(), NumBindings); + // Provide the range of bindings which may have a nested pack. + llvm::ArrayRef<BindingDecl *> bindings() const { + return {getTrailingObjects<BindingDecl *>(), NumBindings}; + } + + // Provide a flattened range to visit each binding. + auto flat_bindings() const { + llvm::ArrayRef<BindingDecl *> Bindings = bindings(); + llvm::ArrayRef<Expr *> PackExprs; + + // Split the bindings into subranges split by the pack. + auto S1 = Bindings.take_until( + [](BindingDecl *BD) { return BD->isParameterPack(); }); + + Bindings = Bindings.drop_front(S1.size()); + if (!Bindings.empty()) { + PackExprs = Bindings.front()->getBindingPackExprs(); + Bindings = Bindings.drop_front(); + } + + auto S2 = llvm::map_range(PackExprs, [](Expr *E) { + auto *DRE = cast<DeclRefExpr>(E); + return cast<BindingDecl>(DRE->getDecl()); + }); + + // llvm::concat must take temporaries or it will capture + // references. ---------------- zygoloid wrote:
I found this comment a bit confusing, because `move` produces a reference rather than a temporary. How about something like "Pass xvalues to llvm::concat to request that it makes a copy." https://github.com/llvm/llvm-project/pull/121417 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits