From aea09dc2d765c2286a2a268a1facd81d15e87f49 Mon Sep 17 00:00:00 2001 From: Chris Smowton Date: Thu, 1 Nov 2018 08:19:51 +0000 Subject: [PATCH] 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. --- src/util/expr.h | 43 ++++++++++++++++++++++++++++++++++--------- src/util/std_code.h | 2 +- 2 files changed, 35 insertions(+), 10 deletions(-) diff --git a/src/util/expr.h b/src/util/expr.h index a89cc19a630..ce9aa101e9b 100644 --- a/src/util/expr.h +++ b/src/util/expr.h @@ -105,13 +105,14 @@ class exprt:public irept void reserve_operands(operandst::size_type n) { operands().reserve(n) ; } - DEPRECATED("use copy_to_operands(expr) instead") + DEPRECATED("use add_to_operands(std::move(expr)) instead") void move_to_operands(exprt &expr); - DEPRECATED("use copy_to_operands(e1, e2) instead") + DEPRECATED("use add_to_operands(std::move(e1), std::move(e2)) instead") void move_to_operands(exprt &e1, exprt &e2); - DEPRECATED("use copy_to_operands(e1, e2, e3) instead") + DEPRECATED( + "use add_to_operands(std::move(e1), std::move(e2), std::move(e3)) instead") void move_to_operands(exprt &e1, exprt &e2, exprt &e3); /// Copy the given argument to the end of `exprt`'s operands. @@ -121,9 +122,16 @@ class exprt:public irept operands().push_back(expr); } - /// Copy the given argument to the end of `exprt`'s operands. + /// Add the given argument to the end of `exprt`'s operands. + /// \param expr: `exprt` to append to the operands + void add_to_operands(const exprt &expr) + { + copy_to_operands(expr); + } + + /// Add the given argument to the end of `exprt`'s operands. /// \param expr: `exprt` to append to the operands - void copy_to_operands(exprt &&expr) + void add_to_operands(exprt &&expr) { operands().push_back(std::move(expr)); } @@ -141,10 +149,18 @@ class exprt:public irept op.push_back(e2); } - /// Copy the given arguments to the end of `exprt`'s operands. + /// Add the given arguments to the end of `exprt`'s operands. + /// \param e1: first `exprt` to append to the operands + /// \param e2: second `exprt` to append to the operands + void add_to_operands(const exprt &e1, const exprt &e2) + { + copy_to_operands(e1, e2); + } + + /// Add the given arguments to the end of `exprt`'s operands. /// \param e1: first `exprt` to append to the operands /// \param e2: second `exprt` to append to the operands - void copy_to_operands(exprt &&e1, exprt &&e2) + void add_to_operands(exprt &&e1, exprt &&e2) { operandst &op = operands(); #ifndef USE_LIST @@ -154,6 +170,15 @@ class exprt:public irept op.push_back(std::move(e2)); } + /// Add the given arguments to the end of `exprt`'s operands. + /// \param e1: first `exprt` to append to the operands + /// \param e2: second `exprt` to append to the operands + /// \param e3: third `exprt` to append to the operands + void add_to_operands(const exprt &e1, const exprt &e2, const exprt &e3) + { + copy_to_operands(e1, e2, e3); + } + /// Copy the given arguments to the end of `exprt`'s operands. /// \param e1: first `exprt` to append to the operands /// \param e2: second `exprt` to append to the operands @@ -169,11 +194,11 @@ class exprt:public irept op.push_back(e3); } - /// Copy the given arguments to the end of `exprt`'s operands. + /// Add the given arguments to the end of `exprt`'s operands. /// \param e1: first `exprt` to append to the operands /// \param e2: second `exprt` to append to the operands /// \param e3: third `exprt` to append to the operands - void copy_to_operands(exprt &&e1, exprt &&e2, exprt &&e3) + void add_to_operands(exprt &&e1, exprt &&e2, exprt &&e3) { operandst &op = operands(); #ifndef USE_LIST diff --git a/src/util/std_code.h b/src/util/std_code.h index be2255a7cd6..7b550bd1c5e 100644 --- a/src/util/std_code.h +++ b/src/util/std_code.h @@ -149,7 +149,7 @@ class code_blockt:public codet void add(codet &&code) { - copy_to_operands(std::move(code)); + add_to_operands(std::move(code)); } void add(codet code, const source_locationt &loc)