Skip to content

Commit 2db1595

Browse files
committed
Update to CBMC 5.61
Add missing symbolt include Remove usage of deprecated goto_instructiont::get_assign() Remove usage of deprecated goto_instructiont::get_function_call() Add missing include for side_effect_exprt Fix usage of goto_instructiont::source_location Fix usage of goto_instructiontt:type Update usage of goto_checkt Remove deprecated calls to initiallize malloc_may_fail variables. This feature is now handled differently in CBMC, see: diffblue/cbmc#6576 Make tests containing argc less strict, the C standard does not guarantee that it is >= 1, just that it is non-negative. For more information, refer to the CBMC commit: 788cb496ee573cc4182273d1513c5a5eb68a383a Make use of refactored update_assumptions_assertions of goto_check Adjust heap domain to newly returned annotated_pointer_constant type. For more information about this constant, see CBMC commit: 112f1d0aaa5a4606aa0e6a06a9e1ee853ebc20ab Update goto_check includes Add removed make_assertions_false to preprocessing Fix goto_check usage Remove direct access to goto_instructiont::guard Do not use soon-to-be-deprecated goto_instructiont::get_code Fix collection of record free variables Remove usage of base_type, it's deprecated Signed-off-by: František Nečas <[email protected]>
1 parent cf9c082 commit 2db1595

30 files changed

+202
-188
lines changed

lib/cbmc

Submodule cbmc updated 2189 files

regression/preconditions/precond_contextsensitive2/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ main.c
33
--context-sensitive --preconditions
44
^EXIT=5$
55
^SIGNAL=0$
6-
^\[__CPROVER__start\]: argc' <= 268435456 && -\(\(signed __CPROVER_bitvector\[33\]\)argc'\) <= -2$
6+
^\[__CPROVER__start\]: argc' <= 2147483647 && -\(\(signed __CPROVER_bitvector\[33\]\)argc'\) <= 0$

regression/termination/abort1/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
int foo(int x)
22
{
33
int y;
4-
if(x<1) while(1) y++;
4+
if(x<0) while(1) y++;
55
return x;
66
}
77

88
int main(int argc, char** argv)
99
{
1010
int x = argc;
1111
x = foo(x);
12-
assert(x>=1);
12+
assert(x>=0);
1313
return x;
1414
}

regression/termination/abort2/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ int foo(int x)
1111
int main(int argc, char** argv)
1212
{
1313
int x = argc;
14-
if(x>=1) x = foo(x);
14+
if(x>=0) x = foo(x);
1515
else bar(); //unreachable
1616
return x;
1717
}

src/2ls/2ls_parse_options.cpp

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ Author: Daniel Kroening, Peter Schrammel
4242
#include <goto-programs/show_symbol_table.h>
4343
#include <goto-programs/initialize_goto_model.h>
4444
#include <goto-programs/show_goto_functions.h>
45-
#include <goto-programs/add_malloc_may_fail_variable_initializations.h>
4645

47-
#include <analyses/goto_check.h>
46+
#include <ansi-c/goto_check_c.h>
47+
#include <goto-programs/goto_check.h>
4848

4949
#include <langapi/mode.h>
5050

