LCOV - code coverage report
Current view: top level - gcc/rust/checks/errors/borrowck/polonius - rust-polonius-ffi.h (source / functions) Coverage Total Hit
Test: gcc.info Lines: 0.0 % 3 0
Test Date: 2024-12-21 13:15:12 Functions: - 0 0
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : // Copyright (C) 2020-2024 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_POLONIUS_FACTS_FFI_H
      20                 :             : #define RUST_POLONIUS_FACTS_FFI_H
      21                 :             : 
      22                 :             : #include "rust-system.h"
      23                 :             : 
      24                 :             : // This file defines the C++ side of the FFI interface to Polonius.
      25                 :             : // The corresponding Rust side is in `gccrs-ffi.rs`.
      26                 :             : 
      27                 :             : // IMPORTANT:
      28                 :             : // This file intentionally does not include any C++ headers
      29                 :             : // to allow seamless binding generation on the Rust side.
      30                 :             : 
      31                 :             : namespace Rust {
      32                 :             : namespace Polonius {
      33                 :             : 
      34                 :             : using Origin = size_t;
      35                 :             : using Loan = size_t;
      36                 :             : /**
      37                 :             :  * Compressed CFG point
      38                 :             :  * Encoding:
      39                 :             :  *  - (bit size - 16) bits: basic block index
      40                 :             :  *  - 15 bits: stmt index inside basic block
      41                 :             :  *  - 1bit: start or mid
      42                 :             :  *
      43                 :             :  * Note: Polonius requires the holding type to be `size_t`/`usize`.
      44                 :             :  */
      45                 :             : using Point = size_t;
      46                 :             : using Variable = size_t;
      47                 :             : using Path = size_t;
      48                 :             : 
      49                 :             : namespace FFI {
      50                 :             : 
      51                 :             : // NOTE: std::pair and std::tuple are complicating the bindings' generation.
      52                 :             : template <typename T1, typename T2> struct Pair
      53                 :             : {
      54                 :             :   T1 first;
      55                 :             :   T2 second;
      56                 :             : 
      57                 :           0 :   Pair (T1 first, T2 second) : first (first), second (second) {}
      58                 :             : };
      59                 :             : 
      60                 :             : template <typename T1, typename T2, typename T3> struct Triple
      61                 :             : {
      62                 :             :   T1 first;
      63                 :             :   T2 second;
      64                 :             :   T3 third;
      65                 :             : 
      66                 :           0 :   Triple (T1 first, T2 second, T3 third)
      67                 :           0 :     : first (first), second (second), third (third)
      68                 :             :   {}
      69                 :             : };
      70                 :             : 
      71                 :             : /** Frozen variant to vector for FFI */
      72                 :             : template <typename T> struct Slice
      73                 :             : {
      74                 :             :   size_t len;
      75                 :             :   const T *const data;
      76                 :             : 
      77                 :             :   template <typename vector>
      78                 :             :   Slice (const vector &v) : len (v.size ()), data (v.data ())
      79                 :             :   {}
      80                 :             : };
      81                 :             : 
      82                 :             : /** Frozen variant of the facts with C ABI and no methods. */
      83                 :             : struct FactsView
      84                 :             : {
      85                 :             :   Slice<Triple<Origin, Loan, Point>> loan_issued_at;
      86                 :             :   Slice<Origin> universal_region;
      87                 :             :   Slice<Pair<Point, Point>> cfg_edge;
      88                 :             :   Slice<Pair<Loan, Point>> loan_killed_at;
      89                 :             :   Slice<Triple<Origin, Origin, Point>> subset_base;
      90                 :             :   Slice<Pair<Point, Loan>> loan_invalidated_at;
      91                 :             :   Slice<Pair<Variable, Point>> var_used_at;
      92                 :             :   Slice<Pair<Variable, Point>> var_defined_at;
      93                 :             :   Slice<Pair<Variable, Point>> var_dropped_at;
      94                 :             :   Slice<Pair<Variable, Origin>> use_of_var_derefs_origin;
      95                 :             :   Slice<Pair<Variable, Origin>> drop_of_var_derefs_origin;
      96                 :             :   Slice<Pair<Path, Path>> child_path;
      97                 :             :   Slice<Pair<Path, Variable>> path_is_var;
      98                 :             :   Slice<Pair<Path, Point>> path_assigned_at_base;
      99                 :             :   Slice<Pair<Path, Point>> path_moved_at_base;
     100                 :             :   Slice<Pair<Path, Point>> path_accessed_at_base;
     101                 :             :   Slice<Pair<Origin, Origin>> known_placeholder_subset;
     102                 :             :   Slice<Pair<Origin, Loan>> placeholder;
     103                 :             : };
     104                 :             : 
     105                 :             : } // namespace FFI
     106                 :             : } // namespace Polonius
     107                 :             : } // namespace Rust
     108                 :             : 
     109                 :             : #endif // RUST_POLONIUS_FACTS_FFI_H
        

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.