diff options
author | Mark Wielaard <mark@klomp.org> | 2021-08-26 01:36:09 +0200 |
---|---|---|
committer | Mark Wielaard <mark@klomp.org> | 2021-08-26 21:03:20 +0200 |
commit | f9e5e530391d9a98b7c965b79bebf305d2630ad7 (patch) | |
tree | 5b21a3e1a29b6df29649ea993cb79434fe86d906 /gcc/rust/ast/rust-path.h | |
parent | 40042ce11fc5d7f62e31be99e82bf6a0db83234a (diff) | |
download | gcc-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-path.h')
-rw-r--r-- | gcc/rust/ast/rust-path.h | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/gcc/rust/ast/rust-path.h b/gcc/rust/ast/rust-path.h index 74ea795..c042a8f 100644 --- a/gcc/rust/ast/rust-path.h +++ b/gcc/rust/ast/rust-path.h @@ -357,8 +357,7 @@ public: return convert_to_simple_path (has_opening_scope_resolution); } - 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; @@ -740,8 +739,7 @@ public: // Creates a trait bound with a clone of this type path as its only element. TraitBound *to_trait_bound (bool in_parens) const override; - 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; @@ -885,8 +883,7 @@ public: {}, Location ()); } - 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; @@ -1023,8 +1020,7 @@ public: return segments; } - Location get_locus () const { return locus; } - Location get_locus_slow () const final override { return get_locus (); } + Location get_locus () const override final { return locus; } }; } // namespace AST } // namespace Rust |