|
| 1 | +/*******************************************************************\ |
| 2 | +
|
| 3 | +Module: Remove function definition |
| 4 | +
|
| 5 | +Author: Michael Tautschnig |
| 6 | +
|
| 7 | +Date: April 2017 |
| 8 | +
|
| 9 | +\*******************************************************************/ |
| 10 | + |
| 11 | +#include <util/message.h> |
| 12 | + |
| 13 | +#include <goto-programs/goto_functions.h> |
| 14 | + |
| 15 | +#include "remove_function.h" |
| 16 | + |
| 17 | +/*******************************************************************\ |
| 18 | +
|
| 19 | +Function: remove_function |
| 20 | +
|
| 21 | + Inputs: |
| 22 | +
|
| 23 | + Outputs: |
| 24 | +
|
| 25 | + Purpose: |
| 26 | +
|
| 27 | +\*******************************************************************/ |
| 28 | + |
| 29 | +void remove_function( |
| 30 | + symbol_tablet &symbol_table, |
| 31 | + goto_functionst &goto_functions, |
| 32 | + const irep_idt &identifier, |
| 33 | + message_handlert &message_handler) |
| 34 | +{ |
| 35 | + messaget message(message_handler); |
| 36 | + |
| 37 | + goto_functionst::function_mapt::iterator entry= |
| 38 | + goto_functions.function_map.find(identifier); |
| 39 | + |
| 40 | + if(entry==goto_functions.function_map.end()) |
| 41 | + { |
| 42 | + message.error() << "No function " << identifier |
| 43 | + << " in goto program" << messaget::eom; |
| 44 | + return; |
| 45 | + } |
| 46 | + else if(entry->second.is_inlined()) |
| 47 | + { |
| 48 | + message.warning() << "Function " << identifier << " is inlined, " |
| 49 | + << "instantiations will not be removed" |
| 50 | + << messaget::eom; |
| 51 | + } |
| 52 | + |
| 53 | + if(entry->second.body_available()) |
| 54 | + { |
| 55 | + message.status() << "Removing body of " << identifier |
| 56 | + << messaget::eom; |
| 57 | + entry->second.clear(); |
| 58 | + symbol_table.lookup(identifier).value.make_nil(); |
| 59 | + } |
| 60 | +} |
| 61 | + |
| 62 | +/*******************************************************************\ |
| 63 | +
|
| 64 | +Function: remove_functions |
| 65 | +
|
| 66 | + Inputs: |
| 67 | +
|
| 68 | + Outputs: |
| 69 | +
|
| 70 | + Purpose: |
| 71 | +
|
| 72 | +\*******************************************************************/ |
| 73 | + |
| 74 | +void remove_functions( |
| 75 | + symbol_tablet &symbol_table, |
| 76 | + goto_functionst &goto_functions, |
| 77 | + const std::list<std::string> &names, |
| 78 | + message_handlert &message_handler) |
| 79 | +{ |
| 80 | + for(const auto &f : names) |
| 81 | + remove_function(symbol_table, goto_functions, f, message_handler); |
| 82 | +} |
0 commit comments