cprover
flatten_byte_extract_exceptions.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: Byte flattening
4 
5 Author: Diffblue Ltd.
6 
7 \*******************************************************************/
8 
9 #ifndef CPROVER_SOLVERS_FLATTENING_FLATTEN_BYTE_EXTRACT_EXCEPTIONS_H
10 #define CPROVER_SOLVERS_FLATTENING_FLATTEN_BYTE_EXTRACT_EXCEPTIONS_H
11 
12 #include <sstream>
13 #include <stdexcept>
14 #include <string>
15 
16 #include <util/std_expr.h>
17 #include <util/std_types.h>
18 
19 class flatten_byte_extract_exceptiont : public std::runtime_error
20 {
21 public:
22  explicit flatten_byte_extract_exceptiont(const std::string &exception_message)
23  : runtime_error(exception_message)
24  {
25  }
26 };
27 
29 {
30 public:
32  : flatten_byte_extract_exceptiont("cannot unpack array of non-const size"),
35  {
36  std::ostringstream error_message;
37  error_message << runtime_error::what() << "\n";
38  error_message << "array_type: " << array_type.pretty();
39  error_message << "\nmax_bytes: " << max_bytes.pretty();
40  computed_error_message = error_message.str();
41  }
42 
43  const char *what() const optional_noexcept override
44  {
45  return computed_error_message.c_str();
46  }
47 
48 private:
51 
53 };
54 
56 {
57 public:
61  const mp_integer &byte_width)
63  "cannot unpack struct with non-byte aligned components"),
67  {
68  std::ostringstream error_message;
69  error_message << runtime_error::what() << "\n";
70  error_message << "width: " << byte_width << "\n";
71  error_message << "component:" << component.get_name() << "\n";
72  error_message << "struct_type: " << struct_type.pretty();
73  computed_error_message = error_message.str();
74  }
75 
76  const char *what() const optional_noexcept override
77  {
78  return computed_error_message.c_str();
79  }
80 
81 private:
85 
87 };
88 
90 {
91 public:
92 public:
95  "cannot unpack object of non-constant width"),
96  src(src),
98  {
99  std::ostringstream error_message;
100  error_message << runtime_error::what() << "\n";
101  error_message << "array_type: " << src.pretty();
102  error_message << "\nmax_bytes: " << max_bytes.pretty();
103  computed_error_message = error_message.str();
104  }
105 
106  const char *what() const optional_noexcept override
107  {
108  return computed_error_message.c_str();
109  }
110 
111 private:
114 
116 };
117 
119 {
120 public:
124  "byte_extract flatting with non-constant size"),
126  {
127  std::ostringstream error_message;
128  error_message << runtime_error::what() << "\n";
129  error_message << "unpack_expr: " << unpack_expr.pretty();
130  computed_error_message = error_message.str();
131  }
132 
133  const char *what() const optional_noexcept override
134  {
135  return computed_error_message.c_str();
136  }
137 
138 private:
140 
142 };
143 
144 #endif // CPROVER_SOLVERS_FLATTENING_FLATTEN_BYTE_EXTRACT_EXCEPTIONS_H
const irep_idt & get_name() const
Definition: std_types.h:182
BigInt mp_integer
Definition: mp_arith.h:22
non_const_array_sizet(const array_typet &array_type, const exprt &max_bytes)
std::string pretty(unsigned indent=0, unsigned max_indent=0) const
Definition: irep.cpp:641
Structure type.
Definition: std_types.h:297
const char * what() const optional_noexcept override
const char * what() const optional_noexcept override
non_const_byte_extraction_sizet(const byte_extract_exprt &unpack_expr)
non_byte_alignedt(const struct_typet &struct_type, const struct_union_typet::componentt &component, const mp_integer &byte_width)
API to expression classes.
const struct_union_typet::componentt component
non_constant_widtht(const exprt &src, const exprt &max_bytes)
const char * what() const optional_noexcept override
API to type classes.
flatten_byte_extract_exceptiont(const std::string &exception_message)
Base class for all expressions.
Definition: expr.h:42
arrays with given size
Definition: std_types.h:1013
TO_BE_DOCUMENTED.
const char * what() const optional_noexcept override