summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/raw_ostream.cpp
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2016-10-29 00:27:22 +0000
committerZachary Turner <zturner@google.com>2016-10-29 00:27:22 +0000
commit5b2243e8840b5cac1a9b0068b1cfbef15067af3a (patch)
tree3a9e2ca0b044e6f9e663e1ea989fcf88c4044913 /llvm/lib/Support/raw_ostream.cpp
parent7be6b4963cfa5bf412be9f35aede7957397632b1 (diff)
downloadbcm5719-llvm-5b2243e8840b5cac1a9b0068b1cfbef15067af3a.tar.gz
bcm5719-llvm-5b2243e8840b5cac1a9b0068b1cfbef15067af3a.zip
Resubmit "Add support for advanced number formatting."
This resubmits r284436 and r284437, which were reverted in r284462 as they were breaking the AArch64 buildbot. The breakage on AArch64 turned out to be a miscompile which is still not fixed, but is actively tracked at llvm.org/pr30748. This resubmission re-writes the code in a way so as to make the miscompile not happen. llvm-svn: 285483
Diffstat (limited to 'llvm/lib/Support/raw_ostream.cpp')
-rw-r--r--llvm/lib/Support/raw_ostream.cpp32
1 files changed, 23 insertions, 9 deletions
diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp
index 8101bc1d2f3..b6835e3ebfe 100644
--- a/llvm/lib/Support/raw_ostream.cpp
+++ b/llvm/lib/Support/raw_ostream.cpp
@@ -114,27 +114,27 @@ void raw_ostream::SetBufferAndMode(char *BufferStart, size_t Size,
}
raw_ostream &raw_ostream::operator<<(unsigned long N) {
- write_ulong(*this, N, 0);
+ write_integer(*this, static_cast<uint64_t>(N), IntegerStyle::Integer);
return *this;
}
raw_ostream &raw_ostream::operator<<(long N) {
- write_long(*this, N, 0);
+ write_integer(*this, static_cast<int64_t>(N), IntegerStyle::Integer);
return *this;
}
raw_ostream &raw_ostream::operator<<(unsigned long long N) {
- write_ulonglong(*this, N, 0);
+ write_integer(*this, static_cast<uint64_t>(N), IntegerStyle::Integer);
return *this;
}
raw_ostream &raw_ostream::operator<<(long long N) {
- write_longlong(*this, N, 0);
+ write_integer(*this, static_cast<int64_t>(N), IntegerStyle::Integer);
return *this;
}
raw_ostream &raw_ostream::write_hex(unsigned long long N) {
- llvm::write_hex(*this, N, 0, false, false);
+ llvm::write_hex(*this, N, HexPrintStyle::Lower);
return *this;
}
@@ -179,12 +179,12 @@ raw_ostream &raw_ostream::write_escaped(StringRef Str,
}
raw_ostream &raw_ostream::operator<<(const void *P) {
- llvm::write_hex(*this, (uintptr_t)P, 0, false, true);
+ llvm::write_hex(*this, (uintptr_t)P, HexPrintStyle::PrefixLower);
return *this;
}
raw_ostream &raw_ostream::operator<<(double N) {
- llvm::write_double(*this, N, 0, 0, FloatStyle::Exponent);
+ llvm::write_double(*this, N, FloatStyle::Exponent);
return *this;
}
@@ -331,9 +331,23 @@ raw_ostream &raw_ostream::operator<<(const FormattedString &FS) {
raw_ostream &raw_ostream::operator<<(const FormattedNumber &FN) {
if (FN.Hex) {
- llvm::write_hex(*this, FN.HexValue, FN.Width, FN.Upper, FN.HexPrefix);
+ HexPrintStyle Style;
+ if (FN.Upper && FN.HexPrefix)
+ Style = HexPrintStyle::PrefixUpper;
+ else if (FN.Upper && !FN.HexPrefix)
+ Style = HexPrintStyle::Upper;
+ else if (!FN.Upper && FN.HexPrefix)
+ Style = HexPrintStyle::PrefixLower;
+ else
+ Style = HexPrintStyle::Lower;
+ llvm::write_hex(*this, FN.HexValue, Style, FN.Width);
} else {
- llvm::write_longlong(*this, FN.DecValue, FN.Width);
+ llvm::SmallString<16> Buffer;
+ llvm::raw_svector_ostream Stream(Buffer);
+ llvm::write_integer(Stream, FN.DecValue, IntegerStyle::Integer);
+ if (Buffer.size() < FN.Width)
+ indent(FN.Width - Buffer.size());
+ (*this) << Buffer;
}
return *this;
}
OpenPOWER on IntegriCloud