Skip to content

prophecy_r_or_w_ok_exprt lowering: adjust for dynamic/static objects #8629

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions src/util/pointer_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ Author: Daniel Kroening, [email protected]
#include "byte_operators.h"
#include "c_types.h"
#include "expr_util.h"
#include "namespace.h"
#include "pointer_offset_size.h"
#include "pointer_predicates.h"
#include "simplify_expr.h"
#include "symbol.h"

void dynamic_object_exprt::set_instance(unsigned int instance)
{
Expand Down Expand Up @@ -247,6 +249,41 @@ exprt pointer_in_range_exprt::lower() const

exprt prophecy_r_or_w_ok_exprt::lower(const namespacet &ns) const
{
exprt base_ptr = skip_typecast(pointer());
if(auto plus_expr = expr_try_dynamic_cast<plus_exprt>(base_ptr))
{
if(plus_expr->op0().id() == ID_address_of)
base_ptr = plus_expr->op0();
}
if(auto address_of = expr_try_dynamic_cast<address_of_exprt>(base_ptr))
{
const exprt &root_object =
object_descriptor_exprt::root_object(address_of->object());
if(auto symbol_expr = expr_try_dynamic_cast<symbol_exprt>(root_object))
{
const symbolt *s_ptr = nullptr;
if(
!ns.lookup(symbol_expr->get_identifier(), s_ptr) &&
s_ptr->is_static_lifetime)
{
return and_exprt{
{not_exprt{null_object(pointer())},
not_exprt{is_invalid_pointer_exprt{pointer()}},
not_exprt{object_lower_bound(pointer(), nil_exprt())},
not_exprt{object_upper_bound(pointer(), size())}}};
}
else if(symbol_expr->get_identifier().starts_with(SYMEX_DYNAMIC_PREFIX
"::"))
{
return and_exprt{
{not_exprt{null_object(pointer())},
not_exprt{is_invalid_pointer_exprt{pointer()}},
not_exprt{same_object(pointer(), deallocated_ptr())},
not_exprt{object_lower_bound(pointer(), nil_exprt())},
not_exprt{object_upper_bound(pointer(), size())}}};
}
}
}
return and_exprt{
{not_exprt{null_object(pointer())},
not_exprt{is_invalid_pointer_exprt{pointer()}},
Expand Down
Loading