30 std::vector<const symbolt *> working_set;
32 working_set.push_back(&in_symbol);
34 while(!working_set.empty())
36 const symbolt *current_symbol_ptr = working_set.back();
37 working_set.pop_back();
38 const symbolt &symbol = *current_symbol_ptr;
40 if(!dest.insert(symbol.
name).second)
48 for(
const auto &s : new_symbols)
49 working_set.push_back(&ns.
lookup(s));
51 if(symbol.
type.
id() == ID_code)
56 for(
const auto &p : parameters)
60 if(!ns.
lookup(p.get_identifier(), s))
61 working_set.push_back(s);
66 static_cast<const exprt &
>(code_type.
find(ID_C_spec_ensures));
67 const exprt requires =
68 static_cast<const exprt &
>(code_type.
find(ID_C_spec_requires));
74 for(
const auto &s : new_symbols)
78 const symbolt *new_symbol =
nullptr;
79 if(!ns.
lookup(s, new_symbol))
81 if(new_symbol->
type.
id() == ID_code)
83 working_set.push_back(new_symbol);
107 const bool keep_file_local)
115 special.insert(
"argc'");
116 special.insert(
"argv'");
117 special.insert(
"envp'");
118 special.insert(
"envp_size'");
125 special.insert(
"__new");
126 special.insert(
"__new_array");
127 special.insert(
"__placement_new");
128 special.insert(
"__placement_new_array");
129 special.insert(
"__delete");
130 special.insert(
"__delete_array");
132 for(symbol_tablet::symbolst::const_iterator
133 it=symbol_table.
symbols.begin();
134 it!=symbol_table.
symbols.end();
138 if(exported.find(it->first)!=exported.end())
142 const symbolt &symbol=it->second;
144 if(special.find(symbol.
name)!=special.end())
150 bool is_function=symbol.
type.
id()==ID_code;
157 if(symbol.
mode==ID_C && is_function && is_file_local)
179 else if(has_body && is_file_local && keep_file_local)
188 if((has_initializer || !symbol.
is_extern) &&
197 for(symbol_tablet::symbolst::const_iterator
198 it=symbol_table.
symbols.begin();
199 it!=symbol_table.
symbols.end();
202 if(exported.find(it->first)==exported.end())
204 symbol_tablet::symbolst::const_iterator next=std::next(it);
205 symbol_table.
erase(it);
irep_idt rounding_mode_identifier()
Return the identifier of the program symbol used to store the current rounding mode.
std::vector< parametert > parameterst
const typet & return_type() const
const parameterst & parameters() const
optionalt< std::string > main
Base class for all expressions.
const irept & find(const irep_namet &name) const
const irep_idt & id() const
Class that provides messages with a built-in verbosity 'level'.
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
bool lookup(const irep_idt &name, const symbolt *&symbol) const override
See documentation for namespace_baset::lookup().
const symbolst & symbols
Read-only field, used to look up symbols given their names.
virtual void erase(const symbolst::const_iterator &entry) override
Remove a symbol from the symbol table.
irep_idt base_name
Base (non-scoped) name.
typet type
Type of symbol.
irep_idt name
The unique identifier.
exprt value
Initial value of symbol.
irep_idt mode
Language mode.
void find_type_and_expr_symbols(const exprt &src, find_symbols_sett &dest)
std::unordered_set< irep_idt > find_symbols_sett
void remove_internal_symbols(symbol_tablet &symbol_table, message_handlert &mh, const bool keep_file_local)
Removes internal symbols from a symbol table A symbol is EXPORTED if it is a.
static void get_symbols(const namespacet &ns, const symbolt &in_symbol, find_symbols_sett &dest)
Remove symbols that are internal only.
#define INITIALIZE_FUNCTION
const code_typet & to_code_type(const typet &type)
Cast a typet to a code_typet.