Skip to content

Commit 5751d2f

Browse files
committed
[Clang][P1016] Address nits; Remove unneeded code
1 parent e497a0c commit 5751d2f

File tree

7 files changed

+6
-29
lines changed

7 files changed

+6
-29
lines changed

clang/include/clang/AST/DeclCXX.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4201,7 +4201,7 @@ class DecompositionDecl final
42014201
getTrailingObjects<BindingDecl *>());
42024202
for (auto *B : Bindings) {
42034203
B->setDecomposedDecl(this);
4204-
if (B->isParameterPack()) {
4204+
if (B->isParameterPack() && B->getBinding()) {
42054205
for (Expr *E : B->getBindingPackExprs()) {
42064206
auto *DRE = cast<DeclRefExpr>(E);
42074207
auto *NestedB = cast<BindingDecl>(DRE->getDecl());
@@ -4251,8 +4251,6 @@ class DecompositionDecl final
42514251
return cast<BindingDecl>(DRE->getDecl());
42524252
});
42534253

4254-
// llvm::concat must take temporaries or it will capture
4255-
// references.
42564254
return llvm::concat<BindingDecl *>(std::move(S1), std::move(S2),
42574255
std::move(Bindings));
42584256
}

clang/include/clang/AST/Expr.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1482,12 +1482,6 @@ class DeclRefExpr final
14821482
setDependence(computeDependence(this, Context));
14831483
}
14841484

1485-
/// Set type and compute and set dependence bits.
1486-
void setTypeFromBinding(QualType T, const ASTContext &Context) {
1487-
setType(T.getNonReferenceType());
1488-
setDependence(computeDependence(this, Context));
1489-
}
1490-
14911485
static bool classof(const Stmt *T) {
14921486
return T->getStmtClass() == DeclRefExprClass;
14931487
}

clang/lib/AST/DeclCXX.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3426,8 +3426,7 @@ VarDecl *BindingDecl::getHoldingVar() const {
34263426
}
34273427

34283428
llvm::ArrayRef<Expr *> BindingDecl::getBindingPackExprs() const {
3429-
if (!Binding)
3430-
return {};
3429+
assert(Binding && "expecting a pack expr");
34313430
auto *RP = cast<ResolvedUnexpandedPackExpr>(Binding);
34323431
return RP->getExprs();
34333432
}

clang/lib/Sema/SemaDeclCXX.cpp

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,25 +1570,13 @@ void Sema::CheckCompleteDecompositionDeclaration(DecompositionDecl *DD) {
15701570
// If the type of the decomposition is dependent, then so is the type of
15711571
// each binding.
15721572
if (DecompType->isDependentType()) {
1573+
// Note that all of the types are still Null or PackExpansionType.
15731574
for (auto *B : DD->bindings()) {
15741575
// Do not overwrite any pack type.
15751576
if (B->getType().isNull())
15761577
B->setType(Context.DependentTy);
15771578
}
15781579
return;
1579-
} else {
1580-
// Set the types of the DeclRefExprs that point to nested pack bindings.
1581-
for (BindingDecl *B : DD->bindings()) {
1582-
if (B->isParameterPack()) {
1583-
for (Expr *E : B->getBindingPackExprs()) {
1584-
auto *DRE = cast<DeclRefExpr>(E);
1585-
auto *NestedB = cast<BindingDecl>(DRE->getDecl());
1586-
QualType T = NestedB->getType();
1587-
DRE->setTypeFromBinding(T, Context);
1588-
}
1589-
break;
1590-
}
1591-
}
15921580
}
15931581

15941582
DecompType = DecompType.getNonReferenceType();

clang/lib/Sema/SemaStmt.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2671,9 +2671,8 @@ StmtResult Sema::BuildCXXForRangeStmt(
26712671
if (!LoopVar->isInvalidDecl() && Kind != BFRK_Check) {
26722672
if (auto *DD = dyn_cast<DecompositionDecl>(LoopVar))
26732673
for (auto *Binding : DD->bindings()) {
2674-
if (!Binding->isParameterPack()) {
2674+
if (!Binding->isParameterPack())
26752675
Binding->setType(Context.DependentTy);
2676-
}
26772676
}
26782677
LoopVar->setType(SubstAutoTypeDependent(LoopVar->getType()));
26792678
}

clang/lib/Sema/SemaTemplateInstantiate.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2494,9 +2494,8 @@ TemplateInstantiator::TransformDeclRefExpr(DeclRefExpr *E) {
24942494
if (!BD)
24952495
return ExprError();
24962496
if (auto *RP =
2497-
dyn_cast_if_present<ResolvedUnexpandedPackExpr>(BD->getBinding())) {
2497+
dyn_cast_if_present<ResolvedUnexpandedPackExpr>(BD->getBinding()))
24982498
return TransformResolvedUnexpandedPackExpr(RP);
2499-
}
25002499
}
25012500

25022501
return inherited::TransformDeclRefExpr(E);

clang/test/SemaCXX/cxx2c-binding-pack.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ void h(int (&arr)[N]) {
161161
// b is a pack referring to the second and
162162
// third elements, and c names the fourth element
163163
static_assert(sizeof...(b) == 2);
164-
auto& [...e] = arr; // e is a pack referring to the four elements of the array
164+
auto& [...e] = arr; // e is a pack referring to the four elements of the array
165165
static_assert(sizeof...(e) == 4);
166166
}
167167

0 commit comments

Comments
 (0)