Skip to content

Commit 50765b2

Browse files
author
Remi Delmas
committed
Fixed doc, commits and formatting
1 parent 3701933 commit 50765b2

File tree

6 files changed

+34
-14
lines changed

6 files changed

+34
-14
lines changed

regression/contracts/assigns_enforce_arrays_05/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
main.c
3-
--enforce-contract assigns_ptr --enforce-contract assigns_range
3+
--enforce-contract assigns_range
44
^EXIT=10$
55
^SIGNAL=0$
66
^VERIFICATION FAILED$

regression/contracts/quantifiers-forall-ensures-enforce/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ int f1(int *arr, int len)
2323
int main()
2424
{
2525
int len;
26-
__CPROVER_assume(0 <= len && len <= MAX_LEN);
26+
__CPROVER_assume(0 < len && len <= MAX_LEN);
2727

2828
int *arr = malloc(len * sizeof(int));
2929
f1(arr, len);

src/analyses/goto_check.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ Author: Daniel Kroening, [email protected]
2525
#include <util/ieee_float.h>
2626
#include <util/invariant.h>
2727
#include <util/make_unique.h>
28-
#include <util/options.h>
2928
#include <util/message.h>
29+
#include <util/options.h>
3030
#include <util/pointer_expr.h>
3131
#include <util/pointer_offset_size.h>
3232
#include <util/pointer_predicates.h>
@@ -50,10 +50,8 @@ class goto_checkt
5050
goto_checkt(
5151
const namespacet &_ns,
5252
const optionst &_options,
53-
message_handlert &_message_handler):
54-
ns(_ns),
55-
local_bitvector_analysis(nullptr),
56-
log(_message_handler)
53+
message_handlert &_message_handler)
54+
: ns(_ns), local_bitvector_analysis(nullptr), log(_message_handler)
5755
{
5856
no_enum_check = false;
5957
enable_bounds_check=_options.get_bool_option("bounds-check");
@@ -1856,7 +1854,7 @@ optionalt<exprt> goto_checkt::rw_ok_check(exprt expr)
18561854
class flag_resett
18571855
{
18581856
public:
1859-
/// \brief Store the current value of \p flag and
1857+
/// \brief Store the current value of \p flag and
18601858
/// then set its value to \p new_value.
18611859
/// \returns true if the flag was already seen before
18621860
bool set_flag(bool &flag, bool new_value)
@@ -1877,7 +1875,7 @@ class flag_resett
18771875
return seen_flags.find(&flag) != seen_flags.end();
18781876
}
18791877

1880-
/// \brief Restore the values of all flags that have been
1878+
/// \brief Restore the values of all flags that have been
18811879
/// modified via `set_flag`.
18821880
~flag_resett()
18831881
{

src/goto-instrument/contracts/assigns.cpp

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,22 @@ assigns_clauset::conditional_address_ranget::conditional_address_ranget(
8181
{
8282
}
8383

84+
// clang-format off
85+
/// \brief Generates and returns snapshot instructions for source_expr.
86+
///
87+
/// ```
88+
/// DECL bool __car_valid
89+
/// DECL char *__car_lb
90+
/// DECL char *__car_ub
91+
/// ASSIGN __car_lb := NULL
92+
/// ASSIGN __car_ub := NULL
93+
/// ASSIGN __car_valid := all_dereferences_are_valid(source_expr) & rw_ok(&(source_expr), size)
94+
/// IF !__car_valid GOTO END_SNAPSHOT
95+
/// ASSIGN __car_lb := &(source_expr)
96+
/// ASSIGN __car_ub := &(source_expr) + size-1
97+
/// END_SNAPSHOT: SKIP
98+
/// ```
99+
// clang-format on
84100
goto_programt
85101
assigns_clauset::conditional_address_ranget::generate_snapshot_instructions()
86102
const
@@ -109,16 +125,17 @@ assigns_clauset::conditional_address_ranget::generate_snapshot_instructions()
109125
null_pointer_exprt{to_pointer_type(slice.first.type())},
110126
location_no_checks));
111127

112-
goto_programt skip_program;
113-
const auto skip_target =
114-
skip_program.add(goto_programt::make_skip(location_no_checks));
115-
128+
// check validity
116129
const auto validity_check_expr = and_exprt{
117130
all_dereferences_are_valid(source_expr, parent.ns),
118131
w_ok_exprt{slice.first, slice.second}};
119132
instructions.add(goto_programt::make_assignment(
120133
validity_condition_var, validity_check_expr, location_no_checks));
121134

135+
// jump here if validity_check_expr is false
136+
goto_programt skip_program;
137+
const auto skip_target = skip_program.add(goto_programt::make_skip(location));
138+
122139
instructions.add(goto_programt::make_goto(
123140
skip_target, not_exprt{validity_condition_var}, location_no_checks));
124141

src/goto-instrument/contracts/contracts.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,6 @@ class code_contractst
216216
///
217217
/// @param function the function to search local static symbols in
218218
/// @param assigns assigns clause where search results are added
219-
/// @return true if failure, false if success
220219
///
221220
/// A symbol is considered a static local symbol iff:
222221
/// - it has a static lifetime annotation

src/goto-instrument/contracts/utils.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,16 @@ void insert_before_swap_and_advance(
9191

9292
/// \brief Adds a new temporary symbol to the symbol table.
9393
///
94+
/// The unique name is generated as:
95+
/// ```
96+
/// "location.function() + "::" + suffix + "$" + uid
97+
/// ```
98+
///
9499
/// \param type: The type of the new symbol.
95100
/// \param location: The source location for the new symbol.
96101
/// \param mode: The mode for the new symbol, e.g. ID_C, ID_java.
97102
/// \param symtab: The symbol table to which the new symbol is to be added.
103+
/// \param suffix: base suffix used to generate the unique name.
98104
/// \return The new symbolt object.
99105
const symbolt &new_tmp_symbol(
100106
const typet &type,

0 commit comments

Comments
 (0)