diff options
author | Arthur Cohen <arthur.cohen@embecosm.com> | 2022-04-08 11:43:50 +0200 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2022-04-12 15:26:11 +0200 |
commit | a376e1939e5ced1fc457d6a35c64c5f75d3da976 (patch) | |
tree | 8bb54730d2c2bfef18d21674e8725090c72453b8 | |
parent | be8f2ead95b292615d1c27f7c486384d32a70c49 (diff) | |
download | gcc-a376e1939e5ced1fc457d6a35c64c5f75d3da976.zip gcc-a376e1939e5ced1fc457d6a35c64c5f75d3da976.tar.gz gcc-a376e1939e5ced1fc457d6a35c64c5f75d3da976.tar.bz2 |
hir: Keep BaseKind enum inside the Node class
Co-authored-by: philberty <philip.herron@embecosm.com>
-rw-r--r-- | gcc/rust/hir/tree/rust-hir.h | 48 | ||||
-rw-r--r-- | gcc/rust/privacy/rust-privacy-check.cc | 2 | ||||
-rw-r--r-- | gcc/rust/privacy/rust-privacy-ctx.cc | 1 | ||||
-rw-r--r-- | gcc/rust/privacy/rust-reachability.cc | 2 |
4 files changed, 27 insertions, 26 deletions
diff --git a/gcc/rust/hir/tree/rust-hir.h b/gcc/rust/hir/tree/rust-hir.h index e2c930e..67cfb3a 100644 --- a/gcc/rust/hir/tree/rust-hir.h +++ b/gcc/rust/hir/tree/rust-hir.h @@ -45,33 +45,33 @@ class HIRTypeVisitor; // forward decl for use in token tree method class Token; -// Kind for downcasting various HIR nodes to other base classes when visiting -// them -enum BaseKind -{ - /* class ExternalItem */ - EXTERNAL, - /* class TraitItem */ - TRAIT_ITEM, - /* class VisItem */ - VIS_ITEM, - /* class Item */ - ITEM, - /* class ImplItem */ - IMPL, - /* class Type */ - TYPE, - /* class Stmt */ - STMT, - /* class Expr */ - EXPR, - /* class Pattern */ - PATTERN, -}; - class Node { public: + // Kind for downcasting various HIR nodes to other base classes when visiting + // them + enum BaseKind + { + /* class ExternalItem */ + EXTERNAL, + /* class TraitItem */ + TRAIT_ITEM, + /* class VisItem */ + VIS_ITEM, + /* class Item */ + ITEM, + /* class ImplItem */ + IMPL, + /* class Type */ + TYPE, + /* class Stmt */ + STMT, + /* class Expr */ + EXPR, + /* class Pattern */ + PATTERN, + }; + /** * Get the kind of HIR node we are dealing with. This is useful for * downcasting to more precise types when necessary, i.e going from an `Item*` diff --git a/gcc/rust/privacy/rust-privacy-check.cc b/gcc/rust/privacy/rust-privacy-check.cc index cbacb6d..d52d8e1 100644 --- a/gcc/rust/privacy/rust-privacy-check.cc +++ b/gcc/rust/privacy/rust-privacy-check.cc @@ -33,7 +33,7 @@ Resolver::resolve (HIR::Crate &crate) const auto &items = crate.items; for (auto &item : items) { - if (item->get_hir_kind () == HIR::VIS_ITEM) + if (item->get_hir_kind () == HIR::Node::VIS_ITEM) { auto vis_item = static_cast<HIR::VisItem *> (item.get ()); vis_item->accept_vis (visitor); diff --git a/gcc/rust/privacy/rust-privacy-ctx.cc b/gcc/rust/privacy/rust-privacy-ctx.cc index 3a44ce0..629944a 100644 --- a/gcc/rust/privacy/rust-privacy-ctx.cc +++ b/gcc/rust/privacy/rust-privacy-ctx.cc @@ -21,6 +21,7 @@ namespace Rust { namespace Privacy { + static ReachLevel insert_if_higher (ReachLevel new_level, std::unordered_map<HirId, ReachLevel>::iterator &existing) diff --git a/gcc/rust/privacy/rust-reachability.cc b/gcc/rust/privacy/rust-reachability.cc index ade026f..e76ba71 100644 --- a/gcc/rust/privacy/rust-reachability.cc +++ b/gcc/rust/privacy/rust-reachability.cc @@ -24,7 +24,7 @@ namespace Privacy { static HIR::VisItem * maybe_get_vis_item (std::unique_ptr<HIR::Item> &item) { - if (item->get_hir_kind () != HIR::VIS_ITEM) + if (item->get_hir_kind () != HIR::Node::VIS_ITEM) return nullptr; return static_cast<HIR::VisItem *> (item.get ()); |