1/*******************************************************************\
3Module: Checks for Errors in C/C++ Programs
5Author: Daniel Kroening, kroening@kroening.com
7\*******************************************************************/
58 _options.get_bool_option(
"memory-cleanup-check");
61 _options.get_bool_option(
"float-div-by-zero-check");
64 _options.get_bool_option(
"signed-overflow-check");
66 _options.get_bool_option(
"unsigned-overflow-check");
68 _options.get_bool_option(
"pointer-overflow-check");
71 _options.get_bool_option(
"undefined-shift-check");
73 _options.get_bool_option(
"float-overflow-check");
80 _options.get_bool_option(
"pointer-primitive-check");
219 std::optional<goto_check_ct::conditiont>
222 const exprt &address,
225 const exprt &pointer,
229 const exprt &address,
250 const std::string &property_class,
306 // the first element of the pair is the base address,
307 // and the second is the size of the region
367 // make this a no-op if the flag is disabled
371 // detect double sets
376 if(flag != new_value)
396 // If the flag has not already been set,
397 // we store its current value in the reset map.
398 // Otherwise, the reset map already holds
399 // the initial value we want to reset it to, keep it as is.
403 // set the flag to false in all cases.
423 // rewrite a => (b => c) to (a && b) => c
440 for(
const auto &instruction :
gf_entry.second.body.instructions)
442 if(!instruction.is_function_call())
445 const auto &function = instruction.call_function();
452 instruction.call_arguments();
460 args[0].type() == args[1].type(),
461 "arguments of allocated_memory must have same type");
475 // clear all assertions about 'symbol'
492 // give up, clear all
504 // add divison by zero subgoal
526 // add divison by zero subgoal
533 "floating-point division by zero",
534 "float-division-by-zero",
550 return;
// not in range yet
552 // we might be looking at a lowered enum_is_in_range_exprt, skip over these
556 if(d.first ==
"disable:enum-range-check")
579 // Undefined for all types and shifts if distance exceeds width,
580 // and also undefined for negative distances.
591 "shift distance is negative",
608 "shift distance too large",
622 "shift operand is negative",
634 "shift of non-integer type",
650 // add divison by zero subgoal
673 const auto &type = expr.
type();
677 // INT_MIN % -1 is, in principle, defined to be zero in
678 // ANSI C, C99, C++98, and C++11. Most compilers, however,
679 // fail to produce 0, and in some cases generate an exception.
680 // C11 explicitly makes this case undefined.
690 "result of signed mod is not representable",
704 // First, check type.
714 // conversion to signed int may overflow
735 "arithmetic overflow on signed type conversion",
753 "arithmetic overflow on unsigned to signed type conversion",
762 // Note that the fractional part is truncated!
776 "arithmetic overflow on float to signed integer type conversion",
794 // only need lower bound check
800 "arithmetic overflow on signed to unsigned type conversion",
818 "arithmetic overflow on signed to unsigned type conversion",
837 "arithmetic overflow on unsigned to unsigned type conversion",
846 // Note that the fractional part is truncated!
860 "arithmetic overflow on float to unsigned integer type conversion",
878 // First, check type.
887 // add overflow subgoal
891 // undefined for signed division INT_MIN/-1
903 "arithmetic overflow on signed division",
917 // overflow on unary- on signed integers can only happen with the
918 // smallest representable number 100....0
925 "arithmetic overflow on signed unary minus",
934 // Overflow on unary- on unsigned integers happens for all operands
935 // that are not zero.
942 "arithmetic overflow on unsigned unary minus",
960 const auto &distance =
shl_expr.distance();
963 // a left shift of a negative value is undefined;
964 // yet this isn't an overflow
973 // a shift with negative distance is undefined;
974 // yet this isn't an overflow
985 // shifting a non-zero value by more than its width is undefined;
986 // yet this isn't an overflow
999 // The semantics of signed left shifts are contentious for the case
1000 // that a '1' is shifted into the signed bit.
1001 // Assuming 32-bit integers, 1<<31 is implementation-defined
1002 // in ANSI C and C++98, but is explicitly undefined by C99,
1037 // a negative distance shift isn't an overflow;
1038 // a negative value shift isn't an overflow;
1039 // a shift that's too far isn't an overflow;
1040 // a shift of zero isn't overflow;
1041 // else check the top bits
1049 "arithmetic overflow on signed shl",
1065 // The overflow checks are binary!
1066 // We break these up.
1068 for(std::size_t i = 1; i < expr.
operands().size(); i++)
1077 tmp.operands().resize(i);
1080 std::string kind = type.
id() ==
ID_unsignedbv ?
"unsigned" :
"signed";
1084 "arithmetic overflow on " + kind +
" " + expr.
id_string(),
1092 else if(expr.
operands().size() == 2)
1094 std::string kind = type.
id() ==
ID_unsignedbv ?
"unsigned" :
"signed";
1099 "arithmetic overflow on " + kind +
" " + expr.
id_string(),
1110 std::string kind = type.
id() ==
ID_unsignedbv ?
"unsigned" :
"signed";
1114 "arithmetic overflow on " + kind +
" " + expr.
id_string(),
1128 // First, check type.
1134 // add overflow subgoal
1138 // Can overflow if casting from larger
1148 "arithmetic overflow on floating-point typecast",
1157 // non-float-to-float
1160 "arithmetic overflow on floating-point typecast",
1172 // Can overflow if dividing by something small
1178 "arithmetic overflow on floating-point division",
1207 std::string kind = expr.
id() ==
ID_plus ?
"addition"
1209 : expr.
id() ==
ID_mult ?
"multiplication"
1214 "arithmetic overflow on floating-point " + kind,
1223 else if(expr.
operands().size() >= 3)
1239 // first, check type
1256 // there a two ways to get a new NaN on division:
1257 // 0/0 = NaN and x/inf = NaN
1258 // (note that x/0 = +-inf for x!=0 and x!=inf)
1296 // -inf + +inf = NaN and +inf + -inf = NaN,
1297 // i.e., signs differ
1312 // +inf - +inf = NaN and -inf - -inf = NaN,
1313 // i.e., signs match
1354 // add same-object subgoal
1360 "same object violation",
1367 for(
const auto &pointer : expr.
operands())
1369 // just this particular byte must be within object bounds or one past the
1374 for(
const auto &
c : conditions)
1378 "pointer relation: " +
c.description,
1379 "pointer arithmetic",
1401 "pointer arithmetic expected to have exactly 2 operands");
1403 // multiplying the offset by the object size must not result in arithmetic
1429 // the result must be within object bounds or one past the end
1433 for(
const auto &
c : conditions)
1437 "pointer arithmetic: " +
c.description,
1438 "pointer arithmetic",
1460 // a dereference *p (with p being a pointer to void) is valid if p points to
1461 // valid memory (of any size). the smallest possible size of the memory
1462 // segment p could be pointing to is 1, hence we use this size for the
1475 for(
const auto &
c : conditions)
1479 "dereference failure: " +
c.description,
1480 "pointer dereference",
1498 const exprt pointer =
1517 for(
const auto &
c : conditions)
1522 "pointer primitives",
1532 // we don't need to include the __CPROVER_same_object primitive here as it
1533 // is replaced by lower level primitives in the special function handling
1534 // during typechecking (see c_typecheck_expr.cpp)
1536 // pointer_object and pointer_offset are well-defined for an arbitrary
1537 // pointer-typed operand (and the operands themselves have been checked
1538 // separately for, e.g., invalid pointer dereferencing via check_rec):
1539 // pointer_object and pointer_offset just extract a subset of bits from the
1540 // pointer. If that pointer was unconstrained (non-deterministic), the result
1541 // will equally be non-deterministic.
1550 const exprt &address,
1564 return ::array_name(
ns, expr);
1591 throw "index got pointer as array type";
1593 throw "bounds check expected array or vector type, got " +
1600 ode.build(expr,
ns);
1604 // we undo typecasts to signedbv
1615 if(!i.has_value() || *i < 0)
1632 // the final offset must not be negative
1638 name +
" lower bound",
1673 name +
" dynamic object upper bound",
1689 // Linking didn't complete, we don't have a size.
1690 // Not clear what to do.
1699 // a variable sized struct member
1701 // Excerpt from the C standard on flexible array members:
1702 // However, when a . (or ->) operator has a left operand that is (a pointer
1703 // to) a structure with a flexible array member and the right operand names
1704 // that member, it behaves as if that member were replaced with the longest
1705 // array (with the same element type) that would not make the structure
1706 // larger than the object being accessed; [...]
1718 name +
" upper bound",
1732 name +
" upper bound",
1756 "count " + name +
" zeros is undefined for value zero",
1767 const std::string &property_class,
1773 // first try simplifier on it
1774 exprt simplified_expr =
1777 // throw away trivial properties?
1813 // we don't look into quantifiers
1840 "'" + expr.
id_string() +
"' must be Boolean, but got " + expr.
pretty());
1844 for(
const auto &op : expr.
operands())
1848 "'" + expr.
id_string() +
"' takes Boolean operands only, but got " +
1865 "first argument of if must be boolean, but got " +
if_expr.cond().pretty());
1892 // avoid building the following expressions when pointer_validity_check
1893 // would return immediately anyway
1897 // we rewrite s->member into *(s+member_offset)
1898 // to avoid requiring memory safety of the entire struct
1933 // Division by zero is undefined behavior for all integer types.
1938 // Division by zero on floating-point numbers may be undefined behavior.
1939 // Annex F of the ISO C21 suggests that implementations that
1940 // define __STDC_IEC_559__ follow IEEE 754 semantics,
1941 // which defines the outcome of division by zero.
1988 // the scoped variables may be used in the assertion
2021 for(
const auto &op : expr.
operands())
2084 // add self-assignment to get helpful counterexample output
2094 "dynamically allocated memory never freed",
2103 const irep_idt &function_identifier,
2117 std::make_unique<local_bitvector_analysist>(goto_function,
ns);
2130 // match named-check related pragmas
2141 resetter.set_flag(*flag,
true, name);
2144 resetter.set_flag(*flag,
false, name);
2147 resetter.disable_flag(*flag, name);
2153 // add checked pragmas for all active checks
2158 // we clear all recorded assertions if
2159 // 1) we want to generate all assertions or
2160 // 2) the instruction is a branch target
2169 // magic ERROR label?
2195 const irep_idt &statement = code.get_statement();
2203 for(
const auto &op : code.operands())
2212 check(assign_lhs,
true);
2213 check(assign_rhs,
false);
2215 // the LHS might invalidate any assertion
2228 // the call might invalidate any assertion
2234 // the return value invalidate any assertion
2239 // this has no successor
2244 // These are further 'exit points' of the program
2248 (function_identifier ==
"abort" || function_identifier ==
"exit" ||
2249 function_identifier ==
"_Exit" ||
2250 (i.
labels.size() == 1 && i.
labels.front() ==
"__VERIFIER_abort")))
2264 // need to mark the dead variable as dead
2290 if(instruction.source_location().is_nil())
2292 instruction.source_location_nonconst().id(
irep_idt());
2294 if(!it->source_location().get_file().empty())
2295 instruction.source_location_nonconst().set_file(
2296 it->source_location().get_file());
2298 if(!it->source_location().get_line().empty())
2299 instruction.source_location_nonconst().set_line(
2300 it->source_location().get_line());
2302 if(!it->source_location().get_function().empty())
2303 instruction.source_location_nonconst().set_function(
2304 it->source_location().get_function());
2306 if(!it->source_location().get_column().empty())
2308 instruction.source_location_nonconst().set_column(
2309 it->source_location().get_column());
2314 // insert new instructions -- make sure targets are not moved
2349 const exprt &address,
2376 "deallocated dynamic object"));
2398 "pointer outside dynamic object bounds"));
2411 "pointer outside object bounds"));
2419 "invalid integer address"));
2425std::optional<goto_check_ct::conditiont>
2427 const exprt &address,
2448 const exprt &pointer,
2471 const irep_idt &function_identifier,
2478 goto_check.
goto_check(function_identifier, goto_function);
2525 auto col = s.find(
":");
2527 if(
col == std::string::npos)
2528 return {};
// separator not found
2530 auto name = s.substr(
col + 1);
2533 return {};
// name unknown
2536 if(!s.compare(0, 6,
"enable"))
2538 else if(!s.compare(0, 7,
"disable"))
2540 else if(!s.compare(0, 7,
"checked"))
2543 return {};
// prefix unknow
2546 return std::pair<irep_idt, check_statust>{name, status};
API to expression classes for bitvectors.
const shift_exprt & to_shift_expr(const exprt &expr)
Cast an exprt to a shift_exprt.
const shl_exprt & to_shl_expr(const exprt &expr)
Cast an exprt to a shl_exprt.
const count_leading_zeros_exprt & to_count_leading_zeros_expr(const exprt &expr)
Cast an exprt to a count_leading_zeros_exprt.
const count_trailing_zeros_exprt & to_count_trailing_zeros_expr(const exprt &expr)
Cast an exprt to a count_trailing_zeros_exprt.
const bitvector_typet & to_bitvector_type(const typet &type)
Cast a typet to a bitvector_typet.
const floatbv_typet & to_floatbv_type(const typet &type)
Cast a typet to a floatbv_typet.
const unsignedbv_typet & to_unsignedbv_type(const typet &type)
Cast a typet to an unsignedbv_typet.
const signedbv_typet & to_signedbv_type(const typet &type)
Cast a typet to a signedbv_typet.
API to expression classes that are internal to the C frontend.
static exprt guard(const exprt::operandst &guards, exprt cond)
pointer_typet pointer_type(const typet &subtype)
signedbv_typet pointer_diff_type()
bitvector_typet char_type()
Operator to return the address of an object.
virtual void clear()
Reset the abstract state.
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
Boolean AND All operands must be boolean, and the result is always boolean.
A base class for binary expressions.
A Boolean expression returning true, iff operation kind would result in an overflow when applied to o...
A base class for expressions that are predicates, i.e., Boolean-typed, and that take exactly two argu...
A base class for relations, i.e., binary predicates whose two operands have the same type.
A goto_instruction_codet representing an assignment in the program.
exprt::operandst argumentst
struct configt::ansi_ct ansi_c
Operator to dereference a pointer.
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
A Boolean expression returning true, iff the value of an enum-typed symbol equals one of the enum's d...
Base class for all expressions.
const source_locationt & find_source_location() const
Get a source_locationt from the expression or from its operands (non-recursively).
std::vector< exprt > operandst
bool is_boolean() const
Return whether the expression represents a Boolean.
typet & type()
Return the type of the expression.
const source_locationt & source_location() const
The Boolean constant false.
~flag_overridet()
Restore the values of all flags that have been modified via set_flag.
void disable_flag(bool &flag, const irep_idt &flag_name)
Sets the given flag to false, overriding any previous value.
void set_flag(bool &flag, bool new_value, const irep_idt &flag_name)
Store the current value of flag and then set its value to new_value.
std::map< bool *, bool > flags_to_reset
flag_overridet(const source_locationt &source_location)
std::set< bool * > disabled_flags
const source_locationt & source_location
std::optional< std::pair< irep_idt, check_statust > > named_check_statust
optional (named-check, status) pair
named_check_statust match_named_check(const irep_idt &named_check) const
Matches a named-check string of the form.
void goto_check(const irep_idt &function_identifier, goto_functiont &goto_function)
void check_rec_logical_op(const exprt &expr, const guardt &guard)
Check a logical operation: check each operand in separation while extending the guarding condition as...
bool enable_float_div_by_zero_check
void check_rec_address(const exprt &expr, const guardt &guard)
Check an address-of expression: if it is a dereference then check the pointer if it is an index then ...
std::function< exprt(exprt)> guardt
std::string array_name(const exprt &)
void collect_allocations(const goto_functionst &goto_functions)
Fill the list of allocations allocationst with <address, size> for every allocation instruction.
bool enable_pointer_check
void memory_leak_check(const irep_idt &function_id)
exprt is_in_bounds_of_some_explicit_allocation(const exprt &pointer, const exprt &size)
std::optional< goto_check_ct::conditiont > get_pointer_is_null_condition(const exprt &address, const exprt &size)
void invalidate(const exprt &lhs)
Remove all assertions containing the symbol in lhs as well as all assertions containing dereference.
void float_div_by_zero_check(const div_exprt &, const guardt &)
check_statust
activation statuses for named checks
void float_overflow_check(const exprt &, const guardt &)
bool enable_pointer_primitive_check
void mod_overflow_check(const mod_exprt &, const guardt &)
check a mod expression for the case INT_MIN % -1
bool requires_pointer_primitive_check(const exprt &expr)
Returns true if the given expression is a pointer primitive that requires validation of the operand t...
std::map< irep_idt, bool * > name_to_flag
Maps a named-check name to the corresponding boolean flag.
std::list< conditiont > conditionst
bool enable_float_overflow_check
bool enable_conversion_check
void check_rec_div(const div_exprt &div_expr, const guardt &guard)
Check that a division is valid: check for division by zero, overflow and NaN (for floating point numb...
bool enable_pointer_overflow_check
void pointer_primitive_check(const exprt &expr, const guardt &guard)
Generates VCCs to check that pointers passed to pointer primitives are either null or valid.
void bounds_check_index(const index_exprt &, const guardt &)
bool enable_signed_overflow_check
conditionst get_pointer_dereferenceable_conditions(const exprt &address, const exprt &size)
void check_rec(const exprt &expr, const guardt &guard, bool is_assigned)
Recursively descend into expr and run the appropriate check for each sub-expression,...
bool check_rec_member(const member_exprt &member, const guardt &guard)
Check that a member expression is valid:
goto_functionst::goto_functiont goto_functiont
void bounds_check(const exprt &, const guardt &)
void check(const exprt &expr, bool is_assigned)
Initiate the recursively analysis of expr with its ‘guard’ set to TRUE.
std::pair< exprt, exprt > allocationt
void pointer_overflow_check(const exprt &, const guardt &)
bool enable_memory_leak_check
void add_guarded_property(const exprt &asserted_expr, const std::string &comment, const std::string &property_class, bool is_fatal, const source_locationt &source_location, const exprt &src_expr, const guardt &guard)
Include the asserted_expr in the code conditioned by the guard.
void conversion_check(const exprt &, const guardt &)
void check_rec_if(const if_exprt &if_expr, const guardt &guard)
Check an if expression: check the if-condition alone, and then check the true/false-cases with the gu...
void integer_overflow_check(const exprt &, const guardt &)
bool enable_assert_to_assume
bool enable_memory_cleanup_check
void nan_check(const exprt &, const guardt &)
bool enable_undefined_shift_check
std::list< allocationt > allocationst
bool enable_enum_range_check
goto_programt::const_targett current_target
void add_all_checked_named_check_pragmas(source_locationt &source_location) const
Adds "checked" pragmas for all named checks on the given source location (prevents any the instanciat...
void div_by_zero_check(const div_exprt &, const guardt &)
optionst::value_listt error_labelst
void add_active_named_check_pragmas(source_locationt &source_location) const
Adds "checked" pragmas for all currently active named checks on the given source location.
void pointer_rel_check(const binary_exprt &, const guardt &)
goto_check_ct(const namespacet &_ns, const optionst &_options, message_handlert &_message_handler)
conditionst get_pointer_points_to_valid_memory_conditions(const exprt &address, const exprt &size)
bool enable_unsigned_overflow_check
void bounds_check_bit_count(const unary_exprt &, const guardt &)
bool enable_div_by_zero_check
void check_shadow_memory_api_calls(const goto_programt::instructiont &)
error_labelst error_labels
void check_rec_arithmetic_op(const exprt &expr, const guardt &guard)
Check that an arithmetic operation is valid: overflow check, NaN-check (for floating point numbers),...
void undefined_shift_check(const shift_exprt &, const guardt &)
std::unique_ptr< local_bitvector_analysist > local_bitvector_analysis
void enum_range_check(const exprt &, const guardt &, bool is_assigned)
void mod_by_zero_check(const mod_exprt &, const guardt &)
std::set< std::pair< exprt, exprt > > assertionst
void pointer_validity_check(const dereference_exprt &expr, const exprt &src_expr, const guardt &guard)
Generates VCCs for the validity of the given dereferencing operation.
A collection of goto functions.
function_mapt function_map
::goto_functiont goto_functiont
static irep_idt entry_point()
Get the identifier of the entry point to a goto model.
A goto function, consisting of function body (see body) and parameter identifiers (see parameter_iden...
symbol_tablet symbol_table
Symbol table.
goto_functionst goto_functions
GOTO functions.
This class represents an instruction in the GOTO intermediate representation.
const symbol_exprt & dead_symbol() const
Get the symbol for DEAD.
bool is_end_function() const
const exprt & call_lhs() const
Get the lhs of a FUNCTION_CALL (may be nil)
const goto_instruction_codet & get_other() const
Get the statement for OTHER.
bool is_target() const
Is this node a branch target?
const exprt & return_value() const
Get the return value of a SET_RETURN_VALUE instruction.
bool is_set_return_value() const
bool has_condition() const
Does this instruction have a condition?
const exprt::operandst & call_arguments() const
Get the arguments of a FUNCTION_CALL.
const exprt & assign_lhs() const
Get the lhs of the assignment for ASSIGN.
const exprt & assign_rhs() const
Get the rhs of the assignment for ASSIGN.
const exprt & call_function() const
Get the function that is called for FUNCTION_CALL.
bool is_function_call() const
const exprt & condition() const
Get the condition of gotos, assume, assert.
source_locationt & source_location_nonconst()
const source_locationt & source_location() const
A generic container class for the GOTO intermediate representation of one function.
static instructiont make_assumption(const exprt &g, const source_locationt &l=source_locationt::nil())
instructionst instructions
The list of instructions in the goto program.
void clear()
Clear the goto program.
void insert_before_swap(targett target)
Insertion that preserves jumps to "target".
instructionst::const_iterator const_targett
static instructiont make_assignment(const code_assignt &_code, const source_locationt &l=source_locationt::nil())
Create an assignment instruction.
targett add(instructiont &&instruction)
Adds a given instruction at the end.
static instructiont make_assertion(const exprt &g, const source_locationt &l=source_locationt::nil())
IEEE-floating-point equality.
static ieee_float_valuet minus_infinity(const ieee_float_spect &_spec)
constant_exprt to_expr() const
static ieee_float_valuet plus_infinity(const ieee_float_spect &_spec)
An IEEE 754 value plus a rounding mode, enabling operations with rounding on values.
void from_integer(const mp_integer &i)
The trinary if-then-else operator.
std::string pretty(unsigned indent=0, unsigned max_indent=0) const
const std::string & id_string() const
const irep_idt & id() const
Evaluates to true if the operand is infinite.
Extract member of struct or union.
const exprt & struct_op() const
Class that provides messages with a built-in verbosity 'level'.
Modulo defined as lhs-(rhs * truncate(lhs/rhs)).
exprt & divisor()
The divisor of a division is the number the dividend is being divided by.
Binary multiplication Associativity is not specified.
A base class for multi-ary expressions Associativity is not specified.
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
The null pointer constant.
Split an expression into a base object and a (byte) offset.
std::list< std::string > value_listt
Boolean OR All operands must be boolean, and the result is always boolean.
The plus expression Associativity is not specified.
The pointer type These are both 'bitvector_typet' (they have a width) and 'type_with_subtypet' (they ...
A base class for shift and rotate operators.
A side_effect_exprt that returns a non-deterministically chosen value.
void add_pragma(const irep_idt &pragma)
void set_function(const irep_idt &function)
Expression to hold a symbol (variable)
Semantic type conversion.
static exprt conditional_cast(const exprt &expr, const typet &type)
The type of an expression, extends irept.
Generic base class for unary expressions.
A Boolean expression returning true, iff negation would result in an overflow when applied to the (si...
Fixed-width bit-vector with unsigned binary interpretation.
static bool is_assigned(dirtyt &dirty, const irep_idt &ident, assignst assigns)
exprt make_binary(const exprt &expr)
splits an expression with >=3 operands into nested binary expressions
bool has_subexpr(const exprt &expr, const std::function< bool(const exprt &)> &pred)
returns true if the expression has a subexpression that satisfies pred
exprt boolean_negate(const exprt &src)
negate a Boolean expression, possibly removing a not_exprt, and swapping false and true
Deprecated expression utility functions.
bool has_symbol_expr(const exprt &src, const irep_idt &identifier, bool include_bound_symbols)
Returns true if one of the symbol expressions in src has identifier identifier; if include_bound_symb...
API to expression classes for floating-point arithmetic.
void goto_check_c(const irep_idt &function_identifier, goto_functionst::goto_functiont &goto_function, const namespacet &ns, const optionst &options, message_handlert &message_handler)
static exprt implication(exprt lhs, exprt rhs)
#define Forall_goto_program_instructions(it, program)
const std::string & id2string(const irep_idt &d)
Abstract interface to support a programming language.
Field-insensitive, location-sensitive bitvector analysis.
API to expression classes for 'mathematical' expressions.
const quantifier_exprt & to_quantifier_expr(const exprt &expr)
Cast an exprt to a quantifier_exprt.
std::unique_ptr< languaget > get_language_from_mode(const irep_idt &mode)
Get the language corresponding to the given mode.
API to expression classes for Pointers.
const r_or_w_ok_exprt & to_r_or_w_ok_expr(const exprt &expr)
bool can_cast_expr< object_size_exprt >(const exprt &base)
const address_of_exprt & to_address_of_expr(const exprt &expr)
Cast an exprt to an address_of_exprt.
const pointer_typet & to_pointer_type(const typet &type)
Cast a typet to a pointer_typet.
const prophecy_r_or_w_ok_exprt & to_prophecy_r_or_w_ok_expr(const exprt &expr)
const dereference_exprt & to_dereference_expr(const exprt &expr)
Cast an exprt to a dereference_exprt.
bool can_cast_expr< prophecy_r_or_w_ok_exprt >(const exprt &base)
std::optional< mp_integer > pointer_offset_size(const typet &type, const namespacet &ns)
Compute the size of a type in bytes, rounding up to full bytes.
std::optional< exprt > size_of_expr(const typet &type, const namespacet &ns)
std::optional< exprt > member_offset_expr(const member_exprt &member_expr, const namespacet &ns)
exprt pointer_offset(const exprt &pointer)
exprt integer_address(const exprt &pointer)
exprt deallocated(const exprt &pointer, const namespacet &ns)
exprt object_size(const exprt &pointer)
exprt object_upper_bound(const exprt &pointer, const exprt &access_size)
exprt dead_object(const exprt &pointer, const namespacet &ns)
exprt same_object(const exprt &p1, const exprt &p2)
exprt null_object(const exprt &pointer)
exprt object_lower_bound(const exprt &pointer, const exprt &offset)
Various predicates over pointers in programs.
static std::string comment(const rw_set_baset::entryt &entry, bool write)
void remove_skip(goto_programt &goto_program, goto_programt::targett begin, goto_programt::targett end)
remove unnecessary skip statements
exprt simplify_expr(exprt src, const namespacet &ns)
#define CHECK_RETURN(CONDITION)
#define UNREACHABLE
This should be used to mark dead code.
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...
#define PRECONDITION(CONDITION)
#define INVARIANT(CONDITION, REASON)
This macro uses the wrapper function 'invariant_violated_string'.
exprt disjunction(const exprt::operandst &op)
1) generates a disjunction for two or more operands 2) for one operand, returns the operand 3) return...
exprt conjunction(exprt a, exprt b)
Conjunction of two expressions.
API to expression classes.
const binary_relation_exprt & to_binary_relation_expr(const exprt &expr)
Cast an exprt to a binary_relation_exprt.
const index_exprt & to_index_expr(const exprt &expr)
Cast an exprt to an index_exprt.
const mod_exprt & to_mod_expr(const exprt &expr)
Cast an exprt to a mod_exprt.
const mult_exprt & to_mult_expr(const exprt &expr)
Cast an exprt to a mult_exprt.
const typecast_exprt & to_typecast_expr(const exprt &expr)
Cast an exprt to a typecast_exprt.
const div_exprt & to_div_expr(const exprt &expr)
Cast an exprt to a div_exprt.
const binary_exprt & to_binary_expr(const exprt &expr)
Cast an exprt to a binary_exprt.
const plus_exprt & to_plus_expr(const exprt &expr)
Cast an exprt to a plus_exprt.
const unary_exprt & to_unary_expr(const exprt &expr)
Cast an exprt to a unary_exprt.
const multi_ary_exprt & to_multi_ary_expr(const exprt &expr)
Cast an exprt to a multi_ary_exprt.
const if_exprt & to_if_expr(const exprt &expr)
Cast an exprt to an if_exprt.
const member_exprt & to_member_expr(const exprt &expr)
Cast an exprt to a member_exprt.
const minus_exprt & to_minus_expr(const exprt &expr)
Cast an exprt to a minus_exprt.
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.
const implies_exprt & to_implies_expr(const exprt &expr)
Cast an exprt to a implies_exprt.
const unary_minus_exprt & to_unary_minus_expr(const exprt &expr)
Cast an exprt to a unary_minus_exprt.
const vector_typet & to_vector_type(const typet &type)
Cast a typet to a vector_typet.
const array_typet & to_array_type(const typet &type)
Cast a typet to an array_typet.
conditiont(const exprt &_assertion, const std::string &_description)
bool is_static_lifetime() const
bool is_dynamic_local() const
bool is_dynamic_heap() const
bool is_uninitialized() const
bool is_integer_address() const