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

merge with master

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2018-03-25 14:57:01 -07:00
commit c513f3ca09
883 changed files with 13979 additions and 16480 deletions

View file

@ -74,7 +74,7 @@ public:
typedef T * iterator;
typedef const T * const_iterator;
array():m_data(0) {}
array():m_data(nullptr) {}
/**
\brief Store the array in the given chunk of memory (mem).
@ -123,7 +123,7 @@ public:
if (CallDestructors)
destroy_elements();
a.deallocate(space(size()), raw_ptr());
m_data = 0;
m_data = nullptr;
}
}
@ -148,7 +148,7 @@ public:
}
unsigned size() const {
if (m_data == 0) {
if (m_data == nullptr) {
return 0;
}
return static_cast<unsigned>(reinterpret_cast<size_t *>(m_data)[SIZE_IDX]);

View file

@ -62,7 +62,7 @@ public:
bit_vector():
m_num_bits(0),
m_capacity(0),
m_data(0) {
m_data(nullptr) {
}
bit_vector(unsigned reserve_num_bits) :
@ -75,7 +75,7 @@ public:
bit_vector(bit_vector const & source):
m_num_bits(source.m_num_bits),
m_capacity(source.m_capacity),
m_data(0) {
m_data(nullptr) {
if (source.m_data) {
m_data = alloc_svect(unsigned, m_capacity);
memcpy(m_data, source.m_data, m_capacity * sizeof(unsigned));

View file

@ -30,8 +30,8 @@ class cancel_eh : public event_handler {
T & m_obj;
public:
cancel_eh(T & o): m_canceled(false), m_obj(o) {}
~cancel_eh() { if (m_canceled) m_obj.dec_cancel(); }
virtual void operator()(event_handler_caller_t caller_id) {
~cancel_eh() override { if (m_canceled) m_obj.dec_cancel(); }
void operator()(event_handler_caller_t caller_id) override {
if (!m_canceled) {
m_caller_id = caller_id;
m_canceled = true;

View file

@ -106,13 +106,13 @@ protected:
SASSERT(target_it < target + target_slots);
if (target_it->is_free()) {
target_it->m_data = list_it->m_data;
target_it->m_next = 0;
target_it->m_next = nullptr;
used_slots++;
}
else {
SASSERT((get_hash(target_it->m_data) & target_mask) == idx);
if (target_cellar == target_end)
return 0; // the cellar is too small...
return nullptr; // the cellar is too small...
SASSERT(target_cellar >= target + target_slots);
SASSERT(target_cellar < target_end);
*target_cellar = *target_it;
@ -123,7 +123,7 @@ protected:
SASSERT(!target_it->is_free());
list_it = list_it->m_next;
}
while (list_it != 0);
while (list_it != nullptr);
}
}
#if 0
@ -164,13 +164,13 @@ protected:
cell * next_cell = copy_table(m_table, m_slots, m_capacity,
new_table, new_slots, new_capacity,
m_used_slots);
if (next_cell != 0) {
if (next_cell != nullptr) {
delete_table();
m_table = new_table;
m_capacity = new_capacity;
m_slots = new_slots;
m_next_cell = next_cell;
m_free_cell = 0;
m_free_cell = nullptr;
CASSERT("chashtable", check_invariant());
return;
}
@ -180,11 +180,11 @@ protected:
}
bool has_free_cells() const {
return m_free_cell != 0 || m_next_cell < m_table + m_capacity;
return m_free_cell != nullptr || m_next_cell < m_table + m_capacity;
}
cell * get_free_cell() {
if (m_free_cell != 0) {
if (m_free_cell != nullptr) {
cell * c = m_free_cell;
m_free_cell = c->m_next;
return c;
@ -211,7 +211,7 @@ protected:
m_used_slots = 0;
m_size = 0;
m_next_cell = m_table + slots;
m_free_cell = 0;
m_free_cell = nullptr;
}
public:
@ -281,7 +281,7 @@ public:
m_size++;
m_used_slots++;
c->m_data = d;
c->m_next = 0;
c->m_next = nullptr;
CASSERT("chashtable_bug", check_invariant());
return;
}
@ -297,7 +297,7 @@ public:
CHS_CODE(m_collisions++;);
it = it->m_next;
}
while (it != 0);
while (it != nullptr);
// d is not in the table.
m_size++;
cell * new_c = get_free_cell();
@ -320,7 +320,7 @@ public:
m_size++;
m_used_slots++;
c->m_data = d;
c->m_next = 0;
c->m_next = nullptr;
CASSERT("chashtable_bug", check_invariant());
return c->m_data;
}
@ -335,7 +335,7 @@ public:
CHS_CODE(m_collisions++;);
it = it->m_next;
}
while (it != 0);
while (it != nullptr);
// d is not in the table.
m_size++;
cell * new_c = get_free_cell();
@ -358,7 +358,7 @@ public:
m_size++;
m_used_slots++;
c->m_data = d;
c->m_next = 0;
c->m_next = nullptr;
CASSERT("chashtable_bug", check_invariant());
return true;
}
@ -373,7 +373,7 @@ public:
CHS_CODE(m_collisions++;);
it = it->m_next;
}
while (it != 0);
while (it != nullptr);
// d is not in the table.
m_size++;
cell * new_c = get_free_cell();
@ -399,7 +399,7 @@ public:
CHS_CODE(const_cast<chashtable*>(this)->m_collisions++;);
c = c->m_next;
}
while (c != 0);
while (c != nullptr);
return false;
}
@ -409,7 +409,7 @@ public:
unsigned idx = h & mask;
cell * c = m_table + idx;
if (c->is_free())
return 0;
return nullptr;
do {
if (equals(c->m_data, d)) {
return &(c->m_data);
@ -417,8 +417,8 @@ public:
CHS_CODE(const_cast<chashtable*>(this)->m_collisions++;);
c = c->m_next;
}
while (c != 0);
return 0;
while (c != nullptr);
return nullptr;
}
bool find(T const & d, T & r) {
@ -436,7 +436,7 @@ public:
CHS_CODE(const_cast<chashtable*>(this)->m_collisions++;);
c = c->m_next;
}
while (c != 0);
while (c != nullptr);
return false;
}
@ -447,13 +447,13 @@ public:
cell * c = m_table + idx;
if (c->is_free())
return;
cell * prev = 0;
cell * prev = nullptr;
do {
if (equals(c->m_data, d)) {
m_size--;
if (prev == 0) {
if (prev == nullptr) {
cell * next = c->m_next;
if (next == 0) {
if (next == nullptr) {
m_used_slots--;
c->mark_free();
SASSERT(c->is_free());
@ -474,7 +474,7 @@ public:
prev = c;
c = c->m_next;
}
while (c != 0);
while (c != nullptr);
}
class iterator {
@ -490,12 +490,12 @@ public:
}
m_it++;
}
m_list_it = 0;
m_list_it = nullptr;
}
public:
iterator(cell * start, cell * end): m_it(start), m_end(end) { move_to_used(); }
iterator():m_it(0), m_end(0), m_list_it(0) {}
iterator():m_it(nullptr), m_end(nullptr), m_list_it(nullptr) {}
T & operator*() {
return m_list_it->m_data;
}
@ -506,7 +506,7 @@ public:
T * operator->() { return &(operator*()); }
iterator & operator++() {
m_list_it = m_list_it->m_next;
if (m_list_it == 0) {
if (m_list_it == nullptr) {
m_it++;
move_to_used();
}
@ -658,7 +658,7 @@ public:
bool find(Key const & k, Value & v) const {
key_value * e = m_table.find_core(key_value(k));
if (e == 0)
if (e == nullptr)
return false;
v = e->m_value;
return true;

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; }
@ -116,58 +116,48 @@ public:
const checked_int64 operator--(int) { checked_int64 tmp(*this); --(*this); return tmp; }
checked_int64& operator+=(checked_int64 const& other) {
if (CHECK && m_value > 0 && other.m_value > 0 &&
(m_value > INT_MAX || other.m_value > INT_MAX)) {
rational r(r64(m_value) + r64(other.m_value));
if (!r.is_int64()) {
throw overflow_exception();
}
m_value = r.get_int64();
return *this;
if (CHECK) {
uint64 x = static_cast<uint64>(m_value);
uint64 y = static_cast<uint64>(other.m_value);
int64 r = static_cast<int64>(x + y);
if (m_value > 0 && other.m_value > 0 && r <= 0) throw overflow_exception();
if (m_value < 0 && other.m_value < 0 && r >= 0) throw overflow_exception();
m_value = r;
}
if (CHECK && m_value < 0 && other.m_value < 0 &&
(m_value < INT_MIN || other.m_value < INT_MIN)) {
rational r(r64(m_value) + r64(other.m_value));
if (!r.is_int64()) {
throw overflow_exception();
}
m_value = r.get_int64();
return *this;
else {
m_value += other.m_value;
}
m_value += other.m_value;
return *this;
}
checked_int64& operator-=(checked_int64 const& other) {
if (CHECK && m_value > 0 && other.m_value < 0 &&
(m_value > INT_MAX || other.m_value < INT_MIN)) {
rational r(r64(m_value) - r64(other.m_value));
if (!r.is_int64()) {
throw overflow_exception();
}
m_value = r.get_int64();
return *this;
if (CHECK) {
uint64 x = static_cast<uint64>(m_value);
uint64 y = static_cast<uint64>(other.m_value);
int64 r = static_cast<int64>(x - y);
if (m_value > 0 && other.m_value < 0 && r <= 0) throw overflow_exception();
if (m_value < 0 && other.m_value > 0 && r >= 0) throw overflow_exception();
m_value = r;
}
if (CHECK && m_value < 0 && other.m_value > 0 &&
(m_value < INT_MIN || other.m_value > INT_MAX)) {
rational r(r64(m_value) - r64(other.m_value));
if (!r.is_int64()) {
throw overflow_exception();
}
m_value = r.get_int64();
return *this;
else {
m_value -= other.m_value;
}
m_value -= other.m_value;
return *this;
}
checked_int64& operator*=(checked_int64 const& other) {
if (CHECK) {
rational r(r64(m_value) * r64(other.m_value));
if (!r.is_int64()) {
throw overflow_exception();
if (INT_MIN < m_value && m_value <= INT_MAX && INT_MIN < other.m_value && other.m_value <= INT_MAX) {
m_value *= other.m_value;
}
// TBD: could be tuned by using known techniques or 128-bit arithmetic.
else {
rational r(r64(m_value) * r64(other.m_value));
if (!r.is_int64()) {
throw overflow_exception();
}
m_value = r.get_int64();
}
m_value = r.get_int64();
}
else {
m_value *= other.m_value;

View file

@ -91,8 +91,8 @@ public:
virtual void reset(cmd_context & ctx) {}
virtual void finalize(cmd_context & ctx) {}
virtual symbol get_name() const { return m_name; }
virtual char const * get_usage() const { return 0; }
virtual char const * get_descr(cmd_context & ctx) const { return 0; }
virtual char const * get_usage() const { return nullptr; }
virtual char const * get_descr(cmd_context & ctx) const { return nullptr; }
virtual unsigned get_arity() const { return 0; }
// command invocation

View file

@ -29,7 +29,7 @@ Revision History:
// -----------------------------------
template<class Set1, class Set2>
void set_intersection(Set1 & tgt, const Set2 & src) {
void set_intersection(Set1 & tgt, const Set2 & src) {
svector<typename Set1::data> to_remove;
for (auto const& itm : tgt)
if (!src.contains(itm))

View file

@ -28,7 +28,7 @@ struct cooperation_lock {
cooperation_lock() {
omp_set_nested(1);
omp_init_nest_lock(&m_lock);
m_task = 0;
m_task = nullptr;
m_owner_thread = -1;
}
~cooperation_lock() {

View file

@ -41,7 +41,7 @@ void notify_assertion_violation(const char * fileName, int line, const char * co
std::cerr << condition << "\n";
}
static str_hashtable* g_enabled_debug_tags = 0;
static str_hashtable* g_enabled_debug_tags = nullptr;
static void init_debug_table() {
if (!g_enabled_debug_tags) {
@ -51,7 +51,7 @@ static void init_debug_table() {
void finalize_debug() {
dealloc(g_enabled_debug_tags);
g_enabled_debug_tags = 0;
g_enabled_debug_tags = nullptr;
}
void enable_debug(const char * tag) {
@ -72,7 +72,7 @@ bool is_debug_enabled(const char * tag) {
#ifndef _WINDOWS
void invoke_gdb() {
char buffer[1024];
int * x = 0;
int * x = nullptr;
for (;;) {
std::cerr << "(C)ontinue, (A)bort, (S)top, (T)hrow exception, Invoke (G)DB\n";
char result;
@ -103,7 +103,7 @@ void invoke_gdb() {
else {
std::cerr << "error starting GDB...\n";
// forcing seg fault.
int * x = 0;
int * x = nullptr;
*x = 0;
}
return;

View file

@ -138,7 +138,7 @@ public:
}
dependency * mk_empty() {
return 0;
return nullptr;
}
dependency * mk_leaf(value const & v) {
@ -148,10 +148,10 @@ public:
}
dependency * mk_join(dependency * d1, dependency * d2) {
if (d1 == 0) {
if (d1 == nullptr) {
return d2;
}
else if (d2 == 0) {
else if (d2 == nullptr) {
return d1;
}
else if (d1 == d2) {

View file

@ -18,16 +18,15 @@ Revision History:
--*/
#ifndef FILE_PATH_H_
#define FILE_PATH_H_
#include<string.h>
#include <cstring>
inline char const * get_extension(char const * file_name) {
if (file_name == 0)
return 0;
char const * last_dot = 0;
if (file_name == nullptr)
return nullptr;
char const * last_dot = nullptr;
for (;;) {
char const * tmp = strchr(file_name, '.');
if (tmp == 0) {
if (tmp == nullptr) {
return last_dot;
}
last_dot = tmp + 1;

View file

@ -23,7 +23,7 @@ Notes:
extern void gparams_register_modules();
static char const * g_old_params_names[] = {
"arith_adaptive","arith_adaptive_assertion_threshold","arith_adaptive_gcd","arith_adaptive_propagation_threshold","arith_add_binary_bounds","arith_blands_rule_threshold","arith_branch_cut_ratio","arith_dump_lemmas","arith_eager_eq_axioms","arith_eager_gcd","arith_eq_bounds","arith_euclidean_solver","arith_expand_eqs","arith_force_simplex","arith_gcd_test","arith_ignore_int","arith_lazy_adapter","arith_lazy_pivoting","arith_max_lemma_size","arith_process_all_eqs","arith_propagate_eqs","arith_propagation_mode","arith_propagation_threshold","arith_prop_strategy","arith_random_initial_value","arith_random_lower","arith_random_seed","arith_random_upper","arith_reflect","arith_skip_big_coeffs","arith_small_lemma_size","arith_solver","arith_stronger_lemmas","array_always_prop_upward","array_canonize","array_cg","array_delay_exp_axiom","array_extensional","array_laziness","array_lazy_ieq","array_lazy_ieq_delay","array_solver","array_weak","async_commands","at_labels_cex","auto_config","bb_eager","bb_ext_gates","bb_quantifiers","bin_clauses","bit2int","bv2int_distribute","bv_blast_max_size","bv_cc","bv_enable_int2bv_propagation","bv_lazy_le","bv_max_sharing","bv_reflect","bv_solver","case_split","check_at_labels","check_proof","cnf_factor","cnf_mode","context_simplifier","dack","dack_eq","dack_factor","dack_gc","dack_gc_inv_decay","dack_threshold","default_qid","default_table","default_table_checked","delay_units","delay_units_threshold","der","display_config","display_dot_proof","display_error_for_visual_studio","display_features","display_proof","display_unsat_core","distribute_forall","dt_lazy_splits","dump_goal_as_smt","elim_and","elim_bounds","elim_nlarith_quantifiers","elim_quantifiers","elim_term_ite","ematching","engine","eq_propagation","hi_div0","ignore_bad_patterns","ignore_setparameter","instruction_max","inst_gen","interactive","internalizer_nnf","lemma_gc_factor","lemma_gc_half","lemma_gc_initial","lemma_gc_new_clause_activity","lemma_gc_new_clause_relevancy","lemma_gc_new_old_ratio","lemma_gc_old_clause_activity","lemma_gc_old_clause_relevancy","lemma_gc_strategy","lift_ite","lookahead_diseq","macro_finder","max_conflicts","max_counterexamples","mbqi","mbqi_force_template","mbqi_max_cexs","mbqi_max_cexs_incr","mbqi_max_iterations","mbqi_trace","minimize_lemmas","model","model_compact","model_completion","model_display_arg_sort","model_hide_unused_partitions","model_on_final_check","model_on_timeout","model_partial","model_v1","model_v2","model_validate","new_core2th_eq","ng_lift_ite","nl_arith","nl_arith_branching","nl_arith_gb","nl_arith_gb_eqs","nl_arith_gb_perturbate","nl_arith_gb_threshold","nl_arith_max_degree","nl_arith_rounds","nnf_factor","nnf_ignore_labels","nnf_mode","nnf_sk_hack","order","order_var_weight","order_weights","phase_selection","pi_arith","pi_arith_weight","pi_avoid_skolems","pi_block_looop_patterns","pi_max_multi_patterns","pi_non_nested_arith_weight","pi_nopat_weight","pi_pull_quantifiers","pi_use_database","pi_warnings","pp_bounded","pp_bv_literals","pp_bv_neg","pp_decimal","pp_decimal_precision","pp_fixed_indent","pp_flat_assoc","pp_max_depth","pp_max_indent","pp_max_num_lines","pp_max_ribbon","pp_max_width","pp_min_alias_size","pp_simplify_implies","pp_single_line","precedence","precedence_gen","pre_demodulator","pre_simplifier","pre_simplify_expr","profile_res_sub","progress_sampling_freq","proof_mode","propagate_booleans","propagate_values","pull_cheap_ite_trees","pull_nested_quantifiers","qi_conservative_final_check","qi_cost","qi_eager_threshold","qi_lazy_instantiation","qi_lazy_quick_checker","qi_lazy_threshold","qi_max_eager_multi_patterns","qi_max_instances","qi_max_lazy_multi_pattern_matching","qi_new_gen","qi_profile","qi_profile_freq","qi_promote_unsat","qi_quick_checker","quasi_macros","random_case_split_freq","random_initial_activity","random_seed","recent_lemma_threshold","reduce_args","refine_inj_axiom","relevancy","relevancy_lemma","rel_case_split_order","restart_adaptive","restart_agility_threshold","restart_factor","restart_initial","restart_strategy","restricted_quasi_macros","simplify_clauses","smtlib2_compliant","smtlib_category","smtlib_dump_lemmas","smtlib_logic","smtlib_source_info","smtlib_trace_path","soft_timeout","solver","spc_bs","spc_es","spc_factor_subsumption_index_opt","spc_initial_subsumption_index_opt","spc_max_subsumption_index_features","spc_min_func_freq_subsumption_index","spc_num_iterations","spc_trace","statistics","strong_context_simplifier","tick","trace","trace_file_name","type_check","user_theory_persist_axioms","user_theory_preprocess_axioms","verbose","warning","well_sorted_check","z3_solver_ll_pp","z3_solver_smt_pp", 0 };
"arith_adaptive","arith_adaptive_assertion_threshold","arith_adaptive_gcd","arith_adaptive_propagation_threshold","arith_add_binary_bounds","arith_blands_rule_threshold","arith_branch_cut_ratio","arith_dump_lemmas","arith_eager_eq_axioms","arith_eager_gcd","arith_eq_bounds","arith_euclidean_solver","arith_expand_eqs","arith_force_simplex","arith_gcd_test","arith_ignore_int","arith_lazy_adapter","arith_lazy_pivoting","arith_max_lemma_size","arith_process_all_eqs","arith_propagate_eqs","arith_propagation_mode","arith_propagation_threshold","arith_prop_strategy","arith_random_initial_value","arith_random_lower","arith_random_seed","arith_random_upper","arith_reflect","arith_skip_big_coeffs","arith_small_lemma_size","arith_solver","arith_stronger_lemmas","array_always_prop_upward","array_canonize","array_cg","array_delay_exp_axiom","array_extensional","array_laziness","array_lazy_ieq","array_lazy_ieq_delay","array_solver","array_weak","async_commands","at_labels_cex","auto_config","bb_eager","bb_ext_gates","bb_quantifiers","bin_clauses","bit2int","bv2int_distribute","bv_blast_max_size","bv_cc","bv_enable_int2bv_propagation","bv_lazy_le","bv_max_sharing","bv_reflect","bv_solver","case_split","check_at_labels","check_proof","cnf_factor","cnf_mode","context_simplifier","dack","dack_eq","dack_factor","dack_gc","dack_gc_inv_decay","dack_threshold","default_qid","default_table","default_table_checked","delay_units","delay_units_threshold","der","display_config","display_dot_proof","display_error_for_visual_studio","display_features","display_proof","display_unsat_core","distribute_forall","dt_lazy_splits","dump_goal_as_smt","elim_and","elim_bounds","elim_nlarith_quantifiers","elim_quantifiers","elim_term_ite","ematching","engine","eq_propagation","hi_div0","ignore_bad_patterns","ignore_setparameter","instruction_max","inst_gen","interactive","internalizer_nnf","lemma_gc_factor","lemma_gc_half","lemma_gc_initial","lemma_gc_new_clause_activity","lemma_gc_new_clause_relevancy","lemma_gc_new_old_ratio","lemma_gc_old_clause_activity","lemma_gc_old_clause_relevancy","lemma_gc_strategy","lift_ite","lookahead_diseq","macro_finder","max_conflicts","max_counterexamples","mbqi","mbqi_force_template","mbqi_max_cexs","mbqi_max_cexs_incr","mbqi_max_iterations","mbqi_trace","minimize_lemmas","model","model_compact","model_completion","model_display_arg_sort","model_hide_unused_partitions","model_on_final_check","model_on_timeout","model_partial","model_v1","model_v2","model_validate","new_core2th_eq","ng_lift_ite","nl_arith","nl_arith_branching","nl_arith_gb","nl_arith_gb_eqs","nl_arith_gb_perturbate","nl_arith_gb_threshold","nl_arith_max_degree","nl_arith_rounds","nnf_factor","nnf_ignore_labels","nnf_mode","nnf_sk_hack","order","order_var_weight","order_weights","phase_selection","pi_arith","pi_arith_weight","pi_avoid_skolems","pi_block_looop_patterns","pi_max_multi_patterns","pi_non_nested_arith_weight","pi_nopat_weight","pi_pull_quantifiers","pi_use_database","pi_warnings","pp_bounded","pp_bv_literals","pp_bv_neg","pp_decimal","pp_decimal_precision","pp_fixed_indent","pp_flat_assoc","pp_max_depth","pp_max_indent","pp_max_num_lines","pp_max_ribbon","pp_max_width","pp_min_alias_size","pp_simplify_implies","pp_single_line","precedence","precedence_gen","pre_demodulator","pre_simplifier","pre_simplify_expr","profile_res_sub","progress_sampling_freq","proof_mode","propagate_booleans","propagate_values","pull_cheap_ite_trees","pull_nested_quantifiers","qi_conservative_final_check","qi_cost","qi_eager_threshold","qi_lazy_instantiation","qi_lazy_quick_checker","qi_lazy_threshold","qi_max_eager_multi_patterns","qi_max_instances","qi_max_lazy_multi_pattern_matching","qi_new_gen","qi_profile","qi_profile_freq","qi_promote_unsat","qi_quick_checker","quasi_macros","random_case_split_freq","random_initial_activity","random_seed","recent_lemma_threshold","reduce_args","refine_inj_axiom","relevancy","relevancy_lemma","rel_case_split_order","restart_adaptive","restart_agility_threshold","restart_factor","restart_initial","restart_strategy","restricted_quasi_macros","simplify_clauses","smtlib2_compliant","smtlib_category","smtlib_dump_lemmas","smtlib_logic","smtlib_source_info","smtlib_trace_path","soft_timeout","solver","spc_bs","spc_es","spc_factor_subsumption_index_opt","spc_initial_subsumption_index_opt","spc_max_subsumption_index_features","spc_min_func_freq_subsumption_index","spc_num_iterations","spc_trace","statistics","strong_context_simplifier","tick","trace","trace_file_name","type_check","user_theory_persist_axioms","user_theory_preprocess_axioms","verbose","warning","well_sorted_check","z3_solver_ll_pp","z3_solver_smt_pp", nullptr };
bool is_old_param_name(symbol const & name) {
char const * const * it = g_old_params_names;
@ -64,7 +64,7 @@ static char const * g_params_renames[] = {
"pp_bv_neg", "pp.bv_neg",
"pp_max_depth", "pp.max_depth",
"pp_min_alias_size", "pp.min_alias_size",
0 };
nullptr };
char const * get_new_param_name(symbol const & p) {
char const * const * it = g_params_renames;
@ -75,7 +75,7 @@ char const * get_new_param_name(symbol const & p) {
}
it += 2;
}
return 0;
return nullptr;
}
struct gparams::imp {
@ -191,7 +191,7 @@ public:
return m_params;
}
else {
params_ref * p = 0;
params_ref * p = nullptr;
if (!m_module_params.find(mod_name, p)) {
p = alloc(params_ref);
m_module_params.insert(mod_name, p);
@ -279,7 +279,7 @@ public:
throw_unknown_parameter(param_name, d, mod_name);
}
else if (k == CPK_UINT) {
long val = strtol(value, 0, 10);
long val = strtol(value, nullptr, 10);
ps.set_uint(param_name, static_cast<unsigned>(val));
}
else if (k == CPK_DOUBLE) {
@ -374,7 +374,7 @@ public:
throw_unknown_parameter(p, d, m);
}
char const * r = d.get_default(p);
if (r == 0)
if (r == nullptr)
return "default";
return r;
}
@ -397,7 +397,7 @@ public:
}
}
else {
params_ref * ps = 0;
params_ref * ps = nullptr;
if (m_module_params.find(m, ps) && ps->contains(p)) {
r = get_value(*ps, p);
}
@ -429,7 +429,7 @@ public:
// so better create a local copy of the parameters.
params_ref get_module(symbol const & module_name) {
params_ref result;
params_ref * ps = 0;
params_ref * ps = nullptr;
#pragma omp critical (gparams)
{
if (m_module_params.find(module_name, ps)) {
@ -470,7 +470,7 @@ public:
dictionary<param_descrs*>::iterator end = get_module_param_descrs().end();
for (; it != end; ++it) {
out << "[module] " << it->m_key;
char const * descr = 0;
char const * descr = nullptr;
if (get_module_descrs().find(it->m_key, descr)) {
out << ", description: " << descr;
}
@ -487,7 +487,7 @@ public:
dictionary<param_descrs*>::iterator end = get_module_param_descrs().end();
for (; it != end; ++it) {
out << "[module] " << it->m_key;
char const * descr = 0;
char const * descr = nullptr;
if (get_module_descrs().find(it->m_key, descr)) {
out << ", description: " << descr;
}
@ -502,14 +502,14 @@ public:
#pragma omp critical (gparams)
{
try {
param_descrs * d = 0;
param_descrs * d = nullptr;
if (!get_module_param_descrs().find(module_name, d)) {
std::stringstream strm;
strm << "unknown module '" << module_name << "'";
throw exception(strm.str());
}
out << "[module] " << module_name;
char const * descr = 0;
char const * descr = nullptr;
if (get_module_descrs().find(module_name, descr)) {
out << ", description: " << descr;
}
@ -568,7 +568,7 @@ public:
}
};
gparams::imp * gparams::g_imp = 0;
gparams::imp * gparams::g_imp = nullptr;
void gparams::reset() {
SASSERT(g_imp != 0);
@ -653,9 +653,9 @@ void gparams::init() {
void gparams::finalize() {
TRACE("gparams", tout << "gparams::finalize()\n";);
if (g_imp != 0) {
if (g_imp != nullptr) {
dealloc(g_imp);
g_imp = 0;
g_imp = nullptr;
}
}

View file

@ -47,7 +47,7 @@ public:
set_global_param('pp.decimal', 'true')
will set the parameter "decimal" in the module "pp" to true.
An exception is thrown if the the parameter name is unknown, or if the value is incorrect.
An exception is thrown if the parameter name is unknown, or if the value is incorrect.
*/
static void set(char const * name, char const * value);
static void set(symbol const & name, char const * value);
@ -57,7 +57,7 @@ public:
If the parameter is not set, then it just returns 'default'.
An exception is thrown if the the parameter name is unknown.
An exception is thrown if the parameter name is unknown.
*/
static std::string get_value(char const * name);
static std::string get_value(symbol const & name);

View file

@ -92,9 +92,9 @@ class ptr_hash_entry {
T * m_ptr;
public:
typedef T * data;
ptr_hash_entry():m_ptr(0) {}
ptr_hash_entry():m_ptr(nullptr) {}
unsigned get_hash() const { return m_hash; }
bool is_free() const { return m_ptr == 0; }
bool is_free() const { return m_ptr == nullptr; }
bool is_deleted() const { return m_ptr == reinterpret_cast<T *>(1); }
bool is_used() const { return m_ptr != reinterpret_cast<T *>(0) && m_ptr != reinterpret_cast<T *>(1); }
T * get_data() const { return m_ptr; }
@ -102,7 +102,7 @@ public:
void set_data(T * d) { m_ptr = d; }
void set_hash(unsigned h) { m_hash = h; }
void mark_as_deleted() { m_ptr = reinterpret_cast<T *>(1); }
void mark_as_free() { m_ptr = 0; }
void mark_as_free() { m_ptr = nullptr; }
};
@ -115,9 +115,9 @@ class ptr_addr_hash_entry : public ptr_hash_entry<T> {
T * m_ptr;
public:
typedef T * data;
ptr_addr_hash_entry():m_ptr(0) {}
ptr_addr_hash_entry():m_ptr(nullptr) {}
unsigned get_hash() const { return get_ptr_hash(m_ptr); }
bool is_free() const { return m_ptr == 0; }
bool is_free() const { return m_ptr == nullptr; }
bool is_deleted() const { return m_ptr == reinterpret_cast<T *>(1); }
bool is_used() const { return m_ptr != reinterpret_cast<T *>(0) && m_ptr != reinterpret_cast<T *>(1); }
T * get_data() const { return m_ptr; }
@ -146,7 +146,7 @@ protected:
void delete_table() {
dealloc_vect(m_table, m_capacity);
m_table = 0;
m_table = nullptr;
}
public:
@ -385,7 +385,7 @@ public:
entry * begin = m_table + idx;
entry * end = m_table + m_capacity;
entry * curr = begin;
entry * del_entry = 0;
entry * del_entry = nullptr;
for (; curr != end; ++curr) {
INSERT_LOOP_BODY();
}
@ -441,7 +441,7 @@ public:
entry * begin = m_table + idx;
entry * end = m_table + m_capacity;
entry * curr = begin;
entry * del_entry = 0;
entry * del_entry = nullptr;
for (; curr != end; ++curr) {
INSERT_LOOP_CORE_BODY();
}
@ -449,7 +449,7 @@ public:
INSERT_LOOP_CORE_BODY();
}
UNREACHABLE();
return 0;
return false;
}
bool insert_if_not_there_core(const data & e, entry * & et) {
@ -506,12 +506,12 @@ public:
for (curr = m_table; curr != begin; ++curr) {
FIND_LOOP_BODY();
}
return 0;
return nullptr;
}
bool find(data const & k, data & r) const {
entry * e = find_core(k);
if (e != 0) {
if (e != nullptr) {
r = e->get_data();
return true;
}
@ -519,7 +519,7 @@ public:
}
bool contains(data const & e) const {
return find_core(e) != 0;
return find_core(e) != nullptr;
}
iterator find(data const & e) const {
@ -602,9 +602,8 @@ public:
core_hashtable& operator|=(core_hashtable const& other) {
if (this == &other) return *this;
iterator i = other.begin(), e = other.end();
for (; i != e; ++i) {
insert(*i);
for (const data& d : other) {
insert(d);
}
return *this;
}
@ -612,10 +611,9 @@ public:
core_hashtable& operator&=(core_hashtable const& other) {
if (this == &other) return *this;
core_hashtable copy(*this);
iterator i = copy.begin(), e = copy.end();
for (; i != e; ++i) {
if (!other.contains(*i)) {
remove(*i);
for (const data& d : copy) {
if (!other.contains(d)) {
remove(d);
}
}
return *this;
@ -624,9 +622,8 @@ public:
core_hashtable& operator=(core_hashtable const& other) {
if (this == &other) return *this;
reset();
iterator i = other.begin(), e = other.end();
for (; i != e; ++i) {
insert(*i);
for (const data& d : other) {
insert(d);
}
return *this;
}

View file

@ -28,7 +28,7 @@ class list {
list * m_tail;
public:
list(T const & h, list * t = 0):
list(T const & h, list * t = nullptr):
m_head(h),
m_tail(t) {
}
@ -73,7 +73,7 @@ unsigned length(list<T> * l) {
*/
template<typename T>
list<T> * append(region & r, list<T> * l1, list<T> * l2) {
if (l2 == 0) {
if (l2 == nullptr) {
return l1;
}
ptr_buffer<list<T> > buffer;

View file

@ -86,7 +86,7 @@ public:
unsigned get_column_width(unsigned column);
unsigned regular_cell_width(unsigned row, unsigned column, std::string name) {
unsigned regular_cell_width(unsigned row, unsigned column, const std::string & name) {
return regular_cell_string(row, column, name).size();
}

View file

@ -79,13 +79,14 @@ public:
void apply_from_left_to_X(vector<X> & w, lp_settings & );
virtual void set_number_of_rows(unsigned /*m*/) {}
virtual void set_number_of_columns(unsigned /*n*/) { }
void set_number_of_rows(unsigned /*m*/) override {}
void set_number_of_columns(unsigned /*n*/) override {}
#ifdef Z3DEBUG
T get_elem(unsigned i, unsigned j) const override { return m_values[i * m_n + j]; }
#endif
T get_elem(unsigned i, unsigned j) const { return m_values[i * m_n + j]; }
unsigned row_count() const { return m_m; }
unsigned column_count() const { return m_n; }
unsigned row_count() const override { return m_m; }
unsigned column_count() const override { return m_n; }
void set_elem(unsigned i, unsigned j, const T& val) { m_values[i * m_n + j] = val; }

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,15 +80,15 @@ 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
unsigned row_count() const { return m_length; }
unsigned column_count() const { return m_length; }
void set_number_of_rows(unsigned m) { m_length = m; }
void set_number_of_columns(unsigned n) { m_length = n; }
T get_elem(unsigned i, unsigned j) const override;
unsigned row_count() const override { return m_length; }
unsigned column_count() const override { return m_length; }
void set_number_of_rows(unsigned m) override { m_length = m; }
void set_number_of_columns(unsigned n) override { m_length = n; }
#endif
void divide_by_diagonal_element() {
m_column_vector.divide(m_diagonal_element);

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

@ -481,7 +481,7 @@ public:
}
bool no_r_lu() const {
return m_r_solver.m_factorization == nullptr || m_r_solver.m_factorization->get_status() == LU_status::Degenerated;
return m_r_solver.m_factorization == nullptr || m_r_solver.m_factorization->get_status() == LU_status::Degenerated;
}
void solve_on_signature_tableau(const lar_solution_signature & signature, const vector<unsigned> & changes_of_basis) {

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())
@ -1157,7 +1157,7 @@ public:
bool explanation_is_correct(const vector<std::pair<mpq, unsigned>>& explanation) const {
#ifdef Z3DEBUG
lconstraint_kind kind;
lconstraint_kind kind = EQ; // initialize it just to avoid a warning
SASSERT(the_relations_are_of_same_type(explanation, kind));
SASSERT(the_left_sides_sum_to_zero(explanation));
mpq rs = sum_of_right_sides_of_explanation(explanation);

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

@ -34,6 +34,7 @@ template void lp::lp_solver<double, double>::print_statistics_on_A(std::ostream
template bool lp::lp_solver<double, double>::problem_is_empty();
template void lp::lp_solver<double, double>::scale();
template void lp::lp_solver<double, double>::set_scaled_cost(unsigned int);
template std::string lp::lp_solver<double, double>::get_column_name(unsigned int) const;
template lp::lp_solver<double, double>::~lp_solver();
template void lp::lp_solver<lp::mpq, lp::mpq>::add_constraint(lp::lp_relation, lp::mpq, unsigned int);
template void lp::lp_solver<lp::mpq, lp::mpq>::cleanup();
@ -53,3 +54,4 @@ template void lp::lp_solver<lp::mpq, lp::mpq>::scale();
template void lp::lp_solver<lp::mpq, lp::mpq>::set_scaled_cost(unsigned int);
template lp::lp_solver<lp::mpq, lp::mpq>::~lp_solver();
template double lp::lp_solver<double, double>::get_column_value_by_name(std::string) const;
template std::string lp::lp_solver<lp::mpq, lp::mpq>::get_column_name(unsigned int) const;

View file

@ -67,31 +67,31 @@ 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);
#ifdef Z3DEBUG
unsigned m_m;
unsigned m_n;
virtual void set_number_of_rows(unsigned m) { m_m = m; m_n = m; }
virtual void set_number_of_columns(unsigned n) { m_m = n; m_n = n; }
void set_number_of_rows(unsigned m) override { m_m = m; m_n = m; }
void set_number_of_columns(unsigned n) override { m_m = n; m_n = n; }
T m_one_over_val;
T get_elem (unsigned i, unsigned j) const;
T get_elem (unsigned i, unsigned j) const override;
unsigned row_count() const { return m_m; } // not defined }
unsigned column_count() const { return m_m; } // not defined }
unsigned row_count() const override { return m_m; } // not defined }
unsigned column_count() const override { 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

@ -95,7 +95,7 @@ inline vector<std::string> string_split(const std::string &source, const char *d
return results;
}
inline vector<std::string> split_and_trim(std::string line) {
inline vector<std::string> split_and_trim(const std::string &line) {
auto split = string_split(line, " \t", false);
vector<std::string> ret;
for (auto s : split) {
@ -127,9 +127,9 @@ class mps_reader {
std::string m_name;
bound * m_bound;
unsigned m_index;
column(std::string name, unsigned index): m_name(name),
m_bound(nullptr),
m_index(index) {
column(const std::string &name, unsigned index): m_name(name),
m_bound(nullptr),
m_index(index) {
}
};
@ -140,7 +140,7 @@ class mps_reader {
unsigned m_index;
T m_right_side;
T m_range;
row(row_type type, std::string name, unsigned index) :
row(row_type type, const std::string &name, unsigned index) :
m_type(type),
m_name(name),
m_index(index),
@ -254,7 +254,7 @@ class mps_reader {
} while (m_is_OK);
}
void read_column_by_columns(std::string column_name, std::string column_data) {
void read_column_by_columns(const std::string & column_name, std::string column_data) {
// uph, let us try to work with columns
if (column_data.size() >= 22) {
std::string ss = column_data.substr(0, 8);
@ -283,7 +283,7 @@ class mps_reader {
}
}
void read_column(std::string column_name, std::string column_data){
void read_column(const std::string & column_name, const std::string & column_data){
auto tokens = split_and_trim(column_data);
for (unsigned i = 0; i < tokens.size() - 1; i+= 2) {
auto row_name = tokens[i];
@ -421,7 +421,7 @@ class mps_reader {
}
void read_bound_by_columns(std::string colstr) {
void read_bound_by_columns(const std::string & colstr) {
if (colstr.size() < 14) {
(*m_message_stream) << "line is too short" << std::endl;
(*m_message_stream) << m_line << std::endl;
@ -763,7 +763,7 @@ public:
}
}
mps_reader(std::string file_name):
mps_reader(const std::string & file_name):
m_is_OK(true),
m_file_name(file_name),
m_file_stream(file_name),

View file

@ -38,10 +38,10 @@ template <typename T> class numeric_traits {};
template <> class numeric_traits<unsigned> {
public:
static bool precise() { return true; }
static unsigned const zero() { return 0; }
static unsigned const one() { return 1; }
static unsigned zero() { return 0; }
static unsigned one() { return 1; }
static bool is_zero(unsigned v) { return v == 0; }
static double const get_double(unsigned const & d) { return d; }
static double get_double(unsigned const & d) { return d; }
};
template <> class numeric_traits<double> {
@ -66,7 +66,7 @@ template <> class numeric_traits<double> {
static rational const & zero() { return rational::zero(); }
static rational const & one() { return rational::one(); }
static bool is_zero(const rational & v) { return v.is_zero(); }
static double const get_double(const rational & d) { return d.get_double();}
static double get_double(const rational & d) { return d.get_double();}
static rational log(rational const& r) { UNREACHABLE(); return r; }
static rational from_string(std::string const & str) { return rational(str.c_str()); }
static bool is_pos(const rational & d) {return d.is_pos();}

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);
@ -109,13 +109,13 @@ class permutation_matrix : public tail_matrix<T, X> {
void transpose_from_right(unsigned i, unsigned j);
#ifdef Z3DEBUG
T get_elem(unsigned i, unsigned j) const{
T get_elem(unsigned i, unsigned j) const override {
return m_permutation[i] == j? numeric_traits<T>::one() : numeric_traits<T>::zero();
}
unsigned row_count() const{ return size(); }
unsigned column_count() const { return size(); }
virtual void set_number_of_rows(unsigned /*m*/) { }
virtual void set_number_of_columns(unsigned /*n*/) { }
unsigned row_count() const override { return size(); }
unsigned column_count() const override { return size(); }
void set_number_of_rows(unsigned /*m*/) override { }
void set_number_of_columns(unsigned /*n*/) override { }
#endif
void multiply_by_permutation_from_left(permutation_matrix<T, X> & p);

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,16 +74,16 @@ 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
T get_elem(unsigned row, unsigned col) const;
unsigned row_count() const { return m_dimension; }
unsigned column_count() const { return m_dimension; }
void set_number_of_rows(unsigned m) { m_dimension = m; }
void set_number_of_columns(unsigned n) { m_dimension = n; }
T get_elem(unsigned row, unsigned col) const override;
unsigned row_count() const override { return m_dimension; }
unsigned column_count() const override { return m_dimension; }
void set_number_of_rows(unsigned m) override { m_dimension = m; }
void set_number_of_columns(unsigned n) override { m_dimension = n; }
#endif
}; // end of row_eta_matrix
}

View file

@ -162,8 +162,8 @@ public:
unsigned dimension() const {return static_cast<unsigned>(m_row_permutation.size());}
#ifdef Z3DEBUG
unsigned row_count() const {return dimension();}
unsigned column_count() const {return dimension();}
unsigned row_count() const override {return dimension();}
unsigned column_count() const override {return dimension();}
#endif
void init_row_headers();
@ -302,11 +302,11 @@ public:
void solve_U_y_indexed_only(indexed_vector<L> & y, const lp_settings&, vector<unsigned> & sorted_active_rows );
#ifdef Z3DEBUG
T get_elem(unsigned i, unsigned j) const { return get(i, j); }
T get_elem(unsigned i, unsigned j) const override { return get(i, j); }
unsigned get_number_of_rows() const { return dimension(); }
unsigned get_number_of_columns() const { return dimension(); }
virtual void set_number_of_rows(unsigned /*m*/) { }
virtual void set_number_of_columns(unsigned /*n*/) { }
void set_number_of_rows(unsigned /*m*/) override { }
void set_number_of_columns(unsigned /*n*/) override { }
#endif
template <typename L>
L dot_product_with_row (unsigned row, const vector<L> & y) const;

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,18 +207,18 @@ 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;
unsigned row_count() const { return m_parent->row_count();}
unsigned column_count() const { return row_count();}
void set_number_of_rows(unsigned) {}
void set_number_of_columns(unsigned) {};
T get_elem (unsigned i, unsigned j) const override;
unsigned row_count() const override { return m_parent->row_count();}
unsigned column_count() const override { return row_count();}
void set_number_of_rows(unsigned) override {}
void set_number_of_columns(unsigned) override {}
#endif
void conjugate_by_permutation(permutation_matrix<T, X> & q);
};

View file

@ -129,7 +129,7 @@ public:
if (e) {
v = e->get_data().m_value;
}
return (0 != e);
return (nullptr != e);
}
value const& get(key const& k, value const& default_value) const {
@ -164,7 +164,7 @@ public:
bool contains(key const & k) const {
return find_core(k) != 0;
return find_core(k) != nullptr;
}
void remove(key const & k) {

View file

@ -361,7 +361,7 @@ void * memory::allocate(size_t s) {
if (counts_exceeded)
throw_alloc_counts_exceeded();
void * r = malloc(s);
if (r == 0)
if (r == nullptr)
throw_out_of_memory();
*(static_cast<size_t*>(r)) = s;
return static_cast<size_t*>(r) + 1; // we return a pointer to the location after the extra field
@ -389,7 +389,7 @@ void* memory::reallocate(void *p, size_t s) {
if (counts_exceeded)
throw_alloc_counts_exceeded();
void *r = realloc(real_p, s);
if (r == 0)
if (r == nullptr)
throw_out_of_memory();
*(static_cast<size_t*>(r)) = s;
return static_cast<size_t*>(r) + 1; // we return a pointer to the location after the extra field

View file

@ -91,7 +91,7 @@ void deallocf(char const* file, int line, T * ptr) {
template<typename T>
void dealloc(T * ptr) {
if (ptr == 0) return;
if (ptr == nullptr) return;
ptr->~T();
memory::deallocate(ptr);
}
@ -112,7 +112,7 @@ T * alloc_vect(unsigned sz) {
template<typename T>
void dealloc_vect(T * ptr, unsigned sz) {
if (ptr == 0) return;
if (ptr == nullptr) return;
T * curr = ptr;
for (unsigned i = 0; i < sz; i++, curr++)
curr->~T();
@ -123,7 +123,7 @@ void dealloc_vect(T * ptr, unsigned sz) {
template<typename T>
void dealloc_svect(T * ptr) {
if (ptr == 0) return;
if (ptr == nullptr) return;
memory::deallocate(ptr);
}

View file

@ -2045,7 +2045,7 @@ void mpf_manager::round(mpf_rounding_mode rm, mpf & o) {
bool inc = false;
switch (rm) {
case MPF_ROUND_NEAREST_TEVEN: inc = round && (last || sticky); break;
case MPF_ROUND_NEAREST_TAWAY: inc = round && (!last || sticky); break;
case MPF_ROUND_NEAREST_TAWAY: inc = round; break;
case MPF_ROUND_TOWARD_POSITIVE: inc = (!o.sign && (round || sticky)); break;
case MPF_ROUND_TOWARD_NEGATIVE: inc = (o.sign && (round || sticky)); break;
case MPF_ROUND_TOWARD_ZERO: inc = false; break;

View file

@ -190,8 +190,8 @@ public:
void mk_pinf(unsigned ebits, unsigned sbits, mpf & o);
void mk_ninf(unsigned ebits, unsigned sbits, mpf & o);
unsynch_mpz_manager & mpz_manager(void) { return m_mpz_manager; }
unsynch_mpq_manager & mpq_manager(void) { return m_mpq_manager; }
unsynch_mpz_manager & mpz_manager() { return m_mpz_manager; }
unsynch_mpq_manager & mpq_manager() { return m_mpq_manager; }
unsigned hash(mpf const & a) {
return hash_u_u(m_mpz_manager.hash(a.significand),

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

@ -201,7 +201,7 @@ void mpfx_manager::set(mpfx & n, uint64 v) {
n.m_sign = 0;
unsigned * w = words(n);
uint64 * _vp = &v;
unsigned * _v = 0;
unsigned * _v = nullptr;
memcpy(&_v, &_vp, sizeof(unsigned*));
for (unsigned i = 0; i < m_total_sz; i++)
w[i] = 0;

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

@ -92,9 +92,9 @@ class mpz {
friend class mpbq_manager;
mpz & operator=(mpz const & other) { UNREACHABLE(); return *this; }
public:
mpz(int v):m_val(v), m_ptr(0) {}
mpz():m_val(0), m_ptr(0) {}
mpz(mpz && other) : m_val(other.m_val), m_ptr(0) {
mpz(int v):m_val(v), m_ptr(nullptr) {}
mpz():m_val(0), m_ptr(nullptr) {}
mpz(mpz && other) : m_val(other.m_val), m_ptr(nullptr) {
std::swap(m_ptr, other.m_ptr);
}
void swap(mpz & other) {
@ -187,7 +187,7 @@ class mpz_manager {
/**
\brief Set \c a with the value stored at m_tmp[IDX], and the given sign.
\c sz is an overapproximation of the the size of the number stored at \c tmp.
\c sz is an overapproximation of the size of the number stored at \c tmp.
*/
template<int IDX>
void set(mpz & a, int sign, unsigned sz);
@ -333,16 +333,16 @@ public:
~mpz_manager();
static bool is_small(mpz const & a) { return a.m_ptr == 0; }
static bool is_small(mpz const & a) { return a.m_ptr == nullptr; }
static mpz mk_z(int val) { return mpz(val); }
void del(mpz & a) {
if (a.m_ptr != 0) {
if (a.m_ptr != nullptr) {
MPZ_BEGIN_CRITICAL();
deallocate(a.m_ptr);
MPZ_END_CRITICAL();
a.m_ptr = 0;
a.m_ptr = nullptr;
}
}

View file

@ -33,9 +33,9 @@ class obj_hash_entry {
T * m_ptr;
public:
typedef T * data;
obj_hash_entry():m_ptr(0) {}
obj_hash_entry():m_ptr(nullptr) {}
unsigned get_hash() const { return m_ptr->hash(); }
bool is_free() const { return m_ptr == 0; }
bool is_free() const { return m_ptr == nullptr; }
bool is_deleted() const { return m_ptr == reinterpret_cast<T *>(1); }
bool is_used() const { return m_ptr != reinterpret_cast<T *>(0) && m_ptr != reinterpret_cast<T *>(1); }
T * get_data() const { return m_ptr; }
@ -43,7 +43,7 @@ public:
void set_data(T * d) { m_ptr = d; }
void set_hash(unsigned h) { SASSERT(h == m_ptr->hash()); }
void mark_as_deleted() { m_ptr = reinterpret_cast<T *>(1); }
void mark_as_free() { m_ptr = 0; }
void mark_as_free() { m_ptr = nullptr; }
};
template<typename T>
@ -60,7 +60,7 @@ public:
struct key_data {
Key * m_key;
Value m_value;
key_data():m_key(0) {
key_data():m_key(nullptr) {
}
key_data(Key * k):
m_key(k) {
@ -85,7 +85,7 @@ public:
typedef key_data data;
obj_map_entry() {}
unsigned get_hash() const { return m_data.hash(); }
bool is_free() const { return m_data.m_key == 0; }
bool is_free() const { return m_data.m_key == nullptr; }
bool is_deleted() const { return m_data.m_key == reinterpret_cast<Key *>(1); }
bool is_used() const { return m_data.m_key != reinterpret_cast<Key *>(0) && m_data.m_key != reinterpret_cast<Key *>(1); }
key_data const & get_data() const { return m_data; }
@ -93,7 +93,7 @@ public:
void set_data(key_data && d) { m_data = std::move(d); }
void set_hash(unsigned h) { SASSERT(h == m_data.hash()); }
void mark_as_deleted() { m_data.m_key = reinterpret_cast<Key *>(1); }
void mark_as_free() { m_data.m_key = 0; }
void mark_as_free() { m_data.m_key = nullptr; }
};
typedef core_hashtable<obj_map_entry, obj_hash<key_data>, default_eq<key_data> > table;
@ -163,7 +163,7 @@ public:
if (e) {
v = e->get_data().m_value;
}
return (0 != e);
return (nullptr != e);
}
value const & find(key * k) const {
@ -191,7 +191,7 @@ public:
}
bool contains(Key * k) const {
return find_core(k) != 0;
return find_core(k) != nullptr;
}
void remove(Key * k) {

View file

@ -34,7 +34,7 @@ class obj_pair_hash_entry {
public:
typedef std::pair<T1*, T2*> data;
obj_pair_hash_entry():m_data(static_cast<T1*>(0),static_cast<T2*>(0)) {}
obj_pair_hash_entry():m_data(static_cast<T1*>(nullptr),static_cast<T2*>(nullptr)) {}
unsigned get_hash() const { return m_hash; }
bool is_free() const { return m_data.first == 0; }
bool is_deleted() const { return m_data.first == reinterpret_cast<T1 *>(1); }
@ -68,8 +68,8 @@ public:
friend class entry;
public:
key_data():
m_key1(0),
m_key2(0),
m_key1(nullptr),
m_key2(nullptr),
m_hash(0) {
}
key_data(Key1 * k1, Key2 * k2):
@ -96,7 +96,7 @@ protected:
typedef key_data data;
entry() {}
unsigned get_hash() const { return m_data.hash(); }
bool is_free() const { return m_data.m_key1 == 0; }
bool is_free() const { return m_data.m_key1 == nullptr; }
bool is_deleted() const { return m_data.m_key1 == reinterpret_cast<Key1 *>(1); }
bool is_used() const { return m_data.m_key1 != reinterpret_cast<Key1 *>(0) && m_data.m_key1 != reinterpret_cast<Key1 *>(1); }
key_data const & get_data() const { return m_data; }
@ -104,7 +104,7 @@ protected:
void set_data(key_data const & d) { m_data = d; }
void set_hash(unsigned h) { SASSERT(h == m_data.hash()); }
void mark_as_deleted() { m_data.m_key1 = reinterpret_cast<Key1 *>(1); }
void mark_as_free() { m_data.m_key1 = 0; }
void mark_as_free() { m_data.m_key1 = nullptr; }
};
typedef core_hashtable<entry, obj_hash<key_data>, default_eq<key_data> > table;
@ -158,11 +158,24 @@ public:
if (e) {
v = e->get_data().get_value();
}
return (0 != e);
return (nullptr != e);
}
Value const & find(Key1 * k1, Key2 * k2) const {
entry * e = find_core(k1, k2);
return e->get_data().get_value();
}
Value const& operator[](std::pair<Key1 *, Key2 *> const& key) const {
return find(key.first, key.second);
}
bool contains(Key1 * k1, Key2 * k2) const {
return find_core(k1, k2) != 0;
return find_core(k1, k2) != nullptr;
}
bool contains(std::pair<Key1 *, Key2 *> const& key) const {
return contains(key.first, key.second);
}
void erase(Key1 * k1, Key2 * k2) {

View file

@ -43,7 +43,7 @@ public:
}
explicit obj_ref(TManager & m):
m_obj(0),
m_obj(nullptr),
m_manager(m) {
}
@ -53,7 +53,7 @@ public:
inc_ref();
}
obj_ref(obj_ref && other) : m_obj(0), m_manager(other.m_manager) {
obj_ref(obj_ref && other) : m_obj(nullptr), m_manager(other.m_manager) {
std::swap(m_obj, other.m_obj);
}
@ -67,9 +67,9 @@ public:
T * get() const { return m_obj; }
operator bool() const { return m_obj != 0; }
operator bool() const { return m_obj != nullptr; }
bool operator!() const { return m_obj == 0; }
bool operator!() const { return m_obj == nullptr; }
operator T*() const { return m_obj; }
@ -94,7 +94,7 @@ public:
void reset() {
dec_ref();
m_obj = 0;
m_obj = nullptr;
}
void swap(obj_ref & n) {

View file

@ -0,0 +1,117 @@
/*++
Copyright (c) 2017 Microsoft Corporation
Module Name:
obj_ref_hashtable.h
Abstract:
corresponding obj_map with reference count managment.
Author:
Nikolaj Bjorner (nbjorner) 2017-12-8
Revision History:
--*/
#ifndef OBJ_REF_HASHTABLE_H_
#define OBJ_REF_HASHTABLE_H_
#include "util/obj_hashtable.h"
template<typename M, typename Key, typename Value>
class obj_ref_map {
M& m;
obj_map<Key, Value> m_table;
public:
typedef typename obj_map<Key, Value> iterator;
typedef Key key;
typedef Value value;
typedef typename obj_map<Key, Value>::key_data key_data;
typedef typename obj_map<Key, Value>::obj_map_entry obj_map_entry;
obj_ref_map(M& m):m(m) {}
~obj_ref_map() { reset(); }
void reset() {
for (auto& kv : m_table) {
m.dec_ref(kv.m_key);
}
m_table.reset();
}
void finalize() {
reset();
m_table.finalize();
}
bool empty() const { return m_table.empty(); }
unsigned size() const { return m_table.size(); }
unsigned capacity() const { return m_table.capacity(); }
iterator begin() const { return m_table.begin(); }
iterator end() const { return m_table.end(); }
void insert(Key * const k, Value const & v) {
if (!m_table.contains(k)) m.inc_ref(k);
m_table.insert(k, v);
}
void insert(Key * const k, Value && v) {
if (!m_table.contains(k)) m.inc_ref(k);
m_table.insert(k, v);
}
key_data const & insert_if_not_there(Key * k, Value const & v) {
if (!m_table.contains(k)) m.inc_ref(k);
return m_table.insert_if_not_there(k, v);
}
obj_map_entry * insert_if_not_there2(Key * k, Value const & v) {
if (!m_table.contains(k)) m.inc_ref(k);
return m_table.insert_if_not_there2(k, v);
}
obj_map_entry * find_core(Key * k) const { return m_table.find_core(k); }
bool find(Key * const k, Value & v) const { return m_table.find(k, v); }
value const & find(key * k) const { return m_table.find(k); }
value & find(key * k) { return m_table.find(k); }
value const & operator[](key * k) const { return find(k); }
value & operator[](key * k) { return find(k); }
iterator find_iterator(Key * k) const { return m_table.find_iterator(k); }
bool contains(Key * k) const { return m_table.contains(k); }
void remove(Key * k) {
if (m_table.contains(k)) {
m_table.remove(k);
m.dec_ref(k);
}
}
void erase(Key * k) { remove(k); }
unsigned long long get_num_collision() const { return m_table.get_num_collision(); }
void swap(obj_ref_map & other) {
m_table.swap(other.m_table);
}
};
#endif /* OBJ_REF_HASHTABLE_H_ */

View file

@ -70,9 +70,9 @@ public:
friend class entry;
public:
key_data():
m_key1(0),
m_key2(0),
m_key3(0),
m_key1(nullptr),
m_key2(nullptr),
m_key3(nullptr),
m_hash(0) {
}
key_data(Key1 * k1, Key2 * k2, Key3 * k3):
@ -102,7 +102,7 @@ protected:
typedef key_data data;
entry() {}
unsigned get_hash() const { return m_data.hash(); }
bool is_free() const { return m_data.m_key1 == 0; }
bool is_free() const { return m_data.m_key1 == nullptr; }
bool is_deleted() const { return m_data.m_key1 == reinterpret_cast<Key1 *>(1); }
bool is_used() const { return m_data.m_key1 != reinterpret_cast<Key1 *>(0) && m_data.m_key1 != reinterpret_cast<Key1 *>(1); }
key_data const & get_data() const { return m_data; }
@ -110,7 +110,7 @@ protected:
void set_data(key_data const & d) { m_data = d; }
void set_hash(unsigned h) { SASSERT(h == m_data.hash()); }
void mark_as_deleted() { m_data.m_key1 = reinterpret_cast<Key1 *>(1); }
void mark_as_free() { m_data.m_key1 = 0; }
void mark_as_free() { m_data.m_key1 = nullptr; }
};
typedef core_hashtable<entry, obj_hash<key_data>, default_eq<key_data> > table;
@ -164,7 +164,7 @@ public:
if (e) {
v = e->get_data().get_value();
}
return (0 != e);
return (nullptr != e);
}
bool contains(Key1 * k1, Key2 * k2, Key3 * k3) const {

View file

@ -34,14 +34,14 @@ class optional {
void destroy() {
if (m_initialized == 1) {
dealloc(m_obj);
m_obj = 0;
m_obj = nullptr;
}
m_initialized = 0;
}
public:
optional():
m_obj(0), m_initialized(0) {}
m_obj(nullptr), m_initialized(0) {}
explicit optional(const T & val) {
construct(val);
@ -128,7 +128,7 @@ class optional<T*> {
public:
optional():m_ptr(0) {}
optional():m_ptr(nullptr) {}
explicit optional(T * val):m_ptr(val) {}
@ -140,7 +140,7 @@ public:
operator bool() const { return m_ptr != 0; }
bool operator!() const { return m_ptr == 0; }
bool operator!() const { return m_ptr == nullptr; }
void reset() { m_ptr = 0; }

View file

@ -31,7 +31,7 @@ inline char * alloc_page(size_t s) { char * r = alloc_svect(char, s+PAGE_HEADER_
inline void del_page(char * page) { dealloc_svect(page - PAGE_HEADER_SZ); }
void del_pages(char * page) {
while (page != 0) {
while (page != nullptr) {
char * prev = prev_page(page);
del_page(page);
page = prev;

View file

@ -24,7 +24,7 @@ Notes:
params_ref params_ref::g_empty_params_ref;
std::string norm_param_name(char const * n) {
if (n == 0)
if (n == nullptr)
return "_";
if (*n == ':')
n++;
@ -62,9 +62,9 @@ struct param_descrs::imp {
info():
m_kind(CPK_INVALID),
m_descr(0),
m_default(0),
m_module(0) {
m_descr(nullptr),
m_default(nullptr),
m_module(nullptr) {
}
};
@ -130,21 +130,21 @@ struct param_descrs::imp {
info i;
if (m_info.find(name, i))
return i.m_module;
return 0;
return nullptr;
}
char const * get_descr(symbol const & name) const {
info i;
if (m_info.find(name, i))
return i.m_descr;
return 0;
return nullptr;
}
char const * get_default(symbol const & name) const {
info i;
if (m_info.find(name, i))
return i.m_default;
return 0;
return nullptr;
}
unsigned size() const {
@ -191,7 +191,7 @@ struct param_descrs::imp {
out << " (" << d.m_kind << ")";
if (include_descr)
out << " " << d.m_descr;
if (d.m_default != 0)
if (d.m_default != nullptr)
out << " (default: " << d.m_default << ")";
out << "\n";
}
@ -521,7 +521,7 @@ params_ref::~params_ref() {
}
params_ref::params_ref(params_ref const & p):
m_params(0) {
m_params(nullptr) {
operator=(p);
}
@ -565,7 +565,7 @@ params_ref & params_ref::operator=(params_ref const & p) {
}
void params_ref::copy(params_ref const & src) {
if (m_params == 0)
if (m_params == nullptr)
operator=(src);
else {
init();
@ -574,7 +574,7 @@ void params_ref::copy(params_ref const & src) {
}
void params_ref::copy_core(params const * src) {
if (src == 0)
if (src == nullptr)
return;
svector<params::entry>::const_iterator it = src->m_entries.begin();
svector<params::entry>::const_iterator end = src->m_entries.end();

View file

@ -37,7 +37,7 @@ class params_ref {
void init();
void copy_core(params const * p);
public:
params_ref():m_params(0) {}
params_ref():m_params(nullptr) {}
params_ref(params_ref const & p);
~params_ref();
@ -115,8 +115,8 @@ public:
param_descrs();
~param_descrs();
void copy(param_descrs & other);
void insert(char const * name, param_kind k, char const * descr, char const * def = 0, char const* module = 0);
void insert(symbol const & name, param_kind k, char const * descr, char const * def = 0, char const* module = 0);
void insert(char const * name, param_kind k, char const * descr, char const * def = nullptr, char const* module = nullptr);
void insert(symbol const & name, param_kind k, char const * descr, char const * def = nullptr, char const* module = nullptr);
bool contains(char const * name) const;
bool contains(symbol const & name) const;
void erase(char const * name);

View file

@ -30,7 +30,7 @@ public:
typedef typename C::allocator allocator;
private:
static size_t capacity(value * vs) {
return vs == 0 ? 0 : (reinterpret_cast<size_t*>(vs))[-1];
return vs == nullptr ? 0 : (reinterpret_cast<size_t*>(vs))[-1];
}
value * allocate_values(size_t c) {
@ -44,7 +44,7 @@ private:
}
void deallocate_values(value * vs) {
if (vs == 0)
if (vs == nullptr)
return;
size_t c = capacity(vs);
TRACE("parray_mem", tout << "deallocated values[" << c << "]: " << vs << "\n";);
@ -73,7 +73,7 @@ private:
unsigned size() const { SASSERT(kind() == ROOT); return m_size; }
cell * next() const { SASSERT(kind() != ROOT); return m_next; }
value const & elem() const { SASSERT(kind() == SET || kind() == PUSH_BACK); return m_elem; }
cell(ckind k):m_ref_count(1), m_kind(k), m_size(0), m_values(0) {}
cell(ckind k):m_ref_count(1), m_kind(k), m_size(0), m_values(nullptr) {}
};
value_manager & m_vmanager;
@ -105,7 +105,7 @@ private:
void del(cell * c) {
while (true) {
cell * next = 0;
cell * next = nullptr;
switch (c->kind()) {
case SET:
case PUSH_BACK:
@ -123,7 +123,7 @@ private:
TRACE("parray_mem", tout << "deallocated cell: " << c << "\n";);
c->~cell();
m_allocator.deallocate(sizeof(cell), c);
if (next == 0)
if (next == nullptr)
return;
SASSERT(next->m_ref_count > 0);
next->m_ref_count--;
@ -214,7 +214,7 @@ private:
}
SASSERT(r->kind() == ROOT);
unsigned sz = r->m_size;
vs = 0;
vs = nullptr;
copy_values(r->m_values, sz, vs);
unsigned i = cs.size();
while (i > 0) {
@ -246,7 +246,7 @@ private:
dec_ref(c->m_next);
if (c->kind() == SET || c->kind() == PUSH_BACK)
dec_ref(c->m_elem);
c->m_next = 0;
c->m_next = nullptr;
c->m_kind = ROOT;
c->m_size = sz;
c->m_values = vs;
@ -262,7 +262,7 @@ public:
bool unshared() const { return m_ref->m_ref_count == 1; }
friend class parray_manager;
public:
ref():m_ref(0), m_updt_counter(0) {}
ref():m_ref(nullptr), m_updt_counter(0) {}
};
public:
@ -283,7 +283,7 @@ public:
void del(ref & r) {
dec_ref(r.m_ref);
r.m_ref = 0;
r.m_ref = nullptr;
r.m_updt_counter = 0;
}
@ -296,7 +296,7 @@ public:
unsigned size(ref const & r) const {
cell * c = r.m_ref;
if (c == 0) return 0;
if (c == nullptr) return 0;
while (true) {
switch (c->kind()) {
case SET:
@ -397,7 +397,7 @@ public:
}
void push_back(ref & r, value const & v) {
if (r.m_ref == 0)
if (r.m_ref == nullptr)
mk(r);
if (r.root()) {
if (r.unshared()) {

View file

@ -48,7 +48,7 @@ public:
Plugin * get_plugin(family_id fid) const {
if (fid == null_family_id) {
return 0;
return nullptr;
}
return m_fid2plugins.get(fid, 0);
}

View file

@ -99,7 +99,7 @@ uint64 prime_generator::operator()(unsigned idx) {
prime_generator g_prime_generator;
prime_iterator::prime_iterator(prime_generator * g):m_idx(0) {
if (g == 0) {
if (g == nullptr) {
m_generator = &g_prime_generator;
m_global = true;
}

View file

@ -45,7 +45,7 @@ class prime_iterator {
prime_generator * m_generator;
bool m_global;
public:
prime_iterator(prime_generator * g = 0);
prime_iterator(prime_generator * g = nullptr);
uint64 next();
static void finalize();
/*

View file

@ -23,7 +23,7 @@ Revision History:
#include<strsafe.h>
#endif
synch_mpq_manager * rational::g_mpq_manager = 0;
synch_mpq_manager * rational::g_mpq_manager = nullptr;
rational rational::m_zero;
rational rational::m_one;
rational rational::m_minus_one;
@ -80,6 +80,6 @@ void rational::finalize() {
m_one.~rational();
m_minus_one.~rational();
dealloc(g_mpq_manager);
g_mpq_manager = 0;
g_mpq_manager = nullptr;
}

View file

@ -37,7 +37,7 @@ class ref {
public:
ref():
m_ptr(0) {
m_ptr(nullptr) {
}
ref(T * ptr):
@ -64,7 +64,7 @@ public:
}
operator bool() const {
return m_ptr != 0;
return m_ptr != nullptr;
}
const T & operator*() const {
@ -100,12 +100,12 @@ public:
void reset() {
dec_ref();
m_ptr = 0;
m_ptr = nullptr;
}
T* detach() {
T* tmp = m_ptr;
m_ptr = 0;
m_ptr = nullptr;
return tmp;
}

View file

@ -38,11 +38,11 @@ inline void region::allocate_page() {
}
region::region() {
m_curr_page = 0;
m_curr_ptr = 0;
m_curr_end_ptr = 0;
m_free_pages = 0;
m_mark = 0;
m_curr_page = nullptr;
m_curr_ptr = nullptr;
m_curr_end_ptr = nullptr;
m_free_pages = nullptr;
m_mark = nullptr;
allocate_page();
}
@ -81,13 +81,13 @@ inline void region::recycle_curr_page() {
}
void region::reset() {
while (m_curr_page != 0) {
while (m_curr_page != nullptr) {
recycle_curr_page();
}
SASSERT(m_curr_page == 0);
m_curr_ptr = 0;
m_curr_end_ptr = 0;
m_mark = 0;
m_curr_ptr = nullptr;
m_curr_end_ptr = nullptr;
m_mark = nullptr;
allocate_page();
}
@ -113,7 +113,7 @@ void region::pop_scope() {
void region::display_mem_stats(std::ostream & out) const {
unsigned n = 0;
char * page = m_curr_page;
while (page != 0) {
while (page != nullptr) {
n++;
page = prev_page(page);
}

View file

@ -24,7 +24,7 @@ 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<int>(strtol(str, 0, 10));
m_val = static_cast<int>(strtol(str, nullptr, 10));
}
s_integer power(const s_integer & r, unsigned p) {

View file

@ -20,7 +20,7 @@ Revision History:
#include<iostream>
#include "util/scoped_ctrl_c.h"
scoped_ctrl_c * scoped_ctrl_c::g_obj = 0;
scoped_ctrl_c * scoped_ctrl_c::g_obj = nullptr;
void scoped_ctrl_c::on_ctrl_c(int) {
if (g_obj->m_first) {

View file

@ -30,7 +30,7 @@ public:
~scoped_ptr_vector() { reset(); }
void reset() { std::for_each(m_vector.begin(), m_vector.end(), delete_proc<T>()); m_vector.reset(); }
void push_back(T * ptr) { m_vector.push_back(ptr); }
void pop_back() { SASSERT(!empty()); set(size()-1, 0); m_vector.pop_back(); }
void pop_back() { SASSERT(!empty()); set(size()-1, nullptr); m_vector.pop_back(); }
T * operator[](unsigned idx) const { return m_vector[idx]; }
void set(unsigned idx, T * ptr) {
if (m_vector[idx] == ptr)
@ -48,7 +48,7 @@ public:
}
else {
for (unsigned i = m_vector.size(); i < sz; i++)
push_back(0);
push_back(nullptr);
}
}
};

View file

@ -33,8 +33,8 @@ Revision History:
#include<sys/time.h>
#include<sys/errno.h>
#include<pthread.h>
#elif defined(_LINUX_) || defined(_FREEBSD_)
// Linux
#elif defined(_LINUX_) || defined(_FREEBSD_) || defined(_NetBSD_)
// Linux & FreeBSD & NetBSD
#include<errno.h>
#include<pthread.h>
#include<sched.h>
@ -66,8 +66,8 @@ struct scoped_timer::imp {
pthread_mutex_t m_mutex;
pthread_cond_t m_condition_var;
struct timespec m_end_time;
#elif defined(_LINUX_) || defined(_FREEBSD_)
// Linux & FreeBSD
#elif defined(_LINUX_) || defined(_FREEBSD_) || defined(_NETBSD_)
// Linux & FreeBSD & NetBSD
pthread_t m_thread_id;
pthread_mutex_t m_mutex;
pthread_cond_t m_cond;
@ -104,7 +104,7 @@ struct scoped_timer::imp {
return st;
}
#elif defined(_LINUX_) || defined(_FREEBSD_)
#elif defined(_LINUX_) || defined(_FREEBSD_) || defined(_NETBSD_)
static void* thread_func(void *arg) {
scoped_timer::imp *st = static_cast<scoped_timer::imp*>(arg);
@ -157,9 +157,9 @@ struct scoped_timer::imp {
m_interval = ms?ms:0xFFFFFFFF;
if (pthread_attr_init(&m_attributes) != 0)
throw default_exception("failed to initialize timer thread attributes");
if (pthread_cond_init(&m_condition_var, NULL) != 0)
if (pthread_cond_init(&m_condition_var, nullptr) != 0)
throw default_exception("failed to initialize timer condition variable");
if (pthread_mutex_init(&m_mutex, NULL) != 0)
if (pthread_mutex_init(&m_mutex, nullptr) != 0)
throw default_exception("failed to initialize timer mutex");
clock_serv_t host_clock;
@ -175,8 +175,8 @@ struct scoped_timer::imp {
if (pthread_create(&m_thread_id, &m_attributes, &thread_func, this) != 0)
throw default_exception("failed to start timer thread");
#elif defined(_LINUX_) || defined(_FREEBSD_)
// Linux & FreeBSD
#elif defined(_LINUX_) || defined(_FREEBSD_) || defined(_NETBSD_)
// Linux & FreeBSD & NetBSD
m_ms = ms;
m_initialized = false;
m_signal_sent = false;
@ -208,7 +208,7 @@ struct scoped_timer::imp {
pthread_cond_signal(&m_condition_var);
pthread_mutex_unlock(&m_mutex);
if (pthread_join(m_thread_id, NULL) != 0)
if (pthread_join(m_thread_id, nullptr) != 0)
throw default_exception("failed to join thread");
if (pthread_mutex_destroy(&m_mutex) != 0)
throw default_exception("failed to destroy pthread mutex");
@ -216,8 +216,8 @@ struct scoped_timer::imp {
throw default_exception("failed to destroy pthread condition variable");
if (pthread_attr_destroy(&m_attributes) != 0)
throw default_exception("failed to destroy pthread attributes object");
#elif defined(_LINUX_) || defined(_FREEBSD_)
// Linux & FreeBSD
#elif defined(_LINUX_) || defined(_FREEBSD_) || defined(_NETBSD_)
// Linux & FreeBSD & NetBSD
bool init = false;
// spin until timer thread has been created
@ -248,7 +248,7 @@ scoped_timer::scoped_timer(unsigned ms, event_handler * eh) {
if (ms != UINT_MAX && ms != 0)
m_imp = alloc(imp, ms, eh);
else
m_imp = 0;
m_imp = nullptr;
}
scoped_timer::~scoped_timer() {

View file

@ -27,8 +27,8 @@ Revision History:
small_object_allocator::small_object_allocator(char const * id) {
for (unsigned i = 0; i < NUM_SLOTS; i++) {
m_chunks[i] = 0;
m_free_list[i] = 0;
m_chunks[i] = nullptr;
m_free_list[i] = nullptr;
}
DEBUG_CODE({
m_id = id;
@ -60,8 +60,8 @@ void small_object_allocator::reset() {
dealloc(c);
c = next;
}
m_chunks[i] = 0;
m_free_list[i] = 0;
m_chunks[i] = nullptr;
m_free_list[i] = nullptr;
}
m_alloc_size = 0;
}
@ -95,7 +95,7 @@ void small_object_allocator::deallocate(size_t size, void * p) {
void * small_object_allocator::allocate(size_t size) {
if (size == 0) return 0;
if (size == 0) return nullptr;
#if defined(Z3DEBUG) && !defined(_WINDOWS)
// Valgrind friendly
@ -113,7 +113,7 @@ void * small_object_allocator::allocate(size_t size) {
slot_id++;
SASSERT(slot_id < NUM_SLOTS);
SASSERT(slot_id > 0);
if (m_free_list[slot_id] != 0) {
if (m_free_list[slot_id] != nullptr) {
void * r = m_free_list[slot_id];
m_free_list[slot_id] = *(reinterpret_cast<void **>(r));
return r;
@ -121,7 +121,7 @@ void * small_object_allocator::allocate(size_t size) {
chunk * c = m_chunks[slot_id];
size = slot_id << PTR_ALIGNMENT;
SASSERT(size >= osize);
if (c != 0) {
if (c != nullptr) {
char * new_curr = c->m_curr + size;
if (new_curr < c->m_data + CHUNK_SIZE) {
void * r = c->m_curr;
@ -142,7 +142,7 @@ size_t small_object_allocator::get_wasted_size() const {
for (unsigned slot_id = 0; slot_id < NUM_SLOTS; slot_id++) {
size_t slot_obj_size = slot_id << PTR_ALIGNMENT;
void ** ptr = reinterpret_cast<void **>(const_cast<small_object_allocator*>(this)->m_free_list[slot_id]);
while (ptr != 0) {
while (ptr != nullptr) {
r += slot_obj_size;
ptr = reinterpret_cast<void**>(*ptr);
}
@ -154,7 +154,7 @@ size_t small_object_allocator::get_num_free_objs() const {
size_t r = 0;
for (unsigned slot_id = 0; slot_id < NUM_SLOTS; slot_id++) {
void ** ptr = reinterpret_cast<void **>(const_cast<small_object_allocator*>(this)->m_free_list[slot_id]);
while (ptr != 0) {
while (ptr != nullptr) {
r ++;
ptr = reinterpret_cast<void**>(*ptr);
}
@ -177,17 +177,17 @@ void small_object_allocator::consolidate() {
ptr_vector<chunk> chunks;
ptr_vector<char> free_objs;
for (unsigned slot_id = 1; slot_id < NUM_SLOTS; slot_id++) {
if (m_free_list[slot_id] == 0)
if (m_free_list[slot_id] == nullptr)
continue;
chunks.reset();
free_objs.reset();
chunk * c = m_chunks[slot_id];
while (c != 0) {
while (c != nullptr) {
chunks.push_back(c);
c = c->m_next;
}
char * ptr = static_cast<char*>(m_free_list[slot_id]);
while (ptr != 0) {
while (ptr != nullptr) {
free_objs.push_back(ptr);
ptr = *(reinterpret_cast<char**>(ptr));
}
@ -198,8 +198,8 @@ void small_object_allocator::consolidate() {
SASSERT(!chunks.empty());
std::sort(chunks.begin(), chunks.end(), ptr_lt<chunk>());
std::sort(free_objs.begin(), free_objs.end(), ptr_lt<char>());
chunk * last_chunk = 0;
void * last_free_obj = 0;
chunk * last_chunk = nullptr;
void * last_free_obj = nullptr;
unsigned chunk_idx = 0;
unsigned obj_idx = 0;
unsigned num_chunks = chunks.size();

View file

@ -29,7 +29,7 @@ bool is_smt2_simple_symbol_char(char s) {
}
bool is_smt2_quoted_symbol(char const * s) {
if (s == 0)
if (s == nullptr)
return false;
if ('0' <= s[0] && s[0] <= '9')
return true;

View file

@ -1,10 +1,20 @@
/*
Copyright (c) 2013 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Copyright (c) 2018 Microsoft Corporation
Module Name:
nat_set.h
Abstract:
Wrapper for sstream.
Author:
Leonardo de Moura (leonardo) 2013
Revision History:
Author: Leonardo de Moura
*/
#pragma once
#include <sstream>

View file

@ -62,10 +62,10 @@ inline void stack::store_mark(void * ptr, bool external) {
}
stack::stack() {
m_curr_page = 0;
m_curr_ptr = 0;
m_curr_end_ptr = 0;
m_free_pages = 0;
m_curr_page = nullptr;
m_curr_ptr = nullptr;
m_curr_end_ptr = nullptr;
m_free_pages = nullptr;
allocate_page(0);
SASSERT(empty());
}

View file

@ -29,7 +29,7 @@ inline void print_stat(std::ostream& out, char const* msg, unsigned num) {
}
inline void print_stat_f(std::ostream& out, char const* msg, float num) {
if (num > 0.0) {
if (num > 0.0f) {
out << msg << num << "\n";
}
}

View file

@ -134,6 +134,11 @@ public:
#include<ctime>
#ifndef CLOCK_PROCESS_CPUTIME_ID
/* BSD */
# define CLOCK_PROCESS_CPUTIME_ID CLOCK_MONOTONIC
#endif
class stopwatch {
unsigned long long m_time; // elapsed time in ns
bool m_running;

View file

@ -22,7 +22,7 @@ Revision History:
#include "util/string_buffer.h"
#include "util/z3_omp.h"
symbol symbol::m_dummy(TAG(void*, static_cast<void*>(0), 2));
symbol symbol::m_dummy(TAG(void*, nullptr, 2));
const symbol symbol::null;
/**
@ -60,7 +60,7 @@ public:
}
};
internal_symbol_table* g_symbol_table = 0;
internal_symbol_table* g_symbol_table = nullptr;
void initialize_symbols() {
if (!g_symbol_table) {
@ -70,12 +70,12 @@ void initialize_symbols() {
void finalize_symbols() {
dealloc(g_symbol_table);
g_symbol_table = 0;
g_symbol_table = nullptr;
}
symbol::symbol(char const * d) {
if (d == 0)
m_data = 0;
if (d == nullptr)
m_data = nullptr;
else
m_data = g_symbol_table->get_str(d);
}
@ -103,7 +103,7 @@ std::string symbol::str() const {
bool symbol::contains(char ch) const {
SASSERT(!is_marked());
if (GET_TAG(m_data) == 0) {
return strchr(m_data, ch) != 0;
return strchr(m_data, ch) != nullptr;
}
else {
return false;

View file

@ -51,7 +51,7 @@ class symbol {
static symbol m_dummy;
public:
symbol():
m_data(0) {
m_data(nullptr) {
}
explicit symbol(char const * d);
explicit symbol(unsigned idx):
@ -69,9 +69,9 @@ public:
unsigned int get_num() const { SASSERT(is_numerical()); return UNBOXINT(m_data); }
std::string str() const;
friend bool operator==(symbol const & s1, char const * s2) {
if (s1.m_data == 0 && s2 == 0)
if (s1.m_data == nullptr && s2 == nullptr)
return true;
if (s1.m_data == 0 || s2 == 0)
if (s1.m_data == nullptr || s2 == nullptr)
return false;
if (!s1.is_numerical())
return strcmp(s1.bare_str(), s2) == 0;
@ -87,7 +87,7 @@ public:
return s;
}
unsigned hash() const {
if (m_data == 0) return 0x9e3779d9;
if (m_data == nullptr) return 0x9e3779d9;
else if (is_numerical()) return get_num();
else return static_cast<unsigned>(reinterpret_cast<size_t const *>(m_data)[-1]);
}

View file

@ -121,7 +121,7 @@ public:
bool find(symbol key, T & result) const {
key_data dummy(key);
hash_entry * e = m_sym_table.find_core(dummy);
if (e == 0) {
if (e == nullptr) {
return false;
}
result = e->get_data().m_data;
@ -140,7 +140,7 @@ public:
if (get_scope_level() > 0) {
key_data dummy(key);
hash_entry * e = m_sym_table.find_core(dummy);
if (e != 0) {
if (e != nullptr) {
m_trail_stack.push_back(e->m_data);
e->m_data.m_data = data;
return;

View file

@ -49,7 +49,7 @@ timeit::timeit(bool enable, char const * msg, std::ostream & out) {
if (enable)
m_imp = alloc(imp, msg, out);
else
m_imp = 0;
m_imp = nullptr;
}
timeit::~timeit() {

View file

@ -27,12 +27,12 @@ Revision History:
#include "util/event_handler.h"
#include "util/scoped_timer.h"
scoped_timer * g_timeout = 0;
void (* g_on_timeout)() = 0;
scoped_timer * g_timeout = nullptr;
void (* g_on_timeout)() = nullptr;
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";
@ -41,7 +41,7 @@ public:
g_on_timeout();
if (g_timeout)
delete g_timeout;
g_timeout = 0;
g_timeout = nullptr;
throw z3_error(ERR_TIMEOUT);
}
}

101
src/util/top_sort.h Normal file
View file

@ -0,0 +1,101 @@
/*++
Copyright (c) 2018 Microsoft Corporation
Module Name:
top_sort.h
Abstract:
Topological sort over objects
Author:
Nikolaj Bjorner (nbjorner) 2018-02-14
Revision History:
--*/
#ifndef TOP_SORT_H_
#define TOP_SORT_H_
#include "util/obj_hashtable.h"
#include "util/vector.h"
#include<algorithm>
#include<type_traits>
#include<memory.h>
#include "util/memory_manager.h"
template<typename T>
class top_sort {
typedef obj_hashtable<T> T_set;
obj_map<T, unsigned> m_partition_id;
obj_map<T, unsigned> m_dfs_num;
ptr_vector<T> m_top_sorted;
ptr_vector<T> m_stack_S;
ptr_vector<T> m_stack_P;
unsigned m_next_preorder;
obj_map<T, T_set*> m_deps;
void traverse(T* f) {
unsigned p_id = 0;
if (m_dfs_num.find(f, p_id)) {
if (!m_partition_id.contains(f)) {
while (!m_stack_P.empty() && m_partition_id.contains(m_stack_P.back()) && m_partition_id[m_stack_P.back()] > p_id) {
m_stack_P.pop_back();
}
}
}
else if (!m_deps.contains(f)) {
return;
}
else {
m_dfs_num.insert(f, m_next_preorder++);
m_stack_S.push_back(f);
m_stack_P.push_back(f);
for (T* g : *m_deps[f]) {
traverse(g);
}
if (f == m_stack_P.back()) {
p_id = m_top_sorted.size();
T* s_f;
do {
s_f = m_stack_S.back();
m_stack_S.pop_back();
m_top_sorted.push_back(s_f);
m_partition_id.insert(s_f, p_id);
}
while (s_f != f);
m_stack_P.pop_back();
}
}
}
public:
~top_sort() {
for (auto & kv : m_deps) dealloc(kv.m_value);
}
void topological_sort() {
m_next_preorder = 0;
m_partition_id.reset();
m_top_sorted.reset();
for (auto & kv : m_deps) {
traverse(kv.m_key);
}
SASSERT(m_stack_S.empty());
SASSERT(m_stack_P.empty());
m_dfs_num.reset();
}
void insert(T* t, T_set* s) {
m_deps.insert(t, s);
}
ptr_vector<T> const& top_sorted() { return m_top_sorted; }
};
#endif /* TOP_SORT_H_ */

View file

@ -24,7 +24,7 @@ std::ofstream tout(".z3-trace");
#endif
static bool g_enable_all_trace_tags = false;
static str_hashtable* g_enabled_trace_tags = 0;
static str_hashtable* g_enabled_trace_tags = nullptr;
static str_hashtable& get_enabled_trace_tags() {
if (!g_enabled_trace_tags) {
@ -35,7 +35,7 @@ static str_hashtable& get_enabled_trace_tags() {
void finalize_trace() {
dealloc(g_enabled_trace_tags);
g_enabled_trace_tags = 0;
g_enabled_trace_tags = nullptr;
}
void enable_trace(const char * tag) {

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,8 +76,8 @@ public:
SASSERT(m_ptr == 0);
}
virtual void undo(Ctx & ctx) {
m_ptr = 0;
void undo(Ctx & ctx) override {
m_ptr = nullptr;
}
};
@ -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) {
@ -102,6 +102,7 @@ public:
unsigned find(unsigned v) const {
while (true) {
SASSERT(v < m_find.size());
unsigned new_v = m_find[v];
if (new_v == v)
return v;

View file

@ -56,7 +56,7 @@ std::ostream& verbose_stream() {
}
static void (*g_fatal_error_handler)(int) = 0;
static void (*g_fatal_error_handler)(int) = nullptr;
void fatal_error(int error_code) {
if (g_fatal_error_handler) {
@ -136,7 +136,7 @@ bool product_iterator_next(unsigned n, unsigned const * sz, unsigned * it) {
}
char const * escaped::end() const {
if (m_str == 0) return 0;
if (m_str == nullptr) return nullptr;
char const * it = m_str;
char const * e = m_str;
while (*it) {

View file

@ -237,7 +237,7 @@ template<typename T>
class scoped_ptr {
T * m_ptr;
public:
scoped_ptr(T * ptr=0):
scoped_ptr(T * ptr=nullptr):
m_ptr(ptr) {
}
@ -254,7 +254,7 @@ public:
}
operator bool() const {
return m_ptr != 0;
return m_ptr != nullptr;
}
const T & operator*() const {
@ -275,7 +275,7 @@ public:
T * detach() {
T* tmp = m_ptr;
m_ptr = 0;
m_ptr = nullptr;
return tmp;
}

View file

@ -57,7 +57,7 @@ class vector {
}
void expand_vector() {
if (m_data == 0) {
if (m_data == nullptr) {
SZ capacity = 2;
SZ * mem = reinterpret_cast<SZ*>(memory::allocate(sizeof(T) * capacity + sizeof(SZ) * 2));
*mem = capacity;
@ -132,12 +132,12 @@ public:
typedef const T * const_iterator;
vector():
m_data(0) {
m_data(nullptr) {
}
vector(SZ s) {
if (s == 0) {
m_data = 0;
m_data = nullptr;
return;
}
SZ * mem = reinterpret_cast<SZ*>(memory::allocate(sizeof(T) * s + sizeof(SZ) * 2));
@ -155,24 +155,24 @@ public:
}
vector(SZ s, T const & elem):
m_data(0) {
m_data(nullptr) {
resize(s, elem);
}
vector(vector const & source):
m_data(0) {
m_data(nullptr) {
if (source.m_data) {
copy_core(source);
}
SASSERT(size() == source.size());
}
vector(vector&& other) : m_data(0) {
vector(vector&& other) : m_data(nullptr) {
std::swap(m_data, other.m_data);
}
vector(SZ s, T const * data):
m_data(0) {
m_data(nullptr) {
for (SZ i = 0; i < s; i++) {
push_back(data[i]);
}
@ -185,7 +185,7 @@ public:
void finalize() {
destroy();
m_data = 0;
m_data = nullptr;
}
vector & operator=(vector const & source) {
@ -197,7 +197,7 @@ public:
copy_core(source);
}
else {
m_data = 0;
m_data = nullptr;
}
return *this;
}
@ -207,7 +207,7 @@ public:
return *this;
}
destroy();
m_data = 0;
m_data = nullptr;
std::swap(m_data, source.m_data);
return *this;
}
@ -224,18 +224,18 @@ public:
void clear() { reset(); }
bool empty() const {
return m_data == 0 || reinterpret_cast<SZ *>(m_data)[SIZE_IDX] == 0;
return m_data == nullptr || reinterpret_cast<SZ *>(m_data)[SIZE_IDX] == 0;
}
SZ size() const {
if (m_data == 0) {
if (m_data == nullptr) {
return 0;
}
return reinterpret_cast<SZ *>(m_data)[SIZE_IDX];
}
SZ capacity() const {
if (m_data == 0) {
if (m_data == nullptr) {
return 0;
}
return reinterpret_cast<SZ *>(m_data)[CAPACITY_IDX];
@ -349,7 +349,7 @@ public:
}
void push_back(T const & elem) {
if (m_data == 0 || reinterpret_cast<SZ *>(m_data)[SIZE_IDX] == reinterpret_cast<SZ *>(m_data)[CAPACITY_IDX]) {
if (m_data == nullptr || reinterpret_cast<SZ *>(m_data)[SIZE_IDX] == reinterpret_cast<SZ *>(m_data)[CAPACITY_IDX]) {
expand_vector();
}
new (m_data + reinterpret_cast<SZ *>(m_data)[SIZE_IDX]) T(elem);
@ -357,7 +357,7 @@ public:
}
void push_back(T && elem) {
if (m_data == 0 || reinterpret_cast<SZ *>(m_data)[SIZE_IDX] == reinterpret_cast<SZ *>(m_data)[CAPACITY_IDX]) {
if (m_data == nullptr || reinterpret_cast<SZ *>(m_data)[SIZE_IDX] == reinterpret_cast<SZ *>(m_data)[CAPACITY_IDX]) {
expand_vector();
}
new (m_data + reinterpret_cast<SZ *>(m_data)[SIZE_IDX]) T(std::move(elem));

View file

@ -62,8 +62,8 @@ void STD_CALL myInvalidParameterHandler(
static bool g_warning_msgs = true;
static bool g_use_std_stdout = false;
static std::ostream* g_error_stream = 0;
static std::ostream* g_warning_stream = 0;
static std::ostream* g_error_stream = nullptr;
static std::ostream* g_warning_stream = nullptr;
static bool g_show_error_msg_prefix = true;
void send_warnings_to_stdout(bool flag) {

View file

@ -33,8 +33,8 @@ class z3_error : public z3_exception {
unsigned m_error_code;
public:
z3_error(unsigned error_code);
virtual char const * msg() const;
virtual unsigned error_code() const;
char const * msg() const override;
unsigned error_code() const override;
};
class default_exception : public z3_exception {
@ -43,8 +43,8 @@ public:
struct fmt {};
default_exception(std::string const& msg);
default_exception(fmt, char const* msg, ...);
virtual ~default_exception() {}
virtual char const * msg() const;
~default_exception() override {}
char const * msg() const override;
};
#endif