]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Adjust HIR dump for IfExpr and IfExprConseqElse
authorMarc Poulhiès <dkm@kataplop.net>
Thu, 10 Aug 2023 20:45:38 +0000 (22:45 +0200)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 18:00:29 +0000 (19:00 +0100)
Adjust the HIR dump for IfExpr and IfExprConseqElse
to use visit_field() and factor common part.

gcc/rust/ChangeLog:

* hir/rust-hir-dump.h (do_ifexpr): New.
* hir/rust-hir-dump.cc (Dump::do_ifexpr): New.
(Dump::visit): Use do_ifexpr and visit_field

Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
gcc/rust/hir/rust-hir-dump.cc
gcc/rust/hir/rust-hir-dump.h

index 012e3cd90cf97590dd4fc8ea30a6379f28ba1c37..d9aa3c11fc140dc469b84e889217407338520300 100644 (file)
@@ -322,6 +322,14 @@ Dump::do_structexprstruct (StructExprStruct &e)
   do_inner_attrs (e);
 }
 
+void
+Dump::do_ifexpr (IfExpr &e)
+{
+  do_expr (e);
+  visit_field ("condition", e.get_if_condition ());
+  visit_field ("if_block", e.get_if_block ());
+}
+
 void
 Dump::do_expr (Expr &e)
 {
@@ -1404,18 +1412,10 @@ Dump::visit (ForLoopExpr &e)
 }
 
 void
-Dump::visit (IfExpr &if_expr)
+Dump::visit (IfExpr &e)
 {
   begin ("IfExpr");
-  begin ("condition");
-
-  if_expr.vis_if_condition (*this);
-  end ("condition");
-
-  begin ("if_block");
-  if_expr.vis_if_block (*this);
-  end ("if_block");
-
+  do_ifexpr (e);
   end ("IfExpr");
 }
 
@@ -1423,18 +1423,8 @@ void
 Dump::visit (IfExprConseqElse &e)
 {
   begin ("IfExprConseqElse");
-
-  begin ("condition");
-  e.vis_if_condition (*this);
-  end ("condition");
-
-  begin ("if_block");
-  e.vis_if_block (*this);
-  end ("if_block");
-
-  begin ("else_block");
-  e.vis_else_block (*this);
-  end ("else_block");
+  do_ifexpr (e);
+  visit_field ("else_block", e.get_else_block ());
 
   end ("IfExprConseqElse");
 }
index 4026eb22ff288cddda85abb6ede57f6875076a70..660841fa02d3a4bc6c43ec5019ee2d164e385211 100644 (file)
@@ -77,6 +77,7 @@ private:
   void do_item (Item &);
   void do_type (Type &);
   void do_expr (Expr &);
+  void do_ifexpr (IfExpr &);
   void do_ifletexpr (IfLetExpr &);
   void do_pathexpr (PathExpr &);
   void do_pathpattern (PathPattern &);