LCOV - code coverage report
Current view: top level - gcc/analyzer - record-layout.h (source / functions) Coverage Total Hit
Test: gcc.info Lines: 61.1 % 18 11
Test Date: 2024-04-27 14:03:13 Functions: 0.0 % 1 0
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : /* Declaration of class record_layout.
       2                 :             :    Copyright (C) 2022-2024 Free Software Foundation, Inc.
       3                 :             :    Contributed by David Malcolm <dmalcolm@redhat.com>.
       4                 :             : 
       5                 :             : This file is part of GCC.
       6                 :             : 
       7                 :             : GCC is free software; you can redistribute it and/or modify it
       8                 :             : under the terms of the GNU General Public License as published by
       9                 :             : the Free Software Foundation; either version 3, or (at your option)
      10                 :             : any later version.
      11                 :             : 
      12                 :             : GCC is distributed in the hope that it will be useful, but
      13                 :             : WITHOUT ANY WARRANTY; without even the implied warranty of
      14                 :             : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      15                 :             : General Public License for more details.
      16                 :             : 
      17                 :             : You should have received a copy of the GNU General Public License
      18                 :             : along with GCC; see the file COPYING3.  If not see
      19                 :             : <http://www.gnu.org/licenses/>.  */
      20                 :             : 
      21                 :             : #ifndef GCC_ANALYZER_RECORD_LAYOUT_H
      22                 :             : #define GCC_ANALYZER_RECORD_LAYOUT_H
      23                 :             : 
      24                 :             : #include "analyzer/store.h"
      25                 :             : 
      26                 :             : namespace ana {
      27                 :             : 
      28                 :             : /* Information of the layout of a RECORD_TYPE, capturing it as a vector
      29                 :             :    of items, where each item is either a field or padding.  */
      30                 :             : 
      31                 :          17 : class record_layout
      32                 :             : {
      33                 :             : public:
      34                 :             :   /* An item within a record; either a field, or padding after a field.  */
      35                 :             :   struct item
      36                 :             :   {
      37                 :             :   public:
      38                 :          88 :     item (const bit_range &br,
      39                 :             :           tree field,
      40                 :             :           bool is_padding)
      41                 :          88 :     : m_bit_range (br),
      42                 :          88 :       m_field (field),
      43                 :          88 :       m_is_padding (is_padding)
      44                 :             :     {
      45                 :             :     }
      46                 :             : 
      47                 :         110 :     bit_offset_t get_start_bit_offset () const
      48                 :             :     {
      49                 :         110 :       return m_bit_range.get_start_bit_offset ();
      50                 :             :     }
      51                 :         240 :     bit_offset_t get_next_bit_offset () const
      52                 :             :     {
      53                 :         240 :       return m_bit_range.get_next_bit_offset ();
      54                 :             :     }
      55                 :             : 
      56                 :         841 :     bool contains_p (bit_offset_t offset) const
      57                 :             :     {
      58                 :         841 :       return m_bit_range.contains_p (offset);
      59                 :             :     }
      60                 :             : 
      61                 :           0 :     void dump_to_pp (pretty_printer *pp) const
      62                 :             :     {
      63                 :           0 :       if (m_is_padding)
      64                 :           0 :         pp_printf (pp, "padding after %qD", m_field);
      65                 :             :       else
      66                 :           0 :         pp_printf (pp, "%qD", m_field);
      67                 :           0 :       pp_string (pp, ", ");
      68                 :           0 :       m_bit_range.dump_to_pp (pp);
      69                 :           0 :     }
      70                 :             : 
      71                 :             :     bit_range m_bit_range;
      72                 :             :     tree m_field;
      73                 :             :     bool m_is_padding;
      74                 :             :   };
      75                 :             : 
      76                 :             :   record_layout (tree record_type);
      77                 :             : 
      78                 :             :   void dump_to_pp (pretty_printer *pp) const;
      79                 :             :   DEBUG_FUNCTION void dump () const;
      80                 :             : 
      81                 :             :   const record_layout::item *get_item_at (bit_offset_t offset) const;
      82                 :             : 
      83                 :             : private:
      84                 :             :   void maybe_pad_to (bit_offset_t next_offset);
      85                 :             : 
      86                 :             :   auto_vec<item> m_items;
      87                 :             : };
      88                 :             : 
      89                 :             : } // namespace ana
      90                 :             : 
      91                 :             : #endif /* GCC_ANALYZER_RECORD_LAYOUT_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.