|
12 | 12 | #include "byte_operators.h"
|
13 | 13 | #include "c_types.h"
|
14 | 14 | #include "expr_util.h"
|
| 15 | +#include "namespace.h" |
15 | 16 | #include "pointer_offset_size.h"
|
16 | 17 | #include "pointer_predicates.h"
|
17 | 18 | #include "simplify_expr.h"
|
| 19 | +#include "symbol.h" |
18 | 20 |
|
19 | 21 | void dynamic_object_exprt::set_instance(unsigned int instance)
|
20 | 22 | {
|
@@ -247,6 +249,41 @@ exprt pointer_in_range_exprt::lower() const
|
247 | 249 |
|
248 | 250 | exprt prophecy_r_or_w_ok_exprt::lower(const namespacet &ns) const
|
249 | 251 | {
|
| 252 | + exprt base_ptr = skip_typecast(pointer()); |
| 253 | + if(auto plus_expr = expr_try_dynamic_cast<plus_exprt>(base_ptr)) |
| 254 | + { |
| 255 | + if(plus_expr->op0().id() == ID_address_of) |
| 256 | + base_ptr = plus_expr->op0(); |
| 257 | + } |
| 258 | + if(auto address_of = expr_try_dynamic_cast<address_of_exprt>(base_ptr)) |
| 259 | + { |
| 260 | + const exprt &root_object = |
| 261 | + object_descriptor_exprt::root_object(address_of->object()); |
| 262 | + if(auto symbol_expr = expr_try_dynamic_cast<symbol_exprt>(root_object)) |
| 263 | + { |
| 264 | + const symbolt *s_ptr = nullptr; |
| 265 | + if( |
| 266 | + !ns.lookup(symbol_expr->get_identifier(), s_ptr) && |
| 267 | + s_ptr->is_static_lifetime) |
| 268 | + { |
| 269 | + return and_exprt{ |
| 270 | + {not_exprt{null_object(pointer())}, |
| 271 | + not_exprt{is_invalid_pointer_exprt{pointer()}}, |
| 272 | + not_exprt{object_lower_bound(pointer(), nil_exprt())}, |
| 273 | + not_exprt{object_upper_bound(pointer(), size())}}}; |
| 274 | + } |
| 275 | + else if(symbol_expr->get_identifier().starts_with(SYMEX_DYNAMIC_PREFIX |
| 276 | + "::")) |
| 277 | + { |
| 278 | + return and_exprt{ |
| 279 | + {not_exprt{null_object(pointer())}, |
| 280 | + not_exprt{is_invalid_pointer_exprt{pointer()}}, |
| 281 | + not_exprt{same_object(pointer(), deallocated_ptr())}, |
| 282 | + not_exprt{object_lower_bound(pointer(), nil_exprt())}, |
| 283 | + not_exprt{object_upper_bound(pointer(), size())}}}; |
| 284 | + } |
| 285 | + } |
| 286 | + } |
250 | 287 | return and_exprt{
|
251 | 288 | {not_exprt{null_object(pointer())},
|
252 | 289 | not_exprt{is_invalid_pointer_exprt{pointer()}},
|
|
0 commit comments