CBMC
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
rename.cpp
Go to the documentation of this file.
1/*******************************************************************\
2
3Module:
4
5Author: Daniel Kroening, kroening@kroening.com
6
7\*******************************************************************/
8
9#include "rename.h"
10
11#include <string>
12
13#include "namespace.h"
14
16get_new_name(const irep_idt &name, const namespacet &ns, char delimiter)
17{
18 const symbolt *symbol;
19 if(ns.lookup(name, symbol))
20 return name;
21
22 std::string prefix = id2string(name) + delimiter;
23
24 return prefix + std::to_string(ns.smallest_unused_suffix(prefix));
25}
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
Definition ai.h:562
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition dstring.h:38
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition namespace.h:91
bool lookup(const irep_idt &name, const symbolt *&symbol) const override
See documentation for namespace_baset::lookup().
std::size_t smallest_unused_suffix(const std::string &prefix) const override
See documentation for namespace_baset::smallest_unused_suffix().
Symbol table entry.
Definition symbol.h:28
const std::string & id2string(const irep_idt &d)
Definition irep.h:44
irep_idt get_new_name(const irep_idt &name, const namespacet &ns, char delimiter)
Build and identifier not yet present in the namespace ns based on name.
Definition rename.cpp:16