LCOV - code coverage report
Current view: top level - gcc/rust/hir/tree - rust-hir-type.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 57.7 % 163 94
Test Date: 2026-11-14 16:39:50 Functions: 66.7 % 33 22
Legend: Lines:     hit not hit

            Line data    Source code
       1              : 
       2              : // Copyright (C) 2020-2026 Free Software Foundation, Inc.
       3              : 
       4              : // This file is part of GCC.
       5              : 
       6              : // GCC is free software; you can redistribute it and/or modify it under
       7              : // the terms of the GNU General Public License as published by the Free
       8              : // Software Foundation; either version 3, or (at your option) any later
       9              : // version.
      10              : 
      11              : // GCC is distributed in the hope that it will be useful, but WITHOUT ANY
      12              : // WARRANTY; without even the implied warranty of MERCHANTABILITY or
      13              : // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
      14              : // for more details.
      15              : 
      16              : // You should have received a copy of the GNU General Public License
      17              : // along with GCC; see the file COPYING3.  If not see
      18              : // <http://www.gnu.org/licenses/>.
      19              : 
      20              : #include "rust-hir-type.h"
      21              : 
      22              : namespace Rust {
      23              : namespace HIR {
      24              : 
      25         1148 : ImplTraitType::ImplTraitType (
      26              :   Analysis::NodeMapping mappings,
      27              :   std::vector<std::unique_ptr<TypeParamBound>> type_param_bounds,
      28              :   location_t locus)
      29         1148 :   : Type (mappings, locus), type_param_bounds (std::move (type_param_bounds))
      30         1148 : {}
      31              : 
      32         3446 : ImplTraitType::ImplTraitType (ImplTraitType const &other)
      33         3446 :   : Type (other.mappings, other.locus)
      34              : {
      35         3446 :   type_param_bounds.reserve (other.type_param_bounds.size ());
      36         6896 :   for (const auto &e : other.type_param_bounds)
      37         3450 :     type_param_bounds.push_back (e->clone_type_param_bound ());
      38         3446 : }
      39              : 
      40              : ImplTraitType &
      41            0 : ImplTraitType::operator= (ImplTraitType const &other)
      42              : {
      43            0 :   locus = other.locus;
      44            0 :   mappings = other.mappings;
      45              : 
      46            0 :   type_param_bounds.reserve (other.type_param_bounds.size ());
      47            0 :   for (const auto &e : other.type_param_bounds)
      48            0 :     type_param_bounds.push_back (e->clone_type_param_bound ());
      49              : 
      50            0 :   return *this;
      51              : }
      52              : 
      53          757 : TraitObjectType::TraitObjectType (
      54              :   Analysis::NodeMapping mappings,
      55              :   std::vector<std::unique_ptr<TypeParamBound>> type_param_bounds,
      56              :   location_t locus, bool is_dyn_dispatch)
      57          757 :   : Type (mappings, locus), has_dyn (is_dyn_dispatch),
      58          757 :     type_param_bounds (std::move (type_param_bounds))
      59          757 : {}
      60              : 
      61          334 : TraitObjectType::TraitObjectType (TraitObjectType const &other)
      62          334 :   : Type (other.mappings, other.locus), has_dyn (other.has_dyn)
      63              : {
      64          334 :   type_param_bounds.reserve (other.type_param_bounds.size ());
      65          942 :   for (const auto &e : other.type_param_bounds)
      66          608 :     type_param_bounds.push_back (e->clone_type_param_bound ());
      67          334 : }
      68              : 
      69              : TraitObjectType &
      70            0 : TraitObjectType::operator= (TraitObjectType const &other)
      71              : {
      72            0 :   mappings = other.mappings;
      73            0 :   has_dyn = other.has_dyn;
      74            0 :   locus = other.locus;
      75            0 :   type_param_bounds.reserve (other.type_param_bounds.size ());
      76            0 :   for (const auto &e : other.type_param_bounds)
      77            0 :     type_param_bounds.push_back (e->clone_type_param_bound ());
      78              : 
      79            0 :   return *this;
      80              : }
      81              : 
      82           80 : ParenthesisedType::ParenthesisedType (Analysis::NodeMapping mappings,
      83              :                                       std::unique_ptr<Type> type_inside_parens,
      84              :                                       location_t locus)
      85              :   : TypeNoBounds (mappings, locus),
      86           80 :     type_in_parens (std::move (type_inside_parens))
      87           80 : {}
      88              : 
      89           16 : ParenthesisedType::ParenthesisedType (ParenthesisedType const &other)
      90           16 :   : TypeNoBounds (other.mappings, other.locus),
      91           16 :     type_in_parens (other.type_in_parens->clone_type ())
      92           16 : {}
      93              : 
      94              : ParenthesisedType &
      95            0 : ParenthesisedType::operator= (ParenthesisedType const &other)
      96              : {
      97            0 :   mappings = other.mappings;
      98            0 :   type_in_parens = other.type_in_parens->clone_type ();
      99            0 :   locus = other.locus;
     100            0 :   return *this;
     101              : }
     102              : 
     103              : std::unique_ptr<TraitBound>
     104            0 : ParenthesisedType::to_trait_bound (bool in_parens) const
     105              : {
     106              :   /* If already in parentheses, don't convert - should stay as
     107              :    * ParenthesisedType */
     108            0 :   if (in_parens)
     109            0 :     return nullptr;
     110              : 
     111              :   /* NOTE: obviously it is unknown whether the internal type is a trait bound
     112              :    * due to polymorphism, so just let the internal type handle it. As
     113              :    * parenthesised type, it must be in parentheses. */
     114            0 :   return type_in_parens->to_trait_bound (true);
     115              : }
     116              : 
     117        10294 : TupleType::TupleType (Analysis::NodeMapping mappings,
     118              :                       std::vector<std::unique_ptr<Type>> elems,
     119              :                       location_t locus)
     120        10294 :   : TypeNoBounds (mappings, locus), elems (std::move (elems))
     121        10294 : {}
     122              : 
     123         3919 : TupleType::TupleType (TupleType const &other)
     124         3919 :   : TypeNoBounds (other.mappings, other.locus)
     125              : {
     126         3919 :   mappings = other.mappings;
     127         3919 :   elems.reserve (other.elems.size ());
     128         9499 :   for (const auto &e : other.elems)
     129         5580 :     elems.push_back (e->clone_type ());
     130         3919 : }
     131              : 
     132              : TupleType &
     133            0 : TupleType::operator= (TupleType const &other)
     134              : {
     135            0 :   locus = other.locus;
     136              : 
     137            0 :   elems.reserve (other.elems.size ());
     138            0 :   for (const auto &e : other.elems)
     139            0 :     elems.push_back (e->clone_type ());
     140              : 
     141            0 :   return *this;
     142              : }
     143              : 
     144          648 : NeverType::NeverType (Analysis::NodeMapping mappings, location_t locus)
     145          648 :   : TypeNoBounds (mappings, locus)
     146          648 : {}
     147              : 
     148        17069 : RawPointerType::RawPointerType (Analysis::NodeMapping mappings, Mutability mut,
     149              :                                 std::unique_ptr<Type> type, location_t locus)
     150        17069 :   : TypeNoBounds (mappings, locus), mut (mut), type (std::move (type))
     151        17069 : {}
     152              : 
     153          445 : RawPointerType::RawPointerType (RawPointerType const &other)
     154          445 :   : TypeNoBounds (other.mappings, other.locus), mut (other.mut),
     155          445 :     type (other.type->clone_type ())
     156          445 : {}
     157              : 
     158              : RawPointerType &
     159            0 : RawPointerType::operator= (RawPointerType const &other)
     160              : {
     161            0 :   mappings = other.mappings;
     162            0 :   mut = other.mut;
     163            0 :   type = other.type->clone_type ();
     164            0 :   locus = other.locus;
     165            0 :   return *this;
     166              : }
     167              : 
     168        67571 : ReferenceType::ReferenceType (Analysis::NodeMapping mappings, Mutability mut,
     169              :                               std::unique_ptr<Type> type_no_bounds,
     170              :                               location_t locus, tl::optional<Lifetime> lifetime)
     171        67571 :   : TypeNoBounds (mappings, locus), lifetime (std::move (lifetime)), mut (mut),
     172        67571 :     type (std::move (type_no_bounds))
     173        67571 : {}
     174              : 
     175        54775 : ReferenceType::ReferenceType (ReferenceType const &other)
     176       109550 :   : TypeNoBounds (other.mappings, other.locus), lifetime (other.lifetime),
     177        54775 :     mut (other.mut), type (other.type->clone_type ())
     178        54775 : {}
     179              : 
     180              : ReferenceType &
     181            0 : ReferenceType::operator= (ReferenceType const &other)
     182              : {
     183            0 :   mappings = other.mappings;
     184            0 :   lifetime = other.lifetime;
     185            0 :   mut = other.mut;
     186            0 :   type = other.type->clone_type ();
     187            0 :   locus = other.locus;
     188              : 
     189            0 :   return *this;
     190              : }
     191              : 
     192         3363 : ArrayType::ArrayType (Analysis::NodeMapping mappings,
     193              :                       std::unique_ptr<Type> type,
     194              :                       std::unique_ptr<Expr> array_size, location_t locus)
     195         3363 :   : TypeNoBounds (mappings, locus), elem_type (std::move (type)),
     196         3363 :     size (std::move (array_size))
     197         3363 : {}
     198              : 
     199          714 : ArrayType::ArrayType (ArrayType const &other)
     200          714 :   : TypeNoBounds (other.mappings, other.locus),
     201          714 :     elem_type (other.elem_type->clone_type ()), size (other.size->clone_expr ())
     202          714 : {}
     203              : 
     204              : ArrayType &
     205            0 : ArrayType::operator= (ArrayType const &other)
     206              : {
     207            0 :   mappings = other.mappings;
     208            0 :   elem_type = other.elem_type->clone_type ();
     209            0 :   size = other.size->clone_expr ();
     210            0 :   locus = other.locus;
     211            0 :   return *this;
     212              : }
     213              : 
     214         5795 : SliceType::SliceType (Analysis::NodeMapping mappings,
     215              :                       std::unique_ptr<Type> type, location_t locus)
     216         5795 :   : TypeNoBounds (mappings, locus), elem_type (std::move (type))
     217         5795 : {}
     218              : 
     219         2509 : SliceType::SliceType (SliceType const &other)
     220         2509 :   : TypeNoBounds (other.mappings, other.locus),
     221         2509 :     elem_type (other.elem_type->clone_type ())
     222         2509 : {}
     223              : 
     224              : SliceType &
     225            0 : SliceType::operator= (SliceType const &other)
     226              : {
     227            0 :   mappings = other.mappings;
     228            0 :   elem_type = other.elem_type->clone_type ();
     229            0 :   locus = other.locus;
     230              : 
     231            0 :   return *this;
     232              : }
     233              : 
     234         2080 : InferredType::InferredType (Analysis::NodeMapping mappings, location_t locus)
     235         2080 :   : TypeNoBounds (mappings, locus)
     236         2080 : {}
     237              : 
     238        26412 : MaybeNamedParam::MaybeNamedParam (Identifier name, ParamKind param_kind,
     239              :                                   std::unique_ptr<Type> param_type,
     240              :                                   location_t locus)
     241        26412 :   : param_type (std::move (param_type)), param_kind (param_kind),
     242        26412 :     name (std::move (name)), locus (locus)
     243        26412 : {}
     244              : 
     245        22950 : MaybeNamedParam::MaybeNamedParam (MaybeNamedParam const &other)
     246        22950 :   : param_type (other.param_type->clone_type ()), param_kind (other.param_kind),
     247        22950 :     name (other.name), locus (other.locus)
     248        22950 : {}
     249              : 
     250              : MaybeNamedParam &
     251            0 : MaybeNamedParam::operator= (MaybeNamedParam const &other)
     252              : {
     253            0 :   name = other.name;
     254            0 :   param_kind = other.param_kind;
     255            0 :   param_type = other.param_type->clone_type ();
     256            0 :   locus = other.locus;
     257              : 
     258            0 :   return *this;
     259              : }
     260              : 
     261         4450 : BareFunctionType::BareFunctionType (
     262              :   Analysis::NodeMapping mappings, std::vector<LifetimeParam> lifetime_params,
     263              :   FunctionQualifiers qualifiers, std::vector<MaybeNamedParam> named_params,
     264              :   bool is_variadic, std::unique_ptr<Type> type, location_t locus)
     265         4450 :   : TypeNoBounds (mappings, locus), for_lifetimes (std::move (lifetime_params)),
     266         4450 :     function_qualifiers (std::move (qualifiers)),
     267         4450 :     params (std::move (named_params)), is_variadic (is_variadic),
     268         4450 :     return_type (std::move (type))
     269         4450 : {}
     270              : 
     271         3755 : BareFunctionType::BareFunctionType (BareFunctionType const &other)
     272         3755 :   : TypeNoBounds (other.mappings, other.locus),
     273         3755 :     for_lifetimes (other.for_lifetimes),
     274         3755 :     function_qualifiers (other.function_qualifiers), params (other.params),
     275         3755 :     is_variadic (other.is_variadic),
     276         3755 :     return_type (other.has_return_type () ? other.return_type->clone_type ()
     277         3755 :                                           : nullptr)
     278         3755 : {}
     279              : 
     280              : BareFunctionType &
     281            0 : BareFunctionType::operator= (BareFunctionType const &other)
     282              : {
     283            0 :   mappings = other.mappings;
     284            0 :   for_lifetimes = other.for_lifetimes;
     285            0 :   function_qualifiers = other.function_qualifiers;
     286            0 :   params = other.params;
     287            0 :   is_variadic = other.is_variadic;
     288            0 :   return_type = other.return_type->clone_type ();
     289            0 :   locus = other.locus;
     290              : 
     291            0 :   return *this;
     292              : }
     293              : 
     294              : } // namespace HIR
     295              : } // namespace Rust
        

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