Added support for completely disabling noexcept using MIJIN_TEST_NO_NOEXCEPT (for testing).

This commit is contained in:
2024-08-29 00:01:23 +02:00
parent a43f92fb58
commit 9ba097fc2f
41 changed files with 643 additions and 564 deletions

View File

@@ -8,6 +8,8 @@
#include <cstdlib>
#include <source_location>
#include "../internal/common.hpp"
#ifdef _WIN32
#pragma comment(lib, "kernel32")
extern "C" __declspec(dllimport) void __stdcall DebugBreak();
@@ -139,7 +141,7 @@ constexpr AssertionResult handleAssert(const char* /* condition */,
#ifdef MIJIN_USE_CUSTOM_ERROR_HANDLER
ErrorHandling handleError(const char* message, const std::source_location& location);
#else
inline ErrorHandling handleError(const char* message, const std::source_location& location) noexcept
inline ErrorHandling handleError(const char* message, const std::source_location& location) MIJIN_NOEXCEPT
{
std::puts(message);
std::printf("Function: %s\n", location.function_name());

View File

@@ -75,7 +75,7 @@ thread_local backtrace_state* gBacktraceState = nullptr;
// public functions
//
Result<Stacktrace> captureStacktrace(unsigned skipFrames) noexcept
Result<Stacktrace> captureStacktrace(unsigned skipFrames) MIJIN_NOEXCEPT
{
#if MIJIN_USE_LIBBACKTRACE
BacktraceData btData;
@@ -104,7 +104,7 @@ Result<Stacktrace> captureStacktrace(unsigned skipFrames) noexcept
#endif // MIJIN_USE_LIBBACKTRACE
}
const Optional<Stacktrace>& getExceptionStacktrace() noexcept
const Optional<Stacktrace>& getExceptionStacktrace() MIJIN_NOEXCEPT
{
return gCurrentExceptionStackTrace;
}

View File

@@ -11,6 +11,7 @@
# include <fmt/format.h>
#endif
#include "./symbol_info.hpp"
#include "../internal/common.hpp"
#include "../types/result.hpp"
#include "../util/iterators.hpp"
@@ -45,20 +46,20 @@ public:
Stacktrace() = default;
Stacktrace(const Stacktrace&) = default;
Stacktrace(Stacktrace&&) = default;
explicit Stacktrace(std::vector<Stackframe> frames) noexcept : frames_(std::move(frames)) {}
explicit Stacktrace(std::vector<Stackframe> frames) MIJIN_NOEXCEPT : frames_(std::move(frames)) {}
Stacktrace& operator=(const Stacktrace&) = default;
Stacktrace& operator=(Stacktrace&&) = default;
[[nodiscard]] const std::vector<Stackframe>& getFrames() const noexcept { return frames_; }
[[nodiscard]] const std::vector<Stackframe>& getFrames() const MIJIN_NOEXCEPT { return frames_; }
};
//
// public functions
//
[[nodiscard]] Result<Stacktrace> captureStacktrace(unsigned skipFrames = 0) noexcept;
[[nodiscard]] const Optional<Stacktrace>& getExceptionStacktrace() noexcept;
[[nodiscard]] Result<Stacktrace> captureStacktrace(unsigned skipFrames = 0) MIJIN_NOEXCEPT;
[[nodiscard]] const Optional<Stacktrace>& getExceptionStacktrace() MIJIN_NOEXCEPT;
template<typename TStream>
TStream& operator<<(TStream& stream, const Stackframe& stackframe)