aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorArthur Cohen <arthur.cohen@embecosm.com>2024-06-24 16:50:43 +0200
committerArthur Cohen <arthur.cohen@embecosm.com>2025-03-19 15:32:04 +0100
commitb4e8bc15f597e1f0e1a5dfae8081f37efaabb88c (patch)
treee5ce457d690bf338b4ed1264dd260edaf3fed7cd /gcc
parentbc2331a565d8005b91495df627f3fa72870770cc (diff)
downloadgcc-b4e8bc15f597e1f0e1a5dfae8081f37efaabb88c.zip
gcc-b4e8bc15f597e1f0e1a5dfae8081f37efaabb88c.tar.gz
gcc-b4e8bc15f597e1f0e1a5dfae8081f37efaabb88c.tar.bz2
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/ast/rust-path.h17
1 files changed, 6 insertions, 11 deletions
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
{