Skip to content

Commit a81235c

Browse files
P-E-PCohenArthur
authored andcommitted
Separate strip information from internal state
Marking a TupleIndexExpr for strip makes it invalid for a generic visitor gcc/rust/ChangeLog: * ast/rust-expr.h (class TupleIndexExpr): Store strip information. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
1 parent ed95875 commit a81235c

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

gcc/rust/ast/rust-expr.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1611,6 +1611,7 @@ class TupleIndexExpr : public ExprWithoutBlock
16111611
TupleIndex tuple_index;
16121612

16131613
location_t locus;
1614+
bool to_strip;
16141615

16151616
// i.e. pair.0
16161617

@@ -1622,13 +1623,15 @@ class TupleIndexExpr : public ExprWithoutBlock
16221623
TupleIndexExpr (std::unique_ptr<Expr> tuple_expr, TupleIndex index,
16231624
std::vector<Attribute> outer_attribs, location_t locus)
16241625
: outer_attrs (std::move (outer_attribs)),
1625-
tuple_expr (std::move (tuple_expr)), tuple_index (index), locus (locus)
1626+
tuple_expr (std::move (tuple_expr)), tuple_index (index), locus (locus),
1627+
to_strip (false)
16261628
{}
16271629

16281630
// Copy constructor requires a clone for tuple_expr
16291631
TupleIndexExpr (TupleIndexExpr const &other)
16301632
: ExprWithoutBlock (other), outer_attrs (other.outer_attrs),
1631-
tuple_index (other.tuple_index), locus (other.locus)
1633+
tuple_index (other.tuple_index), locus (other.locus),
1634+
to_strip (other.to_strip)
16321635
{
16331636
// guard to prevent null dereference (only required if error state)
16341637
if (other.tuple_expr != nullptr)
@@ -1642,6 +1645,7 @@ class TupleIndexExpr : public ExprWithoutBlock
16421645
tuple_index = other.tuple_index;
16431646
locus = other.locus;
16441647
outer_attrs = other.outer_attrs;
1648+
to_strip = other.to_strip;
16451649

16461650
// guard to prevent null dereference (only required if error state)
16471651
if (other.tuple_expr != nullptr)
@@ -1661,8 +1665,8 @@ class TupleIndexExpr : public ExprWithoutBlock
16611665
void accept_vis (ASTVisitor &vis) override;
16621666

16631667
// Invalid if tuple expr is null, so base stripping on that.
1664-
void mark_for_strip () override { tuple_expr = nullptr; }
1665-
bool is_marked_for_strip () const override { return tuple_expr == nullptr; }
1668+
void mark_for_strip () override { to_strip = true; }
1669+
bool is_marked_for_strip () const override { return to_strip; }
16661670

16671671
// TODO: is this better? Or is a "vis_block" better?
16681672
Expr &get_tuple_expr ()

0 commit comments

Comments
 (0)