summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/APFloat.cpp
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2016-04-05 20:45:04 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2016-04-05 20:45:04 +0000
commit91d3cfed785b46723ebbf8197f70aa0f854c05d7 (patch)
tree94f71306bb51cc3e1cadab7d71e0de2d51328b89 /llvm/lib/Support/APFloat.cpp
parent27e95f7c7b22117e5f36d1ef874dac9b48555f18 (diff)
downloadbcm5719-llvm-91d3cfed785b46723ebbf8197f70aa0f854c05d7.tar.gz
bcm5719-llvm-91d3cfed785b46723ebbf8197f70aa0f854c05d7.zip
Revert "Fix Clang-tidy modernize-deprecated-headers warnings in remaining files; other minor fixes."
This reverts commit r265454 since it broke the build. E.g.: http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_build/22413/ llvm-svn: 265459
Diffstat (limited to 'llvm/lib/Support/APFloat.cpp')
-rw-r--r--llvm/lib/Support/APFloat.cpp74
1 files changed, 30 insertions, 44 deletions
diff --git a/llvm/lib/Support/APFloat.cpp b/llvm/lib/Support/APFloat.cpp
index e2debfc5466..a8e14d6c08b 100644
--- a/llvm/lib/Support/APFloat.cpp
+++ b/llvm/lib/Support/APFloat.cpp
@@ -14,19 +14,14 @@
#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/APSInt.h"
-#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/FoldingSet.h"
#include "llvm/ADT/Hashing.h"
-#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MathExtras.h"
-#include <algorithm>
-#include <cassert>
-#include <cstdint>
#include <cstring>
-#include <limits>
+#include <limits.h>
using namespace llvm;
@@ -98,21 +93,18 @@ namespace llvm {
const unsigned int maxPowerOfFiveExponent = maxExponent + maxPrecision - 1;
const unsigned int maxPowerOfFiveParts = 2 + ((maxPowerOfFiveExponent * 815)
/ (351 * integerPartWidth));
-
-} // end namespace llvm
-
-namespace {
+}
/* A bunch of private, handy routines. */
-inline unsigned int
+static inline unsigned int
partCountForBits(unsigned int bits)
{
return ((bits) + integerPartWidth - 1) / integerPartWidth;
}
/* Returns 0U-9U. Return values >= 10U are not digits. */
-inline unsigned int
+static inline unsigned int
decDigitValue(unsigned int c)
{
return c - '0';
@@ -123,7 +115,7 @@ decDigitValue(unsigned int c)
If the exponent overflows, returns a large exponent with the
appropriate sign. */
-int
+static int
readExponent(StringRef::iterator begin, StringRef::iterator end)
{
bool isNegative;
@@ -167,7 +159,7 @@ readExponent(StringRef::iterator begin, StringRef::iterator end)
/* This is ugly and needs cleaning up, but I don't immediately see
how whilst remaining safe. */
-int
+static int
totalExponent(StringRef::iterator p, StringRef::iterator end,
int exponentAdjustment)
{
@@ -216,7 +208,7 @@ totalExponent(StringRef::iterator p, StringRef::iterator end,
return exponent;
}
-StringRef::iterator
+static StringRef::iterator
skipLeadingZeroesAndAnyDot(StringRef::iterator begin, StringRef::iterator end,
StringRef::iterator *dot)
{
@@ -257,7 +249,7 @@ struct decimalInfo {
int normalizedExponent;
};
-void
+static void
interpretDecimal(StringRef::iterator begin, StringRef::iterator end,
decimalInfo *D)
{
@@ -316,7 +308,7 @@ interpretDecimal(StringRef::iterator begin, StringRef::iterator end,
/* Return the trailing fraction of a hexadecimal number.
DIGITVALUE is the first hex digit of the fraction, P points to
the next digit. */
-lostFraction
+static lostFraction
trailingHexadecimalFraction(StringRef::iterator p, StringRef::iterator end,
unsigned int digitValue)
{
@@ -347,7 +339,7 @@ trailingHexadecimalFraction(StringRef::iterator p, StringRef::iterator end,
/* Return the fraction lost were a bignum truncated losing the least
significant BITS bits. */
-lostFraction
+static lostFraction
lostFractionThroughTruncation(const integerPart *parts,
unsigned int partCount,
unsigned int bits)
@@ -369,7 +361,7 @@ lostFractionThroughTruncation(const integerPart *parts,
}
/* Shift DST right BITS bits noting lost fraction. */
-lostFraction
+static lostFraction
shiftRight(integerPart *dst, unsigned int parts, unsigned int bits)
{
lostFraction lost_fraction;
@@ -382,7 +374,7 @@ shiftRight(integerPart *dst, unsigned int parts, unsigned int bits)
}
/* Combine the effect of two lost fractions. */
-lostFraction
+static lostFraction
combineLostFractions(lostFraction moreSignificant,
lostFraction lessSignificant)
{
@@ -403,7 +395,7 @@ combineLostFractions(lostFraction moreSignificant,
See "How to Read Floating Point Numbers Accurately" by William D
Clinger. */
-unsigned int
+static unsigned int
HUerrBound(bool inexactMultiply, unsigned int HUerr1, unsigned int HUerr2)
{
assert(HUerr1 < 2 || HUerr2 < 2 || (HUerr1 + HUerr2 < 8));
@@ -417,7 +409,7 @@ HUerrBound(bool inexactMultiply, unsigned int HUerr1, unsigned int HUerr2)
/* The number of ulps from the boundary (zero, or half if ISNEAREST)
when the least significant BITS are truncated. BITS cannot be
zero. */
-integerPart
+static integerPart
ulpsFromBoundary(const integerPart *parts, unsigned int bits, bool isNearest)
{
unsigned int count, partBits;
@@ -462,7 +454,7 @@ ulpsFromBoundary(const integerPart *parts, unsigned int bits, bool isNearest)
/* Place pow(5, power) in DST, and return the number of parts used.
DST must be at least one part larger than size of the answer. */
-unsigned int
+static unsigned int
powerOf5(integerPart *dst, unsigned int power)
{
static const integerPart firstEightPowers[] = { 1, 5, 25, 125, 625, 3125,
@@ -525,17 +517,17 @@ powerOf5(integerPart *dst, unsigned int power)
/* Zero at the end to avoid modular arithmetic when adding one; used
when rounding up during hexadecimal output. */
-const char hexDigitsLower[] = "0123456789abcdef0";
-const char hexDigitsUpper[] = "0123456789ABCDEF0";
-const char infinityL[] = "infinity";
-const char infinityU[] = "INFINITY";
-const char NaNL[] = "nan";
-const char NaNU[] = "NAN";
+static const char hexDigitsLower[] = "0123456789abcdef0";
+static const char hexDigitsUpper[] = "0123456789ABCDEF0";
+static const char infinityL[] = "infinity";
+static const char infinityU[] = "INFINITY";
+static const char NaNL[] = "nan";
+static const char NaNU[] = "NAN";
/* Write out an integerPart in hexadecimal, starting with the most
significant nibble. Write out exactly COUNT hexdigits, return
COUNT. */
-unsigned int
+static unsigned int
partAsHex (char *dst, integerPart part, unsigned int count,
const char *hexDigitChars)
{
@@ -553,7 +545,7 @@ partAsHex (char *dst, integerPart part, unsigned int count,
}
/* Write out an unsigned decimal integer. */
-char *
+static char *
writeUnsignedDecimal (char *dst, unsigned int n)
{
char buff[40], *p;
@@ -571,7 +563,7 @@ writeUnsignedDecimal (char *dst, unsigned int n)
}
/* Write out a signed decimal integer. */
-char *
+static char *
writeSignedDecimal (char *dst, int value)
{
if (value < 0) {
@@ -583,8 +575,6 @@ writeSignedDecimal (char *dst, int value)
return dst;
}
-} // end anonymous namespace
-
/* Constructors. */
void
APFloat::initialize(const fltSemantics *ourSemantics)
@@ -862,13 +852,11 @@ APFloat::semanticsPrecision(const fltSemantics &semantics)
{
return semantics.precision;
}
-
APFloat::ExponentType
APFloat::semanticsMaxExponent(const fltSemantics &semantics)
{
return semantics.maxExponent;
}
-
APFloat::ExponentType
APFloat::semanticsMinExponent(const fltSemantics &semantics)
{
@@ -1919,6 +1907,7 @@ APFloat::opStatus APFloat::roundToIntegral(roundingMode rounding_mode) {
return fs;
}
+
/* Comparison requires normalized numbers. */
APFloat::cmpResult
APFloat::compare(const APFloat &rhs) const
@@ -2569,16 +2558,14 @@ APFloat::convertFromDecimalString(StringRef str, roundingMode rounding_mode)
/* Check whether the normalized exponent is high enough to overflow
max during the log-rebasing in the max-exponent check below. */
- } else if (D.normalizedExponent - 1 >
- std::numeric_limits<int>::max() / 42039) {
+ } else if (D.normalizedExponent - 1 > INT_MAX / 42039) {
fs = handleOverflow(rounding_mode);
/* If it wasn't, then it also wasn't high enough to overflow max
during the log-rebasing in the min-exponent check. Check that it
won't overflow min in either check, then perform the min-exponent
check. */
- } else if ((D.normalizedExponent - 1 <
- std::numeric_limits<int>::min() / 42039) ||
+ } else if (D.normalizedExponent - 1 < INT_MIN / 42039 ||
(D.normalizedExponent + 1) * 28738 <=
8651 * (semantics->minExponent - (int) semantics->precision)) {
/* Underflow to zero and round. */
@@ -3232,7 +3219,7 @@ APFloat::initFromQuadrupleAPInt(const APInt &api)
uint64_t mysignificand2 = i2 & 0xffffffffffffLL;
initialize(&APFloat::IEEEquad);
- assert(partCount() == 2);
+ assert(partCount()==2);
sign = static_cast<unsigned int>(i2>>63);
if (myexponent==0 &&
@@ -3498,7 +3485,6 @@ APFloat::APFloat(double d) {
}
namespace {
-
void append(SmallVectorImpl<char> &Buffer, StringRef Str) {
Buffer.append(Str.begin(), Str.end());
}
@@ -3535,6 +3521,7 @@ namespace {
significand = significand.trunc(significand.getActiveBits());
}
+
void AdjustToPrecision(SmallVectorImpl<char> &buffer,
int &exp, unsigned FormatPrecision) {
unsigned N = buffer.size();
@@ -3579,8 +3566,7 @@ namespace {
exp += FirstSignificant;
buffer.erase(&buffer[0], &buffer[FirstSignificant]);
}
-
-} // end anonymous namespace
+}
void APFloat::toString(SmallVectorImpl<char> &Str,
unsigned FormatPrecision,
OpenPOWER on IntegriCloud