Skip to content

Commit 0cdd9c6

Browse files
committed
Improve structure of JSON static-analysis dump
1 parent 7df9f15 commit 0cdd9c6

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

src/analyses/static_analysis.cpp

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Author: Daniel Kroening, [email protected]
1515
#include <cassert>
1616
#include <memory>
1717

18+
#include <util/json_irep.h>
1819
#include <util/std_expr.h>
1920
#include <util/std_code.h>
2021

@@ -115,20 +116,28 @@ jsont static_analysis_baset::output_json(
115116
const irep_idt &identifier) const
116117
{
117118
json_arrayt retval;
119+
json_irept irep_converter(true);
118120

119121
forall_goto_program_instructions(i_it, goto_program)
120122
{
121-
std::ostringstream out;
122-
out << "**** " << i_it->location_number << " "
123-
<< i_it->source_location << "\n";
124-
125-
get_state(i_it).output(ns, out);
126-
out << "\n";
127-
#if 1
128-
goto_program.output_instruction(ns, identifier, out, i_it);
129-
out << "\n";
130-
#endif
131-
retval.push_back(json_stringt(out.str()));
123+
json_objectt instruction_object;
124+
instruction_object["location_number"]=
125+
json_numbert(std::to_string(i_it->location_number));
126+
instruction_object["source_location"]=
127+
irep_converter.convert_from_irep(i_it->source_location);
128+
instruction_object["code"]=
129+
irep_converter.convert_from_irep(i_it->code);
130+
{
131+
std::ostringstream pretty_type;
132+
pretty_type << i_it->type;
133+
instruction_object["instruction_type"]=json_stringt(pretty_type.str());
134+
}
135+
{
136+
std::ostringstream state_text;
137+
get_state(i_it).output(ns, state_text);
138+
instruction_object["state"]=json_stringt(state_text.str());
139+
}
140+
retval.push_back(instruction_object);
132141
}
133142

134143
return retval;

0 commit comments

Comments
 (0)