LCOV - code coverage report
Current view: top level - gcc/rust - rust-gcc.h Coverage Total Hit
Test: gcc.info Lines: 100.0 % 5 5
Test Date: 2026-02-28 14:20:25 Functions: - 0 0
Legend: Lines:     hit not hit

            Line data    Source code
       1              : // rust-gcc.cc -- Rust frontend to gcc IR.
       2              : // Copyright (C) 2011-2026 Free Software Foundation, Inc.
       3              : // Contributed by Ian Lance Taylor, Google.
       4              : // forked from gccgo
       5              : 
       6              : // This file is part of GCC.
       7              : 
       8              : // GCC is free software; you can redistribute it and/or modify it under
       9              : // the terms of the GNU General Public License as published by the Free
      10              : // Software Foundation; either version 3, or (at your option) any later
      11              : // version.
      12              : 
      13              : // GCC is distributed in the hope that it will be useful, but WITHOUT ANY
      14              : // WARRANTY; without even the implied warranty of MERCHANTABILITY or
      15              : // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
      16              : // for more details.
      17              : 
      18              : // You should have received a copy of the GNU General Public License
      19              : // along with GCC; see the file COPYING3.  If not see
      20              : // <http://www.gnu.org/licenses/>.
      21              : 
      22              : // This has to be included outside of extern "C", so we have to
      23              : // include it here before tree.h includes it later.
      24              : 
      25              : #ifndef RUST_GCC
      26              : #define RUST_GCC
      27              : 
      28              : #include "rust-location.h"
      29              : 
      30              : // Bvariable is a bit more complicated, because of zero-sized types.
      31              : // The GNU linker does not permit dynamic variables with zero size.
      32              : // When we see such a variable, we generate a version of the type with
      33              : // non-zero size.  However, when referring to the global variable, we
      34              : // want an expression of zero size; otherwise, if, say, the global
      35              : // variable is passed to a function, we will be passing a
      36              : // non-zero-sized value to a zero-sized value, which can lead to a
      37              : // miscompilation.
      38              : 
      39              : class Bvariable
      40              : {
      41              : public:
      42        63047 :   Bvariable (tree t) : t_ (t), orig_type_ (NULL) {}
      43              : 
      44           50 :   Bvariable (tree t, tree orig_type) : t_ (t), orig_type_ (orig_type) {}
      45              : 
      46              :   // Get the tree for use as an expression.
      47              :   tree get_tree (location_t) const;
      48              : 
      49              :   // Get the actual decl;
      50        26598 :   tree get_decl () const { return this->t_; }
      51              : 
      52              :   // Create an error variable.  This is used for cases which should
      53              :   // not occur in a correct program, in order to keep the compilation
      54              :   // going without crashing.
      55              :   static Bvariable *error_variable ();
      56              : 
      57              : private:
      58              :   tree t_;
      59              :   tree orig_type_;
      60              : };
      61              : 
      62              : // like Bvariable, but orig_type_ == nullptr always holds
      63              : // could be any variable which isn't a zero-sized global
      64              : class LocalVariable
      65              : {
      66              : public:
      67        41671 :   LocalVariable (tree t) : t (t) {}
      68              : 
      69              :   // Get the tree for use as an expression.
      70              :   tree get_tree (location_t) const;
      71              : 
      72              :   // Get the actual decl;
      73              :   tree get_decl () const { return t; }
      74              : 
      75              :   // Create an error variable.  This is used for cases which should
      76              :   // not occur in a correct program, in order to keep the compilation
      77              :   // going without crashing.
      78              :   static LocalVariable error_variable ();
      79              : 
      80        41331 :   operator Bvariable * () const { return new Bvariable (t); }
      81              : 
      82              : private:
      83              :   tree t;
      84              : };
      85              : 
      86              : #endif // RUST_GCC
        

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.