blob: 003e847bbb448df4b2810ee1c16878b74139643c [file] [log] [blame]
Zachary Turner2d11c202015-02-27 09:15:59 +00001//===- LinePrinter.h ------------------------------------------ *- C++ --*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef LLVM_TOOLS_LLVMPDBDUMP_LINEPRINTER_H
11#define LLVM_TOOLS_LLVMPDBDUMP_LINEPRINTER_H
12
13#include "llvm/ADT/Twine.h"
14#include "llvm/Support/raw_ostream.h"
Zachary Turnerf5abda22015-03-01 06:49:49 +000015#include "llvm/Support/Regex.h"
16
17#include <list>
Zachary Turner2d11c202015-02-27 09:15:59 +000018
19namespace llvm {
20
21class LinePrinter {
22 friend class WithColor;
23
24public:
25 LinePrinter(int Indent, raw_ostream &Stream);
26
Zachary Turnerf5abda22015-03-01 06:49:49 +000027 template <typename Iter> void SetTypeFilters(Iter Begin, Iter End) {
28 TypeFilters.assign(Begin, End);
29 }
30 template <typename Iter> void SetSymbolFilters(Iter Begin, Iter End) {
31 SymbolFilters.assign(Begin, End);
32 }
33 template <typename Iter> void SetCompilandFilters(Iter Begin, Iter End) {
34 CompilandFilters.assign(Begin, End);
35 }
36
Zachary Turner2d11c202015-02-27 09:15:59 +000037 void Indent();
38 void Unindent();
Zachary Turner2d11c202015-02-27 09:15:59 +000039 void NewLine();
40
41 raw_ostream &getStream() { return OS; }
42
Zachary Turnerf5abda22015-03-01 06:49:49 +000043 bool IsTypeExcluded(llvm::StringRef TypeName);
44 bool IsSymbolExcluded(llvm::StringRef SymbolName);
45 bool IsCompilandExcluded(llvm::StringRef CompilandName);
46
Zachary Turner2d11c202015-02-27 09:15:59 +000047private:
48 raw_ostream &OS;
49 int IndentSpaces;
50 int CurrentIndent;
Zachary Turnerf5abda22015-03-01 06:49:49 +000051
52 std::list<Regex> CompilandFilters;
53 std::list<Regex> TypeFilters;
54 std::list<Regex> SymbolFilters;
Zachary Turner2d11c202015-02-27 09:15:59 +000055};
56
57template <class T>
58inline raw_ostream &operator<<(LinePrinter &Printer, const T &Item) {
59 Printer.getStream() << Item;
60 return Printer.getStream();
61}
62
63enum class PDB_ColorItem {
64 None,
65 Address,
66 Type,
67 Keyword,
68 Offset,
69 Identifier,
70 Path,
71 SectionHeader,
72 LiteralValue,
73};
74
75class WithColor {
76public:
77 WithColor(LinePrinter &P, PDB_ColorItem C);
78 ~WithColor();
79
80 raw_ostream &get() { return OS; }
81
82private:
83 void translateColor(PDB_ColorItem C, raw_ostream::Colors &Color,
84 bool &Bold) const;
85 raw_ostream &OS;
86};
87}
88
89#endif