Go to the documentation of this file.
26 typedef std::map<unsigned, goto_programt::const_targett>
dead_mapt;
33 dominators(goto_program);
35 for(cfg_dominatorst::cfgt::entry_mapt::const_iterator
41 if(n.dominators.empty())
42 dest.insert(std::make_pair(it->first->location_number,
52 if(!it->is_end_function())
53 dest.insert(std::make_pair(it->location_number, it));
63 dest.insert(std::make_pair(it->location_number, it));
73 os <<
"\n*** " << function_identifier <<
" ***\n";
75 for(dead_mapt::const_iterator it=dead_map.begin();
78 it->second->output(os);
90 for(dead_mapt::const_iterator it=dead_map.begin();
98 "source_location", it->second->source_location().as_string());
116 const irep_idt &function_identifier,
126 "The last instruction in a goto-program must be END_FUNCTION");
134 for(dead_mapt::const_iterator it=dead_map.begin();
138 std::ostringstream oss;
140 std::string s=oss.str();
143 assert(n!=std::string::npos);
145 n=s.find_first_not_of(
' ');
146 assert(n!=std::string::npos);
174 if(!gf_entry.second.body_available())
183 called.find(decl.
name) != called.end() ||
191 if(!dead_map.empty())
196 add_to_json(ns, gf_entry.first, goto_program, dead_map, json_result);
201 os << json_result <<
'\n';
211 xmlt xml_result(
"unreachable-instructions");
217 if(!gf_entry.second.body_available())
224 if(!dead_map.empty())
229 ns, gf_entry.first, gf_entry.second.body, dead_map, json_result);
233 add_to_xml(gf_entry.first, gf_entry.second.body, dead_map, xml_result);
239 ns, gf_entry.first, gf_entry.second.body, dead_map, out);
245 out << json_result <<
'\n';
247 out << xml_result <<
'\n';
299 const std::unordered_set<irep_idt> &called,
305 xmlt xml_result(unreachable ?
306 "unreachable-functions" :
307 "reachable-functions");
316 unreachable == (called.find(decl.
name) != called.end() ||
325 if(gf_entry.second.body_available())
338 last_location = end_function->source_location();
373 os << *file_name_opt <<
' ';
376 os <<
' ' << *line_opt;
378 os <<
' ' << *line_opt;
384 os << json_result <<
'\n';
386 os << xml_result <<
'\n';
421 std::unordered_set<irep_idt> called;
425 if(!gf_entry.second.body_available())
431 called.insert(gf_entry.first);
443 std::unordered_set<irep_idt> called =
457 std::unordered_set<irep_idt> called =
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
static void add_to_json(const namespacet &ns, const irep_idt &function_identifier, const goto_programt &goto_program, const dead_mapt &dead_map, json_arrayt &dest)
bool static_unreachable_instructions(const goto_modelt &goto_model, const ai_baset &ai, const optionst &options, std::ostream &out)
void output(std::ostream &out) const
std::map< unsigned, goto_programt::const_targett > dead_mapt
const irept & find(const irep_idt &name) const
typet type
Type of symbol.
virtual cstate_ptrt abstract_state_before(locationt l) const
Get a copy of the abstract state before the given instruction, without needing to know what kind of d...
irep_idt base_name
Base (non-scoped) name.
static void all_unreachable(const goto_programt &goto_program, dead_mapt &dest)
void set_option(const std::string &option, const bool value)
static void xml_output_function(const irep_idt &function, const source_locationt &first_location, const source_locationt &last_location, xmlt &dest)
std::string to_string(const string_not_contains_constraintt &expr)
Used for debug printing.
static void add_to_xml(const irep_idt &function_identifier, const goto_programt &goto_program, const dead_mapt &dead_map, xmlt &dest)
function_mapt function_map
const irep_idt & get_line() const
std::unordered_set< irep_idt > compute_called_functions(const goto_functionst &goto_functions)
computes the functions that are (potentially) called
static void list_functions(const goto_modelt &goto_model, const std::unordered_set< irep_idt > &called, const optionst &options, std::ostream &os, bool unreachable)
void reachable_functions(const goto_modelt &goto_model, const bool json, std::ostream &os)
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
static void build_dead_map_from_ai(const goto_programt &goto_program, const ai_baset &ai, dead_mapt &dest)
bool lookup(const irep_idt &name, const symbolt *&symbol) const override
See documentation for namespace_baset::lookup().
const code_typet & to_code_type(const typet &type)
Cast a typet to a code_typet.
void unreachable_functions(const goto_modelt &goto_model, const bool json, std::ostream &os)
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...
static optionalt< std::string > line_string_opt(const source_locationt &source_location)
const std::string & id2string(const irep_idt &d)
std::string concat_dir_file(const std::string &directory, const std::string &file_name)
#define PRECONDITION(CONDITION)
static void json(json_objectT &result, const irep_idt &property_id, const property_infot &property_info)
json_arrayt & make_array()
nonstd::optional< T > optionalt
static void unreachable_instructions(const goto_programt &goto_program, dead_mapt &dest)
std::unordered_set< irep_idt > compute_called_functions_from_ai(const goto_modelt &goto_model, const ai_baset &ai)
instructionst instructions
The list of instructions in the goto program.
static optionalt< std::string > file_name_string_opt(const source_locationt &source_location)
static void output_dead_plain(const namespacet &ns, const irep_idt &function_identifier, const goto_programt &goto_program, const dead_mapt &dead_map, std::ostream &os)
goto_functionst goto_functions
GOTO functions.
bool static_reachable_functions(const goto_modelt &goto_model, const ai_baset &ai, const optionst &options, std::ostream &out)
void set_attribute(const std::string &attribute, unsigned value)
source_locationt location
Source code location of definition of symbol.
bool get_bool_option(const std::string &option) const
This is the basic interface of the abstract interpreter with default implementations of the core func...
A generic container class for the GOTO intermediate representation of one function.
static void json_output_function(const irep_idt &function, const source_locationt &first_location, const source_locationt &last_location, json_arrayt &dest)
const irep_idt & get_file() const
instructionst::const_iterator const_targett
bool static_unreachable_functions(const goto_modelt &goto_model, const ai_baset &ai, const optionst &options, std::ostream &out)
unsignedbv_typet size_type()
const irep_idt & get_working_directory() const
symbol_tablet symbol_table
Symbol table.
irep_idt name
The unique identifier.
jsont & push_back(const jsont &json)
#define forall_goto_program_instructions(it, program)
xmlt & new_element(const std::string &key)