aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend/rust-compile-item.h
diff options
context:
space:
mode:
authorMarc Poulhiès <dkm@kataplop.net>2022-01-15 22:43:08 +0100
committerMarc Poulhiès <dkm@kataplop.net>2022-02-25 20:37:37 +0100
commitdffb1adabd3853a8d1100e53d5fa351f8b5f180c (patch)
tree1daec8a8d99f4936805928920132a2b4be794c88 /gcc/rust/backend/rust-compile-item.h
parentb695eb8f0bae01e00dfb9e9bf2554d1b48b76a9a (diff)
downloadgcc-dffb1adabd3853a8d1100e53d5fa351f8b5f180c.zip
gcc-dffb1adabd3853a8d1100e53d5fa351f8b5f180c.tar.gz
gcc-dffb1adabd3853a8d1100e53d5fa351f8b5f180c.tar.bz2
HIR Visitor refactoring
This change split the single HIR visitor in smaller abstract ones: - Stmt - VisItem - Pattern - ExternalItem - Impl - Type - Expression Instead of providing a Base class with empty visit() methods, they are kept abstract to avoid the case where a missing visit() is silently ignored: implementors must explicitely override all visit. There is also a FullVisitor that covers all HIR nodes and also provides a Base class with empty behavior. fixes #825 Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
Diffstat (limited to 'gcc/rust/backend/rust-compile-item.h')
-rw-r--r--gcc/rust/backend/rust-compile-item.h30
1 files changed, 22 insertions, 8 deletions
diff --git a/gcc/rust/backend/rust-compile-item.h b/gcc/rust/backend/rust-compile-item.h
index 897fe85..63316b9 100644
--- a/gcc/rust/backend/rust-compile-item.h
+++ b/gcc/rust/backend/rust-compile-item.h
@@ -24,11 +24,9 @@
namespace Rust {
namespace Compile {
-class CompileItem : public HIRCompileBase
+class CompileItem : public HIRCompileBase, public HIR::HIRStmtVisitor
{
protected:
- using Rust::Compile::HIRCompileBase::visit;
-
public:
static tree compile (HIR::Item *item, Context *ctx,
TyTy::BaseType *concrete = nullptr,
@@ -46,17 +44,33 @@ public:
}
void visit (HIR::StaticItem &var) override;
-
void visit (HIR::ConstantItem &constant) override;
-
void visit (HIR::Function &function) override;
-
void visit (HIR::ImplBlock &impl_block) override;
-
void visit (HIR::ExternBlock &extern_block) override;
-
void visit (HIR::Module &module) override;
+ // Empty visit for unused Stmt HIR nodes.
+ void visit (HIR::TupleStruct &) override {}
+ void visit (HIR::EnumItem &) override {}
+ void visit (HIR::EnumItemTuple &) override {}
+ void visit (HIR::EnumItemStruct &) override {}
+ void visit (HIR::EnumItemDiscriminant &) override {}
+ void visit (HIR::TypePathSegmentFunction &) override {}
+ void visit (HIR::TypePath &) override {}
+ void visit (HIR::QualifiedPathInType &) override {}
+ void visit (HIR::ExternCrate &) override {}
+ void visit (HIR::UseDeclaration &) override {}
+ void visit (HIR::TypeAlias &) override {}
+ void visit (HIR::StructStruct &) override {}
+ void visit (HIR::Enum &) override {}
+ void visit (HIR::Union &) override {}
+ void visit (HIR::Trait &) override {}
+ void visit (HIR::EmptyStmt &) override {}
+ void visit (HIR::LetStmt &) override {}
+ void visit (HIR::ExprStmtWithoutBlock &) override {}
+ void visit (HIR::ExprStmtWithBlock &) override {}
+
protected:
CompileItem (Context *ctx, TyTy::BaseType *concrete, Location ref_locus)
: HIRCompileBase (ctx), concrete (concrete), reference (error_mark_node),