| 1 |
// Copyright (C) 2020-2025 Free Software Foundation, Inc. |
| 2 |
|
| 3 |
// This file is part of GCC. |
| 4 |
|
| 5 |
// GCC is free software; you can redistribute it and/or modify it under |
| 6 |
// the terms of the GNU General Public License as published by the Free |
| 7 |
// Software Foundation; either version 3, or (at your option) any later |
| 8 |
// version. |
| 9 |
|
| 10 |
// GCC is distributed in the hope that it will be useful, but WITHOUT ANY |
| 11 |
// WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 12 |
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 13 |
// for more details. |
| 14 |
|
| 15 |
// You should have received a copy of the GNU General Public License |
| 16 |
// along with GCC; see the file COPYING3. If not see |
| 17 |
// <http://www.gnu.org/licenses/>. |
| 18 |
|
| 19 |
#include "rust-privacy-check.h" |
| 20 |
#include "rust-reachability.h" |
| 21 |
#include "rust-hir-type-check.h" |
| 22 |
#include "rust-hir-map.h" |
| 23 |
#include "rust-name-resolver.h" |
| 24 |
#include "rust-visibility-resolver.h" |
| 25 |
#include "rust-pub-restricted-visitor.h" |
| 26 |
#include "rust-privacy-reporter.h" |
| 27 |
|
| 28 |
extern bool |
| 29 |
saw_errors (void); |
| 30 |
|
| 31 |
namespace Rust { |
| 32 |
namespace Privacy { |
| 33 |
|
| 34 |
void |
| 35 |
Resolver::resolve (HIR::Crate &crate) |
| 36 |
{ |
| 37 |
PrivacyContext ctx; |
| 38 |
auto &mappings = Analysis::Mappings::get (); |
| 39 |
auto resolver = Rust::Resolver::Resolver::get (); |
| 40 |
auto ty_ctx = ::Rust::Resolver::TypeCheckContext::get (); |
| 41 |
|
| 42 |
VisibilityResolver (mappings, *resolver).go (crate); |
| 43 |
PubRestrictedVisitor (mappings).go (crate); |
| 44 |
PrivacyReporter (mappings, *resolver, *ty_ctx).go (crate); |
| 45 |
|
| 46 |
auto visitor = ReachabilityVisitor (ctx, *ty_ctx); |
| 47 |
|
| 48 |
for (auto &item : crate.get_items ()) |
| 49 |
{ |
| 50 |
if (item->get_hir_kind () == HIR::Node::VIS_ITEM) |
| 51 |
{ |
| 52 |
auto vis_item = static_cast<HIR::VisItem *> (item.get ()); |
| 53 |
vis_item->accept_vis (visitor); |
| 54 |
} |
| 55 |
} |
| 56 |
|
| 57 |
if (saw_errors ()) |
| 58 |
return; |
| 59 |
} |
| 60 |
} // namespace Privacy |
| 61 |
} // namespace Rust |