1 /* Declaration of class record_layout.
2 Copyright (C) 2022-2024 Free Software Foundation, Inc.
3 Contributed by David Malcolm <dmalcolm@redhat.com>.
5 This file is part of GCC.
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)
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.
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/>. */
21 #ifndef GCC_ANALYZER_RECORD_LAYOUT_H
22 #define GCC_ANALYZER_RECORD_LAYOUT_H
24 #include "analyzer/store.h"
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. */
34 /* An item within a record; either a field, or padding after a field. */
38 item (const bit_range
&br
,
43 m_is_padding (is_padding
)
47 bit_offset_t
get_start_bit_offset () const
49 return m_bit_range
.get_start_bit_offset ();
51 bit_offset_t
get_next_bit_offset () const
53 return m_bit_range
.get_next_bit_offset ();
56 bool contains_p (bit_offset_t offset
) const
58 return m_bit_range
.contains_p (offset
);
61 void dump_to_pp (pretty_printer
*pp
) const
64 pp_printf (pp
, "padding after %qD", m_field
);
66 pp_printf (pp
, "%qD", m_field
);
68 m_bit_range
.dump_to_pp (pp
);
71 bit_range m_bit_range
;
76 record_layout (tree record_type
);
78 void dump_to_pp (pretty_printer
*pp
) const;
79 DEBUG_FUNCTION
void dump () const;
81 const record_layout::item
*get_item_at (bit_offset_t offset
) const;
84 void maybe_pad_to (bit_offset_t next_offset
);
86 auto_vec
<item
> m_items
;
91 #endif /* GCC_ANALYZER_RECORD_LAYOUT_H */