LLVM: include/llvm/Support/FormattedStream.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14#ifndef LLVM_SUPPORT_FORMATTEDSTREAM_H

15#define LLVM_SUPPORT_FORMATTEDSTREAM_H

16

20#include

21

22namespace llvm {

23

24

25

26

27

28

29

30

32

33

34

36

37

38

39

40

41 std::pair<unsigned, unsigned> Position;

42

43

44

45

46 const char *Scanned;

47

48

49

50

51

52

53

55

56

57

58 bool DisableScan;

59

60 void write_impl(const char *Ptr, size_t Size) override;

61

62

63

64 uint64_t current_pos() const override {

65

66

67

68 return TheStream->tell();

69 }

70

71

72

73

74

75 void ComputePosition(const char *Ptr, size_t size);

76

77

78

79

80 void UpdatePosition(const char *Ptr, size_t Size);

81

83 releaseStream();

84

85 TheStream = &Stream;

86

87

88

89

90

91 if (size_t BufferSize = TheStream->GetBufferSize())

93 else

95 TheStream->SetUnbuffered();

96

98

99 Scanned = nullptr;

100 }

101

102 void PreDisableScan() {

103 assert(!DisableScan);

105 assert(PartialUTF8Char.empty());

106 DisableScan = true;

107 }

108

109 void PostDisableScan() {

111 DisableScan = false;

113 }

114

115 struct DisableScanScope {

117

119 S->PreDisableScan();

120 }

121 ~DisableScanScope() { S->PostDisableScan(); }

122 };

123

124public:

125

126

127

128

129

130

131

132

133

134

136 : TheStream(nullptr), Position(0, 0), DisableScan(false) {

137 setStream(Stream);

138 }

140 : TheStream(nullptr), Position(0, 0), Scanned(nullptr),

141 DisableScan(false) {}

142

145 releaseStream();

146 }

147

148

149

150

151

152

154

156

158 return Position.first;

159 }

160

162

164 return Position.second;

165 }

166

169 DisableScanScope S(this);

171 }

172 return *this;

173 }

174

177 DisableScanScope S(this);

179 }

180 return *this;

181 }

182

184 bool BG = false) override {

186 DisableScanScope S(this);

188 }

189 return *this;

190 }

191

193 return TheStream->is_displayed();

194 }

195

196private:

197 void releaseStream() {

198

199

200 if (!TheStream)

201 return;

202 if (size_t BufferSize = GetBufferSize())

203 TheStream->SetBufferSize(BufferSize);

204 else

205 TheStream->SetUnbuffered();

206 }

207};

208

209

210

212

213

214

216

217

218

220

221}

222

223

224#endif

assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")

This file defines the SmallString class.

SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...

formatted_raw_ostream - A raw_ostream that wraps another one and keeps track of line and column posit...

Definition FormattedStream.h:31

bool is_displayed() const override

This function determines if this stream is connected to a "tty" or "console" window.

Definition FormattedStream.h:192

~formatted_raw_ostream() override

Definition FormattedStream.h:143

raw_ostream & resetColor() override

Resets the colors to terminal defaults.

Definition FormattedStream.h:167

unsigned getColumn()

Definition FormattedStream.h:155

unsigned getLine()

Definition FormattedStream.h:161

formatted_raw_ostream()

Definition FormattedStream.h:139

raw_ostream & changeColor(enum Colors Color, bool Bold=false, bool BG=false) override

Changes the foreground color of text that will be output from this point forward.

Definition FormattedStream.h:183

formatted_raw_ostream(raw_ostream &Stream)

formatted_raw_ostream - Open the specified file for writing.

Definition FormattedStream.h:135

raw_ostream & reverseColor() override

Reverses the foreground and background colors.

Definition FormattedStream.h:175

raw_ostream(bool unbuffered=false, OStreamKind K=OStreamKind::OK_OStream)

void SetBufferSize(size_t Size)

Set the stream to be buffered, using the specified buffer size.

virtual raw_ostream & changeColor(enum Colors Color, bool Bold=false, bool BG=false)

Changes the foreground color of text that will be output from this point forward.

virtual raw_ostream & resetColor()

Resets the colors to terminal defaults.

virtual raw_ostream & reverseColor()

Reverses the foreground and background colors.

void SetUnbuffered()

Set the stream to be unbuffered.

const char * getBufferStart() const

Return the beginning of the current stream buffer, or 0 if the stream is unbuffered.

virtual void enable_colors(bool enable)

size_t GetNumBytesInBuffer() const

bool colors_enabled() const

This is an optimization pass for GlobalISel generic memory operations.

auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)

Get the size of a range.

LLVM_ABI formatted_raw_ostream & fdbgs()

fdbgs() - This returns a reference to a formatted_raw_ostream for debug output.

LLVM_ABI formatted_raw_ostream & fouts()

fouts() - This returns a reference to a formatted_raw_ostream for standard output.

LLVM_ABI formatted_raw_ostream & ferrs()

ferrs() - This returns a reference to a formatted_raw_ostream for standard error.