cprover
locals.cpp
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: Local variables
4 
5 Author: Daniel Kroening
6 
7 Date: March 2013
8 
9 \*******************************************************************/
10 
13 
14 #include "locals.h"
15 
16 #include <util/std_expr.h>
17 
18 void localst::build(const goto_functiont &goto_function)
19 {
20  forall_goto_program_instructions(it, goto_function.body)
21  if(it->is_decl())
22  {
23  const code_declt &code_decl=to_code_decl(it->code);
24  locals_map[code_decl.get_identifier()] = code_decl.symbol();
25  }
26 
27  for(const auto &param : goto_function.type.parameters())
28  locals_map[param.get_identifier()]=
29  symbol_exprt(param.get_identifier(), param.type());
30 }
31 
32 void localst::output(std::ostream &out) const
33 {
34  for(const auto &local : locals_map)
35  out << local.first << "\n";
36 }
const code_declt & to_code_decl(const codet &code)
Definition: std_code.h:399
locals_mapt locals_map
Definition: locals.h:38
goto_programt body
Definition: goto_function.h:29
const irep_idt & get_identifier() const
Definition: std_code.h:370
A codet representing the declaration of a local variable.
Definition: std_code.h:352
API to expression classes.
void output(std::ostream &out) const
Definition: locals.cpp:32
void build(const goto_functiont &goto_function)
Definition: locals.cpp:18
code_typet type
The type of the function, indicating the return type and parameter types.
Definition: goto_function.h:32
A goto function, consisting of function type (see type), function body (see body), and parameter identifiers (see parameter_identifiers).
Definition: goto_function.h:26
symbol_exprt & symbol()
Definition: std_code.h:360
const parameterst & parameters() const
Definition: std_types.h:893
Expression to hold a symbol (variable)
Definition: std_expr.h:143
Local variables whose address is taken.
#define forall_goto_program_instructions(it, program)
Definition: goto_program.h:804