Commit fc32eee3 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook GitHub Bot

use do-while-false in FOLLY_SAFE_CHECK

Summary: To avoid the marginal but still unnecessary compile-time cost of constructing a lambda. And enclose the full thing in braces so it can be used in an unbraced `if`.

Reviewed By: ot, luciang

Differential Revision: D27817005

fbshipit-source-id: 9a1a6e0389fea5907a3a20cffbd6a029b0a85eb9
parent fa173c4e
...@@ -31,24 +31,25 @@ ...@@ -31,24 +31,25 @@
#define FOLLY_DETAIL_SAFE_CHECK_LINKAGE static #define FOLLY_DETAIL_SAFE_CHECK_LINKAGE static
#endif #endif
#define FOLLY_DETAIL_SAFE_CHECK_IMPL(d, p, expr, expr_s, ...) \ #define FOLLY_DETAIL_SAFE_CHECK_IMPL(d, p, expr, expr_s, ...) \
if ((!d || ::folly::kIsDebug || ::folly::kIsSanitize) && \ do { \
!static_cast<bool>(expr)) { \ if ((!d || ::folly::kIsDebug || ::folly::kIsSanitize) && \
FOLLY_DETAIL_SAFE_CHECK_LINKAGE constexpr auto \ !static_cast<bool>(expr)) { \
__folly_detail_safe_assert_fun = __PRETTY_FUNCTION__; \ FOLLY_DETAIL_SAFE_CHECK_LINKAGE constexpr auto \
FOLLY_DETAIL_SAFE_CHECK_LINKAGE constexpr ::folly::detail::safe_assert_arg \ __folly_detail_safe_assert_fun = __PRETTY_FUNCTION__; \
__folly_detail_safe_assert_arg{ \ FOLLY_DETAIL_SAFE_CHECK_LINKAGE constexpr ::folly::detail:: \
FOLLY_PP_STRINGIZE(expr_s), \ safe_assert_arg __folly_detail_safe_assert_arg{ \
__FILE__, \ FOLLY_PP_STRINGIZE(expr_s), \
__LINE__, \ __FILE__, \
__folly_detail_safe_assert_fun, \ __LINE__, \
::folly::detail::safe_assert_msg_types<decltype( \ __folly_detail_safe_assert_fun, \
::folly::detail::safe_assert_msg_types_seq_of( \ ::folly::detail::safe_assert_msg_types<decltype( \
__VA_ARGS__))>::value.data}; \ ::folly::detail::safe_assert_msg_types_seq_of( \
::folly::detail::safe_assert_terminate<p>( \ __VA_ARGS__))>::value.data}; \
__folly_detail_safe_assert_arg, __VA_ARGS__); \ ::folly::detail::safe_assert_terminate<p>( \
} \ __folly_detail_safe_assert_arg, __VA_ARGS__); \
[] {}() } \
} while (false)
// FOLLY_SAFE_CHECK // FOLLY_SAFE_CHECK
// //
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment