aboutsummaryrefslogtreecommitdiff
path: root/tools/lldb-test/FormatUtil.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2019-01-19 10:06:29 +0000
committerDimitry Andric <dim@FreeBSD.org>2019-01-19 10:06:29 +0000
commit94994d372d014ce4c8758b9605d63fae651bd8aa (patch)
tree51c0b708bd59f205d6b35cb2a8c24d62f0c33d77 /tools/lldb-test/FormatUtil.cpp
parent39be7ce23363d12ae3e49aeb1fdb2bfeb892e836 (diff)
Diffstat (limited to 'tools/lldb-test/FormatUtil.cpp')
-rw-r--r--tools/lldb-test/FormatUtil.cpp47
1 files changed, 22 insertions, 25 deletions
diff --git a/tools/lldb-test/FormatUtil.cpp b/tools/lldb-test/FormatUtil.cpp
index 381cbd6e25b8..970f25a6b42f 100644
--- a/tools/lldb-test/FormatUtil.cpp
+++ b/tools/lldb-test/FormatUtil.cpp
@@ -14,6 +14,11 @@
using namespace lldb_private;
using namespace llvm;
+LinePrinter::Line::~Line() {
+ if (P)
+ P->NewLine();
+}
+
LinePrinter::LinePrinter(int Indent, llvm::raw_ostream &Stream)
: OS(Stream), IndentSpaces(Indent), CurrentIndent(0) {}
@@ -31,39 +36,31 @@ void LinePrinter::Unindent(uint32_t Amount) {
void LinePrinter::NewLine() {
OS << "\n";
- OS.indent(CurrentIndent);
-}
-
-void LinePrinter::print(const Twine &T) { OS << T; }
-
-void LinePrinter::printLine(const Twine &T) {
- NewLine();
- OS << T;
}
void LinePrinter::formatBinary(StringRef Label, ArrayRef<uint8_t> Data,
uint32_t StartOffset) {
- NewLine();
- OS << Label << " (";
- if (!Data.empty()) {
- OS << "\n";
- OS << format_bytes_with_ascii(Data, StartOffset, 32, 4,
- CurrentIndent + IndentSpaces, true);
- NewLine();
+ if (Data.empty()) {
+ line() << Label << " ()";
+ return;
}
- OS << ")";
+ line() << Label << " (";
+ OS << format_bytes_with_ascii(Data, StartOffset, 32, 4,
+ CurrentIndent + IndentSpaces, true);
+ NewLine();
+ line() << ")";
}
void LinePrinter::formatBinary(StringRef Label, ArrayRef<uint8_t> Data,
uint64_t Base, uint32_t StartOffset) {
- NewLine();
- OS << Label << " (";
- if (!Data.empty()) {
- OS << "\n";
- Base += StartOffset;
- OS << format_bytes_with_ascii(Data, Base, 32, 4,
- CurrentIndent + IndentSpaces, true);
- NewLine();
+ if (Data.empty()) {
+ line() << Label << " ()";
+ return;
}
- OS << ")";
+ line() << Label << " (";
+ Base += StartOffset;
+ OS << format_bytes_with_ascii(Data, Base, 32, 4, CurrentIndent + IndentSpaces,
+ true);
+ NewLine();
+ line() << ")";
}