Branch data Line data Source code
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 saw_errors (void);
29 : :
30 : : namespace Rust {
31 : : namespace Privacy {
32 : :
33 : : void
34 : 3953 : Resolver::resolve (HIR::Crate &crate)
35 : : {
36 : 3953 : PrivacyContext ctx;
37 : 3953 : auto &mappings = Analysis::Mappings::get ();
38 : 3953 : auto resolver = Rust::Resolver::Resolver::get ();
39 : 3953 : auto ty_ctx = ::Rust::Resolver::TypeCheckContext::get ();
40 : :
41 : 3953 : VisibilityResolver (mappings, *resolver).go (crate);
42 : 3953 : PubRestrictedVisitor (mappings).go (crate);
43 : 3953 : PrivacyReporter (mappings, *resolver, *ty_ctx).go (crate);
44 : :
45 : 3953 : auto visitor = ReachabilityVisitor (ctx, *ty_ctx);
46 : :
47 : 20535 : for (auto &item : crate.get_items ())
48 : : {
49 : 16582 : if (item->get_hir_kind () == HIR::Node::VIS_ITEM)
50 : : {
51 : 16582 : auto vis_item = static_cast<HIR::VisItem *> (item.get ());
52 : 16582 : vis_item->accept_vis (visitor);
53 : : }
54 : : }
55 : :
56 : 3953 : if (saw_errors ())
57 : 10 : return;
58 : 3953 : }
59 : : } // namespace Privacy
60 : : } // namespace Rust
|