3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-23 17:15:31 +00:00

Use override rather than virtual.

This commit is contained in:
Bruce Mitchener 2018-02-10 09:15:12 +07:00
parent ce123d9dbc
commit 7167fda1dc
220 changed files with 2546 additions and 2548 deletions

View file

@ -41,7 +41,7 @@ public:
checked_int64(checked_int64 const& other) { m_value = other.m_value; }
class overflow_exception : public z3_exception {
virtual char const * msg() const { return "checked_int64 overflow/underflow";}
char const * msg() const override { return "checked_int64 overflow/underflow";}
};
bool is_zero() const { return m_value == 0; }

View file

@ -46,7 +46,7 @@ public:
#endif
m_column_index(column_index) {}
bool is_dense() const { return false; }
bool is_dense() const override { return false; }
void print(std::ostream & out) {
print_matrix(*this, out);
@ -65,12 +65,12 @@ public:
return m_diagonal_element;
}
void apply_from_left(vector<X> & w, lp_settings & );
void apply_from_left(vector<X> & w, lp_settings & ) override;
template <typename L>
void apply_from_left_local(indexed_vector<L> & w, lp_settings & settings);
void apply_from_left_to_T(indexed_vector<T> & w, lp_settings & settings) {
void apply_from_left_to_T(indexed_vector<T> & w, lp_settings & settings) override {
apply_from_left_local(w, settings);
}
@ -80,8 +80,8 @@ public:
m_column_vector.push_back(row_index, val);
}
void apply_from_right(vector<T> & w);
void apply_from_right(indexed_vector<T> & w);
void apply_from_right(vector<T> & w) override;
void apply_from_right(indexed_vector<T> & w) override;
T get_elem(unsigned i, unsigned j) const;
#ifdef Z3DEBUG

View file

