52 std::map<irep_idt, irep_idt> renamed_funs;
53 std::vector<symbolt> new_syms;
54 std::vector<symbol_tablet::symbolst::const_iterator> old_syms;
56 for(
auto sym_it =
model.symbol_table.symbols.begin();
57 sym_it !=
model.symbol_table.symbols.end();
60 const symbolt &sym = sym_it->second;
62 if(sym.
type.
id() != ID_code)
71 new_sym.
name = mangled;
77 new_syms.push_back(new_sym);
78 old_syms.push_back(sym_it);
81 renamed_funs.insert(std::make_pair(sym.
name, mangled));
83 log.debug() <<
"Mangling: " << sym.
name <<
" -> " << mangled <<
log.eom;
86 for(
const auto &sym : new_syms)
87 model.symbol_table.insert(sym);
88 for(
const auto &sym : old_syms)
89 model.symbol_table.erase(sym);
91 for(
auto it =
model.symbol_table.begin(); it !=
model.symbol_table.end();
94 const symbolt &sym = it->second;
98 if(rename(e) && rename(t))
101 symbolt &new_sym = it.get_writeable_symbol();
106 for(
auto &fun :
model.goto_functions.function_map)
108 if(!fun.second.body_available())
110 for(
auto &ins : fun.second.body.instructions)
112 rename(ins.code_nonconst());
113 if(ins.has_condition())
114 rename(ins.condition_nonconst());
119 for(
const auto &pair : renamed_funs)
121 auto found =
model.goto_functions.function_map.find(pair.first);
123 found !=
model.goto_functions.function_map.end(),
124 "There should exist an entry in the function_map for the original name "
125 "of the function that we renamed '" +
126 std::string(pair.first.c_str()) +
"'");
128 auto inserted =
model.goto_functions.function_map.emplace(
129 pair.second, std::move(found->second));
131 log.debug() <<
"Found a mangled name that already exists: "
132 << std::string(pair.second.c_str()) <<
log.eom;
134 model.goto_functions.function_map.erase(found);