Commit e7a9b358 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot

#define FOLLY_ERASE FOLLY_ALWAYS_INLINE FOLLY_ATTR_VISIBILITY_HIDDEN

Summary: [Folly] `#define FOLLY_ERASE FOLLY_ALWAYS_INLINE FOLLY_ATTR_VISIBILITY_HIDDEN`.

Reviewed By: vitaut

Differential Revision: D16686469

fbshipit-source-id: cedaee61955a40ae28ad2b0da565fc9fb385bc6e
parent 9876b788
......@@ -180,3 +180,12 @@
#define FOLLY_MICROSOFT_ABI_VER _MSC_VER
#endif
#endif
// FOLLY_ERASE
//
// A conceptual attribute/syntax combo for erasing a function from the build
// artifacts and forcing all call-sites to inline the callee, at least as far
// as each compiler supports.
//
// Semantically includes the inline specifier.
#define FOLLY_ERASE FOLLY_ALWAYS_INLINE FOLLY_ATTR_VISIBILITY_HIDDEN
......@@ -65,13 +65,12 @@ template <bool If, class T>
using AddConstIf = std::conditional_t<If, const T, T>;
template <class Fn, class A>
FOLLY_ALWAYS_INLINE FOLLY_ATTR_VISIBILITY_HIDDEN auto fold(Fn&&, A&& a) {
FOLLY_ERASE auto fold(Fn&&, A&& a) {
return static_cast<A&&>(a);
}
template <class Fn, class A, class B, class... Bs>
FOLLY_ALWAYS_INLINE FOLLY_ATTR_VISIBILITY_HIDDEN auto
fold(Fn&& fn, A&& a, B&& b, Bs&&... bs) {
FOLLY_ERASE auto fold(Fn&& fn, A&& a, B&& b, Bs&&... bs) {
return fold(
// This looks like a use of fn after a move of fn, but in reality, this is
// just a cast and not a move. That's because regardless of which fold
......
......@@ -64,7 +64,7 @@ class ThreadLocal {
explicit ThreadLocal(F&& constructor)
: constructor_(std::forward<F>(constructor)) {}
FOLLY_ALWAYS_INLINE FOLLY_ATTR_VISIBILITY_HIDDEN T* get() const {
FOLLY_ERASE T* get() const {
auto const ptr = tlp_.get();
return FOLLY_LIKELY(!!ptr) ? ptr : makeTlp();
}
......
......@@ -61,7 +61,7 @@ constexpr array_detail::return_type<D, TList...> make_array(TList&&... t) {
namespace array_detail {
template <typename MakeItem, std::size_t... Index>
FOLLY_ALWAYS_INLINE FOLLY_ATTR_VISIBILITY_HIDDEN constexpr auto make_array_with(
FOLLY_ERASE constexpr auto make_array_with(
MakeItem const& make,
std::index_sequence<Index...>) {
return std::array<decltype(make(0)), sizeof...(Index)>{{make(Index)...}};
......
......@@ -30,14 +30,12 @@ namespace detail {
#if FOLLY_SSE_PREREQ(2, 0)
__m128i _mm_loadu_si128_nosan(__m128i const* const p);
FOLLY_ALWAYS_INLINE FOLLY_ATTR_VISIBILITY_HIDDEN __m128i
_mm_loadu_si128_unchecked(__m128i const* const p) {
FOLLY_ERASE __m128i _mm_loadu_si128_unchecked(__m128i const* const p) {
return kIsSanitize ? _mm_loadu_si128_nosan(p) : _mm_loadu_si128(p);
}
__m128i _mm_load_si128_nosan(__m128i const* const p);
FOLLY_ALWAYS_INLINE FOLLY_ATTR_VISIBILITY_HIDDEN __m128i
_mm_load_si128_unchecked(__m128i const* const p) {
FOLLY_ERASE __m128i _mm_load_si128_unchecked(__m128i const* const p) {
return kIsSanitize ? _mm_load_si128_nosan(p) : _mm_load_si128(p);
}
......
......@@ -81,8 +81,7 @@ class StaticSingletonManagerWithRtti {
}
template <bool Noexcept>
FOLLY_ATTR_VISIBILITY_HIDDEN FOLLY_ALWAYS_INLINE static void* create_(
Arg& arg) noexcept(Noexcept) {
FOLLY_ERASE static void* create_(Arg& arg) noexcept(Noexcept) {
return create_(arg);
}
FOLLY_NOINLINE static void* create_(Arg& arg);
......@@ -94,7 +93,7 @@ using StaticSingletonManager = std::conditional_t<
StaticSingletonManagerSansRtti>;
template <typename T, typename Tag>
FOLLY_ALWAYS_INLINE FOLLY_ATTR_VISIBILITY_HIDDEN T& createGlobal() {
FOLLY_ERASE T& createGlobal() {
return StaticSingletonManager::create<T, Tag>();
}
......
......@@ -29,8 +29,7 @@ namespace folly {
/// QueuedImmediateExecutor.
class InlineExecutor : public Executor {
public:
FOLLY_ATTR_VISIBILITY_HIDDEN FOLLY_ALWAYS_INLINE static InlineExecutor&
instance() noexcept {
FOLLY_ERASE static InlineExecutor& instance() noexcept {
auto const value = cache.load(std::memory_order_acquire);
return value ? *value : instance_slow();
}
......
......@@ -1411,15 +1411,12 @@ namespace futures {
namespace detail {
template <typename V, typename... Fs, std::size_t... Is>
FOLLY_ALWAYS_INLINE FOLLY_ATTR_VISIBILITY_HIDDEN void
foreach_(std::index_sequence<Is...>, V&& v, Fs&&... fs) {
FOLLY_ERASE void foreach_(std::index_sequence<Is...>, V&& v, Fs&&... fs) {
using _ = int[];
void(_{0, (void(v(index_constant<Is>{}, static_cast<Fs&&>(fs))), 0)...});
}
template <typename V, typename... Fs>
FOLLY_ALWAYS_INLINE FOLLY_ATTR_VISIBILITY_HIDDEN void foreach(
V&& v,
Fs&&... fs) {
FOLLY_ERASE void foreach(V&& v, Fs&&... fs) {
using _ = std::index_sequence_for<Fs...>;
foreach_(_{}, static_cast<V&&>(v), static_cast<Fs&&>(fs)...);
}
......
......@@ -51,11 +51,11 @@ template <typename Ex>
// clang-format off
namespace detail {
template <typename T>
FOLLY_ALWAYS_INLINE FOLLY_ATTR_VISIBILITY_HIDDEN T&& to_exception_arg_(T&& t) {
FOLLY_ERASE T&& to_exception_arg_(T&& t) {
return static_cast<T&&>(t);
}
template <std::size_t N>
FOLLY_ALWAYS_INLINE FOLLY_ATTR_VISIBILITY_HIDDEN char const* to_exception_arg_(
FOLLY_ERASE char const* to_exception_arg_(
char const (&array)[N]) {
return static_cast<char const*>(array);
}
......@@ -78,8 +78,7 @@ template <typename Ex, typename... Args>
///
/// Converts any arguments of type `char const[N]` to `char const*`.
template <typename Ex, typename... Args>
[[noreturn]] FOLLY_ALWAYS_INLINE FOLLY_ATTR_VISIBILITY_HIDDEN void
throw_exception(Args&&... args) {
[[noreturn]] FOLLY_ERASE void throw_exception(Args&&... args) {
detail::throw_exception_<Ex>(
detail::to_exception_arg_(static_cast<Args&&>(args))...);
}
......@@ -89,7 +88,7 @@ throw_exception(Args&&... args) {
/// Terminates as if by forwarding to throw_exception but in a noexcept context.
// clang-format off
template <typename Ex, typename... Args>
[[noreturn]] FOLLY_ALWAYS_INLINE FOLLY_ATTR_VISIBILITY_HIDDEN void
[[noreturn]] FOLLY_ERASE void
terminate_with(Args&&... args) noexcept {
detail::terminate_with_<Ex>(
detail::to_exception_arg_(static_cast<Args&&>(args))...);
......@@ -182,11 +181,11 @@ template <typename F, typename... A>
/// def);
/// assert(result == input < 0 ? def : input);
template <typename E, typename Try, typename Catch, typename... CatchA>
FOLLY_ALWAYS_INLINE FOLLY_ATTR_VISIBILITY_HIDDEN auto
catch_exception(Try&& t, Catch&& c, CatchA&&... a) -> typename std::common_type<
decltype(static_cast<Try&&>(t)()),
decltype(static_cast<Catch&&>(
c)(std::declval<E>(), static_cast<CatchA&&>(a)...))>::type {
FOLLY_ERASE auto catch_exception(Try&& t, Catch&& c, CatchA&&... a) ->
typename std::common_type<
decltype(static_cast<Try&&>(t)()),
decltype(static_cast<Catch&&>(
c)(std::declval<E>(), static_cast<CatchA&&>(a)...))>::type {
#if FOLLY_HAS_EXCEPTIONS
try {
return static_cast<Try&&>(t)();
......@@ -222,10 +221,10 @@ catch_exception(Try&& t, Catch&& c, CatchA&&... a) -> typename std::common_type<
/// def);
/// assert(result == input < 0 ? def : input);
template <typename Try, typename Catch, typename... CatchA>
FOLLY_ALWAYS_INLINE FOLLY_ATTR_VISIBILITY_HIDDEN auto
catch_exception(Try&& t, Catch&& c, CatchA&&... a) -> typename std::common_type<
decltype(static_cast<Try&&>(t)()),
decltype(static_cast<Catch&&>(c)(static_cast<CatchA&&>(a)...))>::type {
FOLLY_ERASE auto catch_exception(Try&& t, Catch&& c, CatchA&&... a) ->
typename std::common_type<
decltype(static_cast<Try&&>(t)()),
decltype(static_cast<Catch&&>(c)(static_cast<CatchA&&>(a)...))>::type {
#if FOLLY_HAS_EXCEPTIONS
try {
return static_cast<Try&&>(t)();
......
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