LCOV - code coverage report
Current view: top level - gcc/rust/hir/tree - rust-hir-visibility.h (source / functions) Coverage Total Hit
Test: gcc.info Lines: 81.8 % 11 9
Test Date: 2025-06-21 16:26:05 Functions: 50.0 % 2 1
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : // Copyright (C) 2020-2024 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_HIR_VISIBILITY_H
      20                 :             : #define RUST_HIR_VISIBILITY_H
      21                 :             : 
      22                 :             : #include "rust-hir-simple-path.h"
      23                 :             : 
      24                 :             : namespace Rust {
      25                 :             : namespace HIR {
      26                 :             : // Visibility of an item
      27                 :      146980 : struct Visibility
      28                 :             : {
      29                 :             : public:
      30                 :             :   enum VisType
      31                 :             :   {
      32                 :             :     PRIVATE,
      33                 :             :     PUBLIC,
      34                 :             :     RESTRICTED,
      35                 :             :     ERROR,
      36                 :             :   };
      37                 :             : 
      38                 :             : private:
      39                 :             :   VisType vis_type;
      40                 :             :   HIR::SimplePath path;
      41                 :             :   location_t locus;
      42                 :             : 
      43                 :             :   // should this store location info?
      44                 :             : 
      45                 :             : public:
      46                 :       39209 :   Visibility (VisType vis_type,
      47                 :             :               HIR::SimplePath path = HIR::SimplePath::create_empty (),
      48                 :             :               location_t locus = UNDEF_LOCATION)
      49                 :       39209 :     : vis_type (vis_type), path (std::move (path)), locus (locus)
      50                 :             :   {}
      51                 :             : 
      52                 :             :   // Returns whether visibility is in an error state.
      53                 :       15598 :   bool is_error () const { return vis_type == ERROR; }
      54                 :             : 
      55                 :             :   // Does the current visibility refer to a simple `pub <item>` entirely public
      56                 :       23867 :   bool is_public () const { return vis_type == PUBLIC; }
      57                 :             : 
      58                 :             :   // Is the current visibility public restricted to a certain path
      59                 :             :   bool is_restricted () const { return vis_type == RESTRICTED; }
      60                 :             : 
      61                 :             :   // Creates an error visibility.
      62                 :           0 :   static Visibility create_error ()
      63                 :             :   {
      64                 :           0 :     return Visibility (ERROR, HIR::SimplePath::create_empty ());
      65                 :             :   }
      66                 :             : 
      67                 :       46250 :   VisType get_vis_type () const { return vis_type; }
      68                 :             : 
      69                 :       15598 :   const HIR::SimplePath &get_path () const
      70                 :             :   {
      71                 :       15598 :     rust_assert (!is_error ());
      72                 :       15598 :     return path;
      73                 :             :   }
      74                 :             : 
      75                 :             :   std::string as_string () const;
      76                 :             : };
      77                 :             : } // namespace HIR
      78                 :             : } // namespace Rust
      79                 :             : 
      80                 :             : #endif
        

Generated by: LCOV version 2.1-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.