d3d12: Add formatting abilities to unreachable macro

This commit is contained in:
Vincent Lejeune 2015-12-13 20:56:50 +01:00
parent d7b4b2fd49
commit 456f83671a
2 changed files with 12 additions and 5 deletions

View File

@ -262,9 +262,9 @@ void D3D12GSRender::initConvertShader()
p.second->Release();
}
void unreachable_internal(const char *msg, const char *file, unsigned line)
void unreachable_internal()
{
LOG_ERROR(RSX, "file %s line %d : %s", file, line, msg);
abort();
#ifdef LLVM_BUILTIN_UNREACHABLE
LLVM_BUILTIN_UNREACHABLE;

View File

@ -45,7 +45,14 @@
# define LLVM_BUILTIN_UNREACHABLE __assume(false)
#endif
LLVM_ATTRIBUTE_NORETURN void unreachable_internal(const char *msg = nullptr, const char *file = nullptr, unsigned line = 0);
LLVM_ATTRIBUTE_NORETURN void unreachable_internal();
template<typename... Args>
void unreachable_internal_verbose(const char *file, unsigned line, const Args &...args)
{
LOG_ERROR(RSX, "file %s line %d : %s", file, line, fmt::format(args...));
unreachable_internal();
}
/// Marks that the current location is not supposed to be reachable.
/// In !NDEBUG builds, prints the message and location info to stderr.
@ -56,8 +63,8 @@ LLVM_ATTRIBUTE_NORETURN void unreachable_internal(const char *msg = nullptr, con
/// Use this instead of assert(0). It conveys intent more clearly and
/// allows compilers to omit some unnecessary code.
#ifndef NDEBUG
#define unreachable(msg) \
unreachable_internal(msg, __FILE__, __LINE__)
#define unreachable(...) \
unreachable_internal_verbose(__FILE__, __LINE__, ##__VA_ARGS__)
//#elif defined(LLVM_BUILTIN_UNREACHABLE)
//#define unreachable(msg) LLVM_BUILTIN_UNREACHABLE
#else