Skip to content

Commit 7dc2753

Browse files
committed
Temp commit
Trying to get the hw-cbmc to work. No luck so far.
1 parent 1472cdf commit 7dc2753

File tree

3 files changed

+39
-18
lines changed

3 files changed

+39
-18
lines changed

src/hw-cbmc/hw_cbmc_parse_options.cpp

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,13 @@ Author: Daniel Kroening, [email protected]
1717
#include <goto-checker/goto_verifier.h>
1818
#include <goto-checker/multi_path_symex_checker.h>
1919
#include <goto-checker/solver_factory.h>
20+
21+
#include <goto-programs/goto_convert_functions.h>
2022
#include <goto-programs/set_properties.h>
2123
#include <goto-programs/show_properties.h>
24+
2225
#include <langapi/mode.h>
26+
2327
#include <trans-word-level/show_modules.h>
2428
#include <trans-word-level/trans_trace_word_level.h>
2529
#include <trans-word-level/unwind.h>
@@ -74,8 +78,6 @@ int hw_cbmc_parse_optionst::doit()
7478
if(cmdline.isset("vcd"))
7579
options.set_option("vcd", cmdline.get_value("vcd"));
7680

77-
symbol_tablet symbol_table;
78-
7981
std::unique_ptr<goto_verifiert> verifier = nullptr;
8082
verifier = util_make_unique<
8183
all_properties_verifier_with_trace_storaget<multi_path_symex_checkert>>(
@@ -87,18 +89,33 @@ int hw_cbmc_parse_optionst::doit()
8789
prop_convt &prop_conv =
8890
static_cast<prop_convt &>(*my_solver->decision_procedure_ptr);
8991

90-
goto_functionst &goto_functions = goto_model.goto_functions;
9192
int get_goto_program_ret =
9293
get_goto_program(goto_model, options, cmdline, ui_message_handler);
9394
if (get_goto_program_ret != -1)
9495
return get_goto_program_ret;
9596

97+
std::list<exprt> constraints;
98+
int get_modules_ret = get_modules(constraints);
99+
if (get_modules_ret != -1)
100+
return get_modules_ret;
101+
102+
goto_convert(goto_model.symbol_table, goto_model.goto_functions,
103+
ui_message_handler);
104+
96105
unwind_no_timeframes = get_bound();
97106
unwind_module = get_top_module();
98-
99107
do_unwind_module(prop_conv);
100108

101-
label_properties(goto_functions);
109+
// the 'extra constraints'
110+
if (!constraints.empty()) {
111+
log.status() << "converting constraints" << messaget::eom;
112+
113+
for (const auto &constraint : constraints) {
114+
prop_conv.set_to_true(constraint);
115+
}
116+
}
117+
118+
label_properties(goto_model.goto_functions);
102119

103120
if (cmdline.isset("show-properties")) {
104121
show_properties(goto_model, ui_message_handler);
@@ -112,7 +129,6 @@ int hw_cbmc_parse_optionst::doit()
112129

113130
const resultt result = (*verifier)();
114131
verifier->report();
115-
show_unwind_trace(options, prop_conv);
116132
return result_to_exit_code(result);
117133
}
118134

src/hw-cbmc/map_vars.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,9 @@ void map_varst::map_vars(const irep_idt &top_module)
694694
<< top_module_symbol.base_name << "'" << eom;
695695
return;
696696
}
697-
697+
698+
namespacet ns(symbol_table);
699+
698700
{
699701
symbolt &s=lookup(struct_symbol);
700702

@@ -712,7 +714,6 @@ void map_varst::map_vars(const irep_idt &top_module)
712714

713715
exprt timeframe_expr=from_integer(0, index_type());
714716

715-
namespacet ns(symbol_table);
716717
index_exprt expr(
717718
symbol_expr, timeframe_expr, ns.follow(symbol_expr.type()).subtype());
718719

@@ -725,6 +726,8 @@ void map_varst::map_vars(const irep_idt &top_module)
725726
if (entry.second.mode == ID_C || entry.second.mode == ID_cpp) {
726727
const irep_idt &base_name = entry.second.base_name;
727728
symbolt &symbol = symbol_table.get_writeable_ref(entry.first);
729+
if (symbol.type.id() == ID_struct_tag)
730+
symbol.type = ns.follow(symbol.type);
728731
if (base_name == "next_timeframe" && symbol.type.id() == ID_code) {
729732
namespacet ns(symbol_table);
730733
add_next_timeframe(symbol, struct_symbol, top_level_inputs, ns);

src/hw-cbmc/next_timeframe.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,19 @@ void add_next_timeframe(
5050
code_blockt block;
5151
block.add(assignment_increase);
5252

53+
const struct_typet &struct_type =
54+
to_struct_type(ns.follow(struct_symbol.type));
55+
5356
// now assign the non-inputs in the module symbol
54-
const index_exprt index_expr(
55-
array_symbol.symbol_expr(),
56-
timeframe_symbol.symbol_expr(),
57-
struct_symbol.type);
57+
const index_exprt index_expr(array_symbol.symbol_expr(),
58+
timeframe_symbol.symbol_expr(), struct_type);
5859

59-
const struct_typet &struct_type=
60-
to_struct_type(ns.follow(struct_symbol.type));
61-
6260
const struct_typet::componentst &components=
6361
struct_type.components();
6462

63+
symbol_exprt struct_symbol_expr{struct_type};
64+
struct_symbol_expr.set_identifier(struct_symbol.name);
65+
6566
for(struct_typet::componentst::const_iterator
6667
c_it=components.begin();
6768
c_it!=components.end();
@@ -72,10 +73,11 @@ void add_next_timeframe(
7273
const typet &type=c_it->type();
7374

7475
if(top_level_inputs.find(name)!=top_level_inputs.end()) continue;
75-
76-
const exprt member_expr1=member_exprt(struct_symbol.symbol_expr(), name, type);
76+
77+
const exprt member_expr1 = member_exprt(struct_symbol_expr, name, type);
7778
const exprt member_expr2=member_exprt(index_expr, name, type);
78-
79+
80+
CHECK_RETURN(member_expr1.op0().type() == member_expr2.op0().type());
7981
const code_assignt member_assignment(member_expr1, member_expr2);
8082
block.add(member_assignment);
8183
}

0 commit comments

Comments
 (0)