LCOV - code coverage report
Current view: top level - gcc/rust/hir/tree - rust-hir-pattern-abstract.h (source / functions) Coverage Total Hit
Test: gcc.info Lines: 62.5 % 8 5
Test Date: 2026-08-22 16:33:35 Functions: 33.3 % 3 1
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              : #ifndef RUST_HIR_PATTERN_ABSTRACT_H
      20              : #define RUST_HIR_PATTERN_ABSTRACT_H
      21              : 
      22              : #include "rust-hir-visitable.h"
      23              : #include "rust-hir-visitor.h"
      24              : #include "rust-hir-node.h"
      25              : #include "rust-system.h"
      26              : 
      27              : namespace Rust {
      28              : namespace TyTy {
      29              : class BaseType;
      30              : }
      31              : namespace HIR {
      32              : // Pattern base HIR node
      33          151 : class Pattern : public Node, virtual public FullVisitable
      34              : {
      35              : public:
      36              :   using FullVisitable::accept_vis;
      37              : 
      38              :   enum PatternType
      39              :   {
      40              :     PATH,
      41              :     LITERAL,
      42              :     IDENTIFIER,
      43              :     WILDCARD,
      44              :     RANGE,
      45              :     REFERENCE,
      46              :     STRUCT,
      47              :     TUPLE_STRUCT,
      48              :     TUPLE,
      49              :     GROUPED,
      50              :     SLICE,
      51              :     ALT
      52              :   };
      53              : 
      54            0 :   BaseKind get_hir_kind () override final { return PATTERN; }
      55              : 
      56              :   // Unique pointer custom clone function
      57        56103 :   std::unique_ptr<Pattern> clone_pattern () const
      58              :   {
      59        56103 :     return std::unique_ptr<Pattern> (clone_pattern_impl ());
      60              :   }
      61              : 
      62              :   virtual ~Pattern () {}
      63              : 
      64              :   // Syntactic refutability. ICEs for patterns whose refutability depends
      65              :   // on type context (Path, Range, Slice, Alt). Callers that might
      66              :   // encounter such patterns must use the typed overload.
      67              :   virtual bool is_refutable () const = 0;
      68              :   // Type-aware refutability. Defaults to the syntactic answer for
      69              :   // patterns whose refutability is independent of the scrutinee type.
      70              : 
      71              :   // Virtual method overriden by classes that enable this.
      72              :   virtual bool
      73          373 :   is_refutable (const TyTy::BaseType &scrutinee ATTRIBUTE_UNUSED) const
      74              :   {
      75          373 :     return is_refutable ();
      76              :   }
      77              : 
      78              :   virtual std::string to_string () const = 0;
      79              : 
      80            0 :   std::string to_debug_string () const
      81              :   {
      82            0 :     return to_string () + get_mappings ().as_string ();
      83              :   }
      84              : 
      85              :   virtual void accept_vis (HIRPatternVisitor &vis) = 0;
      86              : 
      87              :   virtual const Analysis::NodeMapping &get_mappings () const = 0;
      88              : 
      89              :   virtual location_t get_locus () const = 0;
      90              : 
      91              :   virtual PatternType get_pattern_type () const = 0;
      92              : 
      93              : protected:
      94              :   // Clone pattern implementation as pure virtual method
      95              :   virtual Pattern *clone_pattern_impl () const = 0;
      96              : };
      97              : 
      98              : } // namespace HIR
      99              : } // namespace Rust
     100              : 
     101              : #endif
        

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.