/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/tools/lldb-test/FormatUtil.h
Line | Count | Source (jump to first uncovered line) |
1 | | //===- FormatUtil.h ------------------------------------------- *- C++ --*-===// |
2 | | // |
3 | | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | | // See https://llvm.org/LICENSE.txt for license information. |
5 | | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | | // |
7 | | //===----------------------------------------------------------------------===// |
8 | | |
9 | | #ifndef LLDB_TOOLS_LLDB_TEST_FORMATUTIL_H |
10 | | #define LLDB_TOOLS_LLDB_TEST_FORMATUTIL_H |
11 | | |
12 | | #include "llvm/ADT/ArrayRef.h" |
13 | | #include "llvm/ADT/StringRef.h" |
14 | | #include "llvm/ADT/Twine.h" |
15 | | #include "llvm/Support/FormatVariadic.h" |
16 | | #include "llvm/Support/raw_ostream.h" |
17 | | |
18 | | #include <list> |
19 | | |
20 | | namespace lldb_private { |
21 | | |
22 | | class LinePrinter { |
23 | | llvm::raw_ostream &OS; |
24 | | int IndentSpaces; |
25 | | int CurrentIndent; |
26 | | |
27 | | public: |
28 | | class Line { |
29 | | LinePrinter *P; |
30 | | |
31 | | public: |
32 | 593k | Line(LinePrinter &P) : P(&P) { P.OS.indent(P.CurrentIndent); } |
33 | | ~Line(); |
34 | | |
35 | 0 | Line(Line &&RHS) : P(RHS.P) { RHS.P = nullptr; } |
36 | | void operator=(Line &&) = delete; |
37 | | |
38 | 593k | operator llvm::raw_ostream &() { return P->OS; } |
39 | | }; |
40 | | |
41 | | LinePrinter(int Indent, llvm::raw_ostream &Stream); |
42 | | |
43 | | void Indent(uint32_t Amount = 0); |
44 | | void Unindent(uint32_t Amount = 0); |
45 | | void NewLine(); |
46 | | |
47 | 593k | void printLine(const llvm::Twine &T) { line() << T; } |
48 | 593k | template <typename... Ts> void formatLine(const char *Fmt, Ts &&... Items) { |
49 | 593k | printLine(llvm::formatv(Fmt, std::forward<Ts>(Items)...)); |
50 | 593k | } void lldb_private::LinePrinter::formatLine<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&>(char const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) Line | Count | Source | 48 | 23 | template <typename... Ts> void formatLine(const char *Fmt, Ts &&... Items) { | 49 | 23 | printLine(llvm::formatv(Fmt, std::forward<Ts>(Items)...)); | 50 | 23 | } |
void lldb_private::LinePrinter::formatLine<llvm::StringRef>(char const*, llvm::StringRef&&) Line | Count | Source | 48 | 65.9k | template <typename... Ts> void formatLine(const char *Fmt, Ts &&... Items) { | 49 | 65.9k | printLine(llvm::formatv(Fmt, std::forward<Ts>(Items)...)); | 50 | 65.9k | } |
void lldb_private::LinePrinter::formatLine<unsigned long, llvm::StringRef>(char const*, unsigned long&&, llvm::StringRef&&) Line | Count | Source | 48 | 69 | template <typename... Ts> void formatLine(const char *Fmt, Ts &&... Items) { | 49 | 69 | printLine(llvm::formatv(Fmt, std::forward<Ts>(Items)...)); | 50 | 69 | } |
void lldb_private::LinePrinter::formatLine<>(char const*) Line | Count | Source | 48 | 40 | template <typename... Ts> void formatLine(const char *Fmt, Ts &&... Items) { | 49 | 40 | printLine(llvm::formatv(Fmt, std::forward<Ts>(Items)...)); | 50 | 40 | } |
void lldb_private::LinePrinter::formatLine<int>(char const*, int&&) Line | Count | Source | 48 | 40 | template <typename... Ts> void formatLine(const char *Fmt, Ts &&... Items) { | 49 | 40 | printLine(llvm::formatv(Fmt, std::forward<Ts>(Items)...)); | 50 | 40 | } |
void lldb_private::LinePrinter::formatLine<bool>(char const*, bool&&) Line | Count | Source | 48 | 65.9k | template <typename... Ts> void formatLine(const char *Fmt, Ts &&... Items) { | 49 | 65.9k | printLine(llvm::formatv(Fmt, std::forward<Ts>(Items)...)); | 50 | 65.9k | } |
void lldb_private::LinePrinter::formatLine<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&>(char const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Line | Count | Source | 48 | 57 | template <typename... Ts> void formatLine(const char *Fmt, Ts &&... Items) { | 49 | 57 | printLine(llvm::formatv(Fmt, std::forward<Ts>(Items)...)); | 50 | 57 | } |
void lldb_private::LinePrinter::formatLine<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(char const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&&) Line | Count | Source | 48 | 57 | template <typename... Ts> void formatLine(const char *Fmt, Ts &&... Items) { | 49 | 57 | printLine(llvm::formatv(Fmt, std::forward<Ts>(Items)...)); | 50 | 57 | } |
void lldb_private::LinePrinter::formatLine<lldb_private::ObjectFile::Type>(char const*, lldb_private::ObjectFile::Type&&) Line | Count | Source | 48 | 57 | template <typename... Ts> void formatLine(const char *Fmt, Ts &&... Items) { | 49 | 57 | printLine(llvm::formatv(Fmt, std::forward<Ts>(Items)...)); | 50 | 57 | } |
void lldb_private::LinePrinter::formatLine<lldb_private::ObjectFile::Strata>(char const*, lldb_private::ObjectFile::Strata&&) Line | Count | Source | 48 | 57 | template <typename... Ts> void formatLine(const char *Fmt, Ts &&... Items) { | 49 | 57 | printLine(llvm::formatv(Fmt, std::forward<Ts>(Items)...)); | 50 | 57 | } |
void lldb_private::LinePrinter::formatLine<unsigned long long>(char const*, unsigned long long&&) Line | Count | Source | 48 | 263k | template <typename... Ts> void formatLine(const char *Fmt, Ts &&... Items) { | 49 | 263k | printLine(llvm::formatv(Fmt, std::forward<Ts>(Items)...)); | 50 | 263k | } |
void lldb_private::LinePrinter::formatLine<char const*>(char const*, char const*&&) Line | Count | Source | 48 | 131k | template <typename... Ts> void formatLine(const char *Fmt, Ts &&... Items) { | 49 | 131k | printLine(llvm::formatv(Fmt, std::forward<Ts>(Items)...)); | 50 | 131k | } |
void lldb_private::LinePrinter::formatLine<unsigned long&, char const*>(char const*, unsigned long&, char const*&&) Line | Count | Source | 48 | 67 | template <typename... Ts> void formatLine(const char *Fmt, Ts &&... Items) { | 49 | 67 | printLine(llvm::formatv(Fmt, std::forward<Ts>(Items)...)); | 50 | 67 | } |
void lldb_private::LinePrinter::formatLine<unsigned long&>(char const*, unsigned long&) Line | Count | Source | 48 | 65.8k | template <typename... Ts> void formatLine(const char *Fmt, Ts &&... Items) { | 49 | 65.8k | printLine(llvm::formatv(Fmt, std::forward<Ts>(Items)...)); | 50 | 65.8k | } |
Unexecuted instantiation: void lldb_private::LinePrinter::formatLine<unsigned int&>(char const*, unsigned int&) |
51 | | |
52 | | void formatBinary(llvm::StringRef Label, llvm::ArrayRef<uint8_t> Data, |
53 | | uint32_t StartOffset); |
54 | | void formatBinary(llvm::StringRef Label, llvm::ArrayRef<uint8_t> Data, |
55 | | uint64_t BaseAddr, uint32_t StartOffset); |
56 | | |
57 | 593k | Line line() { return Line(*this); } |
58 | 0 | int getIndentLevel() const { return CurrentIndent; } |
59 | | }; |
60 | | |
61 | | struct AutoIndent { |
62 | | explicit AutoIndent(LinePrinter &L, uint32_t Amount = 0) |
63 | 65.8k | : L(&L), Amount(Amount) { |
64 | 65.8k | L.Indent(Amount); |
65 | 65.8k | } |
66 | 65.8k | ~AutoIndent() { |
67 | 65.8k | if (L) |
68 | 65.8k | L->Unindent(Amount); |
69 | 65.8k | } |
70 | | |
71 | | LinePrinter *L = nullptr; |
72 | | uint32_t Amount = 0; |
73 | | }; |
74 | | |
75 | | } // namespace lldb_private |
76 | | |
77 | | #endif |