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

use static in FOLLY_SAFE_CHECK for clang+asan

Summary: Avoid enlarging data sections. The use of `static` causes data sections to be smaller in certain critical cases.

Reviewed By: cmds, luciang

Differential Revision: D27813138

fbshipit-source-id: 020b14927be5ac035d5f66e7cd652a58f8f820d0
parent e31125bc
...@@ -24,18 +24,27 @@ ...@@ -24,18 +24,27 @@
#include <folly/Preprocessor.h> #include <folly/Preprocessor.h>
#include <folly/lang/CArray.h> #include <folly/lang/CArray.h>
#if __GNUC__ && !__clang__ && FOLLY_SANITIZE_ADDRESS
// gcc+asan has a bug that discards sections when using `static` below
#define FOLLY_DETAIL_SAFE_CHECK_LINKAGE
#else
#define FOLLY_DETAIL_SAFE_CHECK_LINKAGE static
#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) && \ if ((!d || ::folly::kIsDebug || ::folly::kIsSanitize) && \
!static_cast<bool>(expr)) { \ !static_cast<bool>(expr)) { \
constexpr auto __folly_detail_safe_assert_fun = __PRETTY_FUNCTION__; \ FOLLY_DETAIL_SAFE_CHECK_LINKAGE constexpr auto \
constexpr ::folly::detail::safe_assert_arg __folly_detail_safe_assert_arg{ \ __folly_detail_safe_assert_fun = __PRETTY_FUNCTION__; \
FOLLY_PP_STRINGIZE(expr_s), \ FOLLY_DETAIL_SAFE_CHECK_LINKAGE constexpr ::folly::detail::safe_assert_arg \
__FILE__, \ __folly_detail_safe_assert_arg{ \
__LINE__, \ FOLLY_PP_STRINGIZE(expr_s), \
__folly_detail_safe_assert_fun, \ __FILE__, \
::folly::detail::safe_assert_msg_types<decltype( \ __LINE__, \
::folly::detail::safe_assert_msg_types_seq_of( \ __folly_detail_safe_assert_fun, \
__VA_ARGS__))>::value.data}; \ ::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_terminate<p>( \
__folly_detail_safe_assert_arg, __VA_ARGS__); \ __folly_detail_safe_assert_arg, __VA_ARGS__); \
} \ } \
......
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