Go to the documentation of this file.
5 #ifndef CPROVER_GOTO_PROGRAMS_NAME_MANGLER_H
6 #define CPROVER_GOTO_PROGRAMS_NAME_MANGLER_H
16 #define FILE_LOCAL_PREFIX CPROVER_PREFIX "file_local_"
29 template <
class MangleFun>
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;
60 const symbolt &sym = sym_it->second;
62 if(sym.
type.
id() != ID_code)
72 new_sym.
name = mangled;
75 new_syms.push_back(new_sym);
76 old_syms.push_back(sym_it);
79 renamed_funs.insert(std::make_pair(sym.
name, mangled));
84 for(
const auto &sym : new_syms)
86 for(
const auto &sym : old_syms)
91 const symbolt &sym = sym_pair.second;
95 if(rename(e) && rename(t))
105 if(!fun.second.body_available())
107 for(
auto &ins : fun.second.body.instructions)
109 rename(ins.code_nonconst());
110 if(ins.has_condition())
111 rename(ins.condition_nonconst());
116 for(
const auto &pair : renamed_funs)
121 "There should exist an entry in the function_map for the original name "
122 "of the function that we renamed '" +
123 std::string(pair.first.c_str()) +
"'");
126 pair.second, std::move(found->second));
128 log.
debug() <<
"Found a mangled name that already exists: "
129 << std::string(pair.second.c_str()) <<
log.
eom;
147 :
forbidden(
"[^\\w]", std::regex::ECMAScript),
171 #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.