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