]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/analyzer/ranges.h
Update copyright years.
[thirdparty/gcc.git] / gcc / analyzer / ranges.h
1 /* Symbolic offsets and ranges.
2 Copyright (C) 2023-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_RANGES_H
22 #define GCC_ANALYZER_RANGES_H
23
24 namespace ana {
25
26 /* Wrapper around an svalue for a value measured in bytes. */
27
28 class symbolic_byte_offset
29 {
30 public:
31 explicit symbolic_byte_offset (int i, region_model_manager &mgr);
32 symbolic_byte_offset (const svalue *num_bytes_sval);
33 explicit symbolic_byte_offset (region_offset offset,
34 region_model_manager &mgr);
35
36 const svalue *get_svalue () const { return m_num_bytes_sval; }
37 tree maybe_get_constant () const;
38
39 void dump_to_pp (pretty_printer *pp, bool) const;
40 void dump (bool) const;
41
42 bool operator== (const symbolic_byte_offset &other) const
43 {
44 return m_num_bytes_sval == other.m_num_bytes_sval;
45 }
46
47 private:
48 const svalue *m_num_bytes_sval;
49 };
50
51 /* A range of byte offsets, where both the start and size of the
52 range can be symbolic. */
53
54 class symbolic_byte_range
55 {
56 public:
57 symbolic_byte_range (symbolic_byte_offset start,
58 symbolic_byte_offset size)
59 : m_start (start),
60 m_size (size)
61 {
62 }
63
64 symbolic_byte_range (region_offset start,
65 const svalue *num_bytes,
66 region_model_manager &mgr);
67
68 void dump_to_pp (pretty_printer *pp,
69 bool simple,
70 region_model_manager &mgr) const;
71 void dump (bool, region_model_manager &mgr) const;
72
73 bool empty_p () const;
74
75 symbolic_byte_offset get_start_byte_offset () const
76 {
77 return m_start;
78 }
79 symbolic_byte_offset get_last_byte_offset (region_model_manager &mgr) const;
80 symbolic_byte_offset get_size_in_bytes () const
81 {
82 return m_size;
83 }
84 symbolic_byte_offset get_next_byte_offset (region_model_manager &mgr) const;
85
86 tristate intersection (const symbolic_byte_range &other,
87 const region_model &model) const;
88
89 private:
90 symbolic_byte_offset m_start;
91 symbolic_byte_offset m_size;
92 };
93
94 } // namespace ana
95
96 #endif /* GCC_ANALYZER_RANGES_H */