LCOV - code coverage report
Current view: top level - gcc/rust/resolve - rust-finalize-imports-2.0.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 36.5 % 63 23
Test Date: 2026-02-28 14:20:25 Functions: 33.3 % 15 5
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-finalize-imports-2.0.h"
      20              : #include "rust-default-resolver.h"
      21              : #include "rust-hir-map.h"
      22              : #include "rust-name-resolution-context.h"
      23              : #include "rust-rib.h"
      24              : #include "rust-system.h"
      25              : #include "rust-toplevel-name-resolver-2.0.h"
      26              : 
      27              : namespace Rust {
      28              : namespace Resolver2_0 {
      29              : 
      30              : void
      31           16 : GlobbingVisitor::go (AST::GlobContainer *container)
      32              : {
      33           16 :   switch (container->get_glob_container_kind ())
      34              :     {
      35            8 :     case AST::GlobContainer::Kind::Module:
      36            8 :       visit_module_container (static_cast<AST::Module &> (*container));
      37            8 :       break;
      38            0 :     case AST::GlobContainer::Kind::Crate:
      39            0 :       visit_crate_container (static_cast<AST::Crate &> (*container));
      40            0 :       break;
      41            8 :     case AST::GlobContainer::Kind::Enum:
      42            8 :       visit_enum_container (static_cast<AST::Enum &> (*container));
      43            8 :       break;
      44            0 :     default:
      45            0 :       rust_unreachable ();
      46              :     }
      47           16 : }
      48              : 
      49              : void
      50            0 : GlobbingVisitor::visit_crate_container (AST::Crate &crate)
      51              : {
      52            0 :   for (auto &i : crate.items)
      53            0 :     visit (i);
      54            0 : }
      55              : 
      56              : void
      57            8 : GlobbingVisitor::visit_module_container (AST::Module &module)
      58              : {
      59           22 :   for (auto &i : module.get_items ())
      60           14 :     visit (i);
      61            8 : }
      62              : 
      63              : void
      64            8 : GlobbingVisitor::visit_enum_container (AST::Enum &item)
      65              : {
      66           24 :   for (auto &variant : item.get_variants ())
      67           26 :     ctx.insert_globbed (variant->get_identifier (), variant->get_node_id (),
      68              :                         Namespace::Types);
      69            8 : }
      70              : 
      71              : void
      72            4 : GlobbingVisitor::visit (AST::Module &module)
      73              : {
      74            5 :   ctx.insert_globbed (module.get_name (), module.get_node_id (),
      75              :                       Namespace::Types);
      76            4 : }
      77              : 
      78              : void
      79            0 : GlobbingVisitor::visit (AST::MacroRulesDefinition &macro)
      80              : {
      81            0 :   ctx.insert_globbed (macro.get_rule_name (), macro.get_node_id (),
      82              :                       Namespace::Macros);
      83            0 : }
      84              : 
      85              : void
      86           10 : GlobbingVisitor::visit (AST::Function &function)
      87              : {
      88           15 :   ctx.insert_globbed (function.get_function_name (), function.get_node_id (),
      89              :                       Namespace::Values);
      90           10 : }
      91              : 
      92              : void
      93            0 : GlobbingVisitor::visit (AST::StaticItem &static_item)
      94              : {
      95            0 :   ctx.insert_globbed (static_item.get_identifier (), static_item.get_node_id (),
      96              :                       Namespace::Values);
      97            0 : }
      98              : 
      99              : void
     100            0 : GlobbingVisitor::visit (AST::StructStruct &struct_item)
     101              : {
     102            0 :   ctx.insert_globbed (struct_item.get_identifier (), struct_item.get_node_id (),
     103              :                       Namespace::Types);
     104            0 :   if (struct_item.is_unit_struct ())
     105            0 :     ctx.insert_globbed (struct_item.get_identifier (),
     106            0 :                         struct_item.get_node_id (), Namespace::Values);
     107            0 : }
     108              : 
     109              : void
     110            0 : GlobbingVisitor::visit (AST::TupleStruct &tuple_struct)
     111              : {
     112            0 :   ctx.insert_globbed (tuple_struct.get_identifier (),
     113            0 :                       tuple_struct.get_node_id (), Namespace::Types);
     114              : 
     115            0 :   ctx.insert_globbed (tuple_struct.get_identifier (),
     116            0 :                       tuple_struct.get_node_id (), Namespace::Values);
     117            0 : }
     118              : 
     119              : void
     120            0 : GlobbingVisitor::visit (AST::Enum &enum_item)
     121              : {
     122            0 :   ctx.insert_globbed (enum_item.get_identifier (), enum_item.get_node_id (),
     123              :                       Namespace::Types);
     124            0 : }
     125              : 
     126              : void
     127            0 : GlobbingVisitor::visit (AST::Union &union_item)
     128              : {
     129            0 :   ctx.insert_globbed (union_item.get_identifier (), union_item.get_node_id (),
     130              :                       Namespace::Values);
     131            0 : }
     132              : 
     133              : void
     134            0 : GlobbingVisitor::visit (AST::ConstantItem &const_item)
     135              : {
     136            0 :   ctx.insert_globbed (const_item.get_identifier (), const_item.get_node_id (),
     137              :                       Namespace::Values);
     138            0 : }
     139              : 
     140              : void
     141            0 : GlobbingVisitor::visit (AST::ExternCrate &crate)
     142            0 : {}
     143              : 
     144              : void
     145            0 : GlobbingVisitor::visit (AST::UseDeclaration &use)
     146              : {
     147              :   // Handle cycles ?
     148            0 : }
     149              : 
     150              : } // namespace Resolver2_0
     151              : } // 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.