Skip to content

Use get_fresh_aux_symbol #3917

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions src/goto-instrument/wmm/shared_buffers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Author: Daniel Kroening, [email protected]
#include "shared_buffers.h"

#include <util/c_types.h>
#include <util/fresh_symbol.h>

#include <linking/static_lifetime_init.h>

Expand Down Expand Up @@ -88,21 +89,22 @@ irep_idt shared_bufferst::add(
const typet &type,
bool instrument)
{
const irep_idt identifier=id2string(object)+suffix;
const namespacet ns(symbol_table);

symbolt new_symbol;
new_symbol.name=identifier;
new_symbol.base_name=id2string(base_name)+suffix;
new_symbol.type=type;
symbolt &new_symbol = get_fresh_aux_symbol(
type,
id2string(object) + suffix,
id2string(base_name) + suffix,
ns.lookup(object).location,
ns.lookup(object).mode,
symbol_table);
new_symbol.is_static_lifetime=true;
new_symbol.value.make_nil();

if(instrument)
instrumentations.insert(identifier);
instrumentations.insert(new_symbol.name);

symbolt *symbol_ptr;
symbol_table.move(new_symbol, symbol_ptr);
return identifier;
return new_symbol.name;
}

void shared_bufferst::add_initialization(goto_programt &goto_program)
Expand Down
18 changes: 9 additions & 9 deletions src/goto-instrument/wmm/weak_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ Date: September 2011

#include <set>

#include <util/fresh_symbol.h>

#include <goto-programs/remove_skip.h>

#include <linking/static_lifetime_init.h>
Expand All @@ -44,7 +46,6 @@ void introduce_temporaries(
messaget &message)
{
namespacet ns(symbol_table);
unsigned tmp_counter=0;

#ifdef LOCAL_MAY
local_may_aliast local_may(goto_function);
Expand Down Expand Up @@ -73,20 +74,19 @@ void introduce_temporaries(
if(rw_set.empty())
continue;

symbolt new_symbol;
new_symbol.base_name="$tmp_guard";
new_symbol.name =
id2string(function_id) + "$tmp_guard" + std::to_string(tmp_counter++);
new_symbol.type=bool_typet();
symbolt &new_symbol = get_fresh_aux_symbol(
bool_typet(),
id2string(function_id),
"$tmp_guard",
instruction.source_location,
ns.lookup(function_id).mode,
symbol_table);
new_symbol.is_static_lifetime=true;
new_symbol.is_thread_local=true;
new_symbol.value.make_nil();

symbol_exprt symbol_expr=new_symbol.symbol_expr();

symbolt *symbol_ptr;
symbol_table.move(new_symbol, symbol_ptr);

goto_programt::instructiont new_i;
new_i.make_assignment();
new_i.code=code_assignt(symbol_expr, instruction.guard);
Expand Down