3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-29 03:45:51 +00:00

Use nullptr.

This commit is contained in:
Bruce Mitchener 2018-02-12 14:05:55 +07:00
parent f01328c65f
commit 76eb7b9ede
625 changed files with 4639 additions and 4639 deletions

View file

@ -48,7 +48,7 @@ namespace algebraic_numbers {
unsigned m_sign_lower:1;
unsigned m_not_rational:1; // if true we know for sure it is not a rational
unsigned m_i:29; // number is the i-th root of p, 0 if it is not known which root of p the number is.
algebraic_cell():m_p_sz(0), m_p(0), m_minimal(false), m_not_rational(false), m_i(0) {}
algebraic_cell():m_p_sz(0), m_p(nullptr), m_minimal(false), m_not_rational(false), m_i(0) {}
bool is_minimal() const { return m_minimal != 0; }
};
@ -186,7 +186,7 @@ namespace algebraic_numbers {
for (unsigned i = 0; i < c->m_p_sz; i++)
qm().del(c->m_p[i]);
m_allocator.deallocate(sizeof(mpz)*c->m_p_sz, c->m_p);
c->m_p = 0;
c->m_p = nullptr;
c->m_p_sz = 0;
}
@ -201,13 +201,13 @@ namespace algebraic_numbers {
}
void del(numeral & a) {
if (a.m_cell == 0)
if (a.m_cell == nullptr)
return;
if (a.is_basic())
del(a.to_basic());
else
del(a.to_algebraic());
a.m_cell = 0;
a.m_cell = nullptr;
}
void reset(numeral & a) {
@ -215,7 +215,7 @@ namespace algebraic_numbers {
}
bool is_zero(numeral const & a) {
return a.m_cell == 0;
return a.m_cell == nullptr;
}
bool is_pos(numeral const & a) {
@ -361,7 +361,7 @@ namespace algebraic_numbers {
basic_cell * mk_basic_cell(mpq & n) {
if (qm().is_zero(n))
return 0;
return nullptr;
void * mem = static_cast<basic_cell*>(m_allocator.allocate(sizeof(basic_cell)));
basic_cell * c = new (mem) basic_cell();
qm().swap(c->m_value, n);
@ -1037,7 +1037,7 @@ namespace algebraic_numbers {
unsigned target_i = UINT_MAX; // index of sequence that is isolating
int target_lV = 0, target_uV = 0;
for (unsigned i = 0; i < num_fs; i++) {
if (seqs[i] == 0)
if (seqs[i] == nullptr)
continue; // sequence was discarded because it does not contain the root.
TRACE("anum_mk_binary", tout << "sequence " << i << "\n"; upm().display(tout, *(seqs[i])); tout << "\n";);
int lV = upm().sign_variations_at(*(seqs[i]), r_i.lower());
@ -1050,7 +1050,7 @@ namespace algebraic_numbers {
);
if (V <= 0) {
// discard sequence, since factor does not contain the root
seqs.set(i, 0);
seqs.set(i, nullptr);
}
else if (V == 1) {
target_i = i;
@ -1115,7 +1115,7 @@ namespace algebraic_numbers {
unsigned target_i = UINT_MAX; // index of sequence that is isolating
int target_lV = 0, target_uV = 0;
for (unsigned i = 0; i < num_fs; i++) {
if (seqs[i] == 0)
if (seqs[i] == nullptr)
continue; // sequence was discarded because it does not contain the root.
int lV = upm().sign_variations_at(*(seqs[i]), r_i.lower());
int uV = upm().sign_variations_at(*(seqs[i]), r_i.upper());
@ -1126,7 +1126,7 @@ namespace algebraic_numbers {
);
if (V <= 0) {
// discard sequence, since factor does not contain the root
seqs.set(i, 0);
seqs.set(i, nullptr);
}
else if (V == 1) {
target_i = i;
@ -2772,7 +2772,7 @@ namespace algebraic_numbers {
manager::manager(reslimit& lim, unsynch_mpq_manager & m, params_ref const & p, small_object_allocator * a) {
m_own_allocator = false;
m_allocator = a;
if (m_allocator == 0) {
if (m_allocator == nullptr) {
m_own_allocator = true;
m_allocator = alloc(small_object_allocator, "algebraic");
}

View file

@ -58,7 +58,7 @@ namespace algebraic_numbers {
typedef _scoped_numeral<manager> scoped_numeral;
typedef _scoped_numeral_vector<manager> scoped_numeral_vector;
manager(reslimit& rl, unsynch_mpq_manager & m, params_ref const & p = params_ref(), small_object_allocator * a = 0);
manager(reslimit& rl, unsynch_mpq_manager & m, params_ref const & p = params_ref(), small_object_allocator * a = nullptr);
~manager();
static void get_param_descrs(param_descrs & r);
@ -372,7 +372,7 @@ namespace algebraic_numbers {
basic_cell * to_basic() const { SASSERT(is_basic()); return UNTAG(basic_cell*, m_cell); }
algebraic_cell * to_algebraic() const { SASSERT(!is_basic()); return UNTAG(algebraic_cell*, m_cell); }
public:
anum():m_cell(0) {}
anum():m_cell(nullptr) {}
};
};

View file

@ -510,7 +510,7 @@ namespace polynomial {
monomial * allocate(unsigned capacity) {
void * mem = memory::allocate(monomial::get_obj_size(capacity));
return new (mem) monomial(UINT_MAX, 0, 0, 0);
return new (mem) monomial(UINT_MAX, 0, nullptr, 0);
}
void deallocate(monomial * ptr, unsigned capacity) {
@ -776,10 +776,10 @@ namespace polynomial {
tmp_monomial m_tmp3;
svector<power> m_powers_tmp;
public:
monomial_manager(small_object_allocator * a = 0) {
monomial_manager(small_object_allocator * a = nullptr) {
m_ref_count = 0;
m_next_var = 0;
if (a == 0) {
if (a == nullptr) {
m_allocator = alloc(small_object_allocator, "polynomial");
m_own_allocator = true;
}
@ -787,7 +787,7 @@ namespace polynomial {
m_allocator = a;
m_own_allocator = false;
}
m_unit = mk_monomial(0, static_cast<power const *>(0));
m_unit = mk_monomial(0, static_cast<power const *>(nullptr));
inc_ref(m_unit);
}
@ -1185,7 +1185,7 @@ namespace polynomial {
sqrt_tmp.reserve(sz);
for (unsigned i = 0; i < sz; i++) {
if (m->degree(i) % 2 == 1)
return 0;
return nullptr;
sqrt_tmp.set_power(i, power(m->get_var(i), m->degree(i) / 2));
}
sqrt_tmp.set_size(sz);
@ -1927,7 +1927,7 @@ namespace polynomial {
}
public:
som_buffer():m_owner(0) {}
som_buffer():m_owner(nullptr) {}
void reset() {
if (empty())
@ -2173,7 +2173,7 @@ namespace polynomial {
public:
som_buffer_vector() {
m_owner = 0;
m_owner = nullptr;
}
~som_buffer_vector() {
@ -2185,7 +2185,7 @@ namespace polynomial {
void set_owner(imp * owner) {
SASSERT(m_owner == owner || m_owner == 0);
if (m_owner == 0) {
if (m_owner == nullptr) {
m_owner = owner;
unsigned sz = m_buffers.size();
for (unsigned i = 0; i < sz; i++) {
@ -2222,7 +2222,7 @@ namespace polynomial {
numeral_vector m_tmp_as;
monomial_vector m_tmp_ms;
public:
cheap_som_buffer():m_owner(0) {}
cheap_som_buffer():m_owner(nullptr) {}
void set_owner(imp * o) { m_owner = o; }
bool empty() const { return m_tmp_ms.empty(); }
@ -2306,12 +2306,12 @@ namespace polynomial {
cheap_som_buffer m_cheap_som_buffer2;
void init() {
m_del_eh = 0;
m_del_eh = nullptr;
m_som_buffer.set_owner(this);
m_som_buffer2.set_owner(this);
m_cheap_som_buffer.set_owner(this);
m_cheap_som_buffer2.set_owner(this);
m_zero = mk_polynomial_core(0, 0, 0);
m_zero = mk_polynomial_core(0, nullptr, nullptr);
m().set(m_zero_numeral, 0);
inc_ref(m_zero);
numeral one(1);
@ -2326,7 +2326,7 @@ namespace polynomial {
m_wrapper(w),
m_manager(m),
m_upm(lim, m) {
if (mm == 0)
if (mm == nullptr)
mm = alloc(monomial_manager);
m_monomial_manager = mm;
m_monomial_manager->inc_ref();
@ -2419,13 +2419,13 @@ namespace polynomial {
void del(polynomial * p) {
TRACE("polynomial", tout << "deleting: "; p->display(tout, m_manager); tout << "\n";);
if (m_del_eh != 0) {
if (m_del_eh != nullptr) {
del_eh * curr = m_del_eh;
do {
(*curr)(p);
curr = curr->m_next;
}
while (curr != 0);
while (curr != nullptr);
}
unsigned sz = p->size();
unsigned obj_sz = polynomial::get_obj_size(sz);
@ -2924,7 +2924,7 @@ namespace polynomial {
imp * m_imp;
ptr_vector<newton_interpolator> m_data;
public:
newton_interpolator_vector():m_imp(0) {}
newton_interpolator_vector():m_imp(nullptr) {}
~newton_interpolator_vector() {
flush();
@ -2983,7 +2983,7 @@ namespace polynomial {
ms.push_back(p->m(i));
}
std::sort(ms.begin(), ms.end(), lex_lt2(x));
monomial * prev = 0;
monomial * prev = nullptr;
for (unsigned i = 0; i < sz; i++) {
monomial * orig_m = ms[i];
monomial * m;
@ -3831,7 +3831,7 @@ namespace polynomial {
r = mk_const(d_a);
return;
}
if (C_star.get() == 0) {
if (C_star.get() == nullptr) {
C_star = q;
m().set(bound, p);
}
@ -4153,7 +4153,7 @@ namespace polynomial {
counter = 0;
min_deg_q = deg_q;
// start from scratch
if (sk == 0) {
if (sk == nullptr) {
interpolator.reset();
interpolator.add(val, q);
}
@ -4165,7 +4165,7 @@ namespace polynomial {
}
else if (deg_q == min_deg_q) {
TRACE("mgcd_detail", tout << "adding sample point...\n";);
if (sk == 0) {
if (sk == nullptr) {
interpolator.add(val, q);
}
else {
@ -4178,7 +4178,7 @@ namespace polynomial {
continue;
}
bool found_candidate = false;
if (sk == 0) {
if (sk == nullptr) {
SASSERT(interpolator.num_sample_points() > 0);
interpolator.mk(x, H);
TRACE("mgcd_detail", tout << "idx: " << idx << "\ncandidate H: " << H << "\n";);
@ -4214,14 +4214,14 @@ namespace polynomial {
r = mul(ci_g, r);
done = true;
}
else if (sk != 0) {
else if (sk != nullptr) {
throw sparse_mgcd_failed();
}
}
if (done) {
TRACE("mgcd", tout << "idx: " << idx << "\nresult: " << r << "\n";);
if (sk == 0 && m_use_sparse_gcd) {
if (sk == nullptr && m_use_sparse_gcd) {
// save skeleton
skeleton * new_sk = alloc(skeleton, *this, H, x);
m_mgcd_skeletons.set(idx, new_sk);
@ -4255,7 +4255,7 @@ namespace polynomial {
m_mgcd_skeletons.reset();
for (unsigned i = 0; i < num_vars; i++) {
vars.push_back(var_min_degrees[i].get_var());
m_mgcd_skeletons.push_back(0);
m_mgcd_skeletons.push_back(nullptr);
}
scoped_numeral c_u(m()), c_v(m());
@ -4311,7 +4311,7 @@ namespace polynomial {
r = mk_const(d_a);
return;
}
if (C_star.get() == 0) {
if (C_star.get() == nullptr) {
C_star = q;
m().set(bound, p);
}
@ -4903,7 +4903,7 @@ namespace polynomial {
*/
template<bool Exact_d, bool Quotient, bool ModD>
void pseudo_division_core(polynomial const * p, polynomial const * q, var x, unsigned & d, polynomial_ref & Q, polynomial_ref & R,
var2degree const * x2d = 0) {
var2degree const * x2d = nullptr) {
SASSERT(is_valid(x));
SASSERT(!ModD || x2d != 0);
TRACE("polynomial", tout << "pseudo_division\np: "; p->display(tout, m_manager);
@ -5138,7 +5138,7 @@ namespace polynomial {
}
monomial const * m_r = R.m(max_R);
numeral const & a_r = R.a(max_R);
monomial * m_r_q = 0;
monomial * m_r_q = nullptr;
VERIFY(div(m_r, m_q, m_r_q));
TRACE("polynomial", tout << "m_r: "; m_r->display(tout); tout << "\nm_q: "; m_q->display(tout); tout << "\n";
if (m_r_q) { tout << "m_r_q: "; m_r_q->display(tout); tout << "\n"; });
@ -5175,7 +5175,7 @@ namespace polynomial {
}
monomial const * m_r = R.m(max_R);
numeral const & a_r = R.a(max_R);
monomial * m_r_q = 0;
monomial * m_r_q = nullptr;
bool q_div_r = div(m_r, m_q, m_r_q);
m_r_q_ref = m_r_q;
TRACE("polynomial", tout << "m_r: "; m_r->display(tout); tout << "\nm_q: "; m_q->display(tout); tout << "\n";
@ -5639,7 +5639,7 @@ namespace polynomial {
pw(h1, d1, hs1);
hs1 = mul(g1, hs1);
G3 = exact_div(Gh3, hs1);
hs1 = 0;
hs1 = nullptr;
}
// prepare for next iteration
@ -6083,7 +6083,7 @@ namespace polynomial {
polynomial_vector::iterator end2 = m_polynomials.end();
for (; it2 != end2; ++it2) {
polynomial * p = *it2;
if (p == 0)
if (p == nullptr)
continue;
p->make_first_maximal();
SASSERT(p->size() <= 1 || !p->lex_sorted());
@ -6404,7 +6404,7 @@ namespace polynomial {
result = const_cast<polynomial*>(r);
return;
}
result = 0;
result = nullptr;
polynomial_ref p1(pm()), q1(pm());
polynomial_ref_buffer ps(pm());
unsigned sz = r->size();

View file

@ -192,7 +192,7 @@ namespace polynomial {
private:
imp * m_imp;
public:
manager(reslimit& lim, numeral_manager & m, monomial_manager * mm = 0);
manager(reslimit& lim, numeral_manager & m, monomial_manager * mm = nullptr);
manager(reslimit& lim, numeral_manager & m, small_object_allocator * a);
~manager();
@ -227,7 +227,7 @@ namespace polynomial {
friend class manager;
del_eh * m_next;
public:
del_eh():m_next(0) {}
del_eh():m_next(nullptr) {}
virtual void operator()(polynomial * p) = 0;
};

View file

@ -47,7 +47,7 @@ namespace polynomial {
m_x(x),
m_hash(h),
m_result_sz(0),
m_result(0) {
m_result(nullptr) {
}
struct hash_proc { unsigned operator()(psc_chain_entry const * entry) const { return entry->m_hash; } };
@ -69,7 +69,7 @@ namespace polynomial {
m_p(p),
m_hash(h),
m_result_sz(0),
m_result(0) {
m_result(nullptr) {
}
struct hash_proc { unsigned operator()(factor_entry const * entry) const { return entry->m_hash; } };

View file

@ -63,8 +63,8 @@ namespace rpolynomial {
m_wrapper(w),
m_manager(m),
m_allocator(a),
m_own_allocator(a == 0) {
if (a == 0)
m_own_allocator(a == nullptr) {
if (a == nullptr)
m_allocator = alloc(small_object_allocator, "rpolynomial");
}
@ -107,7 +107,7 @@ namespace rpolynomial {
unsigned sz = p->size();
for (unsigned i = 0; i < sz; i++) {
poly_or_num * pn = p->arg(i);
if (pn == 0)
if (pn == nullptr)
continue;
if (is_num(pn)) {
del_numeral(to_num_ptr(pn));
@ -141,11 +141,11 @@ namespace rpolynomial {
static bool is_const(polynomial const * p) {
SASSERT(p == 0 || (p->max_var() == null_var) == (p->size() == 1 && p->arg(0) != 0 && is_num(p->arg(0))));
return p == 0 || p->max_var() == null_var;
return p == nullptr || p->max_var() == null_var;
}
bool is_zero(polynomial const * p) {
return p == 0;
return p == nullptr;
}
static bool is_univariate(polynomial const * p) {
@ -154,7 +154,7 @@ namespace rpolynomial {
unsigned sz = p->size();
for (unsigned i = 0; i < sz; i++) {
poly_or_num * pn = p->arg(i);
if (pn == 0)
if (pn == nullptr)
continue;
if (is_poly(pn))
return false;
@ -169,7 +169,7 @@ namespace rpolynomial {
SASSERT(sz > 0);
SASSERT(p->arg(sz - 1) != 0);
for (unsigned i = 0; i < sz - 1; i++) {
if (p->arg(i) != 0)
if (p->arg(i) != nullptr)
return false;
}
SASSERT(is_poly(p->arg(sz - 1)));
@ -179,13 +179,13 @@ namespace rpolynomial {
unsigned degree(polynomial const * p) {
SASSERT(p != 0);
SASSERT(p->size() > 0);
return p == 0 ? 0 : p->size() - 1;
return p == nullptr ? 0 : p->size() - 1;
}
bool eq(polynomial const * p1, polynomial const * p2) {
if (p1 == p2)
return true;
if (p1 == 0 || p2 == 0)
if (p1 == nullptr || p2 == nullptr)
return false;
if (p1->size() != p2->size())
return false;
@ -195,9 +195,9 @@ namespace rpolynomial {
for (unsigned i = 0; i < sz; i++) {
poly_or_num * pn1 = p1->arg(i);
poly_or_num * pn2 = p2->arg(i);
if (pn1 == 0 && pn2 == 0)
if (pn1 == nullptr && pn2 == nullptr)
continue;
if (pn1 == 0 || pn2 == 0)
if (pn1 == nullptr || pn2 == nullptr)
return false;
if (is_num(pn1) && is_num(pn2)) {
if (!m_manager.eq(to_num(pn1), to_num(pn2)))
@ -217,7 +217,7 @@ namespace rpolynomial {
void inc_ref_args(unsigned sz, poly_or_num * const * args) {
for (unsigned i = 0; i < sz; i++) {
poly_or_num * pn = args[i];
if (pn == 0 || is_num(pn))
if (pn == nullptr || is_num(pn))
continue;
inc_ref(to_poly(pn));
}
@ -226,7 +226,7 @@ namespace rpolynomial {
void dec_ref_args(unsigned sz, poly_or_num * const * args) {
for (unsigned i = 0; i < sz; i++) {
poly_or_num * pn = args[i];
if (pn == 0 || is_num(pn))
if (pn == nullptr || is_num(pn))
continue;
dec_ref(to_poly(pn));
}
@ -234,7 +234,7 @@ namespace rpolynomial {
unsigned trim(unsigned sz, poly_or_num * const * args) {
while (sz > 0) {
if (args[sz - 1] != 0)
if (args[sz - 1] != nullptr)
return sz;
sz--;
}
@ -281,8 +281,8 @@ namespace rpolynomial {
polynomial * mk_poly(unsigned sz, poly_or_num * const * args, var max_var) {
poly_or_num * _p = mk_poly_core(sz, args, max_var);
if (_p == 0)
return 0;
if (_p == nullptr)
return nullptr;
else if (is_num(_p))
return allocate_poly(1, &_p, null_var);
else
@ -291,7 +291,7 @@ namespace rpolynomial {
polynomial * mk_const(numeral const & n) {
if (m_manager.is_zero(n))
return 0;
return nullptr;
numeral * a = mk_numeral();
m_manager.set(*a, n);
poly_or_num * _a = to_poly_or_num(a);
@ -322,8 +322,8 @@ namespace rpolynomial {
}
poly_or_num * unpack(polynomial const * p) {
if (p == 0) {
return 0;
if (p == nullptr) {
return nullptr;
}
else if (is_const(p)) {
SASSERT(p->size() == 1);
@ -336,8 +336,8 @@ namespace rpolynomial {
}
polynomial * pack(poly_or_num * p) {
if (p == 0)
return 0;
if (p == nullptr)
return nullptr;
else if (is_num(p))
return mk_poly(1, &p, null_var);
else
@ -345,8 +345,8 @@ namespace rpolynomial {
}
poly_or_num * mul_core(numeral const & c, poly_or_num * p) {
if (m_manager.is_zero(c) || p == 0) {
return 0;
if (m_manager.is_zero(c) || p == nullptr) {
return nullptr;
}
else if (is_num(p)) {
numeral * r = mk_numeral();
@ -379,7 +379,7 @@ namespace rpolynomial {
if (m_manager.is_zero(c)) {
return p;
}
else if (p == 0) {
else if (p == nullptr) {
numeral * r = mk_numeral();
m_manager.set(*r, c);
return to_poly_or_num(r);
@ -388,7 +388,7 @@ namespace rpolynomial {
numeral a;
m_manager.add(c, to_num(p), a);
if (m_manager.is_zero(a))
return 0;
return nullptr;
numeral * new_arg = mk_numeral();
m_manager.swap(*new_arg, a);
return to_poly_or_num(new_arg);
@ -662,7 +662,7 @@ namespace rpolynomial {
while (i > 0) {
--i;
poly_or_num * pn = p->arg(i);
if (pn == 0)
if (pn == nullptr)
continue;
if (first)
first = false;
@ -730,7 +730,7 @@ namespace rpolynomial {
}
bool manager::is_zero(polynomial const * p) {
return p == 0;
return p == nullptr;
}
#if 0

View file

@ -51,7 +51,7 @@ namespace rpolynomial {
private:
imp * m_imp;
public:
manager(numeral_manager & m, small_object_allocator * a = 0);
manager(numeral_manager & m, small_object_allocator * a = nullptr);
~manager();
numeral_manager & m() const;

View file

@ -190,7 +190,7 @@ namespace upolynomial {
// Copy elements from p to buffer.
void core_manager::set(unsigned sz, numeral const * p, numeral_vector & buffer) {
if (p != 0 && buffer.c_ptr() == p) {
if (p != nullptr && buffer.c_ptr() == p) {
SASSERT(buffer.size() == sz);
return;
}

View file

@ -117,7 +117,7 @@ namespace upolynomial {
numeral_vector m_sqf_tmp2;
numeral_vector m_pw_tmp;
static bool is_alias(numeral const * p, numeral_vector & buffer) { return buffer.c_ptr() != 0 && buffer.c_ptr() == p; }
static bool is_alias(numeral const * p, numeral_vector & buffer) { return buffer.c_ptr() != nullptr && buffer.c_ptr() == p; }
void neg_core(unsigned sz1, numeral const * p1, numeral_vector & buffer);
void add_core(unsigned sz1, numeral const * p1, unsigned sz2, numeral const * p2, numeral_vector & buffer);
void sub_core(unsigned sz1, numeral const * p1, unsigned sz2, numeral const * p2, numeral_vector & buffer);