17 #include <unordered_set> 24 typedef std::unordered_set<irep_idt, irep_id_hash>
linest;
25 typedef std::unordered_map<irep_idt, linest, irep_id_hash>
filest;
26 typedef std::unordered_map<irep_idt, filest, irep_id_hash>
working_dirst;
36 filest &files=dest[it->source_location.get_working_directory()];
40 !it->source_location.is_built_in())
41 files[
file].insert(it->source_location.get_line());
53 for(
const std::pair<irep_idt, filest> &files : eloc_map)
54 for(
const std::pair<irep_idt, linest> &lines : files.second)
55 eloc+=lines.second.size();
57 std::cout <<
"Effective lines of code: " << eloc <<
'\n';
65 for(
const std::pair<irep_idt, filest> &files : eloc_map)
66 for(
const std::pair<irep_idt, linest> &lines : files.second)
69 if(!files.first.empty())
72 for(
const irep_idt &line : lines.second)
73 std::cout <<
file <<
':' << line <<
'\n';
80 goto_functionst::function_mapt::const_iterator start=
84 !start->second.body_available())
86 std::cout <<
"No entry point found, path length undefined\n";
90 struct visited_cfg_nodet
94 visited_cfg_nodet():visited(
false)
105 const cfgt::entryt &start_node=
107 const cfgt::entryt &last_node=
111 cfg.shortest_path(start_node, last_node, shortest_path);
112 std::cout <<
"Shortest control-flow path: " << shortest_path.size()
113 <<
" instructions\n";
115 std::size_t n_loops=0, loop_ins=0;
119 if(i_it->is_backwards_goto() ||
120 i_it==gf_it->second.body.instructions.begin())
122 const cfgt::entryt &node=cfg.entry_map[i_it];
124 cfg.shortest_loop(node, loop);
129 loop_ins+=loop.size()-1;
134 std::cout <<
"Loop information: " << n_loops <<
" loops, " 135 << loop_ins <<
" instructions in shortest paths of loop bodies\n";
137 std::size_t n_reachable=0;
138 cfg.visit_reachable(start_node);
139 for(std::size_t i=0; i<cfg.size(); ++i)
142 std::cout <<
"Reachable instructions: " << n_reachable <<
"\n";
std::string concat_dir_file(const std::string &directory, const std::string &file_name)
const std::string & id2string(const irep_idt &d)
instructionst instructions
The list of instructions in the goto program.
A multi-procedural control flow graph (CFG) whose nodes store references to instructions in a GOTO pr...
static void collect_eloc(const goto_functionst &goto_functions, working_dirst &dest)
std::unordered_map< irep_idt, filest, irep_id_hash > working_dirst
static irep_idt entry_point()
std::list< path_nodet > patht
void print_path_lengths(const goto_functionst &goto_functions)
std::unordered_set< irep_idt, irep_id_hash > linest
void count_eloc(const goto_functionst &goto_functions)
Count effective lines of code.
function_mapt function_map
std::unordered_map< irep_idt, linest, irep_id_hash > filest
A specialization of goto_program_templatet over goto programs in which instructions have codet type...
void list_eloc(const goto_functionst &goto_functions)
#define forall_goto_functions(it, functions)
#define forall_goto_program_instructions(it, program)