Refactor log.
This commit is contained in:
@@ -3,16 +3,38 @@
|
||||
#include <format>
|
||||
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "Error.h"
|
||||
|
||||
template <>
|
||||
struct std::formatter<llvm::StringRef> : std::formatter<std::string_view> {
|
||||
using Base = std::formatter<std::string_view>;
|
||||
|
||||
template <typename ParseContext>
|
||||
constexpr auto parse(ParseContext& ctx) {
|
||||
return std::formatter<std::string_view>::parse(ctx);
|
||||
return Base::parse(ctx);
|
||||
}
|
||||
|
||||
template <typename FormatContext>
|
||||
auto format(llvm::StringRef s, FormatContext& ctx) const {
|
||||
return std::formatter<std::string_view>::format(std::string_view(s.str()), ctx);
|
||||
return Base::format(std::string_view(s.str()), ctx);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct std::formatter<llvm::Error> : std::formatter<llvm::StringRef> {
|
||||
using Base = std::formatter<llvm::StringRef>;
|
||||
|
||||
template <typename ParseContext>
|
||||
constexpr auto parse(ParseContext& ctx) {
|
||||
return Base::parse(ctx);
|
||||
}
|
||||
|
||||
template <typename FormatContext>
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user