Line data Source code
1 : // Copyright (C) 2020-2026 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-finalized-name-resolution-context.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 4339 : Resolver::resolve (HIR::Crate &crate)
35 : {
36 4339 : PrivacyContext ctx;
37 4339 : auto &mappings = Analysis::Mappings::get ();
38 4339 : auto &resolver = Resolver2_0::FinalizedNameResolutionContext::get ();
39 4339 : auto ty_ctx = ::Rust::Resolver::TypeCheckContext::get ();
40 :
41 4339 : VisibilityResolver (mappings, resolver).go (crate);
42 4339 : PubRestrictedVisitor (mappings).go (crate);
43 4339 : PrivacyReporter (mappings, resolver, *ty_ctx).go (crate);
44 :
45 4339 : auto visitor = ReachabilityVisitor (ctx, *ty_ctx);
46 :
47 22168 : for (auto &item : crate.get_items ())
48 : {
49 17829 : if (item->get_hir_kind () == HIR::Node::VIS_ITEM)
50 : {
51 17829 : auto vis_item = static_cast<HIR::VisItem *> (item.get ());
52 17829 : vis_item->accept_vis (visitor);
53 : }
54 : }
55 :
56 4339 : if (saw_errors ())
57 10 : return;
58 4339 : }
59 : } // namespace Privacy
60 : } // namespace Rust
|