17 #include <unordered_set> 28 typedef std::unordered_set<irep_idt>
linest;
29 typedef std::unordered_map<irep_idt, linest>
filest;
40 filest &files=dest[it->source_location.get_working_directory()];
44 !it->source_location.is_built_in())
45 files[
file].insert(it->source_location.get_line());
57 for(
const std::pair<irep_idt, filest> &files : eloc_map)
58 for(
const std::pair<irep_idt, linest> &lines : files.second)
59 eloc+=lines.second.size();
61 std::cout <<
"Effective lines of code: " << eloc <<
'\n';
69 for(
const std::pair<irep_idt, filest> &files : eloc_map)
70 for(
const std::pair<irep_idt, linest> &lines : files.second)
73 if(!files.first.empty())
76 for(
const irep_idt &line : lines.second)
77 std::cout <<
file <<
':' << line <<
'\n';
84 goto_functionst::function_mapt::const_iterator start=
88 !start->second.body_available())
90 std::cout <<
"No entry point found, path length undefined\n";
94 struct visited_cfg_nodet
98 visited_cfg_nodet():visited(
false)
109 const cfgt::entryt &start_node=
111 const cfgt::entryt &last_node=
115 cfg.shortest_path(start_node, last_node, shortest_path);
116 std::cout <<
"Shortest control-flow path: " << shortest_path.size()
117 <<
" instructions\n";
119 std::size_t n_loops=0, loop_ins=0;
123 if(i_it->is_backwards_goto() ||
124 i_it==gf_it->second.body.instructions.begin())
126 const cfgt::entryt &node=cfg.entry_map[i_it];
128 cfg.shortest_loop(node, loop);
133 loop_ins+=loop.size()-1;
138 std::cout <<
"Loop information: " << n_loops <<
" loops, " 139 << loop_ins <<
" instructions in shortest paths of loop bodies\n";
141 std::size_t n_reachable=0;
142 cfg.visit_reachable(start_node);
143 for(std::size_t i=0; i<cfg.size(); ++i)
146 std::cout <<
"Reachable instructions: " << n_reachable <<
"\n";
155 goto_functionst::function_mapt::const_iterator f_it =
157 const bool has_initialize =
159 std::unordered_set<irep_idt> initialized;
163 for(
const auto &ins : f_it->second.body.instructions)
184 const symbolt &symbol = symbol_entry.second;
189 (has_initialize && initialized.find(symbol.
name) == initialized.end()))
199 std::cout <<
"Total size of global objects: " << total_size <<
" bits\n";
std::string concat_dir_file(const std::string &directory, const std::string &file_name)
irep_idt name
The unique identifier.
const std::string & id2string(const irep_idt &d)
A multi-procedural control flow graph (CFG) whose nodes store references to instructions in a GOTO pr...
const irep_idt & get_identifier() const
const exprt & root_object() const
function_mapt function_map
mp_integer pointer_offset_bits(const typet &type, const namespacet &ns)
symbol_tablet symbol_table
Symbol table.
Symbol table entry.This is a symbol in the symbol table, stored in an object of type symbol_tablet...
bool get_bool(const irep_namet &name) const
void print_path_lengths(const goto_modelt &goto_model)
std::unordered_set< irep_idt > linest
const code_assignt & to_code_assign(const codet &code)
std::unordered_map< irep_idt, filest > working_dirst
const irep_idt & id() const
void build(const exprt &expr, const namespacet &ns)
Build an object_descriptor_exprt from a given expr.
#define INITIALIZE_FUNCTION
void list_eloc(const goto_modelt &goto_model)
instructionst instructions
The list of instructions in the goto program.
static void collect_eloc(const goto_modelt &goto_model, working_dirst &dest)
std::list< path_nodet > patht
bool has_prefix(const std::string &s, const std::string &prefix)
split an expression into a base object and a (byte) offset
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast a generic exprt to a symbol_exprt.
dstringt has one field, an unsigned integer no which is an index into a static table of strings...
Count effective lines of code.
A generic container class for the GOTO intermediate representation of one function.
typet type
Type of symbol.
static irep_idt entry_point()
void count_eloc(const goto_modelt &goto_model)
Expression to hold a symbol (variable)
std::unordered_map< irep_idt, linest > filest
#define forall_goto_functions(it, functions)
#define forall_goto_program_instructions(it, program)
goto_functionst goto_functions
GOTO functions.
void print_global_state_size(const goto_modelt &goto_model)