From b4e8bc15f597e1f0e1a5dfae8081f37efaabb88c Mon Sep 17 00:00:00 2001 From: Arthur Cohen Date: Mon, 24 Jun 2024 16:50:43 +0200 Subject: gccrs: ast: PathPattern: Remove `remove_all_segments` method This method was used only for stripping PathPattern AST nodes during `cfg-strip`, which seems like a misnomer and makes it a good candidate for simplification. gcc/rust/ChangeLog: * ast/rust-path.h (class PathInExpression): Remove `remove_all_segments` method, add a `marked_for_strip` flag instead. --- gcc/rust/ast/rust-path.h | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'gcc') diff --git a/gcc/rust/ast/rust-path.h b/gcc/rust/ast/rust-path.h index b20f31c..53ccf1d 100644 --- a/gcc/rust/ast/rust-path.h +++ b/gcc/rust/ast/rust-path.h @@ -581,13 +581,6 @@ protected: * possible, and creates a SimplePath from them. */ SimplePath convert_to_simple_path (bool with_opening_scope_resolution) const; - // Removes all segments of the path. - void remove_all_segments () - { - segments.clear (); - segments.shrink_to_fit (); - } - public: /* Returns whether the path is a single segment (excluding qualified path * initial as segment). */ @@ -611,6 +604,8 @@ class PathInExpression : public PathPattern, public PathExpr location_t locus; NodeId _node_id; + bool marked_for_strip; + public: std::string as_string () const override; @@ -621,7 +616,8 @@ public: : PathPattern (std::move (path_segments)), outer_attrs (std::move (outer_attrs)), has_opening_scope_resolution (has_opening_scope_resolution), - locus (locus), _node_id (Analysis::Mappings::get ().get_next_node_id ()) + locus (locus), _node_id (Analysis::Mappings::get ().get_next_node_id ()), + marked_for_strip (false) {} // Creates an error state path in expression. @@ -650,9 +646,8 @@ public: void accept_vis (ASTVisitor &vis) override; - // Invalid if path is empty (error state), so base stripping on that. - void mark_for_strip () override { remove_all_segments (); } - bool is_marked_for_strip () const override { return is_error (); } + void mark_for_strip () override { marked_for_strip = true; } + bool is_marked_for_strip () const override { return marked_for_strip; } bool opening_scope_resolution () const { -- cgit v1.1