Skip to content

Commit fd4f563

Browse files
Add side_effect_exprt constructor with location
Location should be specified in side_effect_exprt, having it as an argument of the constructor ensure we don't forget about it.
1 parent 98657d8 commit fd4f563

File tree

2 files changed

+65
-8
lines changed

2 files changed

+65
-8
lines changed

src/util/std_code.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,34 @@ code_blockt create_fatal_assertion(
118118
result.add_source_location() = loc;
119119
return result;
120120
}
121+
122+
side_effect_exprt::side_effect_exprt(
123+
const irep_idt &statement,
124+
const typet &_type,
125+
const source_locationt &loc)
126+
: exprt(ID_side_effect, _type)
127+
{
128+
set_statement(statement);
129+
add_source_location() = loc;
130+
}
131+
132+
side_effect_expr_nondett::side_effect_expr_nondett(
133+
const typet &_type,
134+
const source_locationt &loc)
135+
: side_effect_exprt(ID_nondet, _type, loc)
136+
{
137+
set_nullable(true);
138+
}
139+
140+
side_effect_expr_function_callt::side_effect_expr_function_callt(
141+
const exprt &_function,
142+
const exprt::operandst &_arguments,
143+
const typet &_type,
144+
const source_locationt &loc)
145+
: side_effect_exprt(ID_function_call, _type, loc)
146+
{
147+
operands().resize(2);
148+
op1().id(ID_arguments);
149+
function() = _function;
150+
arguments() = _arguments;
151+
}

src/util/std_code.h

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,19 +1271,24 @@ inline const code_expressiont &to_code_expression(const codet &code)
12711271
class side_effect_exprt:public exprt
12721272
{
12731273
public:
1274-
DEPRECATED("Use side_effect_exprt(statement, type) instead")
1275-
explicit side_effect_exprt(const irep_idt &statement):
1276-
exprt(ID_side_effect)
1274+
DEPRECATED("Use side_effect_exprt(statement, type, loc) instead")
1275+
explicit side_effect_exprt(const irep_idt &statement) : exprt(ID_side_effect)
12771276
{
12781277
set_statement(statement);
12791278
}
12801279

1280+
DEPRECATED("Use side_effect_exprt(statement, type, loc) instead")
12811281
side_effect_exprt(const irep_idt &statement, const typet &_type):
12821282
exprt(ID_side_effect, _type)
12831283
{
12841284
set_statement(statement);
12851285
}
12861286

1287+
side_effect_exprt(
1288+
const irep_idt &statement,
1289+
const typet &_type,
1290+
const source_locationt &loc);
1291+
12871292
const irep_idt &get_statement() const
12881293
{
12891294
return get(ID_statement);
@@ -1335,18 +1340,21 @@ inline const side_effect_exprt &to_side_effect_expr(const exprt &expr)
13351340
class side_effect_expr_nondett:public side_effect_exprt
13361341
{
13371342
public:
1338-
DEPRECATED("Use side_effect_expr_nondett(statement, type) instead")
1343+
DEPRECATED("Use side_effect_expr_nondett(statement, type, loc) instead")
13391344
side_effect_expr_nondett():side_effect_exprt(ID_nondet)
13401345
{
13411346
set_nullable(true);
13421347
}
13431348

1349+
DEPRECATED("Use side_effect_expr_nondett(statement, type, loc) instead")
13441350
explicit side_effect_expr_nondett(const typet &_type):
13451351
side_effect_exprt(ID_nondet, _type)
13461352
{
13471353
set_nullable(true);
13481354
}
13491355

1356+
side_effect_expr_nondett(const typet &_type, const source_locationt &loc);
1357+
13501358
void set_nullable(bool nullable)
13511359
{
13521360
set(ID_is_nondet_nullable, nullable);
@@ -1387,13 +1395,19 @@ inline const side_effect_expr_nondett &to_side_effect_expr_nondet(
13871395
class side_effect_expr_function_callt:public side_effect_exprt
13881396
{
13891397
public:
1390-
DEPRECATED("Use side_effect_expr_function_callt(...) instead")
1391-
side_effect_expr_function_callt():side_effect_exprt(ID_function_call)
1398+
DEPRECATED(
1399+
"Use side_effect_expr_function_callt("
1400+
"function, arguments, type, loc) instead")
1401+
side_effect_expr_function_callt()
1402+
: side_effect_exprt(ID_function_call, typet(), source_locationt())
13921403
{
13931404
operands().resize(2);
13941405
op1().id(ID_arguments);
13951406
}
13961407

1408+
DEPRECATED(
1409+
"Use side_effect_expr_function_callt("
1410+
"function, arguments, type, loc) instead")
13971411
side_effect_expr_function_callt(
13981412
const exprt &_function,
13991413
const exprt::operandst &_arguments)
@@ -1405,6 +1419,9 @@ class side_effect_expr_function_callt:public side_effect_exprt
14051419
arguments() = _arguments;
14061420
}
14071421

1422+
DEPRECATED(
1423+
"Use side_effect_expr_function_callt("
1424+
"function, arguments, type, loc) instead")
14081425
side_effect_expr_function_callt(
14091426
const exprt &_function,
14101427
const exprt::operandst &_arguments,
@@ -1417,6 +1434,12 @@ class side_effect_expr_function_callt:public side_effect_exprt
14171434
arguments() = _arguments;
14181435
}
14191436

1437+
side_effect_expr_function_callt(
1438+
const exprt &_function,
1439+
const exprt::operandst &_arguments,
1440+
const typet &_type,
1441+
const source_locationt &loc);
1442+
14201443
exprt &function()
14211444
{
14221445
return op0();
@@ -1473,8 +1496,11 @@ class side_effect_expr_throwt:public side_effect_exprt
14731496
{
14741497
}
14751498

1476-
explicit side_effect_expr_throwt(const irept &exception_list):
1477-
side_effect_exprt(ID_throw)
1499+
explicit side_effect_expr_throwt(
1500+
const irept &exception_list,
1501+
const typet &type,
1502+
const source_locationt &loc)
1503+
: side_effect_exprt(ID_throw, type, loc)
14781504
{
14791505
set(ID_exception_list, exception_list);
14801506
}

0 commit comments

Comments
 (0)