aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend/rust-compile-stmt.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-stmt.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-stmt.h')
-rw-r--r--gcc/rust/backend/rust-compile-stmt.h28
1 files changed, 25 insertions, 3 deletions
diff --git a/gcc/rust/backend/rust-compile-stmt.h b/gcc/rust/backend/rust-compile-stmt.h
index 24a2084..2dfb520 100644
--- a/gcc/rust/backend/rust-compile-stmt.h
+++ b/gcc/rust/backend/rust-compile-stmt.h
@@ -26,10 +26,8 @@
namespace Rust {
namespace Compile {
-class CompileStmt : public HIRCompileBase
+class CompileStmt : public HIRCompileBase, public HIR::HIRStmtVisitor
{
- using Rust::Compile::HIRCompileBase::visit;
-
public:
static tree Compile (HIR::Stmt *stmt, Context *ctx)
{
@@ -103,6 +101,30 @@ public:
}
}
+ // 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::Module &) override {}
+ void visit (HIR::ExternCrate &) override {}
+ void visit (HIR::UseDeclaration &) override {}
+ void visit (HIR::Function &) override {}
+ void visit (HIR::TypeAlias &) override {}
+ void visit (HIR::StructStruct &) override {}
+ void visit (HIR::Enum &) override {}
+ void visit (HIR::Union &) override {}
+ void visit (HIR::ConstantItem &) override {}
+ void visit (HIR::StaticItem &) override {}
+ void visit (HIR::Trait &) override {}
+ void visit (HIR::ImplBlock &) override {}
+ void visit (HIR::ExternBlock &) override {}
+ void visit (HIR::EmptyStmt &) override {}
+
private:
CompileStmt (Context *ctx) : HIRCompileBase (ctx), translated (nullptr) {}