cprover
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 "symbol.h"
14 #include "namespace.h"
15 
19 void get_new_name(symbolt &symbol, const namespacet &ns)
20 {
21  get_new_name(symbol.name, ns);
22 }
23 
27 void get_new_name(irep_idt &new_name, const namespacet &ns, char delimiter)
28 {
29  const symbolt *symbol;
30  if(ns.lookup(new_name, symbol))
31  return; // name not taken yet
32 
33  std::string prefix = id2string(new_name) + delimiter;
34 
35  new_name = prefix + std::to_string(ns.smallest_unused_suffix(prefix));
36 }
irep_idt name
The unique identifier.
Definition: symbol.h:43
const std::string & id2string(const irep_idt &d)
Definition: irep.h:43
Symbol table entry.
Symbol table entry.This is a symbol in the symbol table, stored in an object of type symbol_tablet...
Definition: symbol.h:30
TO_BE_DOCUMENTED.
Definition: namespace.h:74
std::size_t smallest_unused_suffix(const std::string &prefix) const override
See documentation for namespace_baset::smallest_unused_suffix().
Definition: namespace.cpp:117
std::string to_string(const string_constraintt &expr)
Used for debug printing.
void get_new_name(symbolt &symbol, const namespacet &ns)
automated variable renaming
Definition: rename.cpp:19
bool lookup(const irep_idt &name, const symbolt *&symbol) const override
See namespace_baset::lookup().
Definition: namespace.cpp:130