[PPL-devel] [GIT] ppl/ppl(master): Replaced all c-style casts.
Patricia Hill
p.m.hill at leeds.ac.uk
Wed Feb 22 14:58:47 CET 2012
Module: ppl/ppl
Branch: master
Commit: a6de4769641faef9750c18f8b69ec884815101e1
URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=a6de4769641faef9750c18f8b69ec884815101e1
Author: Patricia Hill <p.m.hill at leeds.ac.uk>
Date: Wed Feb 22 13:03:42 2012 +0000
Replaced all c-style casts.
Detected by ECLAIR service castexpr.
---
src/Bit_Row.cc | 4 ++--
src/CO_Tree.cc | 7 ++++---
src/CO_Tree.templates.hh | 2 +-
src/Float.defs.hh | 18 +++++++++---------
src/Float.inlines.hh | 8 ++++----
src/Interval.defs.hh | 2 +-
src/checked_mpq.inlines.hh | 2 +-
src/checked_mpz.inlines.hh | 2 +-
src/intervals.defs.hh | 11 +++++++----
9 files changed, 30 insertions(+), 26 deletions(-)
diff --git a/src/Bit_Row.cc b/src/Bit_Row.cc
index ac56da2..d1e1256 100644
--- a/src/Bit_Row.cc
+++ b/src/Bit_Row.cc
@@ -63,7 +63,7 @@ PPL::Bit_Row::next(unsigned long position) const {
// Mask off any bits before `position' in the first limb.
mp_limb_t limb
- = *p & ((~(mp_limb_t) 0) << (position % PPL_BITS_PER_GMP_LIMB));
+ = *p & ((~static_cast<mp_limb_t>(0)) << (position % PPL_BITS_PER_GMP_LIMB));
while (true) {
if (limb != 0)
@@ -112,7 +112,7 @@ PPL::Bit_Row::prev(unsigned long position) const {
}
else {
const mp_limb_t mask
- = (~(mp_limb_t) 0)
+ = (~static_cast<mp_limb_t>(0))
>> (PPL_BITS_PER_GMP_LIMB - 1 - position % PPL_BITS_PER_GMP_LIMB);
p += li;
limb = *p & mask;
diff --git a/src/CO_Tree.cc b/src/CO_Tree.cc
index 1c4cc88..94cd7f5 100644
--- a/src/CO_Tree.cc
+++ b/src/CO_Tree.cc
@@ -518,7 +518,7 @@ PPL::CO_Tree::init(dimension_type reserved_size1) {
max_depth = integer_log2(reserved_size1) + 1;
size_ = 0;
- reserved_size = ((dimension_type)1 << max_depth) - 1;
+ reserved_size = (static_cast<dimension_type>(1) << max_depth) - 1;
indexes = new dimension_type[reserved_size + 2];
try {
data = data_allocator.allocate(reserved_size + 1);
@@ -574,7 +574,7 @@ PPL::CO_Tree::structure_OK() const {
if (reserved_size < 3)
return false;
- if (reserved_size != ((dimension_type)1 << max_depth) - 1)
+ if (reserved_size != (static_cast<dimension_type>(1) << max_depth) - 1)
return false;
if (data == NULL)
@@ -752,7 +752,8 @@ PPL::CO_Tree::rebalance(tree_iterator itr, dimension_type key,
height_t itr_depth_minus_1 = itr.depth() - 1;
height_t height = max_depth - itr_depth_minus_1;
dimension_type subtree_size;
- dimension_type subtree_reserved_size = ((dimension_type)1 << height) - 1;
+ dimension_type subtree_reserved_size = (static_cast<dimension_type>(1)
+ << height) - 1;
const bool deleting = itr.index() == unused_index;
PPL_ASSERT(deleting || key != unused_index);
if (deleting)
diff --git a/src/CO_Tree.templates.hh b/src/CO_Tree.templates.hh
index 1831302..488f541 100644
--- a/src/CO_Tree.templates.hh
+++ b/src/CO_Tree.templates.hh
@@ -36,7 +36,7 @@ CO_Tree::CO_Tree(Iterator i, dimension_type n) {
}
dimension_type new_max_depth = integer_log2(n) + 1;
- reserved_size = ((dimension_type)1 << new_max_depth) - 1;
+ reserved_size = (static_cast<dimension_type>(1) << new_max_depth) - 1;
if (is_greater_than_ratio(n, reserved_size, max_density_percent)
&& reserved_size != 3)
diff --git a/src/Float.defs.hh b/src/Float.defs.hh
index 1b29841..d1865c5 100644
--- a/src/Float.defs.hh
+++ b/src/Float.defs.hh
@@ -215,10 +215,10 @@ struct float_intel_double_extended {
static const uint32_t MSP_NEG_INF = 0x0000ffff;
static const uint32_t MSP_POS_ZERO = 0x00000000;
static const uint32_t MSP_NEG_ZERO = 0x00008000;
- static const uint64_t LSP_INF = (uint64_t)0x8000000000000000ULL;
+ static const uint64_t LSP_INF = static_cast<uint64_t>(0x8000000000000000ULL);
static const uint64_t LSP_ZERO = 0;
- static const uint64_t LSP_DMAX = (uint64_t)0x7fffffffffffffffULL;
- static const uint64_t LSP_NMAX = (uint64_t)0xffffffffffffffffULL;
+ static const uint64_t LSP_DMAX = static_cast<uint64_t>(0x7fffffffffffffffULL);
+ static const uint64_t LSP_NMAX = static_cast<uint64_t>(0xffffffffffffffffULL);
static const unsigned int BASE = 2;
static const unsigned int EXPONENT_BITS = 15;
static const unsigned int MANTISSA_BITS = 63;
@@ -252,14 +252,14 @@ struct float_ieee754_quad {
uint64_t lsp;
uint64_t msp;
#endif
- static const uint64_t MSP_SGN_MASK = (uint64_t)0x8000000000000000ULL;
- static const uint64_t MSP_POS_INF = (uint64_t)0x7fff000000000000ULL;
- static const uint64_t MSP_NEG_INF = (uint64_t)0xffff000000000000ULL;
- static const uint64_t MSP_POS_ZERO = (uint64_t)0x0000000000000000ULL;
- static const uint64_t MSP_NEG_ZERO = (uint64_t)0x8000000000000000ULL;
+ static const uint64_t MSP_SGN_MASK = static_cast<uint64_t>(0x8000000000000000ULL);
+ static const uint64_t MSP_POS_INF = static_cast<uint64_t>(0x7fff000000000000ULL);
+ static const uint64_t MSP_NEG_INF = static_cast<uint64_t>(0xffff000000000000ULL);
+ static const uint64_t MSP_POS_ZERO = static_cast<uint64_t>(0x0000000000000000ULL);
+ static const uint64_t MSP_NEG_ZERO = static_cast<uint64_t>(0x8000000000000000ULL);
static const uint64_t LSP_INF = 0;
static const uint64_t LSP_ZERO = 0;
- static const uint64_t LSP_MAX = (uint64_t)0xffffffffffffffffULL;
+ static const uint64_t LSP_MAX = static_cast<uint64_t>(0xffffffffffffffffULL);
static const unsigned int BASE = 2;
static const unsigned int EXPONENT_BITS = 15;
static const unsigned int MANTISSA_BITS = 112;
diff --git a/src/Float.inlines.hh b/src/Float.inlines.hh
index ce371e0..ebfb716 100644
--- a/src/Float.inlines.hh
+++ b/src/Float.inlines.hh
@@ -362,7 +362,7 @@ float_intel_double_extended::inc() {
inline void
float_intel_double_extended::set_max(bool negative) {
msp = 0x00007ffe;
- lsp = (uint64_t)0xffffffffffffffffULL;
+ lsp = static_cast<uint64_t>(0xffffffffffffffffULL);
if (negative)
msp |= MSP_SGN_MASK;
}
@@ -441,8 +441,8 @@ float_ieee754_quad::inc() {
inline void
float_ieee754_quad::set_max(bool negative) {
- msp = (uint64_t)0x7ffeffffffffffffULL;
- lsp = (uint64_t)0xffffffffffffffffULL;
+ msp = static_cast<uint64_t>(0x7ffeffffffffffffULL);
+ lsp = static_cast<uint64_t>(0xffffffffffffffffULL);
if (negative)
msp |= MSP_SGN_MASK;
}
@@ -453,7 +453,7 @@ float_ieee754_quad::build(bool negative, mpz_t mantissa, int exponent) {
mpz_export(parts, 0, -1, 8, 0, 0, mantissa);
lsp = parts[0];
msp = parts[1];
- msp &= ((((uint64_t)1) << (MANTISSA_BITS - 64)) - 1);
+ msp &= ((static_cast<uint64_t>(1) << (MANTISSA_BITS - 64)) - 1);
if (negative)
msp |= MSP_SGN_MASK;
int exponent_repr = exponent + EXPONENT_BIAS;
diff --git a/src/Interval.defs.hh b/src/Interval.defs.hh
index 7be0400..febedb0 100644
--- a/src/Interval.defs.hh
+++ b/src/Interval.defs.hh
@@ -329,7 +329,7 @@ public:
case V_EQ:
case V_NE:
assign(UNIVERSE);
- rs = (Relation_Symbol) c.rel();
+ rs = static_cast<Relation_Symbol>(c.rel());
return refine_existential(rs, c.value());
}
}
diff --git a/src/checked_mpq.inlines.hh b/src/checked_mpq.inlines.hh
index c702d0d..3ed1cb9 100644
--- a/src/checked_mpq.inlines.hh
+++ b/src/checked_mpq.inlines.hh
@@ -50,7 +50,7 @@ classify_mpq(const mpq_class& v, bool nan, bool inf, bool sign) {
}
}
if (sign)
- return (Result) sgn<Policy>(v);
+ return static_cast<Result>(sgn<Policy>(v));
return V_LGE;
}
diff --git a/src/checked_mpz.inlines.hh b/src/checked_mpz.inlines.hh
index 8ba2c4d..afa84b0 100644
--- a/src/checked_mpz.inlines.hh
+++ b/src/checked_mpz.inlines.hh
@@ -87,7 +87,7 @@ classify_mpz(const mpz_class& v, bool nan, bool inf, bool sign) {
}
}
if (sign)
- return (Result) sgn<Policy>(v);
+ return static_cast<Result>(sgn<Policy>(v));
return V_LGE;
}
diff --git a/src/intervals.defs.hh b/src/intervals.defs.hh
index 29c1081..a4f3754 100644
--- a/src/intervals.defs.hh
+++ b/src/intervals.defs.hh
@@ -61,15 +61,18 @@ enum I_Result {
};
inline I_Result operator|(I_Result a, I_Result b) {
- return static_cast<I_Result>((unsigned)a | (unsigned)b);
+ return static_cast<I_Result>(static_cast<unsigned>(a)
+ | static_cast<unsigned>(b));
}
inline I_Result operator&(I_Result a, I_Result b) {
- return static_cast<I_Result>((unsigned)a & (unsigned)b);
+ return static_cast<I_Result>(static_cast<unsigned>(a)
+ & static_cast<unsigned>(b));
}
inline I_Result operator-(I_Result a, I_Result b) {
- return static_cast<I_Result>((unsigned)a & ~(unsigned)b);
+ return static_cast<I_Result>(static_cast<unsigned>(a)
+ & ~static_cast<unsigned>(b));
}
template <typename Criteria, typename T>
@@ -340,7 +343,7 @@ struct I_Constraint_Rel {
PPL_ASSERT(result_relation_class(r) == r);
}
I_Constraint_Rel(Relation_Symbol r)
- : rel((Result)r) {
+ : rel(static_cast<Result>(r)) {
}
operator Result() const {
return rel;
More information about the PPL-devel
mailing list