CBMC
rename.cpp
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module:
4 
5 Author: Daniel Kroening, kroening@kroening.com
6 
7 \*******************************************************************/
8 
9 #include "rename.h"
10 
11 #include <string>
12 
13 #include "namespace.h"
14 
16 get_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 }
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:94
bool lookup(const irep_idt &name, const symbolt *&symbol) const override
See documentation for namespace_baset::lookup().
Definition: namespace.cpp:148
std::size_t smallest_unused_suffix(const std::string &prefix) const override
See documentation for namespace_baset::smallest_unused_suffix().
Definition: namespace.cpp:130
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
std::string to_string(const string_not_contains_constraintt &expr)
Used for debug printing.