Skip to content

Commit 3b3dd76

Browse files
committed
Use range based for loop in Sema::CheckParameterPacksForExpansion. NFC
Signed-off-by: Jun Zhang <jun@junz.org>
1 parent 5c3ea07 commit 3b3dd76

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

clang/lib/Sema/SemaTemplateVariadic.cpp

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -677,21 +677,19 @@ bool Sema::CheckParameterPacksForExpansion(
677677
Optional<unsigned> NumPartialExpansions;
678678
SourceLocation PartiallySubstitutedPackLoc;
679679

680-
for (ArrayRef<UnexpandedParameterPack>::iterator i = Unexpanded.begin(),
681-
end = Unexpanded.end();
682-
i != end; ++i) {
680+
for (UnexpandedParameterPack ParmPack : Unexpanded) {
683681
// Compute the depth and index for this parameter pack.
684682
unsigned Depth = 0, Index = 0;
685683
IdentifierInfo *Name;
686684
bool IsVarDeclPack = false;
687685

688-
if (const TemplateTypeParmType *TTP
689-
= i->first.dyn_cast<const TemplateTypeParmType *>()) {
686+
if (const TemplateTypeParmType *TTP =
687+
ParmPack.first.dyn_cast<const TemplateTypeParmType *>()) {
690688
Depth = TTP->getDepth();
691689
Index = TTP->getIndex();
692690
Name = TTP->getIdentifier();
693691
} else {
694-
NamedDecl *ND = i->first.get<NamedDecl *>();
692+
NamedDecl *ND = ParmPack.first.get<NamedDecl *>();
695693
if (isa<VarDecl>(ND))
696694
IsVarDeclPack = true;
697695
else
@@ -706,9 +704,9 @@ bool Sema::CheckParameterPacksForExpansion(
706704
// Figure out whether we're instantiating to an argument pack or not.
707705
typedef LocalInstantiationScope::DeclArgumentPack DeclArgumentPack;
708706

709-
llvm::PointerUnion<Decl *, DeclArgumentPack *> *Instantiation
710-
= CurrentInstantiationScope->findInstantiationOf(
711-
i->first.get<NamedDecl *>());
707+
llvm::PointerUnion<Decl *, DeclArgumentPack *> *Instantiation =
708+
CurrentInstantiationScope->findInstantiationOf(
709+
ParmPack.first.get<NamedDecl *>());
712710
if (Instantiation->is<DeclArgumentPack *>()) {
713711
// We could expand this function parameter pack.
714712
NewPackSize = Instantiation->get<DeclArgumentPack *>()->size();
@@ -745,7 +743,7 @@ bool Sema::CheckParameterPacksForExpansion(
745743
RetainExpansion = true;
746744
// We don't actually know the new pack size yet.
747745
NumPartialExpansions = NewPackSize;
748-
PartiallySubstitutedPackLoc = i->second;
746+
PartiallySubstitutedPackLoc = ParmPack.second;
749747
continue;
750748
}
751749
}
@@ -756,7 +754,7 @@ bool Sema::CheckParameterPacksForExpansion(
756754
// Record it.
757755
NumExpansions = NewPackSize;
758756
FirstPack.first = Name;
759-
FirstPack.second = i->second;
757+
FirstPack.second = ParmPack.second;
760758
HaveFirstPack = true;
761759
continue;
762760
}
@@ -767,12 +765,12 @@ bool Sema::CheckParameterPacksForExpansion(
767765
// the same number of arguments specified.
768766
if (HaveFirstPack)
769767
Diag(EllipsisLoc, diag::err_pack_expansion_length_conflict)
770-
<< FirstPack.first << Name << *NumExpansions << NewPackSize
771-
<< SourceRange(FirstPack.second) << SourceRange(i->second);
768+
<< FirstPack.first << Name << *NumExpansions << NewPackSize
769+
<< SourceRange(FirstPack.second) << SourceRange(ParmPack.second);
772770
else
773771
Diag(EllipsisLoc, diag::err_pack_expansion_length_conflict_multilevel)
774-
<< Name << *NumExpansions << NewPackSize
775-
<< SourceRange(i->second);
772+
<< Name << *NumExpansions << NewPackSize
773+
<< SourceRange(ParmPack.second);
776774
return true;
777775
}
778776
}

0 commit comments

Comments
 (0)