Skip to content

Commit 0015602

Browse files
committed
Prepare DECL/DEAD construction with location
Add new constructors to code_{decl,dead}t that also take a location. This will help avoid some *_nonconst() calls. To facilitate this, an additional make_dead instruction builder is also needed (which just mirrors what we already have for other instruction types).
1 parent ce2680b commit 0015602

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

src/goto-programs/goto_instruction_code.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,11 @@ class code_deadt : public codet
129129
{
130130
}
131131

132+
code_deadt(symbol_exprt symbol, source_locationt loc)
133+
: codet(ID_dead, {std::move(symbol)}, std::move(loc))
134+
{
135+
}
136+
132137
symbol_exprt &symbol()
133138
{
134139
return static_cast<symbol_exprt &>(op0());
@@ -201,6 +206,11 @@ class code_declt : public codet
201206
{
202207
}
203208

209+
code_declt(symbol_exprt symbol, source_locationt loc)
210+
: codet(ID_decl, {std::move(symbol)}, std::move(loc))
211+
{
212+
}
213+
204214
symbol_exprt &symbol()
205215
{
206216
return static_cast<symbol_exprt &>(op0());

src/goto-programs/goto_program.h

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -929,13 +929,27 @@ class goto_programt
929929
return instructiont(_code, l, OTHER, nil_exprt(), {});
930930
}
931931

932+
static instructiont make_decl(
933+
const code_declt &_code,
934+
const source_locationt &l = source_locationt::nil())
935+
{
936+
return instructiont(_code, l, DECL, nil_exprt(), {});
937+
}
938+
932939
static instructiont make_decl(
933940
const symbol_exprt &symbol,
934941
const source_locationt &l = source_locationt::nil())
935942
{
936943
return instructiont(code_declt(symbol), l, DECL, nil_exprt(), {});
937944
}
938945

946+
static instructiont make_dead(
947+
const code_deadt &_code,
948+
const source_locationt &l = source_locationt::nil())
949+
{
950+
return instructiont(_code, l, DEAD, nil_exprt(), {});
951+
}
952+
939953
static instructiont make_dead(
940954
const symbol_exprt &symbol,
941955
const source_locationt &l = source_locationt::nil())
@@ -1047,13 +1061,6 @@ class goto_programt
10471061
code_assignt(std::move(lhs), std::move(rhs)), l, ASSIGN, nil_exprt(), {});
10481062
}
10491063

1050-
static instructiont make_decl(
1051-
const code_declt &_code,
1052-
const source_locationt &l = source_locationt::nil())
1053-
{
1054-
return instructiont(_code, l, DECL, nil_exprt(), {});
1055-
}
1056-
10571064
/// Create a function call instruction
10581065
static instructiont make_function_call(
10591066
const code_function_callt &_code,

0 commit comments

Comments
 (0)