LCOV - code coverage report
Current view: top level - gcc/rust/resolve - rust-default-resolver.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 100.0 % 75 75
Test Date: 2025-04-19 15:48:17 Functions: 100.0 % 17 17
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : // Copyright (C) 2020-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-default-resolver.h"
      20                 :             : #include "rust-ast-full.h"
      21                 :             : #include "rust-ast-visitor.h"
      22                 :             : #include "rust-item.h"
      23                 :             : 
      24                 :             : namespace Rust {
      25                 :             : namespace Resolver2_0 {
      26                 :             : 
      27                 :             : void
      28                 :       16854 : DefaultResolver::visit (AST::BlockExpr &expr)
      29                 :             : {
      30                 :             :   // extracting the lambda from the `scoped` call otherwise the code looks like
      31                 :             :   // a hot turd thanks to our .clang-format
      32                 :             : 
      33                 :       16854 :   auto inner_fn = [this, &expr] () { AST::DefaultASTVisitor::visit (expr); };
      34                 :             : 
      35                 :       16854 :   ctx.scoped (Rib::Kind::Normal, expr.get_node_id (), inner_fn);
      36                 :       16852 : }
      37                 :             : 
      38                 :             : void
      39                 :        1375 : DefaultResolver::visit (AST::Module &module)
      40                 :             : {
      41                 :        1375 :   auto item_fn = [this, &module] () { AST::DefaultASTVisitor::visit (module); };
      42                 :             : 
      43                 :        4125 :   ctx.scoped (Rib::Kind::Module, module.get_node_id (), item_fn,
      44                 :        1375 :               module.get_name ());
      45                 :        1375 : }
      46                 :             : 
      47                 :             : void
      48                 :       15468 : DefaultResolver::visit (AST::Function &function)
      49                 :             : {
      50                 :       15468 :   auto def_fn
      51                 :       15468 :     = [this, &function] () { AST::DefaultASTVisitor::visit (function); };
      52                 :             : 
      53                 :       15468 :   ctx.scoped (Rib::Kind::Function, function.get_node_id (), def_fn);
      54                 :       15466 : }
      55                 :             : 
      56                 :             : void
      57                 :          16 : DefaultResolver::visit (AST::ForLoopExpr &expr)
      58                 :             : {
      59                 :          16 :   ctx.scoped (Rib::Kind::Normal, expr.get_node_id (),
      60                 :          16 :               [this, &expr] () { AST::DefaultASTVisitor::visit (expr); });
      61                 :          16 : }
      62                 :             : 
      63                 :             : void
      64                 :        2856 : DefaultResolver::visit (AST::Trait &trait)
      65                 :             : {
      66                 :        2856 :   auto inner_fn = [this, &trait] () { AST::DefaultASTVisitor::visit (trait); };
      67                 :             : 
      68                 :        8568 :   ctx.scoped (Rib::Kind::TraitOrImpl, trait.get_node_id (), inner_fn,
      69                 :        2856 :               trait.get_identifier () /* FIXME: Is that valid?*/);
      70                 :        2856 : }
      71                 :             : 
      72                 :             : void
      73                 :         521 : DefaultResolver::visit (AST::InherentImpl &impl)
      74                 :             : {
      75                 :         521 :   auto inner_fn = [this, &impl] () { AST::DefaultASTVisitor::visit (impl); };
      76                 :             : 
      77                 :         521 :   ctx.scoped (Rib::Kind::TraitOrImpl, impl.get_node_id (), inner_fn);
      78                 :         521 : }
      79                 :             : 
      80                 :             : void
      81                 :        1964 : DefaultResolver::visit (AST::TraitImpl &impl)
      82                 :             : {
      83                 :        1964 :   auto inner_fn = [this, &impl] () { AST::DefaultASTVisitor::visit (impl); };
      84                 :             : 
      85                 :        1964 :   ctx.scoped (Rib::Kind::TraitOrImpl, impl.get_node_id (), inner_fn);
      86                 :        1963 : }
      87                 :             : 
      88                 :             : void
      89                 :         567 : DefaultResolver::visit (AST::StructStruct &type)
      90                 :             : {
      91                 :         567 :   auto inner_fn = [this, &type] () { AST::DefaultASTVisitor::visit (type); };
      92                 :             : 
      93                 :        1134 :   ctx.scoped (Rib::Kind::Item /* FIXME: Correct? */, type.get_node_id (),
      94                 :         567 :               inner_fn, type.get_struct_name ());
      95                 :         567 : }
      96                 :             : 
      97                 :             : void
      98                 :         803 : DefaultResolver::visit (AST::TupleStruct &type)
      99                 :             : {
     100                 :         803 :   auto inner_fn = [this, &type] () { AST::DefaultASTVisitor::visit (type); };
     101                 :             : 
     102                 :        1605 :   ctx.scoped (Rib::Kind::Item /* FIXME: Correct? */, type.get_node_id (),
     103                 :         803 :               inner_fn, type.get_struct_name ());
     104                 :         802 : }
     105                 :             : 
     106                 :             : void
     107                 :         516 : DefaultResolver::visit (AST::Enum &type)
     108                 :             : {
     109                 :         516 :   auto variant_fn = [this, &type] () { AST::DefaultASTVisitor::visit (type); };
     110                 :             : 
     111                 :        1548 :   ctx.scoped (Rib::Kind::Item /* FIXME: Correct? */, type.get_node_id (),
     112                 :         516 :               variant_fn, type.get_identifier ());
     113                 :         516 : }
     114                 :             : 
     115                 :             : void
     116                 :          83 : DefaultResolver::visit (AST::Union &type)
     117                 :             : {
     118                 :          83 :   auto inner_fn = [this, &type] () { AST::DefaultASTVisitor::visit (type); };
     119                 :             : 
     120                 :         249 :   ctx.scoped (Rib::Kind::Item /* FIXME: Correct? */, type.get_node_id (),
     121                 :          83 :               inner_fn, type.get_identifier ());
     122                 :          83 : }
     123                 :             : 
     124                 :             : void
     125                 :        1396 : DefaultResolver::visit (AST::TypeAlias &type)
     126                 :             : {
     127                 :        1396 :   auto inner_fn = [this, &type] () { AST::DefaultASTVisitor::visit (type); };
     128                 :             : 
     129                 :        4188 :   ctx.scoped (Rib::Kind::Item /* FIXME: Correct? */, type.get_node_id (),
     130                 :        1396 :               inner_fn, type.get_new_type_name ());
     131                 :        1396 : }
     132                 :             : 
     133                 :             : void
     134                 :          17 : DefaultResolver::visit (AST::ClosureExprInner &expr)
     135                 :             : {
     136                 :          17 :   if (expr.is_marked_for_strip ())
     137                 :             :     return;
     138                 :             : 
     139                 :          17 :   AST::DefaultASTVisitor::visit (expr);
     140                 :             : }
     141                 :             : 
     142                 :             : void
     143                 :           5 : DefaultResolver::visit (AST::ClosureExprInnerTyped &expr)
     144                 :             : {
     145                 :           5 :   if (expr.is_marked_for_strip ())
     146                 :             :     return;
     147                 :             : 
     148                 :           5 :   AST::DefaultASTVisitor::visit (expr);
     149                 :             : }
     150                 :             : 
     151                 :             : void
     152                 :         307 : DefaultResolver::visit (AST::MatchExpr &expr)
     153                 :             : {
     154                 :         307 :   if (expr.is_marked_for_strip ())
     155                 :             :     return;
     156                 :             : 
     157                 :         307 :   AST::DefaultASTVisitor::visit (expr);
     158                 :             : }
     159                 :             : 
     160                 :             : void
     161                 :         471 : DefaultResolver::visit (AST::ConstantItem &item)
     162                 :             : {
     163                 :         471 :   if (item.has_expr ())
     164                 :             :     {
     165                 :         466 :       auto expr_vis
     166                 :         466 :         = [this, &item] () { AST::DefaultASTVisitor::visit (item); };
     167                 :             : 
     168                 :             :       // FIXME: Why do we need a Rib here?
     169                 :         466 :       ctx.scoped (Rib::Kind::ConstantItem, item.get_node_id (), expr_vis);
     170                 :             :     }
     171                 :         471 : }
     172                 :             : 
     173                 :             : void
     174                 :          77 : DefaultResolver::visit (AST::StaticItem &item)
     175                 :             : {
     176                 :          77 :   auto expr_vis = [this, &item] () { AST::DefaultASTVisitor::visit (item); };
     177                 :             : 
     178                 :             :   // FIXME: Why do we need a Rib here?
     179                 :          77 :   ctx.scoped (Rib::Kind::ConstantItem, item.get_node_id (), expr_vis);
     180                 :          77 : }
     181                 :             : 
     182                 :             : } // namespace Resolver2_0
     183                 :             : } // 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.