1 //===- LinePrinter.cpp ------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "LinePrinter.h"
12 #include "llvm/Support/Regex.h"
18 LinePrinter::LinePrinter(int Indent, llvm::raw_ostream &Stream)
19 : OS(Stream), IndentSpaces(Indent), CurrentIndent(0) {}
21 void LinePrinter::Indent() { CurrentIndent += IndentSpaces; }
23 void LinePrinter::Unindent() {
24 CurrentIndent = std::max(0, CurrentIndent - IndentSpaces);
27 void LinePrinter::NewLine() {
29 OS.indent(CurrentIndent);
32 bool LinePrinter::IsTypeExcluded(llvm::StringRef TypeName) {
36 for (auto &Expr : TypeFilters) {
37 if (Expr.match(TypeName))
43 bool LinePrinter::IsSymbolExcluded(llvm::StringRef SymbolName) {
44 if (SymbolName.empty())
47 for (auto &Expr : SymbolFilters) {
48 if (Expr.match(SymbolName))
54 bool LinePrinter::IsCompilandExcluded(llvm::StringRef CompilandName) {
55 if (CompilandName.empty())
58 for (auto &Expr : CompilandFilters) {
59 if (Expr.match(CompilandName))
65 WithColor::WithColor(LinePrinter &P, PDB_ColorItem C) : OS(P.OS) {
66 if (C == PDB_ColorItem::None)
69 raw_ostream::Colors Color;
71 translateColor(C, Color, Bold);
72 OS.changeColor(Color, Bold);
76 WithColor::~WithColor() { OS.resetColor(); }
78 void WithColor::translateColor(PDB_ColorItem C, raw_ostream::Colors &Color,
81 case PDB_ColorItem::Address:
82 Color = raw_ostream::YELLOW;
85 case PDB_ColorItem::Keyword:
86 Color = raw_ostream::MAGENTA;
89 case PDB_ColorItem::Offset:
90 Color = raw_ostream::YELLOW;
93 case PDB_ColorItem::Type:
94 Color = raw_ostream::CYAN;
97 case PDB_ColorItem::Identifier:
98 Color = raw_ostream::CYAN;
101 case PDB_ColorItem::Path:
102 Color = raw_ostream::CYAN;
105 case PDB_ColorItem::SectionHeader:
106 Color = raw_ostream::RED;
109 case PDB_ColorItem::LiteralValue:
110 Color = raw_ostream::GREEN;