Line data Source code
1 : /* A (base_region, symbolic byte offset) pair.
2 : Copyright (C) 2026 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_SYMBOLIC_POINTERS_H
22 : #define GCC_ANALYZER_SYMBOLIC_POINTERS_H
23 :
24 : #include "analyzer/symbolic-ranges.h"
25 :
26 : namespace ana {
27 : namespace symbolic {
28 :
29 : /* A (base_region, symbolic byte offset) pair.
30 : Note that these have a granularity of *bytes*. */
31 :
32 : class pointer
33 : {
34 : public:
35 : using symbolic_byte_offset = symbolic::scalar<integer_with_unit<units::byte>>;
36 :
37 50061 : pointer (const region &base_reg,
38 : const symbolic_byte_offset &byte_offset)
39 17581 : : m_base_reg (base_reg),
40 17581 : m_byte_offset (byte_offset)
41 : {
42 : }
43 :
44 : void dump () const;
45 :
46 : bool
47 5707 : operator== (const pointer &other) const
48 : {
49 5707 : return (&m_base_reg == &other.m_base_reg
50 5707 : && &m_byte_offset == &other.m_byte_offset);
51 : }
52 :
53 : bool
54 4 : operator!= (const pointer &other) const
55 : {
56 8 : return !(*this == other);
57 : }
58 :
59 : int
60 : cmp (const pointer &other) const;
61 :
62 : bool
63 962098 : zero_offset_p () const
64 : {
65 962098 : return m_byte_offset.is_zero_p ();
66 : }
67 :
68 : bool non_null_p () const;
69 :
70 : std::unique_ptr<text_art::tree_widget>
71 : make_dump_widget (node_dump_state &nds) const;
72 :
73 : void
74 : accept_node_visitor (symbolic::node_visitor &v) const;
75 :
76 : std::unique_ptr<json::object>
77 : to_json () const;
78 :
79 : const region &
80 6861327 : get_base_region () const { return m_base_reg; }
81 :
82 : const symbolic_byte_offset &
83 2883191 : get_byte_offset () const { return m_byte_offset; }
84 :
85 : static tristate
86 : eval_condition (const pointer &lhs_ptr,
87 : enum tree_code op,
88 : const pointer &rhs_ptr,
89 : const region_model &model);
90 :
91 : private:
92 : const region &m_base_reg;
93 : const symbolic_byte_offset &m_byte_offset;
94 : };
95 :
96 : } // namespace ana::symbolic
97 :
98 : } // namespace ana
99 :
100 : #endif /* GCC_ANALYZER_SYMBOLIC_POINTERS_H */
|