Skip to content

Commit 84b7d0a

Browse files
Split output_graphml into proof and refutation
because they need different input objects. This avoids creating objects for unused arguments.
1 parent cd34e43 commit 84b7d0a

File tree

3 files changed

+26
-12
lines changed

3 files changed

+26
-12
lines changed

src/cbmc/bmc.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ safety_checkert::resultt bmct::execute(
153153
if(options.is_set("paths"))
154154
return safety_checkert::resultt::PAUSED;
155155
report_success(ui_message_handler);
156-
output_graphml(resultt::SAFE, error_trace, equation, ns, options);
156+
output_graphml(equation, ns, options);
157157
return safety_checkert::resultt::SAFE;
158158
}
159159

@@ -222,7 +222,7 @@ safety_checkert::resultt bmct::stop_on_fail(prop_convt &prop_conv)
222222
{
223223
case decision_proceduret::resultt::D_UNSATISFIABLE:
224224
report_success(ui_message_handler);
225-
output_graphml(resultt::SAFE, error_trace, equation, ns, options);
225+
output_graphml(equation, ns, options);
226226
return resultt::SAFE;
227227

228228
case decision_proceduret::resultt::D_SATISFIABLE:
@@ -235,7 +235,7 @@ safety_checkert::resultt bmct::stop_on_fail(prop_convt &prop_conv)
235235
build_error_trace(
236236
error_trace, ns, equation, prop_conv, ui_message_handler);
237237
output_error_trace(error_trace, ns, trace_options(), ui_message_handler);
238-
output_graphml(resultt::UNSAFE, error_trace, equation, ns, options);
238+
output_graphml(error_trace, ns, options);
239239
}
240240

241241
report_failure(ui_message_handler);

src/goto-checker/bmc_util.cpp

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,9 @@ void output_error_trace(
8787
}
8888
}
8989

90-
/// outputs witnesses in graphml format
90+
/// outputs an error witness in graphml format
9191
void output_graphml(
92-
safety_checkert::resultt result,
9392
const goto_tracet &goto_trace,
94-
const symex_target_equationt &symex_target_equation,
9593
const namespacet &ns,
9694
const optionst &options)
9795
{
@@ -100,13 +98,30 @@ void output_graphml(
10098
return;
10199

102100
graphml_witnesst graphml_witness(ns);
103-
if(result == safety_checkert::resultt::UNSAFE)
104-
graphml_witness(goto_trace);
105-
else if(result == safety_checkert::resultt::SAFE)
106-
graphml_witness(symex_target_equation);
101+
graphml_witness(goto_trace);
102+
103+
if(graphml == "-")
104+
write_graphml(graphml_witness.graph(), std::cout);
107105
else
106+
{
107+
std::ofstream out(graphml);
108+
write_graphml(graphml_witness.graph(), out);
109+
}
110+
}
111+
112+
/// outputs a proof in graphml format
113+
void output_graphml(
114+
const symex_target_equationt &symex_target_equation,
115+
const namespacet &ns,
116+
const optionst &options)
117+
{
118+
const std::string graphml = options.get_option("graphml-witness");
119+
if(graphml.empty())
108120
return;
109121

122+
graphml_witnesst graphml_witness(ns);
123+
graphml_witness(symex_target_equation);
124+
110125
if(graphml == "-")
111126
write_graphml(graphml_witness.graph(), std::cout);
112127
else

src/goto-checker/bmc_util.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,8 @@ void output_error_trace(
4848
const trace_optionst &,
4949
ui_message_handlert &);
5050

51+
void output_graphml(const goto_tracet &, const namespacet &, const optionst &);
5152
void output_graphml(
52-
safety_checkert::resultt,
53-
const goto_tracet &,
5453
const symex_target_equationt &,
5554
const namespacet &,
5655
const optionst &);

0 commit comments

Comments
 (0)