Disable tests for strdup/strndup on __hpux__
[official-gcc.git] / gcc / analyzer / record-layout.h
blob2fa1e4aa4b0fbeb33872f6cd17a7c2003370c78d
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)
10 any later version.
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"
26 namespace ana {
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. */
31 class record_layout
33 public:
34 /* An item within a record; either a field, or padding after a field. */
35 struct item
37 public:
38 item (const bit_range &br,
39 tree field,
40 bool is_padding)
41 : m_bit_range (br),
42 m_field (field),
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
63 if (m_is_padding)
64 pp_printf (pp, "padding after %qD", m_field);
65 else
66 pp_printf (pp, "%qD", m_field);
67 pp_string (pp, ", ");
68 m_bit_range.dump_to_pp (pp);
71 bit_range m_bit_range;
72 tree m_field;
73 bool m_is_padding;
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;
83 private:
84 void maybe_pad_to (bit_offset_t next_offset);
86 auto_vec<item> m_items;
89 } // namespace ana
91 #endif /* GCC_ANALYZER_RECORD_LAYOUT_H */