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
...@@ -32,12 +32,13 @@ ...@@ -32,12 +32,13 @@
#endif #endif
#define FOLLY_DETAIL_SAFE_CHECK_IMPL(d, p, expr, expr_s, ...) \ #define FOLLY_DETAIL_SAFE_CHECK_IMPL(d, p, expr, expr_s, ...) \
do { \
if ((!d || ::folly::kIsDebug || ::folly::kIsSanitize) && \ if ((!d || ::folly::kIsDebug || ::folly::kIsSanitize) && \
!static_cast<bool>(expr)) { \ !static_cast<bool>(expr)) { \
FOLLY_DETAIL_SAFE_CHECK_LINKAGE constexpr auto \ FOLLY_DETAIL_SAFE_CHECK_LINKAGE constexpr auto \
__folly_detail_safe_assert_fun = __PRETTY_FUNCTION__; \ __folly_detail_safe_assert_fun = __PRETTY_FUNCTION__; \
FOLLY_DETAIL_SAFE_CHECK_LINKAGE constexpr ::folly::detail::safe_assert_arg \ FOLLY_DETAIL_SAFE_CHECK_LINKAGE constexpr ::folly::detail:: \
__folly_detail_safe_assert_arg{ \ safe_assert_arg __folly_detail_safe_assert_arg{ \
FOLLY_PP_STRINGIZE(expr_s), \ FOLLY_PP_STRINGIZE(expr_s), \
__FILE__, \ __FILE__, \
__LINE__, \ __LINE__, \
...@@ -48,7 +49,7 @@ ...@@ -48,7 +49,7 @@
::folly::detail::safe_assert_terminate<p>( \ ::folly::detail::safe_assert_terminate<p>( \
__folly_detail_safe_assert_arg, __VA_ARGS__); \ __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