forked from OSchip/llvm-project
Use range based for loop in Sema::CheckParameterPacksForExpansion. NFC
Signed-off-by: Jun Zhang <jun@junz.org>
This commit is contained in:
parent
5c3ea07848
commit
3b3dd76d8d
clang/lib/Sema
|
@ -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;
|
||||
}
|
||||
|
@ -768,11 +766,11 @@ bool Sema::CheckParameterPacksForExpansion(
|
|||
if (HaveFirstPack)
|
||||
Diag(EllipsisLoc, diag::err_pack_expansion_length_conflict)
|
||||
<< FirstPack.first << Name << *NumExpansions << NewPackSize
|
||||
<< SourceRange(FirstPack.second) << SourceRange(i->second);
|
||||
<< SourceRange(FirstPack.second) << SourceRange(ParmPack.second);
|
||||
else
|
||||
Diag(EllipsisLoc, diag::err_pack_expansion_length_conflict_multilevel)
|
||||
<< Name << *NumExpansions << NewPackSize
|
||||
<< SourceRange(i->second);
|
||||
<< SourceRange(ParmPack.second);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue