[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)
Younan Zhang via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 2 01:40:48 PST 2025
================
@@ -757,23 +780,42 @@ bool Sema::CheckParameterPacksForExpansion(
bool HaveFirstPack = false;
std::optional<unsigned> NumPartialExpansions;
SourceLocation PartiallySubstitutedPackLoc;
+ typedef LocalInstantiationScope::DeclArgumentPack DeclArgumentPack;
for (UnexpandedParameterPack ParmPack : Unexpanded) {
// Compute the depth and index for this parameter pack.
unsigned Depth = 0, Index = 0;
IdentifierInfo *Name;
bool IsVarDeclPack = false;
+ ResolvedUnexpandedPackExpr *ResolvedPack = nullptr;
if (const TemplateTypeParmType *TTP =
ParmPack.first.dyn_cast<const TemplateTypeParmType *>()) {
Depth = TTP->getDepth();
Index = TTP->getIndex();
Name = TTP->getIdentifier();
+ } else if (auto *RP =
+ ParmPack.first.dyn_cast<ResolvedUnexpandedPackExpr *>()) {
+ ResolvedPack = RP;
} else {
NamedDecl *ND = cast<NamedDecl *>(ParmPack.first);
if (isa<VarDecl>(ND))
IsVarDeclPack = true;
- else
+ else if (isa<BindingDecl>(ND)) {
+ // find the instantiated BindingDecl and check it for a resolved pack
+ llvm::PointerUnion<Decl *, DeclArgumentPack *> *Instantiation =
+ CurrentInstantiationScope->findInstantiationOf(ND);
+ if (Decl *B = Instantiation->dyn_cast<Decl *>()) {
----------------
zyn0217 wrote:
I think we need to assert the Instatiation cannot be a DeclArgumentPack *
https://github.com/llvm/llvm-project/pull/121417
More information about the cfe-commits
mailing list