Use range based for loop in Sema::CheckParameterPacksForExpansion. NFC

Signed-off-by: Jun Zhang <jun@junz.org>
This commit is contained in:
Jun Zhang 2022-04-22 11:32:38 +08:00
parent 5c3ea07848
commit 3b3dd76d8d
No known key found for this signature in database
GPG Key ID: E19904830B621534
1 changed files with 13 additions and 15 deletions

View File

@ -677,21 +677,19 @@ bool Sema::CheckParameterPacksForExpansion(
Optional<unsigned> NumPartialExpansions;
SourceLocation PartiallySubstitutedPackLoc;
for (ArrayRef<UnexpandedParameterPack>::iterator i = Unexpanded.begin(),
end = Unexpanded.end();
i != end; ++i) {
for (UnexpandedParameterPack ParmPack : Unexpanded) {
// Compute the depth and index for this parameter pack.
unsigned Depth = 0, Index = 0;
IdentifierInfo *Name;
bool IsVarDeclPack = false;
if (const TemplateTypeParmType *TTP
= i->first.dyn_cast<const TemplateTypeParmType *>()) {
if (const TemplateTypeParmType *TTP =
ParmPack.first.dyn_cast<const TemplateTypeParmType *>()) {
Depth = TTP->getDepth();
Index = TTP->getIndex();
Name = TTP->getIdentifier();
} else {
NamedDecl *ND = i->first.get<NamedDecl *>();
NamedDecl *ND = ParmPack.first.get<NamedDecl *>();
if (isa<VarDecl>(ND))
IsVarDeclPack = true;
else
@ -706,9 +704,9 @@ bool Sema::CheckParameterPacksForExpansion(
// Figure out whether we're instantiating to an argument pack or not.
typedef LocalInstantiationScope::DeclArgumentPack DeclArgumentPack;
llvm::PointerUnion<Decl *, DeclArgumentPack *> *Instantiation
= CurrentInstantiationScope->findInstantiationOf(
i->first.get<NamedDecl *>());
llvm::PointerUnion<Decl *, DeclArgumentPack *> *Instantiation =
CurrentInstantiationScope->findInstantiationOf(
ParmPack.first.get<NamedDecl *>());
if (Instantiation->is<DeclArgumentPack *>()) {
// We could expand this function parameter pack.
NewPackSize = Instantiation->get<DeclArgumentPack *>()->size();
@ -745,7 +743,7 @@ bool Sema::CheckParameterPacksForExpansion(
RetainExpansion = true;
// We don't actually know the new pack size yet.
NumPartialExpansions = NewPackSize;
PartiallySubstitutedPackLoc = i->second;
PartiallySubstitutedPackLoc = ParmPack.second;
continue;
}
}
@ -756,7 +754,7 @@ bool Sema::CheckParameterPacksForExpansion(
// Record it.
NumExpansions = NewPackSize;
FirstPack.first = Name;
FirstPack.second = i->second;
FirstPack.second = ParmPack.second;
HaveFirstPack = true;
continue;
}
@ -767,12 +765,12 @@ bool Sema::CheckParameterPacksForExpansion(
// the same number of arguments specified.
if (HaveFirstPack)
Diag(EllipsisLoc, diag::err_pack_expansion_length_conflict)
<< FirstPack.first << Name << *NumExpansions << NewPackSize
<< SourceRange(FirstPack.second) << SourceRange(i->second);
<< FirstPack.first << Name << *NumExpansions << NewPackSize
<< SourceRange(FirstPack.second) << SourceRange(ParmPack.second);
else
Diag(EllipsisLoc, diag::err_pack_expansion_length_conflict_multilevel)
<< Name << *NumExpansions << NewPackSize
<< SourceRange(i->second);
<< Name << *NumExpansions << NewPackSize
<< SourceRange(ParmPack.second);
return true;
}
}