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 @@
#define FOLLY_DETAIL_SAFE_CHECK_LINKAGE static
#endif
#define FOLLY_DETAIL_SAFE_CHECK_IMPL(d, p, expr, expr_s, ...) \
if ((!d || ::folly::kIsDebug || ::folly::kIsSanitize) && \
!static_cast<bool>(expr)) { \
FOLLY_DETAIL_SAFE_CHECK_LINKAGE constexpr auto \
__folly_detail_safe_assert_fun = __PRETTY_FUNCTION__; \
FOLLY_DETAIL_SAFE_CHECK_LINKAGE constexpr ::folly::detail::safe_assert_arg \
__folly_detail_safe_assert_arg{ \
FOLLY_PP_STRINGIZE(expr_s), \
__FILE__, \
__LINE__, \
__folly_detail_safe_assert_fun, \
::folly::detail::safe_assert_msg_types<decltype( \
::folly::detail::safe_assert_msg_types_seq_of( \
__VA_ARGS__))>::value.data}; \
::folly::detail::safe_assert_terminate<p>( \
__folly_detail_safe_assert_arg, __VA_ARGS__); \
} \
[] {}()
#define FOLLY_DETAIL_SAFE_CHECK_IMPL(d, p, expr, expr_s, ...) \
do { \
if ((!d || ::folly::kIsDebug || ::folly::kIsSanitize) && \
!static_cast<bool>(expr)) { \
FOLLY_DETAIL_SAFE_CHECK_LINKAGE constexpr auto \
__folly_detail_safe_assert_fun = __PRETTY_FUNCTION__; \
FOLLY_DETAIL_SAFE_CHECK_LINKAGE constexpr ::folly::detail:: \
safe_assert_arg __folly_detail_safe_assert_arg{ \
FOLLY_PP_STRINGIZE(expr_s), \
__FILE__, \
__LINE__, \
__folly_detail_safe_assert_fun, \
::folly::detail::safe_assert_msg_types<decltype( \
::folly::detail::safe_assert_msg_types_seq_of( \
__VA_ARGS__))>::value.data}; \
::folly::detail::safe_assert_terminate<p>( \
__folly_detail_safe_assert_arg, __VA_ARGS__); \
} \
} while (false)
// 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