Skip to content

Commit 565542d

Browse files
authored
Merge pull request #4925 from danpoe/feature/get-fresh-symbol-in-namespace
Create auxiliary symbols with a different name than symbols in namespace [blocks: #4885]
2 parents 1edf4d9 + 1e96324 commit 565542d

File tree

2 files changed

+43
-2
lines changed

2 files changed

+43
-2
lines changed

src/util/fresh_symbol.cpp

+33-2
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,16 @@ Author: Chris Smowton, [email protected]
1717
#include "symbol.h"
1818
#include "symbol_table_base.h"
1919

20-
/// Installs a fresh-named symbol with the requested name pattern.
20+
/// Installs a fresh-named symbol with respect to the given namespace `ns` with
21+
/// the requested name pattern in the given symbol table
2122
/// \param type: The type of the new symbol.
2223
/// \param name_prefix: The new symbol will be named
2324
/// `name_prefix::basename_prefix$num` unless name_prefix is empty, in which
2425
/// case the :: prefix is omitted.
2526
/// \param basename_prefix: See `name_prefix`.
2627
/// \param source_location: The source location for the new symbol.
2728
/// \param symbol_mode: The mode for the new symbol, e.g. ID_C, ID_java.
29+
/// \param ns: the new symbol has a different name than any symbols in `ns`
2830
/// \param symbol_table: The symbol table to add the new symbol to.
2931
/// \return The new symbol.
3032
symbolt &get_fresh_aux_symbol(
@@ -33,9 +35,9 @@ symbolt &get_fresh_aux_symbol(
3335
const std::string &basename_prefix,
3436
const source_locationt &source_location,
3537
const irep_idt &symbol_mode,
38+
const namespacet &ns,
3639
symbol_table_baset &symbol_table)
3740
{
38-
namespacet ns(symbol_table);
3941
irep_idt identifier = basename_prefix;
4042
std::size_t prefix_size = 0;
4143
if(!name_prefix.empty())
@@ -55,3 +57,32 @@ symbolt &get_fresh_aux_symbol(
5557

5658
return res.first;
5759
}
60+
61+
/// Installs a fresh-named symbol with the requested name pattern in the given
62+
/// symbol table
63+
/// \param type: The type of the new symbol.
64+
/// \param name_prefix: The new symbol will be named
65+
/// `name_prefix::basename_prefix$num` unless name_prefix is empty, in which
66+
/// case the :: prefix is omitted.
67+
/// \param basename_prefix: See `name_prefix`.
68+
/// \param source_location: The source location for the new symbol.
69+
/// \param symbol_mode: The mode for the new symbol, e.g. ID_C, ID_java.
70+
/// \param symbol_table: The symbol table to add the new symbol to.
71+
/// \return The new symbol.
72+
symbolt &get_fresh_aux_symbol(
73+
const typet &type,
74+
const std::string &name_prefix,
75+
const std::string &basename_prefix,
76+
const source_locationt &source_location,
77+
const irep_idt &symbol_mode,
78+
symbol_table_baset &symbol_table)
79+
{
80+
return get_fresh_aux_symbol(
81+
type,
82+
name_prefix,
83+
basename_prefix,
84+
source_location,
85+
symbol_mode,
86+
namespacet(symbol_table),
87+
symbol_table);
88+
}

src/util/fresh_symbol.h

+10
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Author: Chris Smowton, [email protected]
1616

1717
#include "irep.h"
1818

19+
class namespacet;
1920
class source_locationt;
2021
class symbolt;
2122
class symbol_table_baset;
@@ -29,4 +30,13 @@ symbolt &get_fresh_aux_symbol(
2930
const irep_idt &symbol_mode,
3031
symbol_table_baset &symbol_table);
3132

33+
symbolt &get_fresh_aux_symbol(
34+
const typet &type,
35+
const std::string &name_prefix,
36+
const std::string &basename_prefix,
37+
const source_locationt &source_location,
38+
const irep_idt &symbol_mode,
39+
const namespacet &ns,
40+
symbol_table_baset &symbol_table);
41+
3242
#endif // CPROVER_UTIL_FRESH_SYMBOL_H

0 commit comments

Comments
 (0)