Skip to content

Commit f8991d9

Browse files
Merge pull request #3580 from peterschrammel/move-symex-bmc
Move symex-bmc and symex-coverage to goto-checker [blocks: 3583]
2 parents af79d4e + 7815d68 commit f8991d9

File tree

11 files changed

+158
-185
lines changed

11 files changed

+158
-185
lines changed

jbmc/src/jbmc/Makefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ OBJ += ../$(CPROVER_DIR)/src/ansi-c/ansi-c$(LIBEXT) \
4343
../$(CPROVER_DIR)/src/cbmc/bmc_cover$(OBJEXT) \
4444
../$(CPROVER_DIR)/src/cbmc/counterexample_beautification$(OBJEXT) \
4545
../$(CPROVER_DIR)/src/cbmc/fault_localization$(OBJEXT) \
46-
../$(CPROVER_DIR)/src/cbmc/symex_bmc$(OBJEXT) \
47-
../$(CPROVER_DIR)/src/cbmc/symex_coverage$(OBJEXT) \
4846
# Empty last line
4947

5048
INCLUDES= -I .. -I ../$(CPROVER_DIR)/src

jbmc/unit/Makefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,6 @@ BMC_DEPS =$(CPROVER_DIR)/src/cbmc/all_properties$(OBJEXT) \
8989
$(CPROVER_DIR)/src/cbmc/cbmc_parse_options$(OBJEXT) \
9090
$(CPROVER_DIR)/src/cbmc/counterexample_beautification$(OBJEXT) \
9191
$(CPROVER_DIR)/src/cbmc/fault_localization$(OBJEXT) \
92-
$(CPROVER_DIR)/src/cbmc/symex_bmc$(OBJEXT) \
93-
$(CPROVER_DIR)/src/cbmc/symex_coverage$(OBJEXT) \
9492
$(CPROVER_DIR)/src/cbmc/xml_interface$(OBJEXT) \
9593
$(CPROVER_DIR)/src/jsil/expr2jsil$(OBJEXT) \
9694
$(CPROVER_DIR)/src/jsil/jsil_convert$(OBJEXT) \

src/cbmc/Makefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ SRC = all_properties.cpp \
66
cbmc_parse_options.cpp \
77
counterexample_beautification.cpp \
88
fault_localization.cpp \
9-
symex_bmc.cpp \
10-
symex_coverage.cpp \
119
xml_interface.cpp \
1210
# Empty last line
1311

src/cbmc/bmc.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ Author: Daniel Kroening, [email protected]
2020
#include <util/ui_message.h>
2121
#include <util/decision_procedure.h>
2222

23+
#include <goto-checker/symex_bmc.h>
24+
2325
#include <goto-programs/goto_trace.h>
2426

2527
#include <goto-symex/symex_target_equation.h>
@@ -29,7 +31,6 @@ Author: Daniel Kroening, [email protected]
2931
#include <goto-programs/safety_checker.h>
3032
#include <goto-symex/memory_model.h>
3133

32-
#include "symex_bmc.h"
3334

3435
class cbmc_solverst;
3536

src/goto-checker/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
SRC = bmc_util.cpp \
22
solver_factory.cpp \
3+
symex_coverage.cpp \
4+
symex_bmc.cpp \
35
# Empty last line
46

57
INCLUDES= -I ..

src/goto-checker/bmc_util.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ Author: Daniel Kroening, Peter Schrammel
1414
#include <fstream>
1515
#include <iostream>
1616

17-
#include <cbmc/symex_bmc.h>
18-
1917
#include <goto-programs/graphml_witness.h>
2018
#include <goto-programs/json_goto_trace.h>
2119
#include <goto-programs/xml_goto_trace.h>
@@ -33,6 +31,8 @@ Author: Daniel Kroening, Peter Schrammel
3331
#include <util/make_unique.h>
3432
#include <util/ui_message.h>
3533

