Go to the documentation of this file.
5 #ifndef CPROVER_GOTO_PROGRAMS_NAME_MANGLER_H
6 #define CPROVER_GOTO_PROGRAMS_NAME_MANGLER_H
27 template <
class MangleFun>
50 std::map<irep_idt, irep_idt> renamed_funs;
51 std::vector<symbolt> new_syms;
52 std::vector<symbol_tablet::symbolst::const_iterator> old_syms;
58 const symbolt &sym = sym_it->second;
60 if(sym.
type.
id() != ID_code)
70 new_sym.
name = mangled;
73 new_syms.push_back(new_sym);
74 old_syms.push_back(sym_it);
77 renamed_funs.insert(std::make_pair(sym.
name, mangled));
82 for(
const auto &sym : new_syms)
84 for(
const auto &sym : old_syms)
89 const symbolt &sym = sym_pair.second;
93 if(rename(e) && rename(t))
103 if(!fun.second.body_available())
105 for(
auto &ins : fun.second.body.instructions)
113 for(
const auto &pair : renamed_funs)
118 "There should exist an entry in the function_map for the original name "
119 "of the function that we renamed '" +
120 std::string(pair.first.c_str()) +
"'");
123 pair.second, std::move(found->second));
126 "The mangled name '" + std::string(pair.second.c_str()) +
127 "' should not already exist in the codebase");
145 :
forbidden(
"[^\\w]", std::regex::ECMAScript),
169 #endif // CPROVER_GOTO_PROGRAMS_NAME_MANGLER_H
Class that provides messages with a built-in verbosity 'level'.
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
const std::regex forbidden
const std::regex multi_under
irep_idt operator()(const symbolt &, const std::string &)
The type of an expression, extends irept.
typet type
Type of symbol.
irep_idt operator()(const symbolt &, const std::string &)
Base class for all expressions.
void mangle()
Mangle all file-local function symbols in the program.
function_mapt function_map
Mangles the names in an entire program and its symbol table.
Mangle identifiers by hashing their working directory with djb2 hash.
Mangle identifiers by including their filename.
symbolt & get_writeable_ref(const irep_idt &name)
Find a symbol in the symbol table for read-write access.
void insert(const class symbol_exprt &old_expr, const class symbol_exprt &new_expr)
const std::string & extra_info
class symbol_exprt symbol_expr() const
Produces a symbol_exprt for a symbol.
virtual std::pair< symbolt &, bool > insert(symbolt symbol) override
Author: Diffblue Ltd.
const irep_idt & id() const
function_name_manglert(message_handlert &mh, goto_modelt &gm, const std::string &extra_info)
exprt value
Initial value of symbol.
goto_functionst goto_functions
GOTO functions.
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.
symbol_tablet symbol_table
Symbol table.
irep_idt name
The unique identifier.