+ Include dependency graph for utils.h:
+ This graph shows which files directly or indirectly include this file:
Go to the source code of this file.
Class that allows to clean expressions of side effects and to generate havoc_slice expressions.
More...
A class that overrides the low-level havocing functions in the base utility class, to havoc only when expressions point to valid memory, i.e.
More...
A class that further overrides the "safe" havoc utilities, and adds support for havocing pointer_object expressions.
More...
Generate a validity check over all dereferences in an expression.
Generate a lexicographic less-than comparison over ordered tuples.
Insert a goto program before a target instruction iterator and advance the iterator.
Insert a goto instruction before a target instruction iterator and update targets of all jumps that points to the iterator to jumping to the inserted instruction.
Turns goto instructions IF cond GOTO label where the condition statically simplifies to false into SKIP instructions.
Returns true iff the given program is loop-free, i.e.
Returns an
irep_idt that essentially says that
target was assigned by the contract of
function_id.
Infer loop assigns using alias analysis result local_may_alias.
Widen expressions in assigns with the following strategy.
This function recursively identifies the "old" expressions within expr and replaces them with corresponding history variables.
This function recursively identifies the "loop_entry" expressions within expr and replaces them with corresponding history variables.
This function generates all the instructions required to initialize history variables.
Return true if target is the head of some transformed loop.
Return true if target is the end of some transformed loop.
Return true if target is an assignment to an instrumented variable with name var_name.
Convert the suffix digits right after prefix of str into unsigned.
Find the goto instruction of loop that jumps to loop_head
Return loop head if finding_head is true, Otherwise return loop end.
Find and return the last instruction of the natural loop with loop_number in function.
Find and return the first instruction of the natural loop with loop_number in function.
Extract loop invariants from annotated loop end.
Extract loop assigns from annotated loop end.
Extract loop decreases from annotated loop end.
Annotate the invariants in invariant_map to their corresponding loops.
Annotate the assigns in assigns_map to their corresponding loops.
Annotate the decreases in decreases_map to their corresponding loops.
Macro Definition Documentation
◆ ENTERED_LOOP
#
define ENTERED_LOOP "__entered_loop"
◆ IN_BASE_CASE
#
define IN_BASE_CASE "__in_base_case"
◆ IN_LOOP_HAVOC_BLOCK
#
define IN_LOOP_HAVOC_BLOCK "__in_loop_havoc_block"
◆ INIT_INVARIANT
#
define INIT_INVARIANT "__init_invariant"
Typedef Documentation
◆ invariant_mapt
Function Documentation
◆ all_dereferences_are_valid()
Generate a validity check over all dereferences in an expression.
This function generates a formula:
r_ok_exprt(pexpr_1, sizeof(*pexpr_1)) && r_ok_exprt(pexpr_2, sizeof(*pexpr_1)) && ...
over all dereferenced pointer expressions *(pexpr_1), *(pexpr_2), ... found in the AST of expr.
- Parameters
-
expr The expression that contains dereferences to be validated.
ns The namespace that defines all symbols appearing in expr.
- Returns
- A conjunctive expression that checks validity of all pointers that are dereferenced within
expr.
Definition at line 175 of file utils.cpp.
◆ annotate_assigns() [1/2]
◆ annotate_assigns() [2/2]
Annotate the assigns in assigns_map to their corresponding loops.
Corresponding loops are specified by keys of assigns_map
Definition at line 725 of file utils.cpp.
◆ annotate_decreases()
Annotate the decreases in decreases_map to their corresponding loops.
Corresponding loops are specified by keys of decreases_map
Definition at line 766 of file utils.cpp.
◆ annotate_invariants()
Annotate the invariants in invariant_map to their corresponding loops.
Corresponding loops are specified by keys of invariant_map
Definition at line 705 of file utils.cpp.
◆ generate_history_variables_initialization()
This function generates all the instructions required to initialize history variables.
Definition at line 494 of file utils.cpp.
◆ generate_lexicographic_less_than_check()
Generate a lexicographic less-than comparison over ordered tuples.
This function creates an expression representing a lexicographic less-than comparison, lhs < rhs, between two ordered tuples of variables. This is used in instrumentation of decreases clauses.
- Parameters
-
lhs A vector of variables representing the LHS of the comparison.
rhs A vector of variables representing the RHS of the comparison.
- Returns
- A lexicographic less-than comparison expression: LHS < RHS.
Definition at line 193 of file utils.cpp.
◆ get_loop_assigns()
Extract loop assigns from annotated loop end.
Definition at line 683 of file utils.cpp.
◆ get_loop_decreases()
Extract loop decreases from annotated loop end.
Will check if the loop decreases is side-effect free if check_side_effect` is set.
Definition at line 688 of file utils.cpp.
◆ get_loop_end()
Find and return the last instruction of the natural loop with loop_number in function.
loop_end -> loop_head
Definition at line 634 of file utils.cpp.
◆ get_loop_end_from_loop_head_and_content()
◆ get_loop_end_from_loop_head_and_content_mutable()
Find the goto instruction of loop that jumps to loop_head
Definition at line 584 of file utils.cpp.
◆ get_loop_head()
Find and return the first instruction of the natural loop with loop_number in function.
loop_end -> loop_head
Definition at line 640 of file utils.cpp.
◆ get_loop_head_or_end()
Return loop head if finding_head is true, Otherwise return loop end.
Definition at line 607 of file utils.cpp.
◆ get_loop_invariants()
Extract loop invariants from annotated loop end.
Will check if the loop invariant is side-effect free if check_side_effect` is set.
Definition at line 666 of file utils.cpp.
◆ get_suffix_unsigned()
const std::string &
prefix
)
Convert the suffix digits right after prefix of str into unsigned.
Definition at line 546 of file utils.cpp.
◆ infer_loop_assigns()
Infer loop assigns using alias analysis result local_may_alias.
Definition at line 344 of file utils.cpp.
◆ insert_before_and_update_jumps()
Insert a goto instruction before a target instruction iterator and update targets of all jumps that points to the iterator to jumping to the inserted instruction.
This method is intended to keep external instruction::targett stable, i.e. they will still point to the same instruction after inserting the new one
This function inserts a instruction i into a destination program destination immediately before a specified instruction iterator target. After insertion, update all jumps that pointing to target to jumping to i instead.
Different from insert_before_swap_and_advance, this function doesn't invalidate the iterator target after insertion. That is, target and all other instruction iterators same as target will still point to the same instruction after insertion.
- Parameters
-
destination The destination program for inserting the i.
target The instruction iterator at which to insert the i.
i The goto instruction to be inserted into the destination.
Definition at line 247 of file utils.cpp.
◆ insert_before_swap_and_advance()
Insert a goto program before a target instruction iterator and advance the iterator.
This function inserts all instruction from a goto program payload into a destination program destination immediately before a specified instruction iterator target. After insertion, target is advanced by the size of the payload, and payload is destroyed.
- Parameters
-
destination The destination program for inserting the payload.
target The instruction iterator at which to insert the payload.
payload The goto program to be inserted into the destination.
Definition at line 237 of file utils.cpp.
◆ is_assignment_to_instrumented_variable()
Return true if target is an assignment to an instrumented variable with name var_name.
Definition at line 524 of file utils.cpp.
◆ is_assigns_clause_replacement_tracking_comment()
◆ is_loop_free()
Returns true iff the given program is loop-free, i.e.
if each SCC of its CFG contains a single element.
Definition at line 271 of file utils.cpp.
◆ is_transformed_loop_end()
Return true if target is the end of some transformed loop.
Definition at line 516 of file utils.cpp.
◆ is_transformed_loop_head()
Return true if target is the head of some transformed loop.
Definition at line 508 of file utils.cpp.
◆ make_assigns_clause_replacement_tracking_comment()
Returns an irep_idt that essentially says that target was assigned by the contract of function_id.
Definition at line 329 of file utils.cpp.
◆ replace_history_loop_entry()
This function recursively identifies the "loop_entry" expressions within expr and replaces them with corresponding history variables.
Definition at line 475 of file utils.cpp.
◆ replace_history_old()
This function recursively identifies the "old" expressions within expr and replaces them with corresponding history variables.
Definition at line 456 of file utils.cpp.
◆ simplify_gotos()
Turns goto instructions IF cond GOTO label where the condition statically simplifies to false into SKIP instructions.
Definition at line 260 of file utils.cpp.
◆ widen_assigns()
Widen expressions in assigns with the following strategy.
If an expression is an array index or object dereference expression, with a non-constant offset, e.g. a[i] or *(b+i) with a non-constant i, then replace it by the entire underlying object. Otherwise, e.g. for a[i] or *(b+i) when i is a known constant, keep the expression in the result.
Definition at line 360 of file utils.cpp.