34+
#include "symex_bmc.h"
35+
3636
void build_error_trace(
3737
goto_tracet &goto_trace,
3838
const namespacet &ns,

src/cbmc/symex_bmc.cpp renamed to src/goto-checker/symex_bmc.cpp

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ Author: Daniel Kroening, [email protected]
1515

1616
#include <limits>
1717

18-
#include <util/source_location.h>
1918
#include <util/simplify_expr.h>
19+
#include <util/source_location.h>
2020

2121
symex_bmct::symex_bmct(
2222
message_handlert &mh,
@@ -35,28 +35,28 @@ void symex_bmct::symex_step(
3535
const get_goto_functiont &get_goto_function,
3636
statet &state)
3737
{
38-
const source_locationt &source_location=state.source.pc->source_location;
38+
const source_locationt &source_location = state.source.pc->source_location;
3939

40-
if(!source_location.is_nil() && last_source_location!=source_location)
40+
if(!source_location.is_nil() && last_source_location != source_location)
4141
{
42-
log.debug() << "BMC at " << source_location.as_string()
43-
<< " (depth " << state.depth << ')' << log.eom;
42+
log.debug() << "BMC at " << source_location.as_string() << " (depth "
43+
<< state.depth << ')' << log.eom;
4444

45-
last_source_location=source_location;
45+
last_source_location = source_location;
4646
}
4747

48-
const goto_programt::const_targett cur_pc=state.source.pc;
49-
const guardt cur_guard=state.guard;
48+
const goto_programt::const_targett cur_pc = state.source.pc;
49+
const guardt cur_guard = state.guard;
5050

51-
if(!state.guard.is_false() &&
52-
state.source.pc->is_assume() &&
53-
simplify_expr(state.source.pc->guard, ns).is_false())
51+
if(
52+
!state.guard.is_false() && state.source.pc->is_assume() &&
53+
simplify_expr(state.source.pc->guard, ns).is_false())
5454
{
5555
log.statistics() << "aborting path on assume(false) at "
5656
<< state.source.pc->source_location << " thread "
5757
<< state.source.thread_nr;
5858

59-
const irep_idt &c=state.source.pc->source_location.get_comment();
59+
const irep_idt &c = state.source.pc->source_location.get_comment();
6060
if(!c.empty())
6161
log.statistics() << ": " << c;
6262

@@ -77,9 +77,9 @@ void symex_bmct::symex_step(
7777
// taken an impossible transition); thus we synthesize a
7878
// transition from the goto instruction to its target to make
7979
// sure the goto is considered covered
80-
if(cur_pc->is_goto() &&
81-
cur_pc->get_target()!=state.source.pc &&
82-
cur_pc->guard.is_true())
80+
if(
81+
cur_pc->is_goto() && cur_pc->get_target() != state.source.pc &&
82+
cur_pc->guard.is_true())
8383
symex_coverage.covered(cur_pc, cur_pc->get_target());
8484
else if(!state.guard.is_false())
8585
symex_coverage.covered(cur_pc, state.source.pc);
@@ -90,18 +90,18 @@ void symex_bmct::merge_goto(
9090
const statet::goto_statet &goto_state,
9191
statet &state)
9292
{
93-
const goto_programt::const_targett prev_pc=goto_state.source.pc;
94-
const guardt prev_guard=goto_state.guard;
93+
const goto_programt::const_targett prev_pc = goto_state.source.pc;
94+
const guardt prev_guard = goto_state.guard;
9595

9696
goto_symext::merge_goto(goto_state, state);
9797

9898
PRECONDITION(prev_pc->is_goto());
99-
if(record_coverage &&
100-
// could the branch possibly be taken?
101-
!prev_guard.is_false() &&
102-
!state.guard.is_false() &&
103-
// branches only, no single-successor goto
104-
!prev_pc->guard.is_true())
99+
if(
100+
record_coverage &&
101+
// could the branch possibly be taken?
102+
!prev_guard.is_false() && !state.guard.is_false() &&
103+
// branches only, no single-successor goto
104+
!prev_pc->guard.is_true())
105105
symex_coverage.covered(prev_pc, state.source.pc);
106106
}
107107

@@ -110,10 +110,10 @@ bool symex_bmct::should_stop_unwind(
110110
const goto_symex_statet::call_stackt &context,
111111
unsigned unwind)
112112
{
113-
const irep_idt id=goto_programt::loop_id(*source.pc);
113+
const irep_idt id = goto_programt::loop_id(*source.pc);
114114

115115
tvt abort_unwind_decision;
116-
unsigned this_loop_limit=std::numeric_limits<unsigned>::max();
116+
unsigned this_loop_limit = std::numeric_limits<unsigned>::max();
117117

118118
for(auto handler : loop_unwind_handlers)
119119
{
@@ -127,7 +127,7 @@ bool symex_bmct::should_stop_unwind(
127127
// / --unwind options to decide:
128128
if(abort_unwind_decision.is_unknown())
129129
{
130-
auto limit=unwindset.get_limit(id, source.thread_nr);
130+
auto limit = unwindset.get_limit(id, source.thread_nr);
131131

132132
if(!limit.has_value())
133133
abort_unwind_decision = tvt(false);
@@ -142,7 +142,7 @@ bool symex_bmct::should_stop_unwind(
142142
log.statistics() << (abort ? "Not unwinding" : "Unwinding") << " loop " << id
143143
<< " iteration " << unwind;
144144

145-
if(this_loop_limit!=std::numeric_limits<unsigned>::max())
145+
if(this_loop_limit != std::numeric_limits<unsigned>::max())
146146
log.statistics() << " (" << this_loop_limit << " max)";
147147

148148
log.statistics() << " " << source.pc->source_location << " thread "
@@ -157,7 +157,7 @@ bool symex_bmct::get_unwind_recursion(
157157
unsigned unwind)
158158
{
159159
tvt abort_unwind_decision;
160-
unsigned this_loop_limit=std::numeric_limits<unsigned>::max();
160+
unsigned this_loop_limit = std::numeric_limits<unsigned>::max();
161161

162162
for(auto handler : recursion_unwind_handlers)
163163
{
@@ -170,7 +170,7 @@ bool symex_bmct::get_unwind_recursion(
170170
// / --unwind options to decide:
171171
if(abort_unwind_decision.is_unknown())
172172
{
173-
auto limit=unwindset.get_limit(id, thread_nr);
173+
auto limit = unwindset.get_limit(id, thread_nr);
174174

175175
if(!limit.has_value())
176176
abort_unwind_decision = tvt(false);
@@ -182,14 +182,14 @@ bool symex_bmct::get_unwind_recursion(
182182
abort_unwind_decision.is_known(), "unwind decision should be taken by now");
183183
bool abort = abort_unwind_decision.is_true();
184184

185-
if(unwind>0 || abort)
185+
if(unwind > 0 || abort)
186186
{
187-
const symbolt &symbol=ns.lookup(id);
187+
const symbolt &symbol = ns.lookup(id);
188188

189189
log.statistics() << (abort ? "Not unwinding" : "Unwinding") << " recursion "
190190
<< symbol.display_name() << " iteration " << unwind;
191191

192-
if(this_loop_limit!=std::numeric_limits<unsigned>::max())
192+
if(this_loop_limit != std::numeric_limits<unsigned>::max())
193193
log.statistics() << " (" << this_loop_limit << " max)";
194194

195195
log.statistics() << log.eom;

src/cbmc/symex_bmc.h renamed to src/goto-checker/symex_bmc.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@ Author: Daniel Kroening, [email protected]
99
/// \file
1010
/// Bounded Model Checking for ANSI-C
1111

12-
#ifndef CPROVER_CBMC_SYMEX_BMC_H
13-
#define CPROVER_CBMC_SYMEX_BMC_H
12+
#ifndef CPROVER_GOTO_CHECKER_SYMEX_BMC_H
13+
#define CPROVER_GOTO_CHECKER_SYMEX_BMC_H
1414

1515
#include <util/message.h>
1616
#include <util/threeval.h>
1717

18-
#include <goto-symex/path_storage.h>
1918
#include <goto-symex/goto_symex.h>
19+
#include <goto-symex/path_storage.h>
2020

2121
#include <goto-instrument/unwindset.h>
2222

2323
#include "symex_coverage.h"
2424

25-
class symex_bmct: public goto_symext
25+
class symex_bmct : public goto_symext
2626
{
2727
public:
2828
symex_bmct(
@@ -41,9 +41,8 @@ class symex_bmct: public goto_symext
4141
/// information for the user (e.g. "unwinding iteration N, max M"), and is not
4242
/// enforced. They return true to halt unwinding, false to authorise
4343
/// unwinding, or Unknown to indicate they have no opinion.
44-
typedef
45-
std::function<tvt(
46-
const goto_symex_statet::call_stackt &, unsigned, unsigned, unsigned &)>
44+
typedef std::function<
45+
tvt(const goto_symex_statet::call_stackt &, unsigned, unsigned, unsigned &)>
4746
loop_unwind_handlert;
4847

4948
/// Recursion unwind handlers take the function ID, the unwind count so far,
@@ -115,4 +114,4 @@ class symex_bmct: public goto_symext
115114
symex_coveraget symex_coverage;
116115
};
117116

118-
#endif // CPROVER_CBMC_SYMEX_BMC_H
117+
#endif // CPROVER_GOTO_CHECKER_SYMEX_BMC_H

0 commit comments

Comments
 (0)