@@ -494,7 +494,7 @@ int twols_parse_optionst::doit()
494494
Forall_goto_program_instructions(i_it, body)
495495
{
496496
if(i_it->is_assert())
497-
i_it->type=goto_program_instruction_typet::ASSUME;
497+
i_it->turn_into_assume();
498498
}
499499
}
500500
}
@@ -855,23 +855,22 @@ void twols_parse_optionst::show_stats(
855855
if(i_it->is_backwards_goto())
856856
nr_loops++;
857857

858-
switch(instruction.type)
858+
switch(instruction.type())
859859
{
860860
case ASSIGN:
861861
{
862-
const code_assignt &assign=instruction.get_assign();
863-
expr_stats_rec(assign.lhs(), stats);
864-
expr_stats_rec(assign.rhs(), stats);
862+
expr_stats_rec(instruction.assign_lhs(), stats);
863+
expr_stats_rec(instruction.assign_rhs(), stats);
865864
break;
866865
}
867866
case ASSUME:
868-
expr_stats_rec(instruction.guard, stats);
867+
expr_stats_rec(instruction.condition(), stats);
869868
break;
870869
case ASSERT:
871-
expr_stats_rec(instruction.guard, stats);
870+
expr_stats_rec(instruction.condition(), stats);
872871
break;
873872
case GOTO:
874-
expr_stats_rec(instruction.guard, stats);
873+
expr_stats_rec(instruction.condition(), stats);
875874
break;
876875

877876
case DECL:
@@ -963,11 +962,6 @@ bool twols_parse_optionst::get_goto_program(
963962
status() << "Adding CPROVER library" << eom;
964963
link_to_library(goto_model, ui_message_handler, cprover_c_library_factory);
965964

966-
// TODO: 2LS currently does not support the possibility of malloc failing,
967-
// we always initialize the CPROVER variables related to failure
968-
// to default (no fail). See if there is a way to improve this.
969-
add_malloc_may_fail_variable_initializations(goto_model);
970-
971965
if(process_goto_program(options, goto_model))
972966
return true;
973967
}
@@ -1065,7 +1059,8 @@ bool twols_parse_optionst::process_goto_program(
10651059

10661060
// add generic checks
10671061
status() << "Generic Property Instrumentation" << eom;
1068-
goto_check(options, goto_model);
1062+
goto_check_c(options, goto_model, *message_handler);
1063+
transform_assertions_assumptions(options, goto_model);
10691064

10701065
#if UNWIND_GOTO_INTO_LOOP
10711066
unwind_goto_into_loop(goto_model, 2);
@@ -1273,7 +1268,7 @@ void twols_parse_optionst::report_properties(
12731268
else
12741269
{
12751270
status() << "[" << it->first << "] "
1276-
<< it->second.pc->source_location.get_comment()
1271+
<< it->second.pc->source_location().get_comment()
12771272
<< ": "
12781273
<< as_string(it->second.status)
12791274
<< eom;

src/2ls/2ls_parse_options.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Author: Daniel Kroening, Peter Schrammel
1616
#include <util/parse_options.h>
1717
#include <util/replace_symbol.h>
1818

19-
#include <analyses/goto_check.h>
19+
#include <goto-programs/goto_check.h>
2020
#include <ssa/dynamic_objects.h>
2121

2222
class goto_modelt;
@@ -187,6 +187,7 @@ class twols_parse_optionst:
187187
void assert_no_builtin_functions(goto_modelt &goto_model);
188188
void assert_no_atexit(goto_modelt &goto_model);
189189
void fix_goto_targets(goto_modelt &goto_model);
190+
void make_assertions_false(goto_modelt &goto_model);
190191
};
191192

192193
#endif

src/2ls/cover_goals_ext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ struct goalt
3232

3333
explicit goalt(const goto_programt::instructiont &instruction)
3434
{
35-
description=id2string(instruction.source_location.get_comment());
35+
description=id2string(instruction.source_location().get_comment());
3636
}
3737

3838
goalt()

src/2ls/dynamic_cfg.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ void dynamic_cfgt::build_cfg(
104104
incoming_edges[it->get_target()].insert(new_node);
105105
goto_programt::const_targett next=it; ++next;
106106
if(next!=goto_program.instructions.end() &&
107-
(!it->is_goto() || !it->guard.is_true()))
107+
(!it->is_goto() || !it->condition().is_true()))
108108
incoming_edges[next].insert(new_node);
109109

110110
continue;
@@ -124,7 +124,7 @@ void dynamic_cfgt::build_cfg(
124124
incoming_edges[it->get_target()].insert(node);
125125
goto_programt::const_targett next=it; ++next;
126126
if(next!=goto_program.instructions.end() &&
127-
(!it->is_goto() || !it->guard.is_true()))
127+
(!it->is_goto() || !it->condition().is_true()))
128128
incoming_edges[next].insert(node);
129129

130130
// alternative loop head detection when unwinder was not used

src/2ls/graphml_witness_ext.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ void graphml_witness_extt::operator()(
4848
index_map.resize(cfg.size());
4949
for(std::size_t i=0; i<cfg.size(); ++i)
5050
{
51-
const source_locationt &source_location=cfg[i].id.pc->source_location;
51+
const source_locationt &source_location=cfg[i].id.pc->source_location();
5252

5353
if(source_location.is_nil() ||
5454
source_location.get_file().empty() ||
@@ -95,7 +95,8 @@ void graphml_witness_extt::add_edge(
9595
const graphmlt::node_indext &to,
9696
const dynamic_cfg_nodet &to_cfg_node)
9797
{
98-
const source_locationt &source_location=from_cfg_node.id.pc->source_location;
98+
const source_locationt &source_location=
99+
from_cfg_node.id.pc->source_location();
99100

100101
xmlt edge("edge");
101102
edge.set_attribute("source", graphml[from].node_name);

src/2ls/horn_encoding.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ void horn_encodingt::translate(
117117
const local_SSAt::nodet &node=*local_SSA.find_node(loc);
118118
#endif
119119
out << "; PC " << loc->location_number
120-
<< " " << loc->source_location << '\n';
120+
<< " " << loc->source_location() << '\n';
121121

122122
out << "(assert (forall (";
123123

@@ -152,7 +152,7 @@ void horn_encodingt::translate(
152152

153153
if(loc->is_goto())
154154
{
155-
if(loc->guard.is_true())
155+
if(loc->condition().is_true())
156156
{
157157
out << "(h-" << function_id << '-'
158158
<< loc->get_target()->location_number;
@@ -169,7 +169,7 @@ void horn_encodingt::translate(
169169
out << ')';
170170
}
171171

172-
if(!loc->guard.is_true())
172+
if(!loc->condition().is_true())
173173
{
174174
goto_programt::instructionst::const_iterator next=loc;
175175
next++;

src/2ls/instrument_goto.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,9 @@ void instrument_gotot::instrument_instruction(
6767

6868
auto assumption=tmp.insert_after(
6969
target,
70-
goto_programt::make_assumption(expr, target->source_location));
71-
assumption->source_location.set_comment("invariant generated by 2LS");
70+
goto_programt::make_assumption(expr, target->source_location()));
71+
assumption->source_location_nonconst().set_comment(
72+
"invariant generated by 2LS");
7273

7374
dest.insert_before_swap(where, tmp);
7475

0 commit comments

Comments
 (0)