Skip to content

Commit

Permalink
fix some violations of warning undef in folly/lang/New.h
Browse files Browse the repository at this point in the history
Summary:
Tweaks for the following violations of warning `undef`:

```
folly/lang/New.h:86:5: error: '__cpp_sized_deallocation' is not defined, evaluates to 0 [-Werror,-Wundef]
#if __cpp_sized_deallocation >= 201309L || (_CPPLIB_VER && !__clang__)
    ^
folly/lang/New.h:86:45: error: '_CPPLIB_VER' is not defined, evaluates to 0 [-Werror,-Wundef]
#if __cpp_sized_deallocation >= 201309L || (_CPPLIB_VER && !__clang__)
                                            ^
folly/lang/New.h:106:5: error: '__cpp_sized_deallocation' is not defined, evaluates to 0 [-Werror,-Wundef]
#if __cpp_sized_deallocation >= 201309L || (_CPPLIB_VER && !__clang__)
    ^
folly/lang/New.h:106:45: error: '_CPPLIB_VER' is not defined, evaluates to 0 [-Werror,-Wundef]
#if __cpp_sized_deallocation >= 201309L || (_CPPLIB_VER && !__clang__)
                                            ^
```

Reviewed By: Orvid

Differential Revision: D46914069

fbshipit-source-id: d80cdf3c295d9dd14674a3e67ed790290f1973b5
  • Loading branch information
yfeldblum authored and facebook-github-bot committed Jun 22, 2023
1 parent f40017a commit 8cd5130
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions folly/lang/New.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,23 @@ namespace folly {
#define FOLLY_DETAIL_LANG_NEW_IMPL_D ::operator delete
#endif

#if __cpp_aligned_new >= 201606 || _CPPLIB_VER
#if defined(__cpp_aligned_new) && __cpp_aligned_new >= 201606
#define FOLLY_DETAIL_LANG_NEW_HAVE_AN 1
#elif defined(_CPPLIB_VER)
#define FOLLY_DETAIL_LANG_NEW_HAVE_AN 1
#else
#define FOLLY_DETAIL_LANG_NEW_HAVE_AN 0
#endif

#if defined(__cpp_sized_deallocation) && __cpp_sized_deallocation >= 201309L
#define FOLLY_DETAIL_LANG_NEW_HAVE_SD 1
#elif defined(_CPPLIB_VER) && !__clang__
#define FOLLY_DETAIL_LANG_NEW_HAVE_SD 1
#else
#define FOLLY_DETAIL_LANG_NEW_HAVE_SD 0
#endif

#if FOLLY_DETAIL_LANG_NEW_HAVE_AN
using std::align_val_t;
#else
enum class align_val_t : std::size_t {};
Expand All @@ -55,7 +71,7 @@ struct operator_new_fn {
FOLLY_NODISCARD FOLLY_ERASE void* operator()( //
std::size_t const s,
FOLLY_MAYBE_UNUSED align_val_t const a) const {
#if __cpp_aligned_new >= 201606 || _CPPLIB_VER
#if FOLLY_DETAIL_LANG_NEW_HAVE_AN
return FOLLY_DETAIL_LANG_NEW_IMPL_N(s, a);
#else
return FOLLY_DETAIL_LANG_NEW_IMPL_N(s);
Expand All @@ -65,7 +81,7 @@ struct operator_new_fn {
std::size_t const s,
FOLLY_MAYBE_UNUSED align_val_t const a,
std::nothrow_t const&) const noexcept {
#if __cpp_aligned_new >= 201606 || _CPPLIB_VER
#if FOLLY_DETAIL_LANG_NEW_HAVE_AN
return FOLLY_DETAIL_LANG_NEW_IMPL_N(s, a, std::nothrow);
#else
return FOLLY_DETAIL_LANG_NEW_IMPL_N(s, std::nothrow);
Expand All @@ -83,7 +99,7 @@ struct operator_delete_fn {
FOLLY_ERASE void operator()( //
void* const p,
FOLLY_MAYBE_UNUSED std::size_t const s) const noexcept {
#if __cpp_sized_deallocation >= 201309L || (_CPPLIB_VER && !__clang__)
#if FOLLY_DETAIL_LANG_NEW_HAVE_SD
return FOLLY_DETAIL_LANG_NEW_IMPL_D(p, s);
#else
return FOLLY_DETAIL_LANG_NEW_IMPL_D(p);
Expand All @@ -92,7 +108,7 @@ struct operator_delete_fn {
FOLLY_ERASE void operator()( //
void* const p,
FOLLY_MAYBE_UNUSED align_val_t const a) const noexcept {
#if __cpp_aligned_new >= 201606 || _CPPLIB_VER
#if FOLLY_DETAIL_LANG_NEW_HAVE_AN
return FOLLY_DETAIL_LANG_NEW_IMPL_D(p, a);
#else
return FOLLY_DETAIL_LANG_NEW_IMPL_D(p);
Expand All @@ -102,14 +118,14 @@ struct operator_delete_fn {
void* const p,
FOLLY_MAYBE_UNUSED std::size_t const s,
FOLLY_MAYBE_UNUSED align_val_t const a) const noexcept {
#if __cpp_aligned_new >= 201606 || _CPPLIB_VER
#if __cpp_sized_deallocation >= 201309L || (_CPPLIB_VER && !__clang__)
#if FOLLY_DETAIL_LANG_NEW_HAVE_AN
#if FOLLY_DETAIL_LANG_NEW_HAVE_SD
return FOLLY_DETAIL_LANG_NEW_IMPL_D(p, s, a);
#else
return FOLLY_DETAIL_LANG_NEW_IMPL_D(p, a);
#endif
#else
#if __cpp_sized_deallocation >= 201309L || (_CPPLIB_VER && !__clang__)
#if FOLLY_DETAIL_LANG_NEW_HAVE_SD
return FOLLY_DETAIL_LANG_NEW_IMPL_D(p, s);
#else
return FOLLY_DETAIL_LANG_NEW_IMPL_D(p);
Expand Down

0 comments on commit 8cd5130

Please sign in to comment.