diff --git a/.gitignore b/.gitignore index 66d7af30..9b233772 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,11 @@ -.vscode +.vscode/ +.idea/ + a.out build*/ repro*/ -__pycache__ +__pycache__/ scratch -.vscode -tmp -bazel-* +tmp/ +bazel-*/ +cmake-build-*/ diff --git a/src/cpptrace.cpp b/src/cpptrace.cpp index d9199878..cbb81b01 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 05c62736..a323b48a 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(); } } diff --git a/src/utils/error.hpp b/src/utils/error.hpp index 19f017f8..6594c1fa 100644 --- a/src/utils/error.hpp +++ b/src/utils/error.hpp @@ -31,15 +31,15 @@ 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 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, + int _line + ) : file(_file), line(_line) {} }; + #define CPPTRACE_CURRENT_LOCATION ::cpptrace::detail::source_location(__FILE__, __LINE__) + enum class assert_type { assert, verify, @@ -117,7 +117,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 +153,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. diff --git a/src/utils/utils.hpp b/src/utils/utils.hpp index 123f8712..ecea6920 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,