From 3b3dd76d8da80ff91295d8c0c23de8462ac22b49 Mon Sep 17 00:00:00 2001 From: Jun Zhang Date: Fri, 22 Apr 2022 11:32:38 +0800 Subject: [PATCH] Use range based for loop in Sema::CheckParameterPacksForExpansion. NFC Signed-off-by: Jun Zhang --- clang/lib/Sema/SemaTemplateVariadic.cpp | 28 ++++++++++++------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/clang/lib/Sema/SemaTemplateVariadic.cpp b/clang/lib/Sema/SemaTemplateVariadic.cpp index 51c79e93ab0a..790792f77b24 100644 --- a/clang/lib/Sema/SemaTemplateVariadic.cpp +++ b/clang/lib/Sema/SemaTemplateVariadic.cpp @@ -677,21 +677,19 @@ bool Sema::CheckParameterPacksForExpansion( Optional NumPartialExpansions; SourceLocation PartiallySubstitutedPackLoc; - for (ArrayRef::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()) { + if (const TemplateTypeParmType *TTP = + ParmPack.first.dyn_cast()) { Depth = TTP->getDepth(); Index = TTP->getIndex(); Name = TTP->getIdentifier(); } else { - NamedDecl *ND = i->first.get(); + NamedDecl *ND = ParmPack.first.get(); if (isa(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 *Instantiation - = CurrentInstantiationScope->findInstantiationOf( - i->first.get()); + llvm::PointerUnion *Instantiation = + CurrentInstantiationScope->findInstantiationOf( + ParmPack.first.get()); if (Instantiation->is()) { // We could expand this function parameter pack. NewPackSize = Instantiation->get()->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; } }