CBMC: /home/runner/work/cbmc/cbmc/src/goto-diff/goto_diff_base.cpp Source File

CBMC
Loading...
Searching...
No Matches
goto_diff_base.cpp
Go to the documentation of this file.
1/*******************************************************************\
2
3Module: GOTO-DIFF Base Class
4
5Author: Peter Schrammel
6
7\*******************************************************************/
8
11
12#include "goto_diff.h"
13
14#include <util/json_irep.h>
15#include <util/options.h>
16
17#include <goto-programs/goto_model.h>
18#include <goto-programs/show_properties.h>
19
22{
24
25 switch(message_handler.get_ui())
26 {
28 {
29 msg.result() << "total number of functions: " << total_functions_count
30 << '\n' << messaget::eom;
33 "modified functions", modified_functions, goto_model2);
35 "deleted functions", deleted_functions, goto_model1);
36 msg.result() << messaget::eom;
37 break;
38 }
40 {
42 {"totalNumberOfFunctions",
43 json_stringt(std::to_string(total_functions_count))}};
45 json_result["newFunctions"].make_array(), new_functions, goto_model2);
47 json_result["modifiedFunctions"].make_array(),
51 json_result["deletedFunctions"].make_array(),
54 msg.result() << json_result << messaget::eom;
55 break;
56 }
58 {
59 msg.error() << "XML output not supported yet" << messaget::eom;
60 break;
61 }
62 }
63}
64
70 const std::string &group_name,
71 const std::set<irep_idt> &function_group,
72 const goto_modelt &goto_model) const
73{
75 for(const auto &function_name : function_group)
76 {
77 output_function(function_name, goto_model);
78 }
79}
80
85 const irep_idt &function_name,
86 const goto_modelt &goto_model) const
87{
89
90 namespacet ns(goto_model.symbol_table);
91 const symbolt &symbol = ns.lookup(function_name);
92
93 msg.result() << " " << symbol.location.get_file() << ": " << function_name;
94
95 if(options.get_bool_option("show-properties"))
96 {
97 const auto goto_function_it =
98 goto_model.goto_functions.function_map.find(function_name);
100 goto_function_it != goto_model.goto_functions.function_map.end());
101 const goto_programt &goto_program = goto_function_it->second.body;
102
103 for(const auto &ins : goto_program.instructions)
104 {
105 if(!ins.is_assert())
106 continue;
107
108 const source_locationt &source_location = ins.source_location();
109 irep_idt property_id = source_location.get_property_id();
110 msg.result() << "\n " << property_id;
111 }
112 }
113
114 msg.result() << messaget::eom;
115}
116
122 json_arrayt &result,
123 const std::set<irep_idt> &function_group,
124 const goto_modelt &goto_model) const
125{
126 for(const auto &function_name : function_group)
127 {
129 result.push_back(jsont()).make_object(), function_name, goto_model);
130 }
131}
132
138 json_objectt &result,
139 const irep_idt &function_name,
140 const goto_modelt &goto_model) const
141{
142 namespacet ns(goto_model.symbol_table);
143 const symbolt &symbol = ns.lookup(function_name);
144
145 result["name"] = json_stringt(function_name);
146 result["sourceLocation"] = json(symbol.location);
147
148 if(options.get_bool_option("show-properties"))
149 {
150 const auto goto_function_it =
151 goto_model.goto_functions.function_map.find(function_name);
153 goto_function_it != goto_model.goto_functions.function_map.end());
154 const goto_programt &goto_program = goto_function_it->second.body;
155
157 result["properties"].make_array(), ns, function_name, goto_program);
158 }
159}
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
Definition ai.h:566
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition dstring.h:38
const optionst & options
Definition goto_diff.h:51
void output_function(const irep_idt &function_name, const goto_modelt &goto_model) const
Output function information in plain text format.
std::set< irep_idt > modified_functions
Definition goto_diff.h:54
void convert_function_group_json(json_arrayt &result, const std::set< irep_idt > &function_group, const goto_modelt &goto_model) const
Convert a function group to JSON.
const goto_modelt & goto_model1
Definition goto_diff.h:49
virtual void output_functions() const
Output diff result.
void convert_function_json(json_objectt &result, const irep_idt &function_name, const goto_modelt &goto_model) const
Convert function information to JSON.
std::set< irep_idt > new_functions
Definition goto_diff.h:54
void output_function_group(const std::string &group_name, const std::set< irep_idt > &function_group, const goto_modelt &goto_model) const
Output group of functions in plain text format.
unsigned total_functions_count
Definition goto_diff.h:53
std::set< irep_idt > deleted_functions
Definition goto_diff.h:54
const goto_modelt & goto_model2
Definition goto_diff.h:50
ui_message_handlert & message_handler
Definition goto_diff.h:48
function_mapt function_map
symbol_tablet symbol_table
Symbol table.
Definition goto_model.h:31
goto_functionst goto_functions
GOTO functions.
Definition goto_model.h:34
A generic container class for the GOTO intermediate representation of one function.
Definition goto_program.h:72
instructionst instructions
The list of instructions in the goto program.
Definition goto_program.h:621
jsont & push_back(const jsont &json)
Definition json.h:212
Definition json.h:27
Class that provides messages with a built-in verbosity 'level'.
Definition message.h:154
mstreamt & result() const
Definition message.h:411
static eomt eom
Definition message.h:289
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition namespace.h:91
bool lookup(const irep_idt &name, const symbolt *&symbol) const override
See documentation for namespace_baset::lookup().
Definition namespace.cpp:134
const irep_idt & get_property_id() const
const irep_idt & get_file() const
Symbol table entry.
Definition symbol.h:28
source_locationt location
Source code location of definition of symbol.
Definition symbol.h:37
virtual uit get_ui() const
Definition ui_message.h:33
GOTO-DIFF Base Class.
Symbol Table + CFG.
Options.
static void json(json_objectT &result, const irep_idt &property_id, const property_infot &property_info)
Definition properties.cpp:120
void convert_properties_json(json_arrayt &json_properties, const namespacet &ns, const irep_idt &identifier, const goto_programt &goto_program)
Collects the properties in the goto program into a json_arrayt
Show the properties.
#define CHECK_RETURN(CONDITION)
Definition invariant.h:495

AltStyle によって変換されたページ (->オリジナル) /