LCOV - code coverage report
Current view: top level - gcc/rust/checks/errors/privacy - rust-privacy-ctx.h Coverage Total Hit
Test: gcc.info Lines: 100.0 % 1 1
Test Date: 2026-02-28 14:20:25 Functions: - 0 0
Legend: Lines:     hit not hit

            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              : #ifndef RUST_PRIVACY_CTX_H
      20              : #define RUST_PRIVACY_CTX_H
      21              : 
      22              : #include "rust-hir-map.h"
      23              : #include "rust-privacy-check.h"
      24              : 
      25              : namespace Rust {
      26              : namespace Privacy {
      27              : 
      28              : /**
      29              :  * Reachability levels of HIR nodes. These levels are computed through the
      30              :  * `ReachabilityVisitor` visitor.
      31              :  */
      32              : enum ReachLevel
      33              : {
      34              :   Unreachable,
      35              :   Reachable,
      36              : };
      37              : 
      38         8244 : class PrivacyContext
      39              : {
      40              : public:
      41              :   /**
      42              :    * Insert a new resolved visibility for a given node. If the node is already
      43              :    * present in the reachability map, then its visibility will only be updated
      44              :    * if the given visibility is higher.
      45              :    *
      46              :    * @param mappings Mappings of the node to store the reach level for
      47              :    * @param reach Level of reachability for the given node
      48              :    *
      49              :    * @return The new reachability level for this node. If this was the first
      50              :    * time inserting this node, then return `reach`. Otherwise, return `reach` or
      51              :    * the existing reach level if it was higher.
      52              :    */
      53              :   ReachLevel update_reachability (const Analysis::NodeMapping &mapping,
      54              :                                   ReachLevel reach);
      55              : 
      56              :   /**
      57              :    * Lookup the visibility of an already declared Node
      58              :    *
      59              :    * @param mapping Mappings of the node to fetch the reach level of
      60              :    *
      61              :    * @return `nullptr` if the reach level for the current node has not been
      62              :    * added, a valid pointer otherwise
      63              :    */
      64              :   const ReachLevel *lookup_reachability (const Analysis::NodeMapping &mapping);
      65              : 
      66              : private:
      67              :   std::unordered_map<DefId, ReachLevel> reachability_map;
      68              : };
      69              : } // namespace Privacy
      70              : } // namespace Rust
      71              : 
      72              : #if CHECKING_P
      73              : namespace selftest {
      74              : void rust_privacy_ctx_test (void);
      75              : }
      76              : #endif // !CHECKING_P
      77              : 
      78              : #endif // !RUST_PRIVACY_CTX_H
        

Generated by: LCOV version 2.4-beta

LCOV profile is generated on x86_64 machine using following configure options: configure --disable-bootstrap --enable-coverage=opt --enable-languages=c,c++,fortran,go,jit,lto,rust,m2 --enable-host-shared. GCC test suite is run with the built compiler.