From 90f3678ada9778277df2e70d4b26e1ec082c4076 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 27 Jul 2021 04:09:15 -0400 Subject: exception: Narrow down specific header We can use the header instead of pulling in all of the exception-style classes. --- src/shader_recompiler/exception.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shader_recompiler/exception.h b/src/shader_recompiler/exception.h index 337e7f0c8..c47aecc1e 100644 --- a/src/shader_recompiler/exception.h +++ b/src/shader_recompiler/exception.h @@ -4,7 +4,7 @@ #pragma once -#include +#include #include #include #include -- cgit v1.2.3 From e490ddf327d88011e4895cdca182260cbed84bcd Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 27 Jul 2021 04:14:32 -0400 Subject: exception: Make what() member function nodiscard --- src/shader_recompiler/exception.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shader_recompiler/exception.h b/src/shader_recompiler/exception.h index c47aecc1e..997169756 100644 --- a/src/shader_recompiler/exception.h +++ b/src/shader_recompiler/exception.h @@ -17,7 +17,7 @@ class Exception : public std::exception { public: explicit Exception(std::string message) noexcept : err_message{std::move(message)} {} - const char* what() const noexcept override { + [[nodiscard]] const char* what() const noexcept override { return err_message.c_str(); } -- cgit v1.2.3 From c27ddb44de04d171b992c679875d98bb51806822 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 27 Jul 2021 04:15:11 -0400 Subject: exception: Make constructors explicit Ensures that exception construction is always explicit. --- src/shader_recompiler/exception.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/shader_recompiler/exception.h b/src/shader_recompiler/exception.h index 997169756..277be8541 100644 --- a/src/shader_recompiler/exception.h +++ b/src/shader_recompiler/exception.h @@ -36,21 +36,21 @@ private: class LogicError : public Exception { public: template - LogicError(const char* message, Args&&... args) + explicit LogicError(const char* message, Args&&... args) : Exception{fmt::format(fmt::runtime(message), std::forward(args)...)} {} }; class RuntimeError : public Exception { public: template - RuntimeError(const char* message, Args&&... args) + explicit RuntimeError(const char* message, Args&&... args) : Exception{fmt::format(fmt::runtime(message), std::forward(args)...)} {} }; class NotImplementedException : public Exception { public: template - NotImplementedException(const char* message, Args&&... args) + explicit NotImplementedException(const char* message, Args&&... args) : Exception{fmt::format(fmt::runtime(message), std::forward(args)...)} { Append(" is not implemented"); } @@ -59,7 +59,7 @@ public: class InvalidArgument : public Exception { public: template - InvalidArgument(const char* message, Args&&... args) + explicit InvalidArgument(const char* message, Args&&... args) : Exception{fmt::format(fmt::runtime(message), std::forward(args)...)} {} }; -- cgit v1.2.3