CBMC
remove_function.cpp
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: Remove function definition
4 
5 Author: Michael Tautschnig
6 
7 Date: April 2017
8 
9 \*******************************************************************/
10 
13 
14 #include "remove_function.h"
15 
16 #include <util/message.h>
17 
19 
27  goto_modelt &goto_model,
28  const irep_idt &identifier,
29  message_handlert &message_handler)
30 {
31  messaget message(message_handler);
32 
33  goto_functionst::function_mapt::iterator entry=
34  goto_model.goto_functions.function_map.find(identifier);
35 
36  if(entry==goto_model.goto_functions.function_map.end())
37  {
38  message.error() << "No function " << identifier
39  << " in goto program" << messaget::eom;
40  return;
41  }
42  else if(to_code_type(goto_model.symbol_table.lookup_ref(identifier).type)
43  .get_inlined())
44  {
45  message.warning() << "Function " << identifier << " is inlined, "
46  << "instantiations will not be removed"
47  << messaget::eom;
48  }
49 
50  if(entry->second.body_available())
51  {
52  message.status() << "Removing body of " << identifier
53  << messaget::eom;
54  entry->second.clear();
55  symbolt &symbol = goto_model.symbol_table.get_writeable_ref(identifier);
56  symbol.value.make_nil();
57  symbol.is_file_local = false;
58  }
59 }
60 
69  goto_modelt &goto_model,
70  const std::list<std::string> &names,
71  message_handlert &message_handler)
72 {
73  for(const auto &f : names)
74  remove_function(goto_model, f, message_handler);
75 }
bool get_inlined() const
Definition: std_types.h:709
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition: dstring.h:38
function_mapt function_map
symbol_tablet symbol_table
Symbol table.
Definition: goto_model.h:31
goto_functionst goto_functions
GOTO functions.
Definition: goto_model.h:34
void make_nil()
Definition: irep.h:442
Class that provides messages with a built-in verbosity 'level'.
Definition: message.h:155
mstreamt & error() const
Definition: message.h:399
mstreamt & warning() const
Definition: message.h:404
mstreamt & status() const
Definition: message.h:414
static eomt eom
Definition: message.h:297
symbolt & get_writeable_ref(const irep_idt &name)
Find a symbol in the symbol table for read-write access.
const symbolt & lookup_ref(const irep_idt &name) const
Find a symbol in the symbol table for read-only access.
Symbol table entry.
Definition: symbol.h:28
bool is_file_local
Definition: symbol.h:73
typet type
Type of symbol.
Definition: symbol.h:31
exprt value
Initial value of symbol.
Definition: symbol.h:34
Symbol Table + CFG.
void remove_function(goto_modelt &goto_model, const irep_idt &identifier, message_handlert &message_handler)
Remove the body of function "identifier" such that an analysis will treat it as a side-effect free fu...
void remove_functions(goto_modelt &goto_model, const std::list< std::string > &names, message_handlert &message_handler)
Remove the body of all functions listed in "names" such that an analysis will treat it as a side-effe...
Remove function definition.
const code_typet & to_code_type(const typet &type)
Cast a typet to a code_typet.
Definition: std_types.h:788