CBMC
Loading...
Searching...
No Matches
remove_function.cpp
Go to the documentation of this file.
1/*******************************************************************\
2
3Module: Remove function definition
4
5Author: Michael Tautschnig
6
7Date: 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"
48 }
49
50 if(entry->second.body_available())
51 {
52 message.status() << "Removing body of " << identifier
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}
virtual void clear()
Reset the abstract state.
Definition ai.h:265
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
Definition ai.h:562
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:446
Class that provides messages with a built-in verbosity 'level'.
Definition message.h:154
mstreamt & error() const
Definition message.h:391
mstreamt & warning() const
Definition message.h:396
static eomt eom
Definition message.h:289
mstreamt & status() const
Definition message.h:406
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
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