blob: 67006b03b098eb53b9e21d94d2a64aa691c86b11 [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
Zachary Turner98162462015-03-01 06:59:57 +000013#include "llvm/ADT/StringRef.h"
Zachary Turner2d11c202015-02-27 09:15:59 +000014#include "llvm/ADT/Twine.h"
15#include "llvm/Support/raw_ostream.h"
Zachary Turnerf5abda22015-03-01 06:49:49 +000016#include "llvm/Support/Regex.h"
17
18#include <list>
Zachary Turner2d11c202015-02-27 09:15:59 +000019
20namespace llvm {
21
22class LinePrinter {
23 friend class WithColor;
24
25public:
26 LinePrinter(int Indent, raw_ostream &Stream);
27
28 void Indent();
29 void Unindent();
Zachary Turner2d11c202015-02-27 09:15:59 +000030 void NewLine();
31
32 raw_ostream &getStream() { return OS; }
Zachary Turner7797c722015-03-02 04:39:56 +000033 int getIndentLevel() const { return CurrentIndent; }
Zachary Turner2d11c202015-02-27 09:15:59 +000034
Zachary Turnerf5abda22015-03-01 06:49:49 +000035 bool IsTypeExcluded(llvm::StringRef TypeName);
36 bool IsSymbolExcluded(llvm::StringRef SymbolName);
37 bool IsCompilandExcluded(llvm::StringRef CompilandName);
38
Zachary Turner2d11c202015-02-27 09:15:59 +000039private:
Zachary Turner7797c722015-03-02 04:39:56 +000040 template <typename Iter>
41 void SetFilters(std::list<Regex> &List, Iter Begin, Iter End) {
42 List.clear();
43 for (; Begin != End; ++Begin)
Benjamin Kramerf5e2fc42015-05-29 19:43:39 +000044 List.emplace_back(StringRef(*Begin));
Zachary Turner7797c722015-03-02 04:39:56 +000045 }
46
Zachary Turner2d11c202015-02-27 09:15:59 +000047 raw_ostream &OS;
48 int IndentSpaces;
49 int CurrentIndent;
Zachary Turnerf5abda22015-03-01 06:49:49 +000050
Zachary Turner4dddcc62015-09-29 19:49:06 +000051 std::list<Regex> ExcludeCompilandFilters;
52 std::list<Regex> ExcludeTypeFilters;
53 std::list<Regex> ExcludeSymbolFilters;
54
55 std::list<Regex> IncludeCompilandFilters;
56 std::list<Regex> IncludeTypeFilters;
57 std::list<Regex> IncludeSymbolFilters;
Zachary Turner2d11c202015-02-27 09:15:59 +000058};
59
60template <class T>
61inline raw_ostream &operator<<(LinePrinter &Printer, const T &Item) {
62 Printer.getStream() << Item;
63 return Printer.getStream();
64}
65
66enum class PDB_ColorItem {
67 None,
68 Address,
69 Type,
70 Keyword,
71 Offset,
72 Identifier,
73 Path,
74 SectionHeader,
75 LiteralValue,
Zachary Turner7797c722015-03-02 04:39:56 +000076 Register,
Zachary Turner2d11c202015-02-27 09:15:59 +000077};
78
79class WithColor {
80public:
81 WithColor(LinePrinter &P, PDB_ColorItem C);
82 ~WithColor();
83
84 raw_ostream &get() { return OS; }
85
86private:
87 void translateColor(PDB_ColorItem C, raw_ostream::Colors &Color,
88 bool &Bold) const;
89 raw_ostream &OS;
90};
91}
92
93#endif