Go to the documentation of this file.
27 std::vector<const symbolt *> working_set;
29 working_set.push_back(&in_symbol);
31 while(!working_set.empty())
33 const symbolt *current_symbol_ptr = working_set.back();
34 working_set.pop_back();
35 const symbolt &symbol = *current_symbol_ptr;
37 if(!dest.insert(symbol.
name).second)
45 for(
const auto &s : new_symbols)
46 working_set.push_back(&ns.
lookup(s));
48 if(symbol.
type.
id() == ID_code)
53 for(
const auto &p : parameters)
57 if(!ns.
lookup(p.get_identifier(), s))
58 working_set.push_back(s);
63 static_cast<const exprt &
>(code_type.
find(ID_C_spec_ensures));
64 const exprt requires =
65 static_cast<const exprt &
>(code_type.
find(ID_C_spec_requires));
71 for(
const auto &s : new_symbols)
75 const symbolt *new_symbol =
nullptr;
76 if(!ns.
lookup(s, new_symbol))
78 if(new_symbol->
type.
id() == ID_code)
80 working_set.push_back(new_symbol);
104 const bool keep_file_local)
112 special.insert(
"argc'");
113 special.insert(
"argv'");
114 special.insert(
"envp'");
115 special.insert(
"envp_size'");
122 special.insert(
"__new");
123 special.insert(
"__new_array");
124 special.insert(
"__placement_new");
125 special.insert(
"__placement_new_array");
126 special.insert(
"__delete");
127 special.insert(
"__delete_array");
129 for(symbol_tablet::symbolst::const_iterator
130 it=symbol_table.
symbols.begin();
131 it!=symbol_table.
symbols.end();
135 if(exported.find(it->first)!=exported.end())
139 const symbolt &symbol=it->second;
141 if(special.find(symbol.
name)!=special.end())
147 bool is_function=symbol.
type.
id()==ID_code;
154 if(symbol.
mode==ID_C && is_function && is_file_local)
176 else if(has_body && is_file_local && keep_file_local)
185 if((has_initializer || !symbol.
is_extern) &&
194 for(symbol_tablet::symbolst::const_iterator
195 it=symbol_table.
symbols.begin();
196 it!=symbol_table.
symbols.end();
199 if(exported.find(it->first)==exported.end())
201 symbol_tablet::symbolst::const_iterator next=std::next(it);
202 symbol_table.
erase(it);
Class that provides messages with a built-in verbosity 'level'.
void find_type_and_expr_symbols(const exprt &src, find_symbols_sett &dest)
std::vector< parametert > parameterst
typet type
Type of symbol.
const irept & find(const irep_namet &name) const
optionalt< std::string > main
Base class for all expressions.
irep_idt base_name
Base (non-scoped) name.
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.
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 code_typet & to_code_type(const typet &type)
Cast a typet to a code_typet.
irep_idt mode
Language mode.
#define INITIALIZE_FUNCTION
const irep_idt & id() const
static void get_symbols(const namespacet &ns, const symbolt &in_symbol, find_symbols_sett &dest)
const parameterst & parameters() const
exprt value
Initial value of symbol.
std::unordered_set< irep_idt > find_symbols_sett
const symbolst & symbols
Read-only field, used to look up symbols given their names.
Remove symbols that are internal only.
const typet & return_type() const
virtual void erase(const symbolst::const_iterator &entry) override
Remove a symbol from the symbol table.
irep_idt name
The unique identifier.