Line data Source code
1 : /* A (cluster_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 (cluster_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 51453 : pointer (const cluster_region &cluster_reg,
38 : const symbolic_byte_offset &byte_offset)
39 18720 : : m_cluster_reg (cluster_reg),
40 18720 : m_byte_offset (byte_offset)
41 : {
42 : }
43 :
44 : void dump () const;
45 :
46 : bool
47 5708 : operator== (const pointer &other) const
48 : {
49 5708 : return (&m_cluster_reg == &other.m_cluster_reg
50 5708 : && &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 967463 : zero_offset_p () const
64 : {
65 967463 : 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 : /* Deprecated (poor terminology); use get_cluster_region instead. */
80 : const cluster_region &
81 6672421 : get_base_region () const { return m_cluster_reg; }
82 :
83 : const cluster_region &
84 271331 : get_cluster_region () const { return m_cluster_reg; }
85 :
86 : const symbolic_byte_offset &
87 3004457 : get_byte_offset () const { return m_byte_offset; }
88 :
89 : static tristate
90 : eval_condition (const pointer &lhs_ptr,
91 : enum tree_code op,
92 : const pointer &rhs_ptr,
93 : const region_model &model);
94 :
95 : private:
96 : const cluster_region &m_cluster_reg;
97 : const symbolic_byte_offset &m_byte_offset;
98 : };
99 :
100 : } // namespace ana::symbolic
101 :
102 : } // namespace ana
103 :
104 : #endif /* GCC_ANALYZER_SYMBOLIC_POINTERS_H */
|