From 2cc4b6f576c543a85a414709c98b5411bfeb447d Mon Sep 17 00:00:00 2001 From: 0blu Date: Sun, 1 Sep 2024 13:22:12 +0200 Subject: [PATCH 1/6] Add `cmake-build-*/` to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 66d7af3..0990c1e 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ scratch .vscode tmp bazel-* +cmake-build-*/ From e3469a8f99b2932e488c0d931783a8a1eb2a631e Mon Sep 17 00:00:00 2001 From: 0blu Date: Thu, 5 Sep 2024 00:06:27 +0200 Subject: [PATCH 2/6] Add `.idea/` (JetBrains' CLion) to `.gitignore` --- .gitignore | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 0990c1e..9b23377 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,11 @@ -.vscode +.vscode/ +.idea/ + a.out build*/ repro*/ -__pycache__ +__pycache__/ scratch -.vscode -tmp -bazel-* +tmp/ +bazel-*/ cmake-build-*/ From dcd69f93fd43d2e5008a91880c4122628316e2fb Mon Sep 17 00:00:00 2001 From: 0blu Date: Sun, 1 Sep 2024 13:22:21 +0200 Subject: [PATCH 3/6] VS14 support: No builtins for `source_location` --- src/utils/error.hpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/utils/error.hpp b/src/utils/error.hpp index 19f017f..f1ced12 100644 --- a/src/utils/error.hpp +++ b/src/utils/error.hpp @@ -31,15 +31,17 @@ namespace detail { // Lightweight std::source_location. struct source_location { const char* const file; - //const char* const function; // disabled for now due to static constexpr restrictions + // const char* const function; // disabled, because there are many different compiler definitions for it (see for example BOOST_CURRENT_FUNCTION) const int line; constexpr source_location( - //const char* _function /*= __builtin_FUNCTION()*/, - const char* _file = __builtin_FILE(), - int _line = __builtin_LINE() - ) : file(_file), /*function(_function),*/ line(_line) {} + const char* _file, + //const char* _function, + int _line + ) : file(_file)/*, function(_function)*/, line(_line) {} }; + #define CPPTRACE_CURRENT_LOCATION ::cpptrace::detail::source_location(__FILE__, __LINE__) + enum class assert_type { assert, verify, @@ -117,7 +119,7 @@ namespace detail { } // Check condition in both debug and release. std::runtime_error on failure. - #define PANIC(...) ((::cpptrace::detail::panic)(CPPTRACE_PFUNC, {}, ::cpptrace::detail::as_string(__VA_ARGS__))) + #define PANIC(...) ((::cpptrace::detail::panic)(CPPTRACE_PFUNC, CPPTRACE_CURRENT_LOCATION, ::cpptrace::detail::as_string(__VA_ARGS__))) template void assert_impl( @@ -153,13 +155,13 @@ namespace detail { // Check condition in both debug and release. std::runtime_error on failure. #define VERIFY(...) ( \ - assert_impl(__VA_ARGS__, ::cpptrace::detail::assert_type::verify, #__VA_ARGS__, CPPTRACE_PFUNC, {}) \ + assert_impl(__VA_ARGS__, ::cpptrace::detail::assert_type::verify, #__VA_ARGS__, CPPTRACE_PFUNC, CPPTRACE_CURRENT_LOCATION) \ ) #ifndef NDEBUG // Check condition in both debug. std::runtime_error on failure. #define ASSERT(...) ( \ - assert_impl(__VA_ARGS__, ::cpptrace::detail::assert_type::assert, #__VA_ARGS__, CPPTRACE_PFUNC, {}) \ + assert_impl(__VA_ARGS__, ::cpptrace::detail::assert_type::assert, #__VA_ARGS__, CPPTRACE_PFUNC, CPPTRACE_CURRENT_LOCATION) \ ) #else // Check condition in both debug. std::runtime_error on failure. From 2616bd8f1562a39dd36a73afc94414f0bec025f6 Mon Sep 17 00:00:00 2001 From: 0blu Date: Thu, 5 Sep 2024 00:12:24 +0200 Subject: [PATCH 4/6] Remove unused variable in `source_location` --- src/utils/error.hpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/utils/error.hpp b/src/utils/error.hpp index f1ced12..6594c1f 100644 --- a/src/utils/error.hpp +++ b/src/utils/error.hpp @@ -31,13 +31,11 @@ namespace detail { // Lightweight std::source_location. struct source_location { const char* const file; - // const char* const function; // disabled, because there are many different compiler definitions for it (see for example BOOST_CURRENT_FUNCTION) const int line; constexpr source_location( const char* _file, - //const char* _function, int _line - ) : file(_file)/*, function(_function)*/, line(_line) {} + ) : file(_file), line(_line) {} }; #define CPPTRACE_CURRENT_LOCATION ::cpptrace::detail::source_location(__FILE__, __LINE__) From 0cc93bdd4445a2e5f9616a369698cdc11082fb34 Mon Sep 17 00:00:00 2001 From: 0blu Date: Sun, 1 Sep 2024 13:23:38 +0200 Subject: [PATCH 5/6] Rename `cache_mode` member to `current_cache_mode` --- src/cpptrace.cpp | 8 ++++---- src/utils/common.hpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cpptrace.cpp b/src/cpptrace.cpp index d919987..cbb81b0 100644 --- a/src/cpptrace.cpp +++ b/src/cpptrace.cpp @@ -495,7 +495,7 @@ namespace cpptrace { namespace detail { std::atomic_bool absorb_trace_exceptions(true); // NOSONAR std::atomic_bool resolve_inlined_calls(true); // NOSONAR - std::atomic cache_mode(cache_mode::prioritize_speed); // NOSONAR + std::atomic current_cache_mode(cache_mode::prioritize_speed); // NOSONAR } void absorb_trace_exceptions(bool absorb) { @@ -508,7 +508,7 @@ namespace cpptrace { namespace experimental { void set_cache_mode(cache_mode mode) { - detail::cache_mode = mode; + detail::current_cache_mode = mode; } } @@ -521,8 +521,8 @@ namespace cpptrace { return resolve_inlined_calls; } - enum cache_mode get_cache_mode() { - return cache_mode; + cache_mode get_cache_mode() { + return current_cache_mode; } CPPTRACE_FORCE_NO_INLINE diff --git a/src/utils/common.hpp b/src/utils/common.hpp index 05c6273..a323b48 100644 --- a/src/utils/common.hpp +++ b/src/utils/common.hpp @@ -40,7 +40,7 @@ namespace detail { bool should_absorb_trace_exceptions(); bool should_resolve_inlined_calls(); - enum cache_mode get_cache_mode(); + cache_mode get_cache_mode(); } } From 391646d218129ad6bd0126c7c171345a37864e6d Mon Sep 17 00:00:00 2001 From: 0blu Date: Sun, 1 Sep 2024 13:24:29 +0200 Subject: [PATCH 6/6] VS14 support: Fix MSVC bug with `std::enable_if` --- src/utils/utils.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/utils/utils.hpp b/src/utils/utils.hpp index 123f871..ecea692 100644 --- a/src/utils/utils.hpp +++ b/src/utils/utils.hpp @@ -496,8 +496,10 @@ namespace detail { template< typename T, typename D - // workaround a msvc bug https://developercommunity.visualstudio.com/t/MSVC-1938331290-preview-fails-to-comp/10505565 - #if !defined(_MSC_VER) || _MSC_VER != 1938 + // workaround for: + // == 19.38-specific msvc bug https://developercommunity.visualstudio.com/t/MSVC-1938331290-preview-fails-to-comp/10505565 + // <= 19.23 msvc also appears to fail (but for a different reason https://godbolt.org/z/6Y5EvdWPK) + #if !defined(_MSC_VER) || !(_MSC_VER <= 1923 || _MSC_VER == 1938) , typename std::enable_if< std::is_same()(std::declval())), void>::value,