19 // Add the symbol to the table or retrieve existing symbol with the same name
20 std::pair<symbolst::iterator, bool> result=
22 symbolt &new_symbol=result.first->second;
29 if(!new_symbol.module.empty())
34 new_symbol.module, new_symbol.
name);
49 return std::make_pair(std::ref(new_symbol), result.second);
69 // Add an empty symbol to the table or retrieve existing symbol with same name
71 // This is not copying the symbol, this is passing the three required
72 // parameters to insert (just in the symbol)
79 // Move the provided symbol into the symbol table, this can't be done
81 result.first.swap(symbol);
83 // Return the address of the symbol in the table
84 new_symbol=&result.first;
85 return !result.second;
92 const symbolt &symbol=entry->second;
100 "symbolt::base_name should not be changed "
101 "after it is added to the symbol_table "
106 if(!symbol.module.empty())
114 "symbolt::module should not be changed "
115 "after it is added to the symbol_table "
132 // Check that identifiers are mapped to the correct symbol
136 const auto &symbol =
elem.second;
138 // First of all, ensure symbol well-formedness
140 vm, symbol.is_well_formed(),
"Symbol is malformed: ",
symbol_key);
142 // Check that symbols[id].name == id
146 "Symbol table entry must map to a symbol with the correct identifier",
147 "Symbol table key '",
149 "' maps to symbol '",
153 // Check that the symbol basename is mapped to its full name
154 if(!symbol.base_name.empty())
162 [&
symbol_key](
const symbol_base_mapt::value_type &match) {
163 return match.second == symbol_key;
169 "The base_name of a symbol should map to itself",
170 "Symbol table key '",
172 "' has a base_name '",
174 "' which does not map to itself");
177 // Check that the module name of the symbol is mapped to the full name
178 if(!symbol.module.empty())
185 [&
symbol_key](
const symbol_module_mapt::value_type &match) {
186 return match.second == symbol_key;
192 "Symbol table module map should map to symbol",
193 "Symbol table key '",
195 "' has a module name of '",
197 "' which does not map to itself");
201 // Check that all base name map entries point to a symbol entry
207 "Symbol table base_name map entries must map to a symbol name",
208 "base_name map entry '",
210 "' maps to non-existant symbol name '",
215 // Check that all module map entries point to a symbol entry
221 "Symbol table module map entries must map to a symbol name",
222 "base_name map entry '",
224 "' maps to non-existant symbol name '",
232 // we cannot use == for comparing the multimaps as it compares the items
233 // sequentially, but the order of items with equal keys depends on the
237 std::vector<std::pair<irep_idt, irep_idt>>
v1(
240 std::vector<std::pair<irep_idt, irep_idt>>
v2(
244 std::sort(
v1.begin(),
v1.end());
245 std::sort(
v2.begin(),
v2.end());
252 std::vector<std::pair<irep_idt, irep_idt>>
v1(
255 std::vector<std::pair<irep_idt, irep_idt>>
v2(
259 std::sort(
v1.begin(),
v1.end());
260 std::sort(
v2.begin(),
v2.end());
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
const symbol_base_mapt & symbol_base_map
Read-only field, used to look up symbol names given their base names.
const symbol_module_mapt & symbol_module_map
Read-only field, used to look up symbol names given their modules.
const symbolst & symbols
Read-only field, used to look up symbols given their names.
bool has_symbol(const irep_idt &name) const
Check whether a symbol exists in the symbol table.
bool operator==(const symbol_tablet &other) const
symbolst internal_symbols
Value referenced by symbol_table_baset::symbols.
virtual void erase(const symbolst::const_iterator &entry) override
Remove a symbol from the symbol table.
symbol_module_mapt internal_symbol_module_map
Value referenced by symbol_table_baset::symbol_module_map.
virtual bool move(symbolt &symbol, symbolt *&new_symbol) override
Move a symbol into the symbol table.
symbol_base_mapt internal_symbol_base_map
Value referenced by symbol_table_baset::symbol_base_map.
virtual std::pair< symbolt &, bool > insert(symbolt symbol) override
Author: Diffblue Ltd.
void validate(const validation_modet vm=validation_modet::INVARIANT) const override
Check that the symbol table is well-formed.
irep_idt name
The unique identifier.
irep_idt irep_idt base_name
Name of module the symbol belongs to.
const std::string & id2string(const irep_idt &d)
#define INVARIANT(CONDITION, REASON)
This macro uses the wrapper function 'invariant_violated_string'.
#define DATA_CHECK_WITH_DIAGNOSTICS(vm, condition, message,...)