LCOV - code coverage report
Current view: top level - gcc/rust/ast - rust-expression-yeast.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 100.0 % 48 48
Test Date: 2025-08-30 13:27:53 Functions: 100.0 % 7 7
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : // Copyright (C) 2025 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-expression-yeast.h"
      20                 :             : #include "rust-ast-visitor.h"
      21                 :             : #include "rust-desugar-question-mark.h"
      22                 :             : #include "rust-desugar-try-block.h"
      23                 :             : #include "rust-desugar-for-loops.h"
      24                 :             : #include "rust-ast-full.h"
      25                 :             : #include "rust-desugar-while-let.h"
      26                 :             : #include "rust-expr.h"
      27                 :             : #include "rust-stmt.h"
      28                 :             : 
      29                 :             : namespace Rust {
      30                 :             : namespace AST {
      31                 :             : 
      32                 :             : void
      33                 :        4208 : ExpressionYeast::go (AST::Crate &crate)
      34                 :             : {
      35                 :        4208 :   DefaultASTVisitor::visit (crate);
      36                 :        4208 : }
      37                 :             : 
      38                 :             : void
      39                 :         232 : ExpressionYeast::dispatch_loops (std::unique_ptr<Expr> &loop_expr)
      40                 :             : {
      41                 :         232 :   auto &loop = static_cast<BaseLoopExpr &> (*loop_expr.get ());
      42                 :             : 
      43                 :         232 :   switch (loop.get_loop_kind ())
      44                 :             :     {
      45                 :          16 :     case BaseLoopExpr::Kind::For:
      46                 :          16 :       DesugarForLoops::go (loop_expr);
      47                 :          16 :       break;
      48                 :           2 :     case BaseLoopExpr::Kind::WhileLet:
      49                 :           2 :       DesugarWhileLet::go (loop_expr);
      50                 :           2 :       break;
      51                 :             :     default:
      52                 :             :       break;
      53                 :             :     }
      54                 :         232 : }
      55                 :             : 
      56                 :             : void
      57                 :       69018 : ExpressionYeast::dispatch (std::unique_ptr<Expr> &expr)
      58                 :             : {
      59                 :       69018 :   switch (expr->get_expr_kind ())
      60                 :             :     {
      61                 :           1 :     case Expr::Kind::ErrorPropagation:
      62                 :           1 :       DesugarQuestionMark::go (expr);
      63                 :           1 :       break;
      64                 :           1 :     case Expr::Kind::Try:
      65                 :           1 :       DesugarTryBlock::go (expr);
      66                 :           1 :       break;
      67                 :         232 :     case Expr::Kind::Loop:
      68                 :         232 :       dispatch_loops (expr);
      69                 :         232 :       break;
      70                 :             : 
      71                 :             :     default:
      72                 :             :       break;
      73                 :             :     }
      74                 :       69018 : }
      75                 :             : 
      76                 :             : void
      77                 :        9091 : ExpressionYeast::visit (ExprStmt &stmt)
      78                 :             : {
      79                 :        9091 :   dispatch (stmt.get_expr_ptr ());
      80                 :             : 
      81                 :        9091 :   DefaultASTVisitor::visit (stmt);
      82                 :        9091 : }
      83                 :             : 
      84                 :             : void
      85                 :       10945 : ExpressionYeast::visit (CallExpr &call)
      86                 :             : {
      87                 :       10945 :   dispatch (call.get_function_expr_ptr ());
      88                 :             : 
      89                 :       23936 :   for (auto &arg : call.get_params ())
      90                 :       12991 :     dispatch (arg);
      91                 :             : 
      92                 :       10945 :   DefaultASTVisitor::visit (call);
      93                 :       10945 : }
      94                 :             : 
      95                 :             : void
      96                 :       21522 : ExpressionYeast::visit (BlockExpr &block)
      97                 :             : {
      98                 :       43490 :   for (auto &stmt : block.get_statements ())
      99                 :       21968 :     if (stmt->get_stmt_kind () == Stmt::Kind::Expr)
     100                 :        9091 :       dispatch (static_cast<ExprStmt &> (*stmt).get_expr_ptr ());
     101                 :             : 
     102                 :       21522 :   if (block.has_tail_expr ())
     103                 :       15626 :     dispatch (block.get_tail_expr_ptr ());
     104                 :             : 
     105                 :       21522 :   DefaultASTVisitor::visit (block);
     106                 :       21522 : }
     107                 :             : 
     108                 :             : void
     109                 :       12417 : ExpressionYeast::visit (LetStmt &stmt)
     110                 :             : {
     111                 :       12417 :   if (stmt.has_init_expr ())
     112                 :       11274 :     dispatch (stmt.get_init_expr_ptr ());
     113                 :             : 
     114                 :       12417 :   DefaultASTVisitor::visit (stmt);
     115                 :       12417 : }
     116                 :             : 
     117                 :             : } // namespace AST
     118                 :             : } // namespace Rust
        

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.