aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/ast/rust-pattern.h
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2021-08-26 01:36:09 +0200
committerMark Wielaard <mark@klomp.org>2021-08-26 21:03:20 +0200
commitf9e5e530391d9a98b7c965b79bebf305d2630ad7 (patch)
tree5b21a3e1a29b6df29649ea993cb79434fe86d906 /gcc/rust/ast/rust-pattern.h
parent40042ce11fc5d7f62e31be99e82bf6a0db83234a (diff)
downloadgcc-f9e5e530391d9a98b7c965b79bebf305d2630ad7.zip
gcc-f9e5e530391d9a98b7c965b79bebf305d2630ad7.tar.gz
gcc-f9e5e530391d9a98b7c965b79bebf305d2630ad7.tar.bz2
Get rid of get_locus_slow
In various places there was the following hack: /* HACK: slow way of getting location from base expression through virtual methods. */ virtual Location get_locus_slow () const { return Location (); } The problem with get_locus_slow () is that if a subclass didn't override it then there was no real location. get_locus_slow was missing for Module, ExternCrate, UseDeclaration, Function, TypeAlias, StructStruct, TupleStruct, Enum, Union, ConstantItem, StaticItem, Trait, ImplBlock, ExternBlock, EmptyStmt, ExprStmtWithoutBlock and ExprStmtWithBlock. All do have a get_locus () function. Simply replace the get_locus_slow virtual method with a real virtual Location get_locus () const = 0 method so we know if something really doesn't have a location. This was only the case for MacroRulesDefinition.
Diffstat (limited to 'gcc/rust/ast/rust-pattern.h')
-rw-r--r--gcc/rust/ast/rust-pattern.h26
1 files changed, 8 insertions, 18 deletions
diff --git a/gcc/rust/ast/rust-pattern.h b/gcc/rust/ast/rust-pattern.h
index 049aaf0..7fd1fa5 100644
--- a/gcc/rust/ast/rust-pattern.h
+++ b/gcc/rust/ast/rust-pattern.h
@@ -51,8 +51,7 @@ public:
has_minus (has_minus), locus (locus)
{}
- Location get_locus () const { return locus; }
- Location get_locus_slow () const final override { return get_locus (); }
+ Location get_locus () const override final { return locus; }
void accept_vis (ASTVisitor &vis) override;
@@ -134,8 +133,7 @@ public:
IdentifierPattern (IdentifierPattern &&other) = default;
IdentifierPattern &operator= (IdentifierPattern &&other) = default;
- Location get_locus () const { return locus; }
- Location get_locus_slow () const final override { return get_locus (); }
+ Location get_locus () const override final { return locus; }
void accept_vis (ASTVisitor &vis) override;
@@ -170,8 +168,7 @@ public:
WildcardPattern (Location locus) : locus (locus) {}
- Location get_locus () const { return locus; }
- Location get_locus_slow () const final override { return get_locus (); }
+ Location get_locus () const override final { return locus; }
void accept_vis (ASTVisitor &vis) override;
@@ -347,8 +344,7 @@ public:
RangePattern (RangePattern &&other) = default;
RangePattern &operator= (RangePattern &&other) = default;
- Location get_locus () const { return locus; }
- Location get_locus_slow () const final override { return get_locus (); }
+ Location get_locus () const override final { return locus; }
void accept_vis (ASTVisitor &vis) override;
@@ -412,8 +408,7 @@ public:
ReferencePattern (ReferencePattern &&other) = default;
ReferencePattern &operator= (ReferencePattern &&other) = default;
- Location get_locus () const { return locus; }
- Location get_locus_slow () const final override { return get_locus (); }
+ Location get_locus () const override final { return locus; }
void accept_vis (ASTVisitor &vis) override;
@@ -806,7 +801,6 @@ public:
bool has_struct_pattern_elems () const { return !elems.is_empty (); }
Location get_locus () const { return path.get_locus (); }
- Location get_locus_slow () const final override { return get_locus (); }
void accept_vis (ASTVisitor &vis) override;
@@ -1028,7 +1022,6 @@ public:
TupleStructPattern &operator= (TupleStructPattern &&other) = default;
Location get_locus () const { return path.get_locus (); }
- Location get_locus_slow () const final override { return get_locus (); }
void accept_vis (ASTVisitor &vis) override;
@@ -1280,8 +1273,7 @@ public:
return *this;
}
- Location get_locus () const { return locus; }
- Location get_locus_slow () const final override { return get_locus (); }
+ Location get_locus () const override final { return locus; }
void accept_vis (ASTVisitor &vis) override;
@@ -1336,8 +1328,7 @@ public:
GroupedPattern (GroupedPattern &&other) = default;
GroupedPattern &operator= (GroupedPattern &&other) = default;
- Location get_locus () const { return locus; }
- Location get_locus_slow () const final override { return get_locus (); }
+ Location get_locus () const override final { return locus; }
void accept_vis (ASTVisitor &vis) override;
@@ -1394,8 +1385,7 @@ public:
SlicePattern (SlicePattern &&other) = default;
SlicePattern &operator= (SlicePattern &&other) = default;
- Location get_locus () const { return locus; }
- Location get_locus_slow () const final override { return get_locus (); }
+ Location get_locus () const override final { return locus; }
void accept_vis (ASTVisitor &vis) override;