Skip to content

Commit 9087e47

Browse files
committed
copy_to_operands(exprt &&) -> add_to_operands
The current name means we end up writing `copy_to_operands(std::move(e))`, which looks like a mistake, since the whole point is it's a move, not a copy. Instead let's call it `add_to_operands` with overloads for copying or moving dependent on reference kind.
1 parent 5e9aba8 commit 9087e47

File tree

2 files changed

+34
-10
lines changed

2 files changed

+34
-10
lines changed

src/util/expr.h

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,13 @@ class exprt:public irept
105105
void reserve_operands(operandst::size_type n)
106106
{ operands().reserve(n) ; }
107107

108-
DEPRECATED("use copy_to_operands(expr) instead")
108+
DEPRECATED("use add_to_operands(expr) instead")
109109
void move_to_operands(exprt &expr);
110110

111-
DEPRECATED("use copy_to_operands(e1, e2) instead")
111+
DEPRECATED("use add_to_operands(e1, e2) instead")
112112
void move_to_operands(exprt &e1, exprt &e2);
113113

114-
DEPRECATED("use copy_to_operands(e1, e2, e3) instead")
114+
DEPRECATED("use add_to_operands(e1, e2, e3) instead")
115115
void move_to_operands(exprt &e1, exprt &e2, exprt &e3);
116116

117117
/// Copy the given argument to the end of `exprt`'s operands.
@@ -121,9 +121,16 @@ class exprt:public irept
121121
operands().push_back(expr);
122122
}
123123

124-
/// Copy the given argument to the end of `exprt`'s operands.
124+
/// Add the given argument to the end of `exprt`'s operands.
125+
/// \param expr: `exprt` to append to the operands
126+
void add_to_operands(const exprt &expr)
127+
{
128+
copy_to_operands(expr);
129+
}
130+
131+
/// Add the given argument to the end of `exprt`'s operands.
125132
/// \param expr: `exprt` to append to the operands
126-
void copy_to_operands(exprt &&expr)
133+
void add_to_operands(exprt &&expr)
127134
{
128135
operands().push_back(std::move(expr));
129136
}
@@ -141,10 +148,18 @@ class exprt:public irept
141148
op.push_back(e2);
142149
}
143150

144-
/// Copy the given arguments to the end of `exprt`'s operands.
151+
/// Add the given arguments to the end of `exprt`'s operands.
152+
/// \param e1: first `exprt` to append to the operands
153+
/// \param e2: second `exprt` to append to the operands
154+
void add_to_operands(const exprt &e1, const exprt &e2)
155+
{
156+
copy_to_operands(e1, e2);
157+
}
158+
159+
/// Add the given arguments to the end of `exprt`'s operands.
145160
/// \param e1: first `exprt` to append to the operands
146161
/// \param e2: second `exprt` to append to the operands
147-
void copy_to_operands(exprt &&e1, exprt &&e2)
162+
void add_to_operands(exprt &&e1, exprt &&e2)
148163
{
149164
operandst &op = operands();
150165
#ifndef USE_LIST
@@ -154,6 +169,15 @@ class exprt:public irept
154169
op.push_back(std::move(e2));
155170
}
156171

172+
/// Add the given arguments to the end of `exprt`'s operands.
173+
/// \param e1: first `exprt` to append to the operands
174+
/// \param e2: second `exprt` to append to the operands
175+
/// \param e3: third `exprt` to append to the operands
176+
void add_to_operands(const exprt &e1, const exprt &e2, const exprt &e3)
177+
{
178+
copy_to_operands(e1, e2, e3);
179+
}
180+
157181
/// Copy the given arguments to the end of `exprt`'s operands.
158182
/// \param e1: first `exprt` to append to the operands
159183
/// \param e2: second `exprt` to append to the operands
@@ -169,11 +193,11 @@ class exprt:public irept
169193
op.push_back(e3);
170194
}
171195

172-
/// Copy the given arguments to the end of `exprt`'s operands.
196+
/// Add the given arguments to the end of `exprt`'s operands.
173197
/// \param e1: first `exprt` to append to the operands
174198
/// \param e2: second `exprt` to append to the operands
175199
/// \param e3: third `exprt` to append to the operands
176-
void copy_to_operands(exprt &&e1, exprt &&e2, exprt &&e3)
200+
void add_to_operands(exprt &&e1, exprt &&e2, exprt &&e3)
177201
{
178202
operandst &op = operands();
179203
#ifndef USE_LIST

src/util/std_code.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ class code_blockt:public codet
149149

150150
void add(codet &&code)
151151
{
152-
copy_to_operands(std::move(code));
152+
add_to_operands(std::move(code));
153153
}
154154

155155
void add(codet code, const source_locationt &loc)

0 commit comments

Comments
 (0)