blob: a4401f8af9552c9947335b9a5166b383c2316067 [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 {
Zachary Turnerec28fc32016-05-04 20:32:13 +000021namespace pdb {
Zachary Turner2d11c202015-02-27 09:15:59 +000022
23class LinePrinter {
24 friend class WithColor;
25
26public:
27 LinePrinter(int Indent, raw_ostream &Stream);
28
29 void Indent();
30 void Unindent();
Zachary Turner2d11c202015-02-27 09:15:59 +000031 void NewLine();
32
33 raw_ostream &getStream() { return OS; }
Zachary Turner7797c722015-03-02 04:39:56 +000034 int getIndentLevel() const { return CurrentIndent; }
Zachary Turner2d11c202015-02-27 09:15:59 +000035
Zachary Turnerf5abda22015-03-01 06:49:49 +000036 bool IsTypeExcluded(llvm::StringRef TypeName);
37 bool IsSymbolExcluded(llvm::StringRef SymbolName);
38 bool IsCompilandExcluded(llvm::StringRef CompilandName);
39
Zachary Turner2d11c202015-02-27 09:15:59 +000040private:
Zachary Turner7797c722015-03-02 04:39:56 +000041 template <typename Iter>
42 void SetFilters(std::list<Regex> &List, Iter Begin, Iter End) {
43 List.clear();
44 for (; Begin != End; ++Begin)
Benjamin Kramerf5e2fc42015-05-29 19:43:39 +000045 List.emplace_back(StringRef(*Begin));
Zachary Turner7797c722015-03-02 04:39:56 +000046 }
47
Zachary Turner2d11c202015-02-27 09:15:59 +000048 raw_ostream &OS;
49 int IndentSpaces;
50 int CurrentIndent;
Zachary Turnerf5abda22015-03-01 06:49:49 +000051
Zachary Turner4dddcc62015-09-29 19:49:06 +000052 std::list<Regex> ExcludeCompilandFilters;
53 std::list<Regex> ExcludeTypeFilters;
54 std::list<Regex> ExcludeSymbolFilters;
55
56 std::list<Regex> IncludeCompilandFilters;
57 std::list<Regex> IncludeTypeFilters;
58 std::list<Regex> IncludeSymbolFilters;
Zachary Turner2d11c202015-02-27 09:15:59 +000059};
60
61template <class T>
62inline raw_ostream &operator<<(LinePrinter &Printer, const T &Item) {
63 Printer.getStream() << Item;
64 return Printer.getStream();
65}
66
67enum class PDB_ColorItem {
68 None,
69 Address,
70 Type,
71 Keyword,
72 Offset,
73 Identifier,
74 Path,
75 SectionHeader,
76 LiteralValue,
Zachary Turner7797c722015-03-02 04:39:56 +000077 Register,
Zachary Turner2d11c202015-02-27 09:15:59 +000078};
79
80class WithColor {
81public:
82 WithColor(LinePrinter &P, PDB_ColorItem C);
83 ~WithColor();
84
85 raw_ostream &get() { return OS; }
86
87private:
Rui Ueyamafa05aac2015-11-03 01:04:44 +000088 void applyColor(PDB_ColorItem C);
Zachary Turner2d11c202015-02-27 09:15:59 +000089 raw_ostream &OS;
90};
91}
Zachary Turnerec28fc32016-05-04 20:32:13 +000092}
Zachary Turner2d11c202015-02-27 09:15:59 +000093
94#endif