From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1643) id 62AF7386DC69; Wed, 8 Jun 2022 12:28:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 62AF7386DC69 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Thomas Schwinge To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/rust/master] privacy: reach: Rename ReachLevel enum X-Act-Checkin: gcc X-Git-Author: Arthur Cohen X-Git-Refname: refs/heads/devel/rust/master X-Git-Oldrev: 8bf037fede04cd8539add51310464f121c7af613 X-Git-Newrev: e01a8140613da2a7aeab99362c38a0e7b2e1e9e6 Message-Id: <20220608122849.62AF7386DC69@sourceware.org> Date: Wed, 8 Jun 2022 12:28:49 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Jun 2022 12:28:49 -0000 https://gcc.gnu.org/g:e01a8140613da2a7aeab99362c38a0e7b2e1e9e6 commit e01a8140613da2a7aeab99362c38a0e7b2e1e9e6 Author: Arthur Cohen Date: Tue Apr 5 12:11:34 2022 +0200 privacy: reach: Rename ReachLevel enum Diff: --- gcc/rust/privacy/rust-privacy-ctx.h | 4 ++-- gcc/rust/privacy/rust-reachability.cc | 7 +++++-- gcc/rust/privacy/rust-reachability.h | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/gcc/rust/privacy/rust-privacy-ctx.h b/gcc/rust/privacy/rust-privacy-ctx.h index 2f10fd35cc5..2a11b56f3ca 100644 --- a/gcc/rust/privacy/rust-privacy-ctx.h +++ b/gcc/rust/privacy/rust-privacy-ctx.h @@ -28,8 +28,8 @@ namespace Privacy { */ enum ReachLevel { - Private, - Public, + Unreachable, + Reachable, }; class PrivacyContext diff --git a/gcc/rust/privacy/rust-reachability.cc b/gcc/rust/privacy/rust-reachability.cc index 3d6ae824354..5cab439739c 100644 --- a/gcc/rust/privacy/rust-reachability.cc +++ b/gcc/rust/privacy/rust-reachability.cc @@ -56,16 +56,19 @@ ReachabilityVisitor::visit (HIR::TypeAlias &type_alias) void ReachabilityVisitor::visit (HIR::StructStruct &struct_item) { - auto struct_reach = ReachLevel::Private; + auto struct_reach = ReachLevel::Unreachable; // FIXME: This feels very wrong. Should we check for `has_visibility` // beforehand? Is it just private otherwise? Should the `HIR::Visibility` also // keep variants for private items? if (struct_item.get_visibility ().get_vis_type () == HIR::Visibility::NONE) - struct_reach = ReachLevel::Public; + struct_reach = ReachLevel::Reachable; // FIXME: Here we want to update only if the visibility is higher ctx.insert_reachability (struct_item.get_mappings (), struct_reach); + // FIXME: We need to also visit the fields as they might have their own set + // of reachability levels + for (auto &field : struct_item.get_fields ()) ctx.insert_reachability (field.get_mappings (), struct_reach); diff --git a/gcc/rust/privacy/rust-reachability.h b/gcc/rust/privacy/rust-reachability.h index 157ef740c73..6d8edc409cc 100644 --- a/gcc/rust/privacy/rust-reachability.h +++ b/gcc/rust/privacy/rust-reachability.h @@ -37,7 +37,7 @@ class ReachabilityVisitor : public HIR::HIRVisItemVisitor { public: ReachabilityVisitor (PrivacyContext &ctx) - : current_level (ReachLevel::Private), ctx (ctx) + : current_level (ReachLevel::Unreachable), ctx (ctx) {} virtual void visit (HIR::Module &mod);