[gcc r14-7910] gccrs: Adjust HIR dump for IfExpr and IfExprConseqElse
Arthur Cohen
cohenarthur@gcc.gnu.org
Tue Jan 16 18:06:33 GMT 2024
https://gcc.gnu.org/g:fa6bba6f220882a29b7a9e020c49043a3a7e869b
commit r14-7910-gfa6bba6f220882a29b7a9e020c49043a3a7e869b
Author: Marc Poulhiès <dkm@kataplop.net>
Date: Thu Aug 10 22:45:38 2023 +0200
gccrs: Adjust HIR dump for IfExpr and IfExprConseqElse
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>
Diff:
---
gcc/rust/hir/rust-hir-dump.cc | 34 ++++++++++++----------------------
gcc/rust/hir/rust-hir-dump.h | 1 +
2 files changed, 13 insertions(+), 22 deletions(-)
diff --git a/gcc/rust/hir/rust-hir-dump.cc b/gcc/rust/hir/rust-hir-dump.cc
index 012e3cd90cf..d9aa3c11fc1 100644
--- a/gcc/rust/hir/rust-hir-dump.cc
+++ b/gcc/rust/hir/rust-hir-dump.cc
@@ -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");
}
diff --git a/gcc/rust/hir/rust-hir-dump.h b/gcc/rust/hir/rust-hir-dump.h
index 4026eb22ff2..660841fa02d 100644
--- a/gcc/rust/hir/rust-hir-dump.h
+++ b/gcc/rust/hir/rust-hir-dump.h
@@ -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 &);
More information about the Gcc-cvs
mailing list