20 std::pair<symbolst::iterator, bool> result=
22 symbolt &new_symbol=result.first->second;
27 symbol_base_mapt::iterator base_result=
49 return std::make_pair(std::ref(new_symbol), result.second);
76 std::pair<symbolt &, bool> result=
insert(std::move(temp_symbol));
81 result.first.swap(symbol);
84 new_symbol=&result.first;
85 return !result.second;
92 const symbolt &symbol=entry->second;
96 while(base_it!=base_it_end && base_it->second!=symbol.
name)
100 "symbolt::base_name should not be changed "
101 "after it is added to the symbol_table "
110 while(module_it != module_it_end && module_it->second != symbol.
name)
113 module_it != module_it_end,
114 "symbolt::module should not be changed "
115 "after it is added to the symbol_table "
133 for(
const auto &elem :
symbols)
135 const auto symbol_key = elem.first;
136 const auto &symbol = elem.second;
140 vm, symbol.is_well_formed(),
"Symbol is malformed: ", symbol_key);
145 symbol.name == symbol_key,
146 "Symbol table entry must map to a symbol with the correct identifier",
147 "Symbol table key '",
149 "' maps to symbol '",
154 if(!symbol.base_name.empty())
156 const auto base_map_search =
158 const bool base_map_matches_symbol =
160 base_map_search.first,
161 base_map_search.second,
162 [&symbol_key](
const symbol_base_mapt::value_type &match) {
163 return match.second == symbol_key;
168 base_map_matches_symbol,
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");
178 if(!symbol.module.empty())
181 bool module_map_matches_symbol =
183 module_map_search.first,
184 module_map_search.second,
185 [&symbol_key](
const symbol_module_mapt::value_type &match) {
186 return match.second == symbol_key;
191 module_map_matches_symbol,
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");
207 "Symbol table base_name map entries must map to a symbol name",
208 "base_name map entry '",
209 base_map_entry.first,
210 "' maps to non-existant symbol name '",
211 base_map_entry.second,
221 "Symbol table module map entries must map to a symbol name",
222 "base_name map entry '",
223 module_map_entry.first,
224 "' maps to non-existant symbol name '",
225 module_map_entry.second,
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());
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 base_name
Base (non-scoped) name.
irep_idt module
Name of module the symbol belongs to.
irep_idt name
The unique identifier.
const std::string & id2string(const irep_idt &d)
#define DATA_CHECK_WITH_DIAGNOSTICS(vm, condition, message,...)