Skip to content

Commit 0021013

Browse files
committed
Support: add 6-parameter format
Since we cannot yet use variadic templates, add a specialisation for 6-parameters to format. This is motivated by a need for the additional parameter for formatting information for an unwind decoder for Windows on ARM. llvm-svn: 209999
1 parent b327103 commit 0021013

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

llvm/include/llvm/Support/Format.h

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,30 @@ class format_object5 : public format_object_base {
170170
}
171171
};
172172

173+
/// format_object6 - This is a templated helper class used by the format
174+
/// function that captures the object to be formated and the format string. When
175+
/// actually printed, this synthesizes the string into a temporary buffer
176+
/// provided and returns whether or not it is big enough.
177+
template <typename T1, typename T2, typename T3, typename T4, typename T5,
178+
typename T6>
179+
class format_object6 : public format_object_base {
180+
T1 Val1;
181+
T2 Val2;
182+
T3 Val3;
183+
T4 Val4;
184+
T5 Val5;
185+
T6 Val6;
186+
public:
187+
format_object6(const char *Fmt, const T1 &Val1, const T2 &Val2,
188+
const T3 &Val3, const T4 &Val4, const T5 &Val5, const T6 &Val6)
189+
: format_object_base(Fmt), Val1(Val1), Val2(Val2), Val3(Val3), Val4(Val4),
190+
Val5(Val5), Val6(Val6) { }
191+
192+
int snprint(char *Buffer, unsigned BufferSize) const override {
193+
return snprintf(Buffer, BufferSize, Fmt, Val1, Val2, Val3, Val4, Val5, Val6);
194+
}
195+
};
196+
173197
/// This is a helper function that is used to produce formatted output.
174198
///
175199
/// This is typically used like:
@@ -231,6 +255,21 @@ inline format_object5<T1, T2, T3, T4, T5> format(const char *Fmt,const T1 &Val1,
231255
return format_object5<T1, T2, T3, T4, T5>(Fmt, Val1, Val2, Val3, Val4, Val5);
232256
}
233257

258+
/// This is a helper function that is used to produce formatted output.
259+
///
260+
/// This is typically used like:
261+
/// \code
262+
/// OS << format("%0.4f", myfloat) << '\n';
263+
/// \endcode
264+
template <typename T1, typename T2, typename T3, typename T4, typename T5,
265+
typename T6>
266+
inline format_object6<T1, T2, T3, T4, T5, T6>
267+
format(const char *Fmt, const T1 &Val1, const T2 &Val2, const T3 &Val3,
268+
const T4 &Val4, const T5 &Val5, const T6 &Val6) {
269+
return format_object6<T1, T2, T3, T4, T5, T6>(Fmt, Val1, Val2, Val3, Val4,
270+
Val5, Val6);
271+
}
272+
234273
} // end namespace llvm
235274

236275
#endif

0 commit comments

Comments
 (0)