Index: llvm/include/llvm/Support/Format.h =================================================================== --- llvm/include/llvm/Support/Format.h +++ llvm/include/llvm/Support/Format.h @@ -75,6 +75,16 @@ /// printed, this synthesizes the string into a temporary buffer provided and /// returns whether or not it is big enough. +// Helper to validate that format() parameters are scalars or pointers. +template struct validate_format_parameters; +template +struct validate_format_parameters { + static_assert(std::is_scalar::value, + "format can't be used with non fundamental / non pointer type"); + validate_format_parameters() { validate_format_parameters(); } +}; +template <> struct validate_format_parameters<> {}; + template class format_object final : public format_object_base { std::tuple Vals; @@ -91,7 +101,9 @@ public: format_object(const char *fmt, const Ts &... vals) - : format_object_base(fmt), Vals(vals...) {} + : format_object_base(fmt), Vals(vals...) { + validate_format_parameters(); + } int snprint(char *Buffer, unsigned BufferSize) const override { return snprint_tuple(Buffer, BufferSize, index_sequence_for());