#pragma once #include #include "Support/Error.h" #include "Support/JSON.h" namespace clice { template void print(std::format_string fmt, Args&&... args) { llvm::outs() << std::vformat(fmt.get(), std::make_format_args(args...)); } } // namespace clice template <> struct std::formatter : std::formatter { using Base = std::formatter; template constexpr auto parse(ParseContext& ctx) { return Base::parse(ctx); } template auto format(llvm::StringRef s, FormatContext& ctx) const { return Base::format(std::string_view(s.str()), ctx); } }; template <> struct std::formatter : std::formatter { using Base = std::formatter; template constexpr auto parse(ParseContext& ctx) { return Base::parse(ctx); } template auto format(const llvm::Error& e, FormatContext& ctx) const { llvm::SmallString<128> buffer; llvm::raw_svector_ostream os(buffer); os << e; return Base::format(buffer, ctx); } }; template struct std::formatter> : std::formatter { using Base = std::formatter; template constexpr auto parse(ParseContext& ctx) { return Base::parse(ctx); } template auto format(const llvm::SmallString& s, FormatContext& ctx) const { return Base::format(llvm::StringRef(s), ctx); } }; template <> struct std::formatter : std::formatter { using Base = std::formatter; template constexpr auto parse(ParseContext& ctx) { return Base::parse(ctx); } template auto format(const clice::json::Value& value, FormatContext& ctx) const { llvm::SmallString<128> buffer; llvm::raw_svector_ostream os{buffer}; os << value; return Base::format(buffer, ctx); } }; template requires clice::support::special_enum struct std::formatter : std::formatter { using Base = std::formatter; template constexpr auto parse(ParseContext& ctx) { return Base::parse(ctx); } template auto format(const E& e, FormatContext& ctx) const { return Base::format(e.name(), ctx); } };