aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2024-09-05 13:37:51 +0200
committerP-E-P <32375388+P-E-P@users.noreply.github.com>2024-09-26 22:48:32 +0000
commit468d24b5d916d6fff90c4795a40f980fcfbc2f58 (patch)
tree8d24ba4364ff24273c461e047edf8e7290f516d2 /gcc
parenta01ac121a33d18040f3b03e1772431a745ca34ba (diff)
downloadgcc-468d24b5d916d6fff90c4795a40f980fcfbc2f58.zip
gcc-468d24b5d916d6fff90c4795a40f980fcfbc2f58.tar.gz
gcc-468d24b5d916d6fff90c4795a40f980fcfbc2f58.tar.bz2
Remove regular visit code
Regular visit code can be replaced with default visit functions. gcc/rust/ChangeLog: * resolve/rust-default-resolver.cc (DefaultResolver::visit): Remove default visit code and replace it with call to default visitor. * resolve/rust-default-resolver.h: Remove removed function's prototypes. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/resolve/rust-default-resolver.cc118
-rw-r--r--gcc/rust/resolve/rust-default-resolver.h8
2 files changed, 3 insertions, 123 deletions
diff --git a/gcc/rust/resolve/rust-default-resolver.cc b/gcc/rust/resolve/rust-default-resolver.cc
index 84099d0..a8bd6de 100644
--- a/gcc/rust/resolve/rust-default-resolver.cc
+++ b/gcc/rust/resolve/rust-default-resolver.cc
@@ -170,17 +170,7 @@ DefaultResolver::visit (AST::ClosureExprInner &expr)
if (expr.is_marked_for_strip ())
return;
- for (auto &param : expr.get_params ())
- {
- if (param.is_error ())
- continue;
-
- param.get_pattern ().accept_vis (*this);
- if (param.has_type_given ())
- param.get_type ().accept_vis (*this);
- }
-
- expr.get_definition_expr ().accept_vis (*this);
+ AST::DefaultASTVisitor::visit (expr);
}
void
@@ -189,63 +179,7 @@ DefaultResolver::visit (AST::ClosureExprInnerTyped &expr)
if (expr.is_marked_for_strip ())
return;
- for (auto &param : expr.get_params ())
- {
- if (param.is_error ())
- continue;
-
- param.get_pattern ().accept_vis (*this);
- if (param.has_type_given ())
- param.get_type ().accept_vis (*this);
- }
-
- expr.get_definition_block ().accept_vis (*this);
- expr.get_return_type ().accept_vis (*this);
-}
-
-void
-DefaultResolver::visit (AST::CallExpr &expr)
-{
- expr.get_function_expr ().accept_vis (*this);
-
- for (auto &param : expr.get_params ())
- param->accept_vis (*this);
-}
-
-void
-DefaultResolver::visit (AST::MethodCallExpr &expr)
-{
- expr.get_receiver_expr ().accept_vis (*this);
-
- if (expr.get_method_name ().has_generic_args ())
- {
- auto &args = expr.get_method_name ().get_generic_args ();
- for (auto &arg : args.get_generic_args ())
- arg.accept_vis (*this);
- for (auto &arg : args.get_binding_args ())
- if (!arg.is_error ())
- arg.get_type ().accept_vis (*this);
- for (auto &arg : args.get_lifetime_args ())
- arg.accept_vis (*this);
- }
-
- for (auto &param : expr.get_params ())
- param->accept_vis (*this);
-}
-
-void
-DefaultResolver::visit (AST::IfExpr &expr)
-{
- expr.get_condition_expr ().accept_vis (*this);
- expr.get_if_block ().accept_vis (*this);
-}
-
-void
-DefaultResolver::visit (AST::IfExprConseqElse &expr)
-{
- expr.get_condition_expr ().accept_vis (*this);
- expr.get_if_block ().accept_vis (*this);
- expr.get_else_block ().accept_vis (*this);
+ AST::DefaultASTVisitor::visit (expr);
}
void
@@ -254,53 +188,7 @@ DefaultResolver::visit (AST::MatchExpr &expr)
if (expr.is_marked_for_strip ())
return;
- expr.get_scrutinee_expr ().accept_vis (*this);
- for (auto &arm : expr.get_match_cases ())
- {
- arm.get_expr ().accept_vis (*this);
- for (auto &pat : arm.get_arm ().get_patterns ())
- pat->accept_vis (*this);
- if (arm.get_arm ().has_match_arm_guard ())
- arm.get_arm ().get_guard_expr ().accept_vis (*this);
- }
-}
-
-void
-DefaultResolver::visit (AST::PathInExpression &expr)
-{
- for (auto &seg : expr.get_segments ())
- if (seg.has_generic_args ())
- {
- auto &args = seg.get_generic_args ();
- for (auto &arg : args.get_generic_args ())
- arg.accept_vis (*this);
- for (auto &arg : args.get_binding_args ())
- if (!arg.is_error ())
- arg.get_type ().accept_vis (*this);
- for (auto &arg : args.get_lifetime_args ())
- arg.accept_vis (*this);
- }
-}
-
-void
-DefaultResolver::visit (AST::EnumItemTuple &item)
-{
- for (auto &field : item.get_tuple_fields ())
- field.get_field_type ().accept_vis (*this);
-}
-
-void
-DefaultResolver::visit (AST::EnumItemStruct &item)
-{
- for (auto &field : item.get_struct_fields ())
- field.get_field_type ().accept_vis (*this);
-}
-
-void
-DefaultResolver::visit (AST::EnumItemDiscriminant &item)
-{
- if (item.has_expr ())
- item.get_expr ().accept_vis (*this);
+ AST::DefaultASTVisitor::visit (expr);
}
void
diff --git a/gcc/rust/resolve/rust-default-resolver.h b/gcc/rust/resolve/rust-default-resolver.h
index 9096f9c..21e67d8 100644
--- a/gcc/rust/resolve/rust-default-resolver.h
+++ b/gcc/rust/resolve/rust-default-resolver.h
@@ -57,17 +57,9 @@ public:
// Visitors that visit their expression node(s)
void visit (AST::ClosureExprInner &) override;
void visit (AST::ClosureExprInnerTyped &) override;
- void visit (AST::CallExpr &) override;
- void visit (AST::MethodCallExpr &) override;
- void visit (AST::IfExpr &) override;
- void visit (AST::IfExprConseqElse &) override;
void visit (AST::MatchExpr &) override;
// Leaf visitors, which do nothing by default
- void visit (AST::PathInExpression &) override;
- void visit (AST::EnumItemTuple &) override;
- void visit (AST::EnumItemStruct &) override;
- void visit (AST::EnumItemDiscriminant &) override;
void visit (AST::ConstantItem &) override;
void visit (AST::StaticItem &) override;