LCOV - code coverage report
Current view: top level - gcc/rust/hir/tree - rust-hir-trait-bound.h (source / functions) Coverage Total Hit
Test: gcc.info Lines: 87.5 % 16 14
Test Date: 2025-06-21 16:26:05 Functions: 100.0 % 5 5
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_TRAIT_BOUND_H
      20                 :             : #define RUST_HIR_TRAIT_BOUND_H
      21                 :             : 
      22                 :             : #include "rust-hir-bound-abstract.h"
      23                 :             : #include "rust-hir-path.h"
      24                 :             : #include "rust-hir-generic-param.h"
      25                 :             : 
      26                 :             : namespace Rust {
      27                 :             : namespace HIR {
      28                 :             : 
      29                 :             : // A trait bound
      30                 :             : class TraitBound : public TypeParamBound
      31                 :             : {
      32                 :             :   bool in_parens;
      33                 :             :   BoundPolarity polarity;
      34                 :             :   std::vector<LifetimeParam> for_lifetimes;
      35                 :             :   TypePath type_path;
      36                 :             :   location_t locus;
      37                 :             : 
      38                 :             :   Analysis::NodeMapping mappings;
      39                 :             : 
      40                 :             : public:
      41                 :             :   // Returns whether trait bound has "for" lifetimes
      42                 :           0 :   bool has_for_lifetimes () const { return !for_lifetimes.empty (); }
      43                 :             : 
      44                 :        1060 :   TraitBound (Analysis::NodeMapping mapping, TypePath type_path,
      45                 :             :               location_t locus, bool in_parens = false,
      46                 :             :               BoundPolarity polarity = BoundPolarity::RegularBound,
      47                 :             :               std::vector<LifetimeParam> for_lifetimes
      48                 :             :               = std::vector<LifetimeParam> ())
      49                 :        1060 :     : in_parens (in_parens), polarity (polarity),
      50                 :        1060 :       for_lifetimes (std::move (for_lifetimes)),
      51                 :        1060 :       type_path (std::move (type_path)), locus (locus), mappings (mapping)
      52                 :        1060 :   {}
      53                 :             : 
      54                 :             :   std::string as_string () const override;
      55                 :             : 
      56                 :        1062 :   location_t get_locus () const override final { return locus; }
      57                 :             : 
      58                 :             :   void accept_vis (HIRFullVisitor &vis) override;
      59                 :             : 
      60                 :        1060 :   Analysis::NodeMapping get_mappings () const override final
      61                 :             :   {
      62                 :        1060 :     return mappings;
      63                 :             :   }
      64                 :             : 
      65                 :         188 :   std::vector<LifetimeParam> &get_for_lifetimes () { return for_lifetimes; }
      66                 :           0 :   bool get_in_parens () { return in_parens; }
      67                 :        1052 :   BoundPolarity get_polarity () { return polarity; }
      68                 :             : 
      69                 :        2088 :   BoundType get_bound_type () const final override { return TRAITBOUND; }
      70                 :             : 
      71                 :        1731 :   TypePath &get_path () { return type_path; }
      72                 :             : 
      73                 :             :   const TypePath &get_path () const { return type_path; }
      74                 :             : 
      75                 :             : protected:
      76                 :             :   /* Use covariance to implement clone function as returning this object rather
      77                 :             :    * than base */
      78                 :         104 :   TraitBound *clone_type_param_bound_impl () const override
      79                 :             :   {
      80                 :         104 :     return new TraitBound (*this);
      81                 :             :   }
      82                 :             : };
      83                 :             : 
      84                 :             : } // namespace HIR
      85                 :             : } // namespace Rust
      86                 :             : 
      87                 :             : #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.