diff --git a/src/ast/euf/ho_matcher.cpp b/src/ast/euf/ho_matcher.cpp index 696f868b2..f86d82b64 100644 --- a/src/ast/euf/ho_matcher.cpp +++ b/src/ast/euf/ho_matcher.cpp @@ -727,7 +727,7 @@ namespace euf { m_hopat2pat.insert(p1, p); m_q2hoq.insert(q, q1); m_hoq2q.insert(q1, q); - m_hopat2free_vars.insert(p1, free_vars); + m_hopat2free_vars.insert(p1, std::move(free_vars)); m_ho_patterns.push_back(p1); m_ho_qs.push_back(q1); trail().push(push_back_vector(m_ho_patterns)); diff --git a/src/ast/polymorphism_inst.cpp b/src/ast/polymorphism_inst.cpp index aa9b1e5fe..be91c8f5e 100644 --- a/src/ast/polymorphism_inst.cpp +++ b/src/ast/polymorphism_inst.cpp @@ -123,7 +123,7 @@ namespace polymorphism { expr_ref e_inst = new_sub(e); if (!m_from_instantiation.contains(e_inst)) { collect_instantiations(e_inst); - auto* new_sub1 = alloc(substitution, new_sub); + auto* new_sub1 = alloc(substitution, std::move(new_sub)); instances.push_back(instantiation(e, e_inst, new_sub1)); new_substs.insert(new_sub1); m_from_instantiation.insert(e_inst); diff --git a/src/math/polynomial/polynomial.cpp b/src/math/polynomial/polynomial.cpp index dde532107..f4cfa1fbd 100644 --- a/src/math/polynomial/polynomial.cpp +++ b/src/math/polynomial/polynomial.cpp @@ -2133,7 +2133,7 @@ namespace polynomial { m_m2pos.reset(m); m_m2pos.set(m, i); } - m_tmp_as.swap(new_as); + m_tmp_as = std::move(new_as); } // For each monomial m diff --git a/src/math/polynomial/upolynomial.cpp b/src/math/polynomial/upolynomial.cpp index 27478bdf0..2cf2a7b4e 100644 --- a/src/math/polynomial/upolynomial.cpp +++ b/src/math/polynomial/upolynomial.cpp @@ -301,7 +301,6 @@ namespace upolynomial { void core_manager::sub(unsigned sz1, numeral const * p1, unsigned sz2, numeral const * p2, numeral_vector & buffer) { sub_core(sz1, p1, sz2, p2, m_basic_tmp); - // buffer = std::move(m_basic_tmp); buffer.swap(m_basic_tmp); } @@ -343,7 +342,6 @@ namespace upolynomial { void core_manager::mul(unsigned sz1, numeral const * p1, unsigned sz2, numeral const * p2, numeral_vector & buffer) { mul_core(sz1, p1, sz2, p2, m_basic_tmp); - // buffer = std::move(m_basic_tmp); buffer.swap(m_basic_tmp); } diff --git a/src/muz/rel/dl_compiler.cpp b/src/muz/rel/dl_compiler.cpp index f9f7f2060..320d0a206 100644 --- a/src/muz/rel/dl_compiler.cpp +++ b/src/muz/rel/dl_compiler.cpp @@ -1145,7 +1145,7 @@ namespace datalog { set_difference(local_deltas, global_deltas); */ func_decl_set local_deltas; - func_decl_set global_deltas(head_preds); + const func_decl_set & global_deltas = head_preds; pred2idx d_global_src; //these deltas serve as sources of tuples for rule evaluation inside the loop get_fresh_registers(global_deltas, d_global_src); diff --git a/src/muz/rel/dl_mk_explanations.cpp b/src/muz/rel/dl_mk_explanations.cpp index d205ddc58..9565a7143 100644 --- a/src/muz/rel/dl_mk_explanations.cpp +++ b/src/muz/rel/dl_mk_explanations.cpp @@ -837,8 +837,8 @@ namespace datalog { SASSERT(&expl_singleton->get_plugin()==m_er_plugin); m_e_fact_relation = static_cast(expl_singleton); } - func_decl_set predicates(m_context.get_predicates()); - for (func_decl* orig_decl : predicates) { + + for (func_decl* orig_decl : m_context.get_predicates()) { TRACE(dl, tout << mk_pp(orig_decl, m_manager) << "\n";); func_decl * e_decl = get_e_decl(orig_decl); diff --git a/src/nlsat/nlsat_scoped_literal_vector.h b/src/nlsat/nlsat_scoped_literal_vector.h index 4c99e38f7..d67805c15 100644 --- a/src/nlsat/nlsat_scoped_literal_vector.h +++ b/src/nlsat/nlsat_scoped_literal_vector.h @@ -29,16 +29,14 @@ namespace nlsat { public: scoped_literal_vector(solver & s):m_solver(s) {} ~scoped_literal_vector() { reset(); } - + scoped_literal_vector(scoped_literal_vector && other) noexcept = default; - - // Move assignment operator + scoped_literal_vector & operator=(scoped_literal_vector && other) noexcept { if (this != &other) { SASSERT(&m_solver == &other.m_solver); reset(); // dec_ref our current literals - m_lits = std::move(other.m_lits); // take ownership of other's literals - // other.m_lits is now empty + m_lits = std::move(other.m_lits); } return *this; } diff --git a/src/qe/nlqsat.cpp b/src/qe/nlqsat.cpp index 1761af08b..263dad43c 100644 --- a/src/qe/nlqsat.cpp +++ b/src/qe/nlqsat.cpp @@ -385,10 +385,9 @@ namespace qe { // They are sorted by size, so we project the largest variables first to avoid // renaming variables. for (unsigned i = vars.size(); i-- > 0;) { - new_result.reset(); ex.project(vars[i], result.size(), result.data(), new_result); TRACE(qe, display_project(tout, vars[i], result, new_result);); - result.swap(new_result); + result = std::move(new_result); } negate_clause(result); } diff --git a/src/sat/smt/arith_theory_checker.h b/src/sat/smt/arith_theory_checker.h index 87868d940..4e84d37c8 100644 --- a/src/sat/smt/arith_theory_checker.h +++ b/src/sat/smt/arith_theory_checker.h @@ -358,7 +358,7 @@ namespace arith { continue; m_ineqs_that_are_eqs.insert(j); if (j < orig_size) { - m_eqs.push_back(m_ineqs[j]); + m_eqs.push_back(std::move(m_ineqs[j])); } else { auto [a, b] = m_deps[j]; diff --git a/src/smt/proto_model/proto_model.cpp b/src/smt/proto_model/proto_model.cpp index 2d97c4522..a62e51603 100644 --- a/src/smt/proto_model/proto_model.cpp +++ b/src/smt/proto_model/proto_model.cpp @@ -239,7 +239,7 @@ void proto_model::cleanup() { unregister_decl(faux); } } - m_aux_decls.swap(found_aux_fs); + m_aux_decls = std::move(found_aux_fs); } TRACE(model_bug, model_v2_pp(tout, *this);); } diff --git a/src/solver/mus.cpp b/src/solver/mus.cpp index 154d72ab6..b225e5379 100644 --- a/src/solver/mus.cpp +++ b/src/solver/mus.cpp @@ -201,7 +201,7 @@ struct mus::imp { } if (!min_core_valid || core.size() < min_core.size()) { // The current core is smallest so far, so we get fewer unknowns from it. - min_core = core; + min_core = std::move(core); min_core_valid = true; min_lit = lit; } diff --git a/src/util/obj_hashtable.h b/src/util/obj_hashtable.h index ae53fbe6d..329f1aa1e 100644 --- a/src/util/obj_hashtable.h +++ b/src/util/obj_hashtable.h @@ -29,13 +29,13 @@ Revision History: */ template class obj_hash_entry { - T * m_ptr = nullptr; + T * m_ptr = nullptr; public: typedef T * data; unsigned get_hash() const { return m_ptr->hash(); } bool is_free() const { return m_ptr == nullptr; } bool is_deleted() const { return m_ptr == reinterpret_cast(1); } - bool is_used() const { return m_ptr != reinterpret_cast(0) && m_ptr != reinterpret_cast(1); } + bool is_used() const { return m_ptr != nullptr && m_ptr != reinterpret_cast(1); } T * get_data() const { return m_ptr; } T * & get_data() { return m_ptr; } void set_data(T * d) { m_ptr = d; } @@ -50,21 +50,18 @@ public: obj_hashtable(unsigned initial_capacity = DEFAULT_HASHTABLE_INITIAL_CAPACITY): core_hashtable, obj_ptr_hash, ptr_eq >(initial_capacity) {} + obj_hashtable(const obj_hashtable & source) = default; + obj_hashtable(obj_hashtable && source) noexcept = default; + obj_hashtable& operator=(const obj_hashtable & other) = delete; + obj_hashtable& operator=(obj_hashtable && other) noexcept = default; }; template class obj_map { public: struct key_data { - Key * m_key = nullptr; - Value m_value; - key_data() {} - key_data(Key *key) : m_key(key) {} - key_data(Key *k, Value const &v) : m_key(k), m_value(v) {} - key_data(key_data &&kd) noexcept = default; - key_data(key_data const &kd) noexcept = default; - key_data &operator=(key_data const &kd) = default; - key_data &operator=(key_data &&kd) = default; + Key * m_key = nullptr; + Value m_value; Value const & get_value() const { return m_value; } Key & get_key () const { return *m_key; } unsigned hash() const { return m_key->hash(); } @@ -94,7 +91,12 @@ public: public: obj_map(unsigned initial_capacity = DEFAULT_HASHTABLE_INITIAL_CAPACITY): m_table(initial_capacity) {} - + + obj_map(const obj_map & source) = default; + obj_map(obj_map && source) noexcept = default; + obj_map& operator=(const obj_map & other) = delete; + obj_map& operator=(obj_map && other) noexcept = default; + typedef typename table::iterator iterator; typedef typename table::data data; typedef typename table::entry entry; @@ -141,16 +143,22 @@ public: return m_table.insert_if_not_there2(key_data(k, v))->get_data().m_value; } + Value& insert_if_not_there(Key * k, Value && v) { + obj_map_entry * e = nullptr; + m_table.insert_if_not_there_core({k, std::move(v)}, e); + return e->get_data().m_value; + } + bool insert_if_not_there_core(Key * k, Value const & v, obj_map_entry * & et) { return m_table.insert_if_not_there_core({k, v}, et); } obj_map_entry * insert_if_not_there3(Key * k, Value const & v) { - return m_table.insert_if_not_there2(key_data(k, v)); + return m_table.insert_if_not_there2({k, v}); } obj_map_entry * find_core(Key * k) const { - return m_table.find_core(key_data(k)); + return m_table.find_core({k}); } bool find(Key * const k, Value & v) const { diff --git a/src/util/s_integer.cpp b/src/util/s_integer.cpp index 53d19270b..848dd2901 100644 --- a/src/util/s_integer.cpp +++ b/src/util/s_integer.cpp @@ -19,10 +19,6 @@ Revision History: #include "util/s_integer.h" -s_integer s_integer::m_zero(0); -s_integer s_integer::m_one(1); -s_integer s_integer::m_minus_one(-1); - s_integer::s_integer(const char * str) { m_val = static_cast(strtol(str, nullptr, 10)); } diff --git a/src/util/s_integer.h b/src/util/s_integer.h index 5accf7b4b..e08439d23 100644 --- a/src/util/s_integer.h +++ b/src/util/s_integer.h @@ -22,9 +22,6 @@ Revision History: class s_integer { int m_val = 0; - static s_integer m_zero; - static s_integer m_one; - static s_integer m_minus_one; public: unsigned hash() const { @@ -39,10 +36,6 @@ public: public: s_integer() = default; explicit s_integer(int n):m_val(n) {} - struct i64 {}; - explicit s_integer(int64_t i, i64):m_val(static_cast(i)) {} - struct ui64 {}; - explicit s_integer(uint64_t i, ui64):m_val(static_cast(i)) {} explicit s_integer(const char * str); explicit s_integer(const rational & r):m_val(static_cast(r.get_int64())) {} @@ -58,12 +51,12 @@ public: uint64_t get_uint64() const { return m_val; } static bool is_unsigned() { return true; } unsigned get_unsigned() const { return static_cast(m_val); } - s_integer const& get_s_integer() const { return *this; } - s_integer const& get_infinitesimal() const { return zero(); } + s_integer get_s_integer() const { return *this; } + s_integer get_infinitesimal() const { return s_integer(0); } static bool is_rational() { return true; } s_integer const& get_rational() const { return *this; } friend inline s_integer numerator(const s_integer & r) { return r; } - friend inline s_integer denominator(const s_integer & r) { return one(); } + friend inline s_integer denominator(const s_integer & r) { return s_integer(1); } s_integer & operator+=(const s_integer & r) { m_val += r.m_val; return *this; } s_integer & operator-=(const s_integer & r) { m_val -= r.m_val; return *this; } s_integer & operator*=(const s_integer & r) { m_val *= r.m_val; return *this; } @@ -103,9 +96,6 @@ public: return result; } - static const s_integer & zero() { return m_zero; } - static const s_integer & one() { return m_one; } - static const s_integer & minus_one() { return m_minus_one; } // Perform: this += c * k void addmul(const s_integer & c, const s_integer & k) { m_val += c.m_val * k.m_val; } void submul(const s_integer & c, const s_integer & k) { m_val -= c.m_val * k.m_val; } @@ -137,5 +127,3 @@ inline s_integer abs(const s_integer & r) { } return result; } - -