summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/raw_ostream.cpp
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2016-11-11 23:57:40 +0000
committerZachary Turner <zturner@google.com>2016-11-11 23:57:40 +0000
commit11db2642fb54487ef18c18cc8555d7ff2f5e823b (patch)
tree0398b217a7902566a3b9309268b2290dd900fc5c /llvm/lib/Support/raw_ostream.cpp
parentda6b5721b52a9f8d74dceec91e19c230af271fb6 (diff)
downloadbcm5719-llvm-11db2642fb54487ef18c18cc8555d7ff2f5e823b.tar.gz
bcm5719-llvm-11db2642fb54487ef18c18cc8555d7ff2f5e823b.zip
[Support] Introduce llvm::formatv() function.
This introduces a new type-safe general purpose formatting library. It provides compile-time type safety, does not require a format specifier (since the type is deduced), and provides mechanisms for extending the format capability to user defined types, and overriding the formatting behavior for existing types. This patch additionally adds documentation for the API to the LLVM programmer's manual. Mailing List Thread: http://lists.llvm.org/pipermail/llvm-dev/2016-October/105836.html Differential Revision: https://reviews.llvm.org/D25587 llvm-svn: 286682
Diffstat (limited to 'llvm/lib/Support/raw_ostream.cpp')
-rw-r--r--llvm/lib/Support/raw_ostream.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp
index 218d4986fff..92c7967cd8f 100644
--- a/llvm/lib/Support/raw_ostream.cpp
+++ b/llvm/lib/Support/raw_ostream.cpp
@@ -20,6 +20,7 @@
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Format.h"
+#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/NativeFormatting.h"
#include "llvm/Support/Process.h"
@@ -114,22 +115,22 @@ void raw_ostream::SetBufferAndMode(char *BufferStart, size_t Size,
}
raw_ostream &raw_ostream::operator<<(unsigned long N) {
- write_integer(*this, static_cast<uint64_t>(N), IntegerStyle::Integer);
+ write_integer(*this, static_cast<uint64_t>(N), 0, IntegerStyle::Integer);
return *this;
}
raw_ostream &raw_ostream::operator<<(long N) {
- write_integer(*this, static_cast<int64_t>(N), IntegerStyle::Integer);
+ write_integer(*this, static_cast<int64_t>(N), 0, IntegerStyle::Integer);
return *this;
}
raw_ostream &raw_ostream::operator<<(unsigned long long N) {
- write_integer(*this, static_cast<uint64_t>(N), IntegerStyle::Integer);
+ write_integer(*this, static_cast<uint64_t>(N), 0, IntegerStyle::Integer);
return *this;
}
raw_ostream &raw_ostream::operator<<(long long N) {
- write_integer(*this, static_cast<int64_t>(N), IntegerStyle::Integer);
+ write_integer(*this, static_cast<int64_t>(N), 0, IntegerStyle::Integer);
return *this;
}
@@ -318,6 +319,12 @@ raw_ostream &raw_ostream::operator<<(const format_object_base &Fmt) {
}
}
+raw_ostream &raw_ostream::operator<<(const formatv_object_base &Obj) {
+ SmallString<128> S;
+ Obj.format(*this);
+ return *this;
+}
+
raw_ostream &raw_ostream::operator<<(const FormattedString &FS) {
unsigned Len = FS.Str.size();
int PadAmount = FS.Width - Len;
@@ -344,7 +351,7 @@ raw_ostream &raw_ostream::operator<<(const FormattedNumber &FN) {
} else {
llvm::SmallString<16> Buffer;
llvm::raw_svector_ostream Stream(Buffer);
- llvm::write_integer(Stream, FN.DecValue, IntegerStyle::Integer);
+ llvm::write_integer(Stream, FN.DecValue, 0, IntegerStyle::Integer);
if (Buffer.size() < FN.Width)
indent(FN.Width - Buffer.size());
(*this) << Buffer;
OpenPOWER on IntegriCloud