From b30524088a8d3454b95c2a94f300caf26ba92fe2 Mon Sep 17 00:00:00 2001 From: Jordan Maples Date: Fri, 6 Mar 2020 11:17:58 -0800 Subject: [PATCH] added some comments and ran clang-format --- include/gsl/gsl_assert | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/include/gsl/gsl_assert b/include/gsl/gsl_assert index ac87ef4..e8f3f66 100644 --- a/include/gsl/gsl_assert +++ b/include/gsl/gsl_assert @@ -36,6 +36,7 @@ // Currently terminate is a no-op in this mode, so we add termination behavior back // #if defined(_MSC_VER) && defined(_HAS_EXCEPTIONS) && !_HAS_EXCEPTIONS + #define GSL_MSVC_USE_STL_NOEXCEPTION_WORKAROUND #include #define RANGE_CHECKS_FAILURE 0 @@ -43,13 +44,13 @@ #if defined(__clang__) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winvalid-noreturn" -#endif +#endif // defined(__clang__) #else #include -#endif +#endif // !defined(_MSC_VER) || !defined(_HAS_EXCEPTIONS) || _HAS_EXCEPTIONS #define GSL_STRINGIFY_DETAIL(x) #x #define GSL_STRINGIFY(x) GSL_STRINGIFY_DETAIL(x) @@ -57,10 +58,12 @@ #if defined(__clang__) || defined(__GNUC__) #define GSL_LIKELY(x) __builtin_expect(!!(x), 1) #define GSL_UNLIKELY(x) __builtin_expect(!!(x), 0) + #else + #define GSL_LIKELY(x) (!!(x)) #define GSL_UNLIKELY(x) (!!(x)) -#endif +#endif // defined(__clang__) || defined(__GNUC__) // // GSL_ASSUME(cond) @@ -87,9 +90,11 @@ namespace details { #if defined(GSL_MSVC_USE_STL_NOEXCEPTION_WORKAROUND) - typedef void (__cdecl *terminate_handler)(); + typedef void(__cdecl* terminate_handler)(); + // clang-format off GSL_SUPPRESS(f.6) // NO-FORMAT: attribute + // clang-format on [[noreturn]] inline void __cdecl default_terminate_handler() { __fastfail(RANGE_CHECKS_FAILURE); @@ -101,7 +106,7 @@ namespace details return handler; } -#endif +#endif // defined(GSL_MSVC_USE_STL_NOEXCEPTION_WORKAROUND) [[noreturn]] inline void terminate() noexcept { @@ -109,13 +114,12 @@ namespace details (*gsl::details::get_terminate_handler())(); #else std::terminate(); -#endif +#endif // defined(GSL_MSVC_USE_STL_NOEXCEPTION_WORKAROUND) } } // namespace details } // namespace gsl - #define GSL_CONTRACT_CHECK(type, cond) \ (GSL_LIKELY(cond) ? static_cast(0) : gsl::details::terminate())