Skip to content

Commit 5712d7d

Browse files
dkmphilberty
authored andcommitted
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 <[email protected]>
1 parent e55113e commit 5712d7d

File tree

2 files changed

+13
-22
lines changed

2 files changed

+13
-22
lines changed

gcc/rust/hir/rust-hir-dump.cc

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,14 @@ Dump::do_structexprstruct (StructExprStruct &e)
322322
do_inner_attrs (e);
323323
}
324324

325+
void
326+
Dump::do_ifexpr (IfExpr &e)
327+
{
328+
do_expr (e);
329+
visit_field ("condition", e.get_if_condition ());
330+
visit_field ("if_block", e.get_if_block ());
331+
}
332+
325333
void
326334
Dump::do_expr (Expr &e)
327335
{
@@ -1404,37 +1412,19 @@ Dump::visit (ForLoopExpr &e)
14041412
}
14051413

14061414
void
1407-
Dump::visit (IfExpr &if_expr)
1415+
Dump::visit (IfExpr &e)
14081416
{
14091417
begin ("IfExpr");
1410-
begin ("condition");
1411-
1412-
if_expr.vis_if_condition (*this);
1413-
end ("condition");
1414-
1415-
begin ("if_block");
1416-
if_expr.vis_if_block (*this);
1417-
end ("if_block");
1418-
1418+
do_ifexpr (e);
14191419
end ("IfExpr");
14201420
}
14211421

14221422
void
14231423
Dump::visit (IfExprConseqElse &e)
14241424
{
14251425
begin ("IfExprConseqElse");
1426-
1427-
begin ("condition");
1428-
e.vis_if_condition (*this);
1429-
end ("condition");
1430-
1431-
begin ("if_block");
1432-
e.vis_if_block (*this);
1433-
end ("if_block");
1434-
1435-
begin ("else_block");
1436-
e.vis_else_block (*this);
1437-
end ("else_block");
1426+
do_ifexpr (e);
1427+
visit_field ("else_block", e.get_else_block ());
14381428

14391429
end ("IfExprConseqElse");
14401430
}

gcc/rust/hir/rust-hir-dump.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ class Dump : public HIRFullVisitor
7777
void do_item (Item &);
7878
void do_type (Type &);
7979
void do_expr (Expr &);
80+
void do_ifexpr (IfExpr &);
8081
void do_ifletexpr (IfLetExpr &);
8182
void do_pathexpr (PathExpr &);
8283
void do_pathpattern (PathPattern &);

0 commit comments

Comments
 (0)