Skip to content

Commit 765db8a

Browse files
committed
[Clang][P1061] Clean up stuff
1 parent 39ab76e commit 765db8a

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

clang/lib/Sema/SemaDeclCXX.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -963,7 +963,6 @@ Sema::ActOnDecompositionDeclarator(Scope *S, Declarator &D,
963963
// - Checks the arity of the structured bindings
964964
// - Creates the resolved pack expr if there is
965965
// one
966-
967966
static bool CheckBindingsCount(Sema &S, DecompositionDecl *DD,
968967
QualType DecompType,
969968
ArrayRef<BindingDecl *> Bindings,
@@ -1621,6 +1620,7 @@ void Sema::CheckCompleteDecompositionDeclaration(DecompositionDecl *DD) {
16211620
// each binding.
16221621
if (DecompType->isDependentType()) {
16231622
for (auto *B : DD->bindings()) {
1623+
// Do not overwrite any pack type.
16241624
if (B->getType().isNull())
16251625
B->setType(Context.DependentTy);
16261626
}

clang/lib/Sema/SemaTemplateInstantiateDecl.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,8 +1180,11 @@ Decl *TemplateDeclInstantiator::VisitDecompositionDecl(DecompositionDecl *D) {
11801180
ResolvedUnexpandedPackExpr *OldResolvedPack = nullptr;
11811181
for (auto *OldBD : D->bindings()) {
11821182
Expr *BindingExpr = OldBD->getBinding();
1183-
if (auto *RP = dyn_cast_if_present<ResolvedUnexpandedPackExpr>(BindingExpr))
1183+
if (auto *RP =
1184+
dyn_cast_if_present<ResolvedUnexpandedPackExpr>(BindingExpr)) {
1185+
assert(!OldResolvedPack && "no more than one pack is allowed");
11841186
OldResolvedPack = RP;
1187+
}
11851188
NewBindings.push_back(cast<BindingDecl>(VisitBindingDecl(OldBD)));
11861189
}
11871190
ArrayRef<BindingDecl*> NewBindingArray = NewBindings;
@@ -1197,13 +1200,13 @@ Decl *TemplateDeclInstantiator::VisitDecompositionDecl(DecompositionDecl *D) {
11971200
// Mark the holding vars (if any) in the pack as instantiated since
11981201
// they are created implicitly.
11991202
auto Bindings = NewDD->bindings();
1200-
auto BPack = std::find_if(
1201-
Bindings.begin(), Bindings.end(),
1202-
[](BindingDecl *D) -> bool { return D->isParameterPack(); });
1203+
auto BPack = llvm::find_if(
1204+
Bindings, [](BindingDecl *D) -> bool { return D->isParameterPack(); });
12031205
auto *NewResolvedPack =
12041206
cast<ResolvedUnexpandedPackExpr>((*BPack)->getBinding());
12051207
auto OldExprs = OldResolvedPack->getExprs();
12061208
auto NewExprs = NewResolvedPack->getExprs();
1209+
assert(OldExprs.size() == NewExprs.size());
12071210
for (unsigned I = 0; I < OldResolvedPack->getNumExprs(); I++) {
12081211
DeclRefExpr *OldDRE = cast<DeclRefExpr>(OldExprs[I]);
12091212
BindingDecl *OldNestedBD = cast<BindingDecl>(OldDRE->getDecl());

clang/lib/Sema/SemaTemplateVariadic.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class CollectUnexpandedParameterPacksVisitor
5252
return;
5353
} else if (auto *BD = dyn_cast<BindingDecl>(ND)) {
5454
Expr *E = BD->getBinding();
55-
if (auto *RP = dyn_cast_if_present<ResolvedUnexpandedPackExpr>(E)) {
55+
if (auto *RP = cast_if_present<ResolvedUnexpandedPackExpr>(E)) {
5656
addUnexpanded(RP);
5757
return;
5858
}
@@ -818,8 +818,6 @@ bool Sema::CheckParameterPacksForExpansion(
818818
unsigned NewPackSize, PendingPackExpansionSize = 0;
819819
if (IsVarDeclPack) {
820820
// Figure out whether we're instantiating to an argument pack or not.
821-
typedef LocalInstantiationScope::DeclArgumentPack DeclArgumentPack;
822-
823821
llvm::PointerUnion<Decl *, DeclArgumentPack *> *Instantiation =
824822
CurrentInstantiationScope->findInstantiationOf(
825823
cast<NamedDecl *>(ParmPack.first));

0 commit comments

Comments
 (0)