cprover
undefined_functions.cpp
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: Handling of functions without body
4 
5 Author: Michael Tautschnig
6 
7 Date: July 2016
8 
9 \*******************************************************************/
10 
13 
14 #include "undefined_functions.h"
15 
16 #include <ostream>
17 
18 #include <util/invariant.h>
19 
21 
23  const goto_modelt &goto_model,
24  std::ostream &os)
25 {
26  const namespacet ns(goto_model.symbol_table);
27 
29  if(!ns.lookup(it->first).is_macro &&
30  !it->second.body_available())
31  os << it->first << '\n';
32 }
33 
35 {
37  Forall_goto_program_instructions(iit, it->second.body)
38  {
40 
41  if(!ins.is_function_call())
42  continue;
43 
45 
46  if(call.function().id()!=ID_symbol)
47  continue;
48 
49  const irep_idt &function=
50  to_symbol_expr(call.function()).get_identifier();
51 
52  goto_functionst::function_mapt::const_iterator entry=
53  goto_model.goto_functions.function_map.find(function);
55  entry!=goto_model.goto_functions.function_map.end(),
56  "called function must be in function_map");
57 
58  if(entry->second.body_available())
59  continue;
60 
63  "`"+id2string(function)+"' is undefined");
64  }
65 }
void undefined_function_abort_path(goto_modelt &goto_model)
const std::string & id2string(const irep_idt &d)
Definition: irep.h:44
void make_assumption(const exprt &g)
Definition: goto_program.h:248
void list_undefined_functions(const goto_modelt &goto_model, std::ostream &os)
void set_comment(const irep_idt &comment)
function_mapt function_map
symbol_tablet symbol_table
Symbol table.
Definition: goto_model.h:29
This class represents an instruction in the GOTO intermediate representation.
Definition: goto_program.h:173
const irep_idt & id() const
Definition: irep.h:259
Symbol Table + CFG.
TO_BE_DOCUMENTED.
Definition: namespace.h:74
A function call.
Definition: std_code.h:858
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast a generic exprt to a symbol_exprt.
Definition: std_expr.h:210
dstringt has one field, an unsigned integer no which is an index into a static table of strings...
Definition: dstring.h:33
The boolean constant false.
Definition: std_expr.h:4497
exprt & function()
Definition: std_code.h:878
source_locationt source_location
The location of the instruction in the source file.
Definition: goto_program.h:182
#define Forall_goto_functions(it, functions)
Handling of functions without body.
#define Forall_goto_program_instructions(it, program)
Definition: goto_program.h:740
#define DATA_INVARIANT(CONDITION, REASON)
Definition: invariant.h:278
#define forall_goto_functions(it, functions)
goto_functionst goto_functions
GOTO functions.
Definition: goto_model.h:32
bool lookup(const irep_idt &name, const symbolt *&symbol) const override
See namespace_baset::lookup().
Definition: namespace.cpp:136
const code_function_callt & to_code_function_call(const codet &code)
Definition: std_code.h:909