Skip to content

Commit c5c75ad

Browse files
author
Daniel Kroening
committed
move setup_unwind to parse_unwindset_options to prevent duplication
1 parent d413dd8 commit c5c75ad

File tree

4 files changed

+48
-42
lines changed

4 files changed

+48
-42
lines changed

src/cbmc/bmc.cpp

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ Author: Daniel Kroening, [email protected]
1515
#include <iostream>
1616

1717
#include <util/exit_codes.h>
18-
#include <util/string2int.h>
19-
#include <util/string_utils.h>
2018

2119
#include <langapi/language_util.h>
2220

@@ -319,7 +317,7 @@ void bmct::setup()
319317

320318
symex.last_source_location.make_nil();
321319

322-
setup_unwind();
320+
parse_unwinding_options(options, symex);
323321
}
324322

325323
safety_checkert::resultt bmct::execute(
@@ -546,43 +544,6 @@ safety_checkert::resultt bmct::stop_on_fail(prop_convt &prop_conv)
546544
}
547545
}
548546

549-
void bmct::setup_unwind()
550-
{
551-
const std::string &set=options.get_option("unwindset");
552-
std::vector<std::string> unwindset_loops;
553-
split_string(set, ',', unwindset_loops, true, true);
554-
555-
for(auto &val : unwindset_loops)
556-
{
557-
unsigned thread_nr=0;
558-
bool thread_nr_set=false;
559-
560-
if(!val.empty() &&
561-
isdigit(val[0]) &&
562-
val.find(":")!=std::string::npos)
563-
{
564-
std::string nr=val.substr(0, val.find(":"));
565-
thread_nr=unsafe_string2unsigned(nr);
566-
thread_nr_set=true;
567-
val.erase(0, nr.size()+1);
568-
}
569-
570-
if(val.rfind(":")!=std::string::npos)
571-
{
572-
std::string id=val.substr(0, val.rfind(":"));
573-
long uw=unsafe_string2int(val.substr(val.rfind(":")+1));
574-
575-
if(thread_nr_set)
576-
symex.set_unwind_thread_loop_limit(thread_nr, id, uw);
577-
else
578-
symex.set_unwind_loop_limit(id, uw);
579-
}
580-
}
581-
582-
if(options.get_option("unwind")!="")
583-
symex.set_unwind_limit(options.get_unsigned_int_option("unwind"));
584-
}
585-
586547
/// Perform core BMC, using an abstract model to supply GOTO function bodies
587548
/// (perhaps created on demand).
588549
/// \param opts: command-line options affecting BMC

src/cbmc/bmc.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,6 @@ class bmct:public safety_checkert
180180
const goto_functionst &,
181181
prop_convt &);
182182

183-
// unwinding
184-
virtual void setup_unwind();
185183
void do_conversion();
186184

187185
virtual void freeze_program_variables();

src/cbmc/symex_bmc.cpp

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Author: Daniel Kroening, [email protected]
1717

1818
#include <util/source_location.h>
1919
#include <util/simplify_expr.h>
20+
#include <util/string_utils.h>
21+
#include <util/string2int.h>
2022

2123
symex_bmct::symex_bmct(
2224
message_handlert &mh,
@@ -236,3 +238,42 @@ void symex_bmct::no_body(const irep_idt &identifier)
236238
<< log.eom;
237239
}
238240
}
241+
242+
void parse_unwinding_options(
243+
const optionst &options,
244+
symex_bmct &symex)
245+
{
246+
const std::string &set=options.get_option("unwindset");
247+
std::vector<std::string> unwindset_loops;
248+
split_string(set, ',', unwindset_loops, true, true);
249+
250+
for(auto &val : unwindset_loops)
251+
{
252+
unsigned thread_nr=0;
253+
bool thread_nr_set=false;
254+
255+
if(!val.empty() &&
256+
isdigit(val[0]) &&
257+
val.find(":")!=std::string::npos)
258+
{
259+
std::string nr=val.substr(0, val.find(":"));
260+
thread_nr=unsafe_string2unsigned(nr);
261+
thread_nr_set=true;
262+
val.erase(0, nr.size()+1);
263+
}
264+
265+
if(val.rfind(":")!=std::string::npos)
266+
{
267+
std::string id=val.substr(0, val.rfind(":"));
268+
long uw=unsafe_string2int(val.substr(val.rfind(":")+1));
269+
270+
if(thread_nr_set)
271+
symex.set_unwind_thread_loop_limit(thread_nr, id, uw);
272+
else
273+
symex.set_unwind_loop_limit(id, uw);
274+
}
275+
}
276+
277+
if(options.get_option("unwind")!="")
278+
symex.set_unwind_limit(options.get_unsigned_int_option("unwind"));
279+
}

src/cbmc/symex_bmc.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,4 +152,10 @@ class symex_bmct: public goto_symext
152152
symex_coveraget symex_coverage;
153153
};
154154

155+
class optionst;
156+
157+
void parse_unwinding_options(
158+
const optionst &,
159+
symex_bmct &);
160+
155161
#endif // CPROVER_CBMC_SYMEX_BMC_H

0 commit comments

Comments
 (0)