LCOV - code coverage report
Current view: top level - gcc/rust/typecheck - rust-tyty-region.h (source / functions) Coverage Total Hit
Test: gcc.info Lines: 100.0 % 28 28
Test Date: 2024-04-27 14:03:13 Functions: - 0 0
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : #ifndef RUST_TYTY_REGION_H
       2                 :             : #define RUST_TYTY_REGION_H
       3                 :             : 
       4                 :             : namespace Rust {
       5                 :             : namespace TyTy {
       6                 :             : 
       7                 :             : class Region
       8                 :             : {
       9                 :             :   enum Variant : uint8_t
      10                 :             :   {
      11                 :             :     UNRESOLVED,
      12                 :             :     STATIC,
      13                 :             :     EARLY_BOUND,
      14                 :             :     LATE_BOUND,
      15                 :             :     NAMED,
      16                 :             :     ANONYMOUS,
      17                 :             :     ERASED,
      18                 :             :   };
      19                 :             : 
      20                 :             :   uint32_t index;
      21                 :             :   uint16_t debruijn_index;
      22                 :             :   Variant variant;
      23                 :             : 
      24                 :             : public:
      25                 :          49 :   Region () : Region (UNRESOLVED) {}
      26                 :       88257 :   Region (const Region &other)
      27                 :       88257 :     : index (other.index), debruijn_index (other.debruijn_index),
      28                 :        6435 :       variant (other.variant)
      29                 :             :   {}
      30                 :        6217 :   Region (Region &&other) noexcept
      31                 :        6217 :     : index (other.index), debruijn_index (other.debruijn_index),
      32                 :        6217 :       variant (other.variant)
      33                 :             :   {}
      34                 :          19 :   Region &operator= (const Region &other)
      35                 :             :   {
      36                 :          19 :     if (this == &other)
      37                 :             :       return *this;
      38                 :          19 :     index = other.index;
      39                 :          19 :     debruijn_index = other.debruijn_index;
      40                 :          19 :     variant = other.variant;
      41                 :          19 :     return *this;
      42                 :             :   }
      43                 :           2 :   Region &operator= (Region &&other) noexcept
      44                 :             :   {
      45                 :           2 :     if (this == &other)
      46                 :             :       return *this;
      47                 :           2 :     index = other.index;
      48                 :           2 :     debruijn_index = other.debruijn_index;
      49                 :           2 :     variant = other.variant;
      50                 :           2 :     return *this;
      51                 :             :   }
      52                 :             : 
      53                 :        1410 :   static Region make_static () { return Region (STATIC); }
      54                 :         164 :   static Region make_early_bound (uint32_t index)
      55                 :             :   {
      56                 :         164 :     return Region (EARLY_BOUND, index);
      57                 :             :   }
      58                 :          36 :   static Region make_late_bound (uint32_t index, uint16_t debruijn_index)
      59                 :             :   {
      60                 :          36 :     return Region (LATE_BOUND, index, debruijn_index);
      61                 :             :   }
      62                 :          10 :   static Region make_named (uint32_t index) { return Region (NAMED, index); }
      63                 :       14476 :   static Region make_anonymous () { return Region (ANONYMOUS); }
      64                 :             :   static Region make_erased () { return Region (ERASED); }
      65                 :             : 
      66                 :             :   size_t get_index () const { return index; }
      67                 :             : 
      68                 :             :   bool is_static () const { return variant == STATIC; }
      69                 :             :   bool is_early_bound () const { return variant == EARLY_BOUND; }
      70                 :             :   bool is_late_bound () const { return variant == LATE_BOUND; }
      71                 :             :   bool is_named () const { return variant == NAMED; }
      72                 :             :   bool is_anonymous () const { return variant == ANONYMOUS; }
      73                 :             : 
      74                 :             :   void shift_down () { debruijn_index++; }
      75                 :             : 
      76                 :             :   WARN_UNUSED_RESULT std::string as_string () const
      77                 :             :   {
      78                 :             :     switch (variant)
      79                 :             :       {
      80                 :             :       case UNRESOLVED:
      81                 :             :         return "'unresolved";
      82                 :             :       case STATIC:
      83                 :             :         return "'static";
      84                 :             :       case EARLY_BOUND:
      85                 :             :         return "'early(" + std::to_string (index) + ")";
      86                 :             :       case LATE_BOUND:
      87                 :             :         return "'late(" + std::to_string (debruijn_index) + ", "
      88                 :             :                + std::to_string (index) + ")";
      89                 :             :       case NAMED:
      90                 :             :         return "'named(" + std::to_string (index) + "";
      91                 :             :       case ANONYMOUS:
      92                 :             :         return "'_";
      93                 :             :       case ERASED:
      94                 :             :         return "'erased";
      95                 :             :       }
      96                 :             : 
      97                 :             :     rust_unreachable ();
      98                 :             :   }
      99                 :             : 
     100                 :             : private:
     101                 :       16096 :   explicit Region (Variant variant, uint32_t index = 0,
     102                 :             :                    uint16_t debruijn_index = 0)
     103                 :        9929 :     : index (index), debruijn_index (debruijn_index), variant (variant)
     104                 :             :   {}
     105                 :             : };
     106                 :             : 
     107                 :             : } // namespace TyTy
     108                 :             : } // namespace Rust
     109                 :             : 
     110                 :             : #endif // RUST_TYTY_REGION_H
        

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.