LCOV - code coverage report
Current view: top level - gcc/rust/typecheck - rust-tyty-region.h Coverage Total Hit
Test: gcc.info Lines: 96.7 % 30 29
Test Date: 2026-02-28 14:20:25 Functions: - 0 0
Legend: Lines:     hit not hit

            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          127 :   Region () : Region (UNRESOLVED) {}
      26       229365 :   Region (const Region &other)
      27       229365 :     : index (other.index), debruijn_index (other.debruijn_index),
      28        31112 :       variant (other.variant)
      29              :   {}
      30        32640 :   Region (Region &&other) noexcept
      31        32640 :     : index (other.index), debruijn_index (other.debruijn_index),
      32        32640 :       variant (other.variant)
      33              :   {}
      34        22124 :   Region &operator= (const Region &other)
      35              :   {
      36        22124 :     if (this == &other)
      37              :       return *this;
      38        22124 :     index = other.index;
      39        22124 :     debruijn_index = other.debruijn_index;
      40        22124 :     variant = other.variant;
      41        22124 :     return *this;
      42              :   }
      43            3 :   Region &operator= (Region &&other) noexcept
      44              :   {
      45            3 :     if (this == &other)
      46              :       return *this;
      47            3 :     index = other.index;
      48            3 :     debruijn_index = other.debruijn_index;
      49            3 :     variant = other.variant;
      50            3 :     return *this;
      51              :   }
      52              : 
      53         2503 :   static Region make_static () { return Region (STATIC); }
      54          223 :   static Region make_early_bound (uint32_t index)
      55              :   {
      56          223 :     return Region (EARLY_BOUND, index);
      57              :   }
      58              :   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        65582 :   static Region make_anonymous () { return Region (ANONYMOUS); }
      64              :   static Region make_erased () { return Region (ERASED); }
      65              : 
      66           61 :   size_t get_index () const { return index; }
      67              : 
      68              :   bool is_static () const { return variant == STATIC; }
      69           71 :   bool is_early_bound () const { return variant == EARLY_BOUND; }
      70              :   bool is_late_bound () const { return variant == LATE_BOUND; }
      71            0 :   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        46305 :   explicit Region (Variant variant, uint32_t index = 0,
     102              :                    uint16_t debruijn_index = 0)
     103        38805 :     : 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.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.