Skip to content

Commit 8a4a548

Browse files
committed
Eliminate CXXExpansionInitListExpr
1 parent 4415e4d commit 8a4a548

23 files changed

+10
-222
lines changed

clang/include/clang/AST/ComputeDependence.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ class DesignatedInitExpr;
9494
class ParenListExpr;
9595
class PseudoObjectExpr;
9696
class AtomicExpr;
97-
class CXXExpansionInitListExpr;
9897
class ArraySectionExpr;
9998
class OMPArrayShapingExpr;
10099
class OMPIteratorExpr;
@@ -192,8 +191,6 @@ ExprDependence computeDependence(ParenListExpr *E);
192191
ExprDependence computeDependence(PseudoObjectExpr *E);
193192
ExprDependence computeDependence(AtomicExpr *E);
194193

195-
ExprDependence computeDependence(CXXExpansionInitListExpr *E);
196-
197194
ExprDependence computeDependence(ArraySectionExpr *E);
198195
ExprDependence computeDependence(OMPArrayShapingExpr *E);
199196
ExprDependence computeDependence(OMPIteratorExpr *E);

clang/include/clang/AST/ExprCXX.h

Lines changed: 6 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -5499,79 +5499,6 @@ class BuiltinBitCastExpr final
54995499
}
55005500
};
55015501

5502-
/// Represents an expansion-init-list of an enumerating expansion statement.
5503-
///
5504-
/// For example, in
5505-
/// \verbatim
5506-
/// template for (auto x : { 1, 2, 3 }) {
5507-
/// // ...
5508-
/// }
5509-
/// \endverbatim
5510-
///
5511-
/// the '{ 1, 2, 3 }' part is parsed and stored as a 'CXXExpansionInitListExpr';
5512-
/// syntactically, this *looks* very similar to an initializer list, but it
5513-
/// isn't actually an expression: '{ 1, 2, 3 }' as a whole is never evaluated
5514-
/// or emitted, only the individual expressions '1', '2', and '3' are. We still
5515-
/// represent it as an expression in the AST for simplicity.
5516-
///
5517-
/// \see CXXEnumeratingExpansionStmtPattern
5518-
class CXXExpansionInitListExpr final
5519-
: public Expr,
5520-
llvm::TrailingObjects<CXXExpansionInitListExpr, Expr *> {
5521-
friend class ASTStmtReader;
5522-
friend TrailingObjects;
5523-
5524-
const unsigned NumExprs;
5525-
SourceLocation LBraceLoc;
5526-
SourceLocation RBraceLoc;
5527-
5528-
CXXExpansionInitListExpr(EmptyShell ES, unsigned NumExprs);
5529-
CXXExpansionInitListExpr(ArrayRef<Expr *> Exprs, SourceLocation LBraceLoc,
5530-
SourceLocation RBraceLoc);
5531-
5532-
public:
5533-
static CXXExpansionInitListExpr *Create(const ASTContext &C,
5534-
ArrayRef<Expr *> Exprs,
5535-
SourceLocation LBraceLoc,
5536-
SourceLocation RBraceLoc);
5537-
5538-
static CXXExpansionInitListExpr *
5539-
CreateEmpty(const ASTContext &C, EmptyShell Empty, unsigned NumExprs);
5540-
5541-
ArrayRef<Expr *> getExprs() const { return getTrailingObjects(NumExprs); }
5542-
MutableArrayRef<Expr *> getExprs() { return getTrailingObjects(NumExprs); }
5543-
unsigned getNumExprs() const { return NumExprs; }
5544-
5545-
bool containsPackExpansion() const;
5546-
5547-
SourceLocation getBeginLoc() const { return getLBraceLoc(); }
5548-
SourceLocation getEndLoc() const { return getRBraceLoc(); }
5549-
5550-
SourceLocation getLBraceLoc() const { return LBraceLoc; }
5551-
SourceLocation getRBraceLoc() const { return RBraceLoc; }
5552-
5553-
child_range children() {
5554-
const_child_range CCR =
5555-
const_cast<const CXXExpansionInitListExpr *>(this)->children();
5556-
return child_range(cast_away_const(CCR.begin()),
5557-
cast_away_const(CCR.end()));
5558-
}
5559-
5560-
const_child_range children() const {
5561-
Stmt **Stmts = getTrailingStmts();
5562-
return const_child_range(Stmts, Stmts + NumExprs);
5563-
}
5564-
5565-
static bool classof(const Stmt *T) {
5566-
return T->getStmtClass() == CXXExpansionInitListExprClass;
5567-
}
5568-
5569-
private:
5570-
Stmt **getTrailingStmts() const {
5571-
return reinterpret_cast<Stmt **>(const_cast<Expr **>(getTrailingObjects()));
5572-
}
5573-
};
5574-
55755502
/// Helper that selects an expression from an expansion init list depending
55765503
/// on the current expansion index.
55775504
///
@@ -5585,17 +5512,17 @@ class CXXExpansionInitListSelectExpr : public Expr {
55855512
public:
55865513
CXXExpansionInitListSelectExpr(EmptyShell Empty);
55875514
CXXExpansionInitListSelectExpr(const ASTContext &C,
5588-
CXXExpansionInitListExpr *Range, Expr *Idx);
5515+
InitListExpr *Range, Expr *Idx);
55895516

5590-
CXXExpansionInitListExpr *getRangeExpr() {
5591-
return cast<CXXExpansionInitListExpr>(SubExprs[RANGE]);
5517+
InitListExpr *getRangeExpr() {
5518+
return cast<InitListExpr>(SubExprs[RANGE]);
55925519
}
55935520

5594-
const CXXExpansionInitListExpr *getRangeExpr() const {
5595-
return cast<CXXExpansionInitListExpr>(SubExprs[RANGE]);
5521+
const InitListExpr *getRangeExpr() const {
5522+
return cast<InitListExpr>(SubExprs[RANGE]);
55965523
}
55975524

5598-
void setRangeExpr(CXXExpansionInitListExpr *E) { SubExprs[RANGE] = E; }
5525+
void setRangeExpr(InitListExpr *E) { SubExprs[RANGE] = E; }
55995526

56005527
Expr *getIndexExpr() { return SubExprs[INDEX]; }
56015528
const Expr *getIndexExpr() const { return SubExprs[INDEX]; }

clang/include/clang/AST/RecursiveASTVisitor.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3130,7 +3130,6 @@ DEF_TRAVERSE_STMT(CXXIteratingExpansionStmtPattern, {})
31303130
DEF_TRAVERSE_STMT(CXXDestructuringExpansionStmtPattern, {})
31313131
DEF_TRAVERSE_STMT(CXXDependentExpansionStmtPattern, {})
31323132
DEF_TRAVERSE_STMT(CXXExpansionStmtInstantiation, {})
3133-
DEF_TRAVERSE_STMT(CXXExpansionInitListExpr, {})
31343133
DEF_TRAVERSE_STMT(CXXExpansionInitListSelectExpr, {})
31353134
DEF_TRAVERSE_STMT(CXXDestructuringExpansionSelectExpr, {})
31363135

clang/include/clang/AST/StmtCXX.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -586,8 +586,6 @@ class CXXExpansionStmtPattern : public Stmt {
586586
return getBody() ? getBody()->getEndLoc() : RParenLoc;
587587
}
588588

589-
bool hasDependentSize() const;
590-
591589
CXXExpansionStmtDecl *getDecl() { return ParentDecl; }
592590
const CXXExpansionStmtDecl *getDecl() const { return ParentDecl; }
593591

@@ -632,7 +630,7 @@ class CXXExpansionStmtPattern : public Stmt {
632630
/// an initializer list, but it isn't actually an expression in and of itself
633631
/// (in that it is never evaluated or emitted) and instead is just treated as
634632
/// a group of expressions. The expansion initializer of this is always a
635-
/// 'CXXExpansionInitListExpr'.
633+
/// syntactic-form 'InitListExpr'.
636634
///
637635
/// Example:
638636
/// \verbatim
@@ -644,7 +642,7 @@ class CXXExpansionStmtPattern : public Stmt {
644642
/// Note that the expression-list may also contain pack expansions, e.g.
645643
/// '{ 1, xs... }', in which case the expansion size is dependent.
646644
///
647-
/// Here, the '{ 1, 2, 3 }' is parsed as a 'CXXExpansionInitListExpr'. This node
645+
/// Here, the '{ 1, 2, 3 }' is parsed as an 'InitListExpr'. This node
648646
/// handles storing (and pack-expanding) the individual expressions.
649647
///
650648
/// Sema then wraps this with a 'CXXExpansionInitListSelectExpr', which also

clang/include/clang/AST/TextNodeDumper.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,6 @@ class TextNodeDumper
314314
VisitCXXDependentScopeMemberExpr(const CXXDependentScopeMemberExpr *Node);
315315
void VisitCXXDestructuringExpansionSelectExpr(
316316
const CXXDestructuringExpansionSelectExpr *Node);
317-
void VisitCXXExpansionInitListExpr(const CXXExpansionInitListExpr *Node);
318317
void VisitObjCAtCatchStmt(const ObjCAtCatchStmt *Node);
319318
void VisitObjCEncodeExpr(const ObjCEncodeExpr *Node);
320319
void VisitObjCMessageExpr(const ObjCMessageExpr *Node);

clang/include/clang/Basic/StmtNodes.td

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ def ConceptSpecializationExpr : StmtNode<Expr>;
187187
def RequiresExpr : StmtNode<Expr>;
188188

189189
// C++26 Expansion statement support expressions
190-
def CXXExpansionInitListExpr : StmtNode<Expr>;
191190
def CXXExpansionInitListSelectExpr : StmtNode<Expr>;
192191
def CXXDestructuringExpansionSelectExpr : StmtNode<Expr>;
193192

clang/include/clang/Serialization/ASTBitCodes.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1942,7 +1942,6 @@ enum StmtCode {
19421942
EXPR_CXX_FOLD, // CXXFoldExpr
19431943
EXPR_CONCEPT_SPECIALIZATION, // ConceptSpecializationExpr
19441944
EXPR_REQUIRES, // RequiresExpr
1945-
EXPR_CXX_EXPANSION_INIT_LIST, // CXXExpansionInitListExpr
19461945
EXPR_CXX_EXPANSION_INIT_LIST_SELECT, // CXXExpansionInitListSelectExpr
19471946
EXPR_CXX_DESTRUCTURING_EXPANSION_SELECT, // CXXDestructuringExpansionSelectExpr
19481947

clang/lib/AST/ASTImporter.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,6 @@ namespace clang {
711711
VisitSubstNonTypeTemplateParmPackExpr(SubstNonTypeTemplateParmPackExpr *E);
712712
ExpectedStmt VisitPseudoObjectExpr(PseudoObjectExpr *E);
713713
ExpectedStmt VisitCXXParenListInitExpr(CXXParenListInitExpr *E);
714-
ExpectedStmt VisitCXXExpansionInitListExpr(CXXExpansionInitListExpr *E);
715714
ExpectedStmt
716715
VisitCXXExpansionInitListSelectExpr(CXXExpansionInitListSelectExpr *E);
717716
ExpectedStmt VisitCXXDestructuringExpansionSelectExpr(
@@ -9480,22 +9479,6 @@ ASTNodeImporter::VisitCXXParenListInitExpr(CXXParenListInitExpr *E) {
94809479
ToInitLoc, ToBeginLoc, ToEndLoc);
94819480
}
94829481

9483-
ExpectedStmt
9484-
ASTNodeImporter::VisitCXXExpansionInitListExpr(CXXExpansionInitListExpr *E) {
9485-
Error Err = Error::success();
9486-
SmallVector<Expr *> ToExprs;
9487-
auto ToLBraceLoc = importChecked(Err, E->getLBraceLoc());
9488-
auto ToRBraceLoc = importChecked(Err, E->getRBraceLoc());
9489-
for (Expr *FromInst : E->getExprs())
9490-
ToExprs.push_back(importChecked(Err, FromInst));
9491-
9492-
if (Err)
9493-
return std::move(Err);
9494-
9495-
return CXXExpansionInitListExpr::Create(Importer.getToContext(), ToExprs,
9496-
ToLBraceLoc, ToRBraceLoc);
9497-
}
9498-
94999482
ExpectedStmt ASTNodeImporter::VisitCXXExpansionInitListSelectExpr(
95009483
CXXExpansionInitListSelectExpr *E) {
95019484
Error Err = Error::success();

clang/lib/AST/ComputeDependence.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -959,10 +959,3 @@ ExprDependence clang::computeDependence(OpenACCAsteriskSizeExpr *E) {
959959
// way.
960960
return ExprDependence::None;
961961
}
962-
963-
ExprDependence clang::computeDependence(CXXExpansionInitListExpr *ILE) {
964-
auto D = ExprDependence::None;
965-
for (Expr *E : ILE->getExprs())
966-
D |= E->getDependence();
967-
return D;
968-
}

clang/lib/AST/Expr.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3689,7 +3689,6 @@ bool Expr::HasSideEffects(const ASTContext &Ctx,
36893689
case RecoveryExprClass:
36903690
case CXXFoldExprClass:
36913691
case CXXExpansionInitListSelectExprClass:
3692-
case CXXExpansionInitListExprClass:
36933692
case CXXDestructuringExpansionSelectExprClass:
36943693
// Make a conservative assumption for dependent nodes.
36953694
return IncludePossibleEffects;

0 commit comments

Comments
 (0)