summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-pdbutil/LinePrinter.h
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/tools/llvm-pdbutil/LinePrinter.h')
-rw-r--r--llvm/tools/llvm-pdbutil/LinePrinter.h33
1 files changed, 30 insertions, 3 deletions
diff --git a/llvm/tools/llvm-pdbutil/LinePrinter.h b/llvm/tools/llvm-pdbutil/LinePrinter.h
index a831dbd9e6e..09bde28f516 100644
--- a/llvm/tools/llvm-pdbutil/LinePrinter.h
+++ b/llvm/tools/llvm-pdbutil/LinePrinter.h
@@ -93,14 +93,41 @@ private:
std::list<Regex> IncludeSymbolFilters;
};
+struct PrintScope {
+ explicit PrintScope(LinePrinter &P, uint32_t IndentLevel)
+ : P(P), IndentLevel(IndentLevel) {}
+ explicit PrintScope(const PrintScope &Other, uint32_t LabelWidth)
+ : P(Other.P), IndentLevel(Other.IndentLevel), LabelWidth(LabelWidth) {}
+
+ LinePrinter &P;
+ uint32_t IndentLevel;
+ uint32_t LabelWidth = 0;
+};
+
+inline Optional<PrintScope> withLabelWidth(const Optional<PrintScope> &Scope,
+ uint32_t W) {
+ if (!Scope)
+ return None;
+ return PrintScope{*Scope, W};
+}
+
struct AutoIndent {
explicit AutoIndent(LinePrinter &L, uint32_t Amount = 0)
- : L(L), Amount(Amount) {
+ : L(&L), Amount(Amount) {
L.Indent(Amount);
}
- ~AutoIndent() { L.Unindent(Amount); }
+ explicit AutoIndent(const Optional<PrintScope> &Scope) {
+ if (Scope.hasValue()) {
+ L = &Scope->P;
+ Amount = Scope->IndentLevel;
+ }
+ }
+ ~AutoIndent() {
+ if (L)
+ L->Unindent(Amount);
+ }
- LinePrinter &L;
+ LinePrinter *L = nullptr;
uint32_t Amount = 0;
};
OpenPOWER on IntegriCloud