@ -27,14 +27,14 @@ struct iterator_on_column:linear_combination_iterator<T> {
const vector<column_cell>& m_column; // the offset in term coeffs
const static_matrix<T, X> & m_A;
int m_i; // the initial offset in the column
unsigned size() const { return m_column.size(); }
unsigned size() const override { return m_column.size(); }
iterator_on_column(const vector<column_cell>& column, const static_matrix<T,X> & A) // the offset in term coeffs
:
m_column(column),
m_A(A),
m_i(-1) {}
bool next(mpq & a, unsigned & i) {
bool next(mpq & a, unsigned & i) override {
if (++m_i >= static_cast<int>(m_column.size()))
return false;
@ -44,7 +44,7 @@ struct iterator_on_column:linear_combination_iterator<T> {
return true;
}
bool next(unsigned & i) {
bool next(unsigned & i) override {
if (++m_i >= static_cast<int>(m_column.size()))
return false;
@ -53,11 +53,11 @@ struct iterator_on_column:linear_combination_iterator<T> {
return true;
}
void reset() {
void reset() override {
m_i = -1;
}
linear_combination_iterator<mpq> * clone() {
linear_combination_iterator<mpq> * clone() override {
iterator_on_column * r = new iterator_on_column(m_column, m_A);
return r;
}

View file

@ -28,8 +28,8 @@ struct iterator_on_indexed_vector:linear_combination_iterator<T> {
m_v(v),
m_offset(0)
{}
unsigned size() const { return m_v.m_index.size(); }
bool next(T & a, unsigned & i) {
unsigned size() const override { return m_v.m_index.size(); }
bool next(T & a, unsigned & i) override {
if (m_offset >= m_v.m_index.size())
return false;
i = m_v.m_index[m_offset++];
@ -37,16 +37,16 @@ struct iterator_on_indexed_vector:linear_combination_iterator<T> {
return true;
}
bool next(unsigned & i) {
bool next(unsigned & i) override {
if (m_offset >= m_v.m_index.size())
return false;
i = m_v.m_index[m_offset++];
return true;
}
void reset() {
void reset() override {
m_offset = 0;
}
linear_combination_iterator<T>* clone() {
linear_combination_iterator<T>* clone() override {
return new iterator_on_indexed_vector(m_v);
}
};

View file

@ -26,11 +26,11 @@ struct iterator_on_pivot_row:linear_combination_iterator<T> {
const indexed_vector<T> & m_v;
unsigned m_basis_j;
iterator_on_indexed_vector<T> m_it;
unsigned size() const { return m_it.size(); }
unsigned size() const override { return m_it.size(); }
iterator_on_pivot_row(const indexed_vector<T> & v, unsigned basis_j) :
m_basis_returned(false),
m_v(v), m_basis_j(basis_j), m_it(v) {}
bool next(T & a, unsigned & i) {
bool next(T & a, unsigned & i) override {
if (m_basis_returned == false) {
m_basis_returned = true;
a = one_of_type<T>();
@ -39,7 +39,7 @@ struct iterator_on_pivot_row:linear_combination_iterator<T> {
}
return m_it.next(a, i);
}
bool next(unsigned & i) {
bool next(unsigned & i) override {
if (m_basis_returned == false) {
m_basis_returned = true;
i = m_basis_j;
@ -47,11 +47,11 @@ struct iterator_on_pivot_row:linear_combination_iterator<T> {
}
return m_it.next(i);
}
void reset() {
void reset() override {
m_basis_returned = false;
m_it.reset();
}
linear_combination_iterator<T> * clone() {
linear_combination_iterator<T> * clone() override {
iterator_on_pivot_row * r = new iterator_on_pivot_row(m_v, m_basis_j);
return r;
}

View file

@ -26,8 +26,8 @@ struct iterator_on_row:linear_combination_iterator<T> {
unsigned m_i; // offset
iterator_on_row(const vector<row_cell<T>> & row) : m_row(row), m_i(0)
{}
unsigned size() const { return m_row.size(); }
bool next(T & a, unsigned & i) {
unsigned size() const override { return m_row.size(); }
bool next(T & a, unsigned & i) override {
if (m_i == m_row.size())
return false;
auto &c = m_row[m_i++];
@ -35,17 +35,17 @@ struct iterator_on_row:linear_combination_iterator<T> {
a = c.get_val();
return true;
}
bool next(unsigned & i) {
bool next(unsigned & i) override {
if (m_i == m_row.size())
return false;
auto &c = m_row[m_i++];
i = c.m_j;
return true;
}
void reset() {
void reset() override {
m_i = 0;
}
linear_combination_iterator<T>* clone() {
linear_combination_iterator<T>* clone() override {
return new iterator_on_row(m_row);
}
};

View file

@ -27,14 +27,14 @@ struct iterator_on_term_with_basis_var:linear_combination_iterator<mpq> {
std::unordered_map<unsigned, mpq>::const_iterator m_i; // the offset in term coeffs
bool m_term_j_returned;
unsigned m_term_j;
unsigned size() const {return static_cast<unsigned>(m_term.m_coeffs.size() + 1);}
unsigned size() const override {return static_cast<unsigned>(m_term.m_coeffs.size() + 1);}
iterator_on_term_with_basis_var(const lar_term & t, unsigned term_j) :
m_term(t),
m_i(t.m_coeffs.begin()),
m_term_j_returned(false),
m_term_j(term_j) {}
bool next(mpq & a, unsigned & i) {
bool next(mpq & a, unsigned & i) override {
if (m_term_j_returned == false) {
m_term_j_returned = true;
a = - one_of_type<mpq>();
@ -48,7 +48,7 @@ struct iterator_on_term_with_basis_var:linear_combination_iterator<mpq> {
m_i++;
return true;
}
bool next(unsigned & i) {
bool next(unsigned & i) override {
if (m_term_j_returned == false) {
m_term_j_returned = true;
i = m_term_j;
@ -60,11 +60,11 @@ struct iterator_on_term_with_basis_var:linear_combination_iterator<mpq> {
m_i++;
return true;
}
void reset() {
void reset() override {
m_term_j_returned = false;
m_i = m_term.m_coeffs.begin();
}
linear_combination_iterator<mpq> * clone() {
linear_combination_iterator<mpq> * clone() override {
iterator_on_term_with_basis_var * r = new iterator_on_term_with_basis_var(m_term, m_term_j);
return r;
}

View file

@ -59,24 +59,24 @@ public:
struct lar_var_constraint: public lar_base_constraint {
unsigned m_j;
vector<std::pair<mpq, var_index>> get_left_side_coefficients() const {
vector<std::pair<mpq, var_index>> get_left_side_coefficients() const override {
vector<std::pair<mpq, var_index>> ret;
ret.push_back(std::make_pair(one_of_type<mpq>(), m_j));
return ret;
}
unsigned size() const { return 1;}
unsigned size() const override { return 1;}
lar_var_constraint(unsigned j, lconstraint_kind kind, const mpq& right_side) : lar_base_constraint(kind, right_side), m_j(j) { }
};
struct lar_term_constraint: public lar_base_constraint {
const lar_term * m_term;
vector<std::pair<mpq, var_index>> get_left_side_coefficients() const {
vector<std::pair<mpq, var_index>> get_left_side_coefficients() const override {
return m_term->coeffs_as_vector();
}
unsigned size() const { return m_term->size();}
unsigned size() const override { return m_term->size();}
lar_term_constraint(const lar_term *t, lconstraint_kind kind, const mpq& right_side) : lar_base_constraint(kind, right_side), m_term(t) { }
virtual mpq get_free_coeff_of_left_side() const { return m_term->m_v;}
mpq get_free_coeff_of_left_side() const override { return m_term->m_v;}
};
@ -92,10 +92,10 @@ public:
SASSERT(false); // should not be called : todo!
}
unsigned size() const {
unsigned size() const override {
return static_cast<unsigned>(m_coeffs.size());
}
vector<std::pair<mpq, var_index>> get_left_side_coefficients() const { return m_coeffs; }
vector<std::pair<mpq, var_index>> get_left_side_coefficients() const override { return m_coeffs; }
};
}

View file

@ -1011,7 +1011,7 @@ public:
return ret;
}
std::string get_column_name(unsigned j) const {
std::string get_column_name(unsigned j) const override {
if (j >= m_terms_start_index)
return std::string("_t") + T_to_string(j);
if (j >= m_columns_to_ext_vars_or_term_indices.size())

View file

@ -207,6 +207,6 @@ public:
void solve();
bool low_bounds_are_set() const { return true; }
bool low_bounds_are_set() const override { return true; }
};
}

View file

@ -33,7 +33,7 @@ class lp_dual_simplex: public lp_solver<T, X> {
vector<column_type> m_column_types_of_logicals;
vector<bool> m_can_enter_basis;
public:
~lp_dual_simplex() {
~lp_dual_simplex() override {
if (m_core_solver != nullptr) {
delete m_core_solver;
}
@ -84,12 +84,12 @@ public:
void copy_m_b_aside_and_set_it_to_zeros();
void find_maximal_solution();
void find_maximal_solution() override;
virtual T get_column_value(unsigned column) const {
T get_column_value(unsigned column) const override {
return this->get_column_value_with_core_solver(column, m_core_solver);
}
T get_current_cost() const;
T get_current_cost() const override;
};
}

View file

@ -770,7 +770,7 @@ public:
void init_reduced_costs();
bool low_bounds_are_set() const { return true; }
bool low_bounds_are_set() const override { return true; }
int advance_on_sorted_breakpoints(unsigned entering, X & t);

View file

@ -70,7 +70,7 @@ public:
void set_core_solver_bounds();
void find_maximal_solution();
void find_maximal_solution() override;
void fill_A_x_and_basis_for_stage_one_total_inf();
@ -79,7 +79,7 @@ public:
void solve_with_total_inf();
~lp_primal_simplex();
~lp_primal_simplex() override;
bool bounds_hold(std::unordered_map<std::string, T> const & solution);
@ -96,11 +96,11 @@ public:
return bounds_hold(solution) && row_constraints_hold(solution);
}
virtual T get_column_value(unsigned column) const {
T get_column_value(unsigned column) const override {
return this->get_column_value_with_core_solver(column, m_core_solver);
}
T get_current_cost() const;
T get_current_cost() const override;
};

View file

@ -109,7 +109,7 @@ private:
default_lp_resource_limit(lp_settings& s): m_settings(s) {
m_sw.start();
}
virtual bool get_cancel_flag() {
bool get_cancel_flag() override {
return (m_sw.get_current_seconds() > m_settings.time_limit);
}
};

View file

@ -67,7 +67,7 @@ public:
#endif
}
bool is_dense() const { return false; }
bool is_dense() const override { return false; }
one_elem_on_diag(const one_elem_on_diag & o);
@ -83,15 +83,15 @@ public:
unsigned row_count() const { return m_m; } // not defined }
unsigned column_count() const { return m_m; } // not defined }
#endif
void apply_from_left(vector<X> & w, lp_settings &) {
void apply_from_left(vector<X> & w, lp_settings &) override {
w[m_i] /= m_val;
}
void apply_from_right(vector<T> & w) {
void apply_from_right(vector<T> & w) override {
w[m_i] /= m_val;
}
void apply_from_right(indexed_vector<T> & w) {
void apply_from_right(indexed_vector<T> & w) override {
if (is_zero(w.m_data[m_i]))
return;
auto & v = w.m_data[m_i] /= m_val;
@ -102,7 +102,7 @@ public:
}
void apply_from_left_to_T(indexed_vector<T> & w, lp_settings & settings);
void apply_from_left_to_T(indexed_vector<T> & w, lp_settings & settings) override;
void conjugate_by_permutation(permutation_matrix<T, X> & p) {
// this = p * this * p(-1)

View file

@ -64,7 +64,7 @@ class permutation_matrix : public tail_matrix<T, X> {
// create a unit permutation of the given length
void init(unsigned length);
unsigned get_rev(unsigned i) { return m_rev[i]; }
bool is_dense() const { return false; }
bool is_dense() const override { return false; }
#ifdef Z3DEBUG
permutation_matrix get_inverse() const {
return permutation_matrix(size(), m_rev);
@ -76,13 +76,13 @@ class permutation_matrix : public tail_matrix<T, X> {
unsigned operator[](unsigned i) const { return m_permutation[i]; }
void apply_from_left(vector<X> & w, lp_settings &);
void apply_from_left(vector<X> & w, lp_settings &) override;
void apply_from_left_to_T(indexed_vector<T> & w, lp_settings & settings);
void apply_from_left_to_T(indexed_vector<T> & w, lp_settings & settings) override;
void apply_from_right(vector<T> & w);
void apply_from_right(vector<T> & w) override;
void apply_from_right(indexed_vector<T> & w);
void apply_from_right(indexed_vector<T> & w) override;
template <typename L>
void copy_aside(vector<L> & t, vector<unsigned> & tmp_index, indexed_vector<L> & w);

View file

@ -50,7 +50,7 @@ public:
m_row_start(row_start), m_row(row) {
}
bool is_dense() const { return false; }
bool is_dense() const override { return false; }
void print(std::ostream & out) {
print_matrix(*this, out);
@ -60,12 +60,12 @@ public:
return m_row_vector.m_data[m_row];
}
void apply_from_left(vector<X> & w, lp_settings &);
void apply_from_left(vector<X> & w, lp_settings &) override;
void apply_from_left_local_to_T(indexed_vector<T> & w, lp_settings & settings);
void apply_from_left_local_to_X(indexed_vector<X> & w, lp_settings & settings);
void apply_from_left_to_T(indexed_vector<T> & w, lp_settings & settings) {
void apply_from_left_to_T(indexed_vector<T> & w, lp_settings & settings) override {
apply_from_left_local_to_T(w, settings);
}
@ -74,8 +74,8 @@ public:
m_row_vector.push_back(row_index, val);
}
void apply_from_right(vector<T> & w);
void apply_from_right(indexed_vector<T> & w);
void apply_from_right(vector<T> & w) override;
void apply_from_right(indexed_vector<T> & w) override;
void conjugate_by_permutation(permutation_matrix<T, X> & p);
#ifdef Z3DEBUG

View file

@ -70,7 +70,7 @@ public:
void init(sparse_matrix<T, X> *parent_matrix, unsigned index_start);
bool is_dense() const { return true; }
bool is_dense() const override { return true; }
ref operator[] (unsigned i) {
SASSERT(i >= m_index_start);
@ -137,13 +137,13 @@ public:
bool is_L_matrix() const;
void apply_from_left_to_T(indexed_vector<T> & w, lp_settings & settings) {
void apply_from_left_to_T(indexed_vector<T> & w, lp_settings & settings) override {
apply_from_left_local(w, settings);
}
void apply_from_right(indexed_vector<T> & w) {
void apply_from_right(indexed_vector<T> & w) override {
#if 1==0
indexed_vector<T> wcopy = w;
apply_from_right(wcopy.m_data);
@ -207,11 +207,11 @@ public:
w = m_work_vector;
#endif
}
void apply_from_left(vector<X> & w, lp_settings & /*settings*/) {
void apply_from_left(vector<X> & w, lp_settings & /*settings*/) override {
apply_from_left_to_vector(w);// , settings);
}
void apply_from_right(vector<T> & w);
void apply_from_right(vector<T> & w) override;
#ifdef Z3DEBUG
T get_elem (unsigned i, unsigned j) const;

View file

@ -178,15 +178,15 @@ public:
static bool field() { return true; }
class exception : public z3_exception {
virtual char const * msg() const { return "multi-precision floating point (mpff) exception"; }
char const * msg() const override { return "multi-precision floating point (mpff) exception"; }
};
class overflow_exception : public exception {
virtual char const * msg() const { return "multi-precision floating point (mpff) overflow"; }
char const * msg() const override { return "multi-precision floating point (mpff) overflow"; }
};
class div0_exception : public exception {
virtual char const * msg() const { return "multi-precision floating point (mpff) division by zero"; }
char const * msg() const override { return "multi-precision floating point (mpff) division by zero"; }
};
mpff_manager(unsigned prec = 2, unsigned initial_capacity = 1024);

View file

@ -125,15 +125,15 @@ public:
static bool field() { return true; }
class exception : public z3_exception {
virtual char const * msg() const { return "multi-precision fixed point (mpfx) exception"; }
char const * msg() const override { return "multi-precision fixed point (mpfx) exception"; }
};
class overflow_exception : public exception {
virtual char const * msg() const { return "multi-precision fixed point (mpfx) overflow"; }
char const * msg() const override { return "multi-precision fixed point (mpfx) overflow"; }
};
class div0_exception : public exception {
virtual char const * msg() const { return "multi-precision fixed point (mpfx) division by zero"; }
char const * msg() const override { return "multi-precision fixed point (mpfx) division by zero"; }
};
mpfx_manager(unsigned int_sz = 2, unsigned frac_sz = 1, unsigned initial_capacity = 1024);

View file

@ -32,7 +32,7 @@ void (* g_on_timeout)() = 0;
class g_timeout_eh : public event_handler {
public:
void operator()(event_handler_caller_t caller_id) {
void operator()(event_handler_caller_t caller_id) override {
#pragma omp critical (g_timeout_cs)
{
std::cout << "timeout\n";

View file

@ -43,10 +43,10 @@ public:
m_old_value(value) {
}
virtual ~value_trail() {
~value_trail() override {
}
virtual void undo(Ctx & ctx) {
void undo(Ctx & ctx) override {
m_value = m_old_value;
}
};
@ -59,10 +59,10 @@ public:
m_value(value) {
}
virtual ~reset_flag_trail() {
~reset_flag_trail() override {
}
virtual void undo(Ctx & ctx) {
void undo(Ctx & ctx) override {
m_value = false;
}
};
@ -76,7 +76,7 @@ public:
SASSERT(m_ptr == 0);
}
virtual void undo(Ctx & ctx) {
void undo(Ctx & ctx) override {
m_ptr = 0;
}
};
@ -94,9 +94,9 @@ public:
m_vector(v),
m_old_size(v.size()) {
}
virtual ~restore_size_trail() {
~restore_size_trail() override {
}
virtual void undo(Ctx & ctx) {
void undo(Ctx & ctx) override {
m_vector.shrink(m_old_size);
}
};
@ -113,10 +113,10 @@ public:
m_old_value(v[idx]) {
}
virtual ~vector_value_trail() {
~vector_value_trail() override {
}
virtual void undo(Ctx & ctx) {
void undo(Ctx & ctx) override {
m_vector[m_idx] = m_old_value;
}
};
@ -128,8 +128,8 @@ class insert_obj_map : public trail<Ctx> {
D* m_obj;
public:
insert_obj_map(obj_map<D,R>& t, D* o) : m_map(t), m_obj(o) {}
virtual ~insert_obj_map() {}
virtual void undo(Ctx & ctx) { m_map.remove(m_obj); }
~insert_obj_map() override {}
void undo(Ctx & ctx) override { m_map.remove(m_obj); }
};
template<typename Ctx, typename M, typename D>
@ -138,8 +138,8 @@ class insert_map : public trail<Ctx> {
D m_obj;
public:
insert_map(M& t, D o) : m_map(t), m_obj(o) {}
virtual ~insert_map() {}
virtual void undo(Ctx & ctx) { m_map.remove(m_obj); }
~insert_map() override {}
void undo(Ctx & ctx) override { m_map.remove(m_obj); }
};
@ -152,7 +152,7 @@ public:
m_vector(v) {
}
virtual void undo(Ctx & ctx) {
void undo(Ctx & ctx) override {
m_vector.pop_back();
}
};
@ -167,10 +167,10 @@ public:
m_idx(idx) {
}
virtual ~set_vector_idx_trail() {
~set_vector_idx_trail() override {
}
virtual void undo(Ctx & ctx) {
void undo(Ctx & ctx) override {
m_vector[m_idx] = 0;
}
};
@ -218,7 +218,7 @@ public:
m_vector(v) {
}
virtual void undo(Ctx & ctx) {
void undo(Ctx & ctx) override {
m_vector.pop_back();
}
};
@ -251,7 +251,7 @@ public:
m_vector[m_idx] = true;
}
virtual void undo(Ctx & ctx) {
void undo(Ctx & ctx) override {
m_vector[m_idx] = false;
}
};
@ -264,7 +264,7 @@ public:
m_obj(obj) {
}
virtual void undo(Ctx & ctx) {
void undo(Ctx & ctx) override {
dealloc(m_obj);
}
};
@ -288,8 +288,8 @@ class insert_obj_trail : public trail<Ctx> {
T* m_obj;
public:
insert_obj_trail(obj_hashtable<T>& t, T* o) : m_table(t), m_obj(o) {}
virtual ~insert_obj_trail() {}
virtual void undo(Ctx & ctx) { m_table.remove(m_obj); }
~insert_obj_trail() override {}
void undo(Ctx & ctx) override { m_table.remove(m_obj); }
};

View file

@ -52,8 +52,8 @@ class union_find {
union_find & m_owner;
public:
mk_var_trail(union_find & o):m_owner(o) {}
virtual ~mk_var_trail() {}
virtual void undo(Ctx & ctx) {
~mk_var_trail() override {}
void undo(Ctx & ctx) override {
m_owner.m_find.pop_back();
m_owner.m_size.pop_back();
m_owner.m_next.pop_back();
@ -70,8 +70,8 @@ class union_find {
unsigned m_r1;
public:
merge_trail(union_find & o, unsigned r1):m_owner(o), m_r1(r1) {}
virtual ~merge_trail() {}
virtual void undo(Ctx & ctx) { m_owner.unmerge(m_r1); }
~merge_trail() override {}
void undo(Ctx & ctx) override { m_owner.unmerge(m_r1); }
};
void unmerge(unsigned r1) {