Skip to content

Commit 7f4a79e

Browse files
author
Owen Jones
committed
Tidy up C symbol factory code
Correct a comment, replace "symbolt const" with "const symbolt", use const pointers in for loops, add the location to the declaration of the main symbol and wrap function header comments better
1 parent a71dfb5 commit 7f4a79e

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/ansi-c/c_nondet_symbol_factory.cpp

+8-6
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ static exprt c_get_nondet_bool(const typet &type)
6161

6262
class symbol_factoryt
6363
{
64-
std::vector<symbolt const *> &symbols_created;
64+
std::vector<const symbolt *> &symbols_created;
6565
symbol_tablet &symbol_table;
6666
const source_locationt &loc;
6767
const bool assume_non_null;
6868
namespacet ns;
6969

7070
public:
7171
symbol_factoryt(
72-
std::vector<symbolt const *> &_symbols_created,
72+
std::vector<const symbolt *> &_symbols_created,
7373
symbol_tablet &_symbol_table,
7474
const source_locationt &loc,
7575
const bool _assume_non_null):
@@ -171,7 +171,7 @@ void symbol_factoryt::gen_nondet_init(
171171
else
172172
{
173173
// Add the following code to assignments:
174-
// IF !(NONDET(_Bool) == FALSE) THEN GOTO <label1>
174+
// IF !NONDET(_Bool) THEN GOTO <label1>
175175
// <expr> = <null pointer>
176176
// GOTO <label2>
177177
// <label1>: <expr> = &tmp$<temporary_counter>;
@@ -233,13 +233,15 @@ exprt c_nondet_symbol_factory(
233233
main_symbol.name=identifier;
234234
main_symbol.base_name=base_name;
235235
main_symbol.type=type;
236+
main_symbol.location=loc;
237+
238+
symbol_exprt main_symbol_expr=main_symbol.symbol_expr();
236239

237240
symbolt *main_symbol_ptr;
238241
bool moving_symbol_failed=symbol_table.move(main_symbol, main_symbol_ptr);
239242
assert(!moving_symbol_failed);
240243

241-
std::vector<symbolt const *> symbols_created;
242-
symbol_exprt main_symbol_expr=(*main_symbol_ptr).symbol_expr();
244+
std::vector<const symbolt *> symbols_created;
243245
symbols_created.push_back(main_symbol_ptr);
244246

245247
symbol_factoryt state(
@@ -252,7 +254,7 @@ exprt c_nondet_symbol_factory(
252254

253255
// Add the following code to init_code for each symbol that's been created:
254256
// <type> <identifier>;
255-
for(symbolt const *symbol_ptr : symbols_created)
257+
for(const symbolt * const symbol_ptr : symbols_created)
256258
{
257259
code_declt decl(symbol_ptr->symbol_expr());
258260
decl.add_source_location()=loc;

0 commit comments

Comments
 (0)