From 95703bb75efc3ca0300b78ab9d3f4d544faad4b6 Mon Sep 17 00:00:00 2001 From: Philip Herron Date: Sun, 17 Sep 2023 15:08:42 +0100 Subject: gccrs: Remove HIR::ForLoopExpr This will end up getting desugared into a LoopExpr with a MatchExpr body. gcc/rust/ChangeLog: * backend/rust-compile-block.h: remove HIR::ForLoopExpr * backend/rust-compile-expr.h: likewise * checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::visit): likewise * checks/errors/privacy/rust-privacy-reporter.h: likewise * checks/errors/rust-const-checker.cc (ConstChecker::visit): likewise * checks/errors/rust-const-checker.h: likewise * checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): likewise * checks/errors/rust-unsafe-checker.h: likewise * checks/lints/rust-lint-marklive.h: likewise * hir/rust-ast-lower.cc (ASTLoweringExprWithBlock::visit): likewise * hir/rust-hir-dump.cc (Dump::visit): likewise * hir/rust-hir-dump.h: likewise * hir/tree/rust-hir-expr.h (class ForLoopExpr): likewise * hir/tree/rust-hir-full-decls.h (class ForLoopExpr): likewise * hir/tree/rust-hir-visitor.h: likewise * hir/tree/rust-hir.cc (ForLoopExpr::as_string): likewise (ForLoopExpr::accept_vis): likewise * typecheck/rust-hir-type-check-expr.h: likewise Signed-off-by: Philip Herron --- gcc/rust/hir/tree/rust-hir-expr.h | 67 --------------------------------- gcc/rust/hir/tree/rust-hir-full-decls.h | 1 - gcc/rust/hir/tree/rust-hir-visitor.h | 3 -- gcc/rust/hir/tree/rust-hir.cc | 36 ------------------ 4 files changed, 107 deletions(-) (limited to 'gcc/rust/hir/tree') diff --git a/gcc/rust/hir/tree/rust-hir-expr.h b/gcc/rust/hir/tree/rust-hir-expr.h index f0e9a36..3bfadbf 100644 --- a/gcc/rust/hir/tree/rust-hir-expr.h +++ b/gcc/rust/hir/tree/rust-hir-expr.h @@ -3092,73 +3092,6 @@ protected: } }; -// For loop expression HIR node (iterator loop) -class ForLoopExpr : public BaseLoopExpr -{ - std::unique_ptr pattern; - std::unique_ptr iterator_expr; - -public: - std::string as_string () const override; - - // Constructor with loop label - ForLoopExpr (Analysis::NodeMapping mappings, - std::unique_ptr loop_pattern, - std::unique_ptr iterator_expr, - std::unique_ptr loop_body, location_t locus, - LoopLabel loop_label, - AST::AttrVec outer_attribs = AST::AttrVec ()) - : BaseLoopExpr (std::move (mappings), std::move (loop_body), locus, - std::move (loop_label), std::move (outer_attribs)), - pattern (std::move (loop_pattern)), - iterator_expr (std::move (iterator_expr)) - {} - - // Copy constructor with clone - ForLoopExpr (ForLoopExpr const &other) - : BaseLoopExpr (other), pattern (other.pattern->clone_pattern ()), - iterator_expr (other.iterator_expr->clone_expr ()) - {} - - // Overloaded assignment operator to clone - ForLoopExpr &operator= (ForLoopExpr const &other) - { - BaseLoopExpr::operator= (other); - pattern = other.pattern->clone_pattern (); - iterator_expr = other.iterator_expr->clone_expr (); - /*loop_block = other.loop_block->clone_block_expr(); - loop_label = other.loop_label; - outer_attrs = other.outer_attrs;*/ - - return *this; - } - - // move constructors - ForLoopExpr (ForLoopExpr &&other) = default; - ForLoopExpr &operator= (ForLoopExpr &&other) = default; - - void accept_vis (HIRFullVisitor &vis) override; - void accept_vis (HIRExpressionVisitor &vis) override; - - std::unique_ptr &get_iterator_expr () { return iterator_expr; } - std::unique_ptr &get_pattern () { return pattern; }; - -protected: - /* Use covariance to implement clone function as returning this object rather - * than base */ - ForLoopExpr *clone_expr_impl () const override - { - return new ForLoopExpr (*this); - } - - /* Use covariance to implement clone function as returning this object rather - * than base */ - ForLoopExpr *clone_expr_with_block_impl () const override - { - return new ForLoopExpr (*this); - } -}; - // forward decl for IfExpr class IfLetExpr; diff --git a/gcc/rust/hir/tree/rust-hir-full-decls.h b/gcc/rust/hir/tree/rust-hir-full-decls.h index a260e7f..96293ce 100644 --- a/gcc/rust/hir/tree/rust-hir-full-decls.h +++ b/gcc/rust/hir/tree/rust-hir-full-decls.h @@ -111,7 +111,6 @@ class BaseLoopExpr; class LoopExpr; class WhileLoopExpr; class WhileLetLoopExpr; -class ForLoopExpr; class IfExpr; class IfExprConseqElse; class IfLetExpr; diff --git a/gcc/rust/hir/tree/rust-hir-visitor.h b/gcc/rust/hir/tree/rust-hir-visitor.h index 38c74f6..4e7a97b 100644 --- a/gcc/rust/hir/tree/rust-hir-visitor.h +++ b/gcc/rust/hir/tree/rust-hir-visitor.h @@ -78,7 +78,6 @@ public: virtual void visit (LoopExpr &expr) = 0; virtual void visit (WhileLoopExpr &expr) = 0; virtual void visit (WhileLetLoopExpr &expr) = 0; - virtual void visit (ForLoopExpr &expr) = 0; virtual void visit (IfExpr &expr) = 0; virtual void visit (IfExprConseqElse &expr) = 0; virtual void visit (IfLetExpr &expr) = 0; @@ -215,7 +214,6 @@ public: virtual void visit (LoopExpr &) override {} virtual void visit (WhileLoopExpr &) override {} virtual void visit (WhileLetLoopExpr &) override {} - virtual void visit (ForLoopExpr &) override {} virtual void visit (IfExpr &) override {} virtual void visit (IfExprConseqElse &) override {} virtual void visit (IfLetExpr &) override {} @@ -442,7 +440,6 @@ public: virtual void visit (LoopExpr &expr) = 0; virtual void visit (WhileLoopExpr &expr) = 0; virtual void visit (WhileLetLoopExpr &expr) = 0; - virtual void visit (ForLoopExpr &expr) = 0; virtual void visit (IfExpr &expr) = 0; virtual void visit (IfExprConseqElse &expr) = 0; virtual void visit (IfLetExpr &expr) = 0; diff --git a/gcc/rust/hir/tree/rust-hir.cc b/gcc/rust/hir/tree/rust-hir.cc index ac1ae63..a3d6e1e 100644 --- a/gcc/rust/hir/tree/rust-hir.cc +++ b/gcc/rust/hir/tree/rust-hir.cc @@ -2290,30 +2290,6 @@ GenericArgsBinding::as_string () const } std::string -ForLoopExpr::as_string () const -{ - std::string str ("ForLoopExpr: "); - - str += "\n Label: "; - if (!has_loop_label ()) - { - str += "none"; - } - else - { - str += loop_label.as_string (); - } - - str += "\n Pattern: " + pattern->as_string (); - - str += "\n Iterator expr: " + iterator_expr->as_string (); - - str += "\n Loop block: " + loop_block->as_string (); - - return str; -} - -std::string RangePattern::as_string () const { if (has_ellipsis_syntax) @@ -4093,12 +4069,6 @@ WhileLetLoopExpr::accept_vis (HIRFullVisitor &vis) } void -ForLoopExpr::accept_vis (HIRFullVisitor &vis) -{ - vis.visit (*this); -} - -void IfExpr::accept_vis (HIRFullVisitor &vis) { vis.visit (*this); @@ -4783,12 +4753,6 @@ RangePattern::accept_vis (HIRPatternVisitor &vis) } void -ForLoopExpr::accept_vis (HIRExpressionVisitor &vis) -{ - vis.visit (*this); -} - -void TypePath::accept_vis (HIRTypeVisitor &vis) { vis.visit (*this); -- cgit v1.1