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

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25#ifndef LLVM_SUPPORT_FORMATVARIADIC_H

26#define LLVM_SUPPORT_FORMATVARIADIC_H

27

37#include

38#include

39#include

40#include

41#include

42#include

43

44namespace llvm {

45

47

55

63};

64

66protected:

70

75

78

79public:

82 for (const auto &R : Replacements) {

84 S << R.Spec;

85 continue;

86 }

87 if (R.Index >= Adapters.size()) {

88 S << R.Spec;

89 continue;

90 }

91

93

95 Align.format(S, R.Options);

96 }

97 }

98

99

102

103 std::string str() const {

104 std::string Result;

106 Stream << *this;

108 return Result;

109 }

110

114 Stream << *this;

115 return Result;

116 }

117

118 template operator SmallString() const { return sstr(); }

119

120 operator std::string() const { return str(); }

121};

122

124

125

126

127 Tuple Parameters;

128 std::array<support::detail::format_adapter *, std::tuple_size::value>

129 ParameterPointers;

130

131

132

133

134

135

136

137

138 struct create_adapters {

139 template <typename... Ts>

140 std::array<support::detail::format_adapter *, std::tuple_size::value>

141 operator()(Ts &...Items) {

142 return {{&Items...}};

143 }

144 };

145

146public:

149 Parameters(std::move(Params)) {

150 ParameterPointers = std::apply(create_adapters(), Parameters);

151 }

152

154

157 Parameters(std::move(rhs.Parameters)) {

158 ParameterPointers = std::apply(create_adapters(), Parameters);

159 Adapters = ParameterPointers;

160 }

161};

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239

240

241

242

243

244

245

246

247

248

249

250

251template <typename... Ts>

252inline auto formatv(bool Validate, const char *Fmt, Ts &&...Vals) {

253 auto Params = std::make_tuple(

256}

257

258

259template <typename... Ts> inline auto formatv(const char *Fmt, Ts &&...Vals) {

260 return formatv<Ts...>(true, Fmt, std::forward(Vals)...);

261}

262

263}

264

265#endif

This file defines the SmallString class.

This file defines the SmallVector class.

ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...

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

This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.

StringRef - Represent a constant reference to a string, i.e.

The instances of the Type class are immutable: once they are created, they are never changed.

void format(raw_ostream &S) const

formatv_object_base(formatv_object_base &&rhs)=default

static SmallVector< ReplacementItem, 2 > parseFormatString(StringRef Fmt, size_t NumArgs, bool Validate)

formatv_object_base(StringRef Fmt, ArrayRef< support::detail::format_adapter * > Adapters, bool Validate)

ArrayRef< support::detail::format_adapter * > Adapters

formatv_object_base(formatv_object_base const &rhs)=delete

SmallString< N > sstr() const

formatv_object(formatv_object &&rhs)

formatv_object(StringRef Fmt, Tuple &&Params, bool Validate)

formatv_object(formatv_object const &rhs)=delete

This class implements an extremely fast bulk output stream that can only output to a stream.

A raw_ostream that writes to an std::string.

A raw_ostream that writes to an SmallVector or SmallString.

std::enable_if_t< uses_format_member< T >::value, T > build_format_adapter(T &&Item)

This is an optimization pass for GlobalISel generic memory operations.

auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)

OutputIt move(R &&Range, OutputIt Out)

Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.

Implement std::hash so that hash_code can be used in STL containers.

This struct is a compact representation of a valid (non-zero power of two) alignment.

Helper class to format to a Width wide field, with alignment Where within that field.

ReplacementItem(StringRef Literal)

ReplacementItem(StringRef Spec, unsigned Index, unsigned Width, AlignStyle Where, char Pad, StringRef Options)