16 #include <unordered_set> 37 std::list<irep_idt> worklist;
38 std::unordered_set<irep_idt, irep_id_hash> functions_reached;
42 goto_functionst::function_mapt::const_iterator e_it;
46 throw "entry point not found";
48 worklist.push_back(entry_point);
55 functions_reached.insert(
id);
57 const auto &p=graph.equal_range(
id);
59 for(
auto it=p.first; it!=p.second; it++)
63 if(functions_reached.find(callee)==functions_reached.end())
64 worklist.push_back(callee);
67 while(!worklist.empty());
70 functions_reached.erase(initialize);
79 if(expr.
id()==ID_symbol)
87 std::unordered_set<irep_idt, irep_id_hash> symbols;
90 symbol_collectort visitor;
92 assert(!functions_reached.empty());
94 for(
const irep_idt &
id : functions_reached)
102 const codet &code=i_it->code;
107 const std::unordered_set<irep_idt, irep_id_hash> &symbols=visitor.symbols;
111 goto_functionst::function_mapt::iterator f_it;
119 if(i_it->is_assign())
126 symbols.find(
id)==symbols.end())
const std::string & id2string(const irep_idt &d)
Remove initializations of unused global variables.
const irep_idt & get_identifier() const
Goto Programs with Functions.
const code_assignt & to_code_assign(const codet &code)
const irep_idt & id() const
void visit(class expr_visitort &visitor)
std::multimap< irep_idt, irep_idt > grapht
static irep_idt entry_point()
API to expression classes.
goto_function_templatet< goto_programt > goto_functiont
function_mapt function_map
bool has_prefix(const std::string &s, const std::string &prefix)
A specialization of goto_program_templatet over goto programs in which instructions have codet type...
void remove_skip(goto_programt &goto_program)
remove unnecessary skip statements
Base class for all expressions.
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast a generic exprt to a symbol_exprt.
virtual void operator()(const exprt &expr)
#define Forall_goto_program_instructions(it, program)
Expression to hold a symbol (variable)
A statement in a programming language.
#define forall_goto_program_instructions(it, program)
void slice_global_inits(const namespacet &ns, goto_functionst &goto_functions)
goto_functionst goto_functions