From 456f83671a305b038c8f7d0720d6b07642a9b7fb Mon Sep 17 00:00:00 2001 From: Vincent Lejeune Date: Sun, 13 Dec 2015 20:56:50 +0100 Subject: [PATCH] d3d12: Add formatting abilities to unreachable macro --- rpcs3/Emu/RSX/D3D12/D3D12Utils.cpp | 4 ++-- rpcs3/Emu/RSX/D3D12/D3D12Utils.h | 13 ++++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/rpcs3/Emu/RSX/D3D12/D3D12Utils.cpp b/rpcs3/Emu/RSX/D3D12/D3D12Utils.cpp index 6c77a9b8ca..73afe3c9d2 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12Utils.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12Utils.cpp @@ -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; diff --git a/rpcs3/Emu/RSX/D3D12/D3D12Utils.h b/rpcs3/Emu/RSX/D3D12/D3D12Utils.h index e4cf19b432..d1d1315c58 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12Utils.h +++ b/rpcs3/Emu/RSX/D3D12/D3D12Utils.h @@ -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 +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