LCOV - code coverage report
Current view: top level - gcc/rust/hir/tree - rust-hir-stmt.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 50.0 % 52 26
Test Date: 2026-02-28 14:20:25 Functions: 57.1 % 7 4
Legend: Lines:     hit not hit

            Line data    Source code
       1              : // Copyright (C) 2020-2026 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              : #include "rust-hir-stmt.h"
      20              : #include "optional.h"
      21              : #include "rust-system.h"
      22              : 
      23              : namespace Rust {
      24              : namespace HIR {
      25              : 
      26        12650 : LetStmt::LetStmt (Analysis::NodeMapping mappings,
      27              :                   std::unique_ptr<Pattern> variables_pattern,
      28              :                   tl::optional<std::unique_ptr<Expr>> init_expr,
      29              :                   tl::optional<std::unique_ptr<Expr>> else_expr,
      30              :                   tl::optional<std::unique_ptr<Type>> type,
      31        12650 :                   AST::AttrVec outer_attrs, location_t locus)
      32        12650 :   : Stmt (std::move (mappings)), outer_attrs (std::move (outer_attrs)),
      33        12650 :     variables_pattern (std::move (variables_pattern)), type (std::move (type)),
      34        25300 :     init_expr (std::move (init_expr)), else_expr (std::move (else_expr)),
      35        12650 :     locus (locus)
      36        12650 : {}
      37              : 
      38           25 : LetStmt::LetStmt (LetStmt const &other)
      39           25 :   : Stmt (other.mappings), outer_attrs (other.outer_attrs), locus (other.locus)
      40              : {
      41              :   // guard to prevent null dereference (only required if error state)
      42           25 :   if (other.variables_pattern != nullptr)
      43           25 :     variables_pattern = other.variables_pattern->clone_pattern ();
      44              : 
      45              :   // guard to prevent null dereference (always required)
      46           25 :   if (other.has_init_expr ())
      47           25 :     init_expr = other.get_init_expr ().clone_expr ();
      48           25 :   if (other.has_else_expr ())
      49            0 :     else_expr = other.get_else_expr ().clone_expr ();
      50              : 
      51           25 :   if (other.has_type ())
      52            7 :     type = other.get_type ().clone_type ();
      53              :   else
      54           18 :     type = tl::nullopt;
      55           25 : }
      56              : 
      57              : LetStmt &
      58            0 : LetStmt::operator= (LetStmt const &other)
      59              : {
      60            0 :   outer_attrs = other.outer_attrs;
      61            0 :   locus = other.locus;
      62              : 
      63              :   // guard to prevent null dereference (only required if error state)
      64            0 :   if (other.variables_pattern != nullptr)
      65            0 :     variables_pattern = other.variables_pattern->clone_pattern ();
      66              :   else
      67            0 :     variables_pattern = nullptr;
      68              : 
      69              :   // guard to prevent null dereference (always required)
      70            0 :   if (other.has_init_expr ())
      71            0 :     init_expr = other.get_init_expr ().clone_expr ();
      72              :   else
      73            0 :     init_expr = nullptr;
      74              : 
      75            0 :   if (other.has_else_expr ())
      76            0 :     else_expr = other.get_else_expr ().clone_expr ();
      77              :   else
      78            0 :     else_expr = tl::nullopt;
      79              : 
      80            0 :   if (other.has_type ())
      81            0 :     type = other.get_type ().clone_type ();
      82              :   else
      83            0 :     type = tl::nullopt;
      84              : 
      85            0 :   return *this;
      86              : }
      87              : 
      88         9260 : ExprStmt::ExprStmt (Analysis::NodeMapping mappings, std::unique_ptr<Expr> expr,
      89         9260 :                     location_t locus, bool must_be_unit)
      90         9260 :   : Stmt (std::move (mappings)), expr (std::move (expr)), locus (locus),
      91         9260 :     must_be_unit (must_be_unit)
      92         9260 : {}
      93              : 
      94            0 : ExprStmt::ExprStmt (Analysis::NodeMapping mappings, std::unique_ptr<Expr> expr,
      95            0 :                     location_t locus)
      96            0 :   : ExprStmt (std::move (mappings), std::move (expr), locus, false)
      97            0 : {}
      98              : 
      99            1 : ExprStmt::ExprStmt (ExprStmt const &other)
     100            1 :   : Stmt (other), expr (other.expr->clone_expr ()), locus (other.locus)
     101            1 : {}
     102              : 
     103              : ExprStmt &
     104            0 : ExprStmt::operator= (ExprStmt const &other)
     105              : {
     106            0 :   Stmt::operator= (other);
     107            0 :   expr = other.expr->clone_expr ();
     108            0 :   locus = other.locus;
     109              : 
     110            0 :   return *this;
     111              : }
     112              : 
     113              : } // namespace HIR
     114              : } // namespace Rust
        

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.