diff options
author | Owen Avery <powerboat9.gamer@gmail.com> | 2023-03-15 23:05:07 -0400 |
---|---|---|
committer | CohenArthur <arthur.cohen@embecosm.com> | 2023-04-12 13:17:19 +0000 |
commit | 132a5011e384994e6121eb606f2442ca61fbe908 (patch) | |
tree | fb9da31637abdbcf97037be6611abc206710a548 /gcc/rust/expand | |
parent | dc5f674759ecea1531e857e35ebccc1d302be7d4 (diff) | |
download | gcc-132a5011e384994e6121eb606f2442ca61fbe908.zip gcc-132a5011e384994e6121eb606f2442ca61fbe908.tar.gz gcc-132a5011e384994e6121eb606f2442ca61fbe908.tar.bz2 |
Unify AST::IfExprConseqIf{,Let} into AST::IfExprConseqElse
This simplifies the AST's representation of if-statements
to match the HIR.
gcc/rust/ChangeLog:
* ast/rust-expr.h
(class IfExprConseqElse): Make else_block ExprWithBlock.
(class IfExprConseqIf): Remove.
(class IfExprConseqIfLet): Remove.
* ast/rust-ast-full-decls.h
(class IfExprConseqIf): Remove.
(class IfExprConseqIfLet): Remove.
* ast/rust-ast.cc
(IfExprConseqElse::as_string): Adjust output.
(IfExprConseqIf::as_string): Remove.
(IfExprConseqIfLet::as_string): Remove.
(IfExprConseqIf::accept_vis): Remove.
(IfExprConseqIfLet::accept_vis): Remove.
* ast/rust-ast-visitor.h
(ASTVisitor::visit): Remove IfExprConseqIf{,Let} visitors.
* ast/rust-ast-tokenstream.cc
(TokenStream::visit): Likewise.
* ast/rust-ast-tokenstream.h
(TokenStream::visit): Likewise.
* ast/rust-ast-dump.cc
(Dump::visit): Likewise.
* ast/rust-ast-dump.h
(Dump::visit): Likewise.
* checks/errors/rust-feature-gate.h
(FeatureGate::visit): Likewise.
* util/rust-attributes.cc
(AttributeChecker::visit): Likewise.
* util/rust-attributes.h
(AttributeChecker::visit): Likewise.
* resolve/rust-early-name-resolver.cc
(EarlyNameResolver::visit): Likewise.
* resolve/rust-early-name-resolver.h
(EarlyNameResolver::visit): Likewise.
* resolve/rust-ast-resolve-base.h
(ResolverBase::visit): Likewise.
* resolve/rust-ast-resolve-base.cc
(ResolverBase::visit): Likewise.
* resolve/rust-ast-resolve-expr.h
(ResolveExpr::visit): Remove IfExprConseqIf visitor.
* resolve/rust-ast-resolve-expr.cc
(ResolveExpr::visit): Likewise.
* expand/rust-cfg-strip.cc
(CfgStrip::visit): Remove IfExprConseqIf{,Let} visitors.
* expand/rust-cfg-strip.h
(CfgStrip::visit): Likewise.
* expand/rust-expand-visitor.cc
(ExpandVisitor::visit): Likewise.
* expand/rust-expand-visitor.h
(ExpandVisitor::visit): Likewise.
* hir/rust-ast-lower-base.cc
(ASTLoweringBase::visit): Likewise.
* hir/rust-ast-lower-base.h
(ASTLoweringBase::visit): Likewise.
* hir/rust-ast-lower-block.h
(ASTLoweringIfBlock::visit): Remove IfExprConseqIf visitor.
(ASTLoweringExprWithBlock::visit): Likewise.
* hir/rust-ast-lower.cc
(ASTLoweringIfBlock::visit):
Remove IfExprConseqIf visitor, adjust IfExprConseqElse lowering.
* hir/rust-ast-lower-expr.h
(ASTLoweringExpr::visit): Remove IfExprConseqIf visitor.
* hir/rust-ast-lower-expr.cc
(ASTLoweringExpr::visit): Likewise.
* parse/rust-parse-impl.h
(Parser::parse_if_expr): Replace IfExprConseqIf{,Let} with IfExprConseqElse.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Diffstat (limited to 'gcc/rust/expand')
-rw-r--r-- | gcc/rust/expand/rust-cfg-strip.cc | 71 | ||||
-rw-r--r-- | gcc/rust/expand/rust-cfg-strip.h | 2 | ||||
-rw-r--r-- | gcc/rust/expand/rust-expand-visitor.cc | 18 | ||||
-rw-r--r-- | gcc/rust/expand/rust-expand-visitor.h | 2 |
4 files changed, 0 insertions, 93 deletions
diff --git a/gcc/rust/expand/rust-cfg-strip.cc b/gcc/rust/expand/rust-cfg-strip.cc index b102049..9c6c249 100644 --- a/gcc/rust/expand/rust-cfg-strip.cc +++ b/gcc/rust/expand/rust-cfg-strip.cc @@ -1701,77 +1701,6 @@ CfgStrip::visit (AST::IfExprConseqElse &expr) "attributes not allowed"); } void -CfgStrip::visit (AST::IfExprConseqIf &expr) -{ - // initial strip test based on outer attrs - expand_cfg_attrs (expr.get_outer_attrs ()); - if (fails_cfg_with_expand (expr.get_outer_attrs ())) - { - expr.mark_for_strip (); - return; - } - - // can't strip condition expr itself, but can strip sub-expressions - auto &condition_expr = expr.get_condition_expr (); - condition_expr->accept_vis (*this); - if (condition_expr->is_marked_for_strip ()) - rust_error_at (condition_expr->get_locus (), - "cannot strip expression in this position - outer " - "attributes not allowed"); - - // can't strip if block itself, but can strip sub-expressions - auto &if_block = expr.get_if_block (); - if_block->accept_vis (*this); - if (if_block->is_marked_for_strip ()) - rust_error_at (if_block->get_locus (), - "cannot strip block expression in this position - outer " - "attributes not allowed"); - - // can't strip if expr itself, but can strip sub-expressions - auto &conseq_if_expr = expr.get_conseq_if_expr (); - conseq_if_expr->accept_vis (*this); - if (conseq_if_expr->is_marked_for_strip ()) - rust_error_at (conseq_if_expr->get_locus (), - "cannot strip consequent if expression in this " - "position - outer attributes not allowed"); -} -void -CfgStrip::visit (AST::IfExprConseqIfLet &expr) -{ - // initial strip test based on outer attrs - expand_cfg_attrs (expr.get_outer_attrs ()); - if (fails_cfg_with_expand (expr.get_outer_attrs ())) - { - expr.mark_for_strip (); - return; - } - - // can't strip condition expr itself, but can strip sub-expressions - auto &condition_expr = expr.get_condition_expr (); - condition_expr->accept_vis (*this); - if (condition_expr->is_marked_for_strip ()) - rust_error_at (condition_expr->get_locus (), - "cannot strip expression in this position - outer " - "attributes not allowed"); - - // can't strip if block itself, but can strip sub-expressions - auto &if_block = expr.get_if_block (); - if_block->accept_vis (*this); - if (if_block->is_marked_for_strip ()) - rust_error_at (if_block->get_locus (), - "cannot strip block expression in this position - outer " - "attributes not allowed"); - - // can't strip if let expr itself, but can strip sub-expressions - auto &conseq_if_let_expr = expr.get_conseq_if_let_expr (); - conseq_if_let_expr->accept_vis (*this); - if (conseq_if_let_expr->is_marked_for_strip ()) - rust_error_at (conseq_if_let_expr->get_locus (), - "cannot strip consequent if let expression in this " - "position - outer attributes not " - "allowed"); -} -void CfgStrip::visit (AST::IfLetExpr &expr) { // initial strip test based on outer attrs diff --git a/gcc/rust/expand/rust-cfg-strip.h b/gcc/rust/expand/rust-cfg-strip.h index 34a8e56..ff71c6e 100644 --- a/gcc/rust/expand/rust-cfg-strip.h +++ b/gcc/rust/expand/rust-cfg-strip.h @@ -131,8 +131,6 @@ public: void visit (AST::ForLoopExpr &expr) override; void visit (AST::IfExpr &expr) override; void visit (AST::IfExprConseqElse &expr) override; - void visit (AST::IfExprConseqIf &expr) override; - void visit (AST::IfExprConseqIfLet &expr) override; void visit (AST::IfLetExpr &expr) override; void visit (AST::IfLetExprConseqElse &expr) override; void visit (AST::IfLetExprConseqIf &expr) override; diff --git a/gcc/rust/expand/rust-expand-visitor.cc b/gcc/rust/expand/rust-expand-visitor.cc index be6bb06..04013da 100644 --- a/gcc/rust/expand/rust-expand-visitor.cc +++ b/gcc/rust/expand/rust-expand-visitor.cc @@ -682,24 +682,6 @@ ExpandVisitor::visit (AST::IfExprConseqElse &expr) } void -ExpandVisitor::visit (AST::IfExprConseqIf &expr) -{ - maybe_expand_expr (expr.get_condition_expr ()); - - visit (expr.get_if_block ()); - visit (expr.get_conseq_if_expr ()); -} - -void -ExpandVisitor::visit (AST::IfExprConseqIfLet &expr) -{ - maybe_expand_expr (expr.get_condition_expr ()); - - visit (expr.get_if_block ()); - visit (expr.get_conseq_if_let_expr ()); -} - -void ExpandVisitor::visit (AST::IfLetExpr &expr) { visit_outer_attrs (expr); diff --git a/gcc/rust/expand/rust-expand-visitor.h b/gcc/rust/expand/rust-expand-visitor.h index c2b3e78..67c9a55 100644 --- a/gcc/rust/expand/rust-expand-visitor.h +++ b/gcc/rust/expand/rust-expand-visitor.h @@ -216,8 +216,6 @@ public: void visit (AST::ForLoopExpr &expr) override; void visit (AST::IfExpr &expr) override; void visit (AST::IfExprConseqElse &expr) override; - void visit (AST::IfExprConseqIf &expr) override; - void visit (AST::IfExprConseqIfLet &expr) override; void visit (AST::IfLetExpr &expr) override; void visit (AST::IfLetExprConseqElse &expr) override; void visit (AST::IfLetExprConseqIf &expr) override; |