diff options
author | Marc Poulhiès <dkm@kataplop.net> | 2024-06-30 23:11:17 +0200 |
---|---|---|
committer | CohenArthur <arthur.cohen@embecosm.com> | 2024-07-15 12:05:54 +0000 |
commit | e2b6a02937c23fe28c895b935a8e12c206e7ec70 (patch) | |
tree | 93c044225e4225b1bfb182dfad6234a594573c8e /gcc/rust/hir/rust-hir-dump.cc | |
parent | d67405831843e84a419be52743fe8bf43dc9d9ae (diff) | |
download | gcc-e2b6a02937c23fe28c895b935a8e12c206e7ec70.zip gcc-e2b6a02937c23fe28c895b935a8e12c206e7ec70.tar.gz gcc-e2b6a02937c23fe28c895b935a8e12c206e7ec70.tar.bz2 |
rust: fix HIR dump for MatchExpr
The visitor was still using the as_string() method.
gcc/rust/ChangeLog:
* hir/rust-hir-dump.cc (Dump::do_matcharm): New.
(Dump::do_matchcase): New.
(Dump::visit(MatchExpr)): Adjust, don't use as_string.
* hir/rust-hir-dump.h (Dump::do_matcharm, Dump::do_matchcase): New.
Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
Diffstat (limited to 'gcc/rust/hir/rust-hir-dump.cc')
-rw-r--r-- | gcc/rust/hir/rust-hir-dump.cc | 43 |
1 files changed, 36 insertions, 7 deletions
diff --git a/gcc/rust/hir/rust-hir-dump.cc b/gcc/rust/hir/rust-hir-dump.cc index bcacc8d..57500e4 100644 --- a/gcc/rust/hir/rust-hir-dump.cc +++ b/gcc/rust/hir/rust-hir-dump.cc @@ -353,6 +353,31 @@ Dump::do_expr (Expr &e) } void +Dump::do_matcharm (MatchArm &e) +{ + begin ("MatchArm"); + // FIXME Can't remember how to handle that. Let's see later. + // do_outer_attrs(e); + visit_collection ("match_arm_patterns", e.get_patterns ()); + visit_field ("guard_expr", e.get_guard_expr ()); + end ("MatchArm"); +} + +void +Dump::do_matchcase (HIR::MatchCase &e) +{ + begin ("MatchCase"); + + begin_field ("arm"); + do_matcharm (e.get_arm ()); + end_field ("arm"); + + visit_field ("expr", e.get_expr ()); + + end ("MatchCase"); +} + +void Dump::do_pathexpr (PathExpr &e) { do_expr (e); @@ -1437,16 +1462,20 @@ Dump::visit (MatchExpr &e) begin ("MatchExpr"); do_inner_attrs (e); do_expr (e); + visit_field ("branch_value", e.get_scrutinee_expr ()); - std::string str; - if (e.get_match_cases ().empty ()) - str = "none"; + if (!e.has_match_arms ()) + { + put_field ("match_arms", "empty"); + } else - for (const auto &arm : e.get_match_cases ()) - str += "\n " + arm.as_string (); - put_field ("match_arms", str); - + { + begin_field ("match_arms"); + for (auto &arm : e.get_match_cases ()) + do_matchcase (arm); + end_field ("match_arms"); + } end ("MatchExpr"); } |