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

avoid append-va-arg in FOLLY_SAFE_CHECK

Summary:
Since clang has a mode which rejects the append-va-arg construct as implemented in `FOLLY_PP_DETAIL_APPEND_VA_ARG`.

Do this by avoiding appending va-args to other args. Instead, take advantage of `operator()` as a workaround.

Avoids:
```
folly/Preprocessor.h:72:46: error: token pasting of ',' and __VA_ARGS__ is a GNU extension [-Werror,-Wgnu-zero-variadic-macro-arguments]
#define FOLLY_PP_DETAIL_APPEND_VA_ARG(...) , ##__VA_ARGS__
                                             ^
```

Reviewed By: luciang

Differential Revision: D33863906

fbshipit-source-id: 14912aca73e332ab811db4c0ac772a2d224a0666
parent 84ff4e5f
......@@ -46,9 +46,10 @@
::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 FOLLY_PP_DETAIL_APPEND_VA_ARG( \
__VA_ARGS__)); \
constexpr ::folly::detail::safe_assert_terminate_w<p> \
__folly_detail_safe_assert_terminate_w{ \
__folly_detail_safe_assert_arg}; \
__folly_detail_safe_assert_terminate_w(__VA_ARGS__); \
} \
} while (false)
......@@ -173,11 +174,19 @@ template <bool P>
[[noreturn]] FOLLY_COLD FOLLY_NOINLINE void safe_assert_terminate(
safe_assert_arg const* arg, ...) noexcept; // the true backing function
template <bool P, typename... A>
[[noreturn]] FOLLY_ERASE void safe_assert_terminate(
safe_assert_arg const& arg, A... a) noexcept {
template <bool P>
struct safe_assert_terminate_w {
safe_assert_arg const& arg;
FOLLY_ERASE constexpr safe_assert_terminate_w(
safe_assert_arg const& arg_) noexcept
: arg{arg_} {}
template <typename... A>
[[noreturn]] FOLLY_ERASE void operator()(A... a) const noexcept {
safe_assert_terminate<P>(&arg, safe_assert_msg_cast_one(a)...);
}
}
};
} // namespace detail
} // namespace folly
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