From 146c24b7ee25026ae410edde34bbc5808a224da8 Mon Sep 17 00:00:00 2001 From: Christopher Dykes Date: Thu, 8 Jun 2017 14:50:17 -0700 Subject: [PATCH] Switch unguarded #pragmas to use portability macros Summary: Otherwise downstream Windows users have to explicitly disable MSVC's warnings about unknown pragmas. Reviewed By: yfeldblum Differential Revision: D5211415 fbshipit-source-id: 42871e03895010818c7e1cb6e57c1885970e98c2 --- folly/IndexedMemPool.h | 7 ++++--- folly/experimental/Bits.h | 33 ++++++++++++++++----------------- folly/gen/Base-inl.h | 8 +++++--- folly/gen/Core-inl.h | 8 +++++--- folly/gen/String-inl.h | 5 +++-- folly/io/IOBuf.h | 9 +++++---- folly/small_vector.h | 6 +++--- 7 files changed, 41 insertions(+), 35 deletions(-) diff --git a/folly/IndexedMemPool.h b/folly/IndexedMemPool.h index 5207c71d..3a49b634 100644 --- a/folly/IndexedMemPool.h +++ b/folly/IndexedMemPool.h @@ -22,13 +22,14 @@ #include #include #include +#include #include #include #include // Ignore shadowing warnings within this file, so includers can use -Wshadow. -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wshadow" +FOLLY_PUSH_WARNING +FOLLY_GCC_DISABLE_WARNING("-Wshadow") namespace folly { @@ -530,4 +531,4 @@ struct IndexedMemPoolRecycler { } // namespace folly -# pragma GCC diagnostic pop +FOLLY_POP_WARNING diff --git a/folly/experimental/Bits.h b/folly/experimental/Bits.h index 03a18c56..7e1d19b0 100644 --- a/folly/experimental/Bits.h +++ b/folly/experimental/Bits.h @@ -55,13 +55,13 @@ struct BitsTraits, typename std::enable_if< static T load(const Unaligned& x) { return x.value; } static void store(Unaligned& x, T v) { x.value = v; } static T loadRMW(const Unaligned& x) { -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wuninitialized" + FOLLY_PUSH_WARNING + FOLLY_GCC_DISABLE_WARNING("-Wuninitialized") #if !__clang__ // for gcc version [4.8, ?) -#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" + FOLLY_GCC_DISABLE_WARNING("-Wmaybe-uninitialized") #endif return x.value; -#pragma GCC diagnostic pop + FOLLY_POP_WARNING } }; @@ -76,13 +76,13 @@ struct BitsTraits, typename std::enable_if< store(UnalignedNoASan& x, T v) { x.value = v; } static T FOLLY_DISABLE_ADDRESS_SANITIZER loadRMW(const UnalignedNoASan& x) { -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wuninitialized" + FOLLY_PUSH_WARNING + FOLLY_GCC_DISABLE_WARNING("-Wuninitialized") #if !__clang__ // for gcc version [4.8, ?) -#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" + FOLLY_GCC_DISABLE_WARNING("-Wmaybe-uninitialized") #endif return x.value; -#pragma GCC diagnostic pop + FOLLY_POP_WARNING } }; @@ -94,13 +94,13 @@ struct BitsTraits @@ -262,7 +261,7 @@ inline void Bits::innerSet(T* p, size_t offset, size_t count, Traits::store(*p, v); } -#pragma GCC diagnostic pop +FOLLY_POP_WARNING template inline bool Bits::test(const T* p, size_t bit) { diff --git a/folly/gen/Base-inl.h b/folly/gen/Base-inl.h index 959696e8..716f5ace 100644 --- a/folly/gen/Base-inl.h +++ b/folly/gen/Base-inl.h @@ -18,9 +18,11 @@ #error This file may only be included from folly/gen/Base.h #endif +#include + // Ignore shadowing warnings within this file, so includers can use -Wshadow. -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wshadow" +FOLLY_PUSH_WARNING +FOLLY_GCC_DISABLE_WARNING("-Wshadow") namespace folly { namespace gen { @@ -2340,4 +2342,4 @@ inline detail::Batch batch(size_t batchSize) { } // gen } // folly -#pragma GCC diagnostic pop +FOLLY_POP_WARNING diff --git a/folly/gen/Core-inl.h b/folly/gen/Core-inl.h index 87891e36..bd66827e 100644 --- a/folly/gen/Core-inl.h +++ b/folly/gen/Core-inl.h @@ -21,9 +21,11 @@ #include #include +#include + // Ignore shadowing warnings within this file, so includers can use -Wshadow. -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wshadow" +FOLLY_PUSH_WARNING +FOLLY_GCC_DISABLE_WARNING("-Wshadow") namespace folly { namespace gen { @@ -376,4 +378,4 @@ public: } // gen } // folly -#pragma GCC diagnostic pop +FOLLY_POP_WARNING diff --git a/folly/gen/String-inl.h b/folly/gen/String-inl.h index 64e86f98..bd571a76 100644 --- a/folly/gen/String-inl.h +++ b/folly/gen/String-inl.h @@ -19,6 +19,7 @@ #endif #include +#include #include namespace folly { @@ -369,7 +370,7 @@ class UnsplitBuffer : public Operator> { template inline Target passthrough(Target target) { return target; } -#pragma GCC diagnostic push +FOLLY_PUSH_WARNING #ifdef __clang__ // Clang isn't happy with eatField() hack below. #pragma GCC diagnostic ignored "-Wreturn-stack-address" @@ -410,7 +411,7 @@ class SplitTo { } }; -#pragma GCC diagnostic pop +FOLLY_POP_WARNING } // namespace detail diff --git a/folly/io/IOBuf.h b/folly/io/IOBuf.h index 22867091..238c4ec6 100644 --- a/folly/io/IOBuf.h +++ b/folly/io/IOBuf.h @@ -29,13 +29,14 @@ #include #include -#include #include +#include +#include #include // Ignore shadowing warnings within this file, so includers can use -Wshadow. -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wshadow" +FOLLY_PUSH_WARNING +FOLLY_GCC_DISABLE_WARNING("-Wshadow") namespace folly { @@ -1544,4 +1545,4 @@ inline IOBuf::Iterator IOBuf::end() const { return cend(); } } // folly -#pragma GCC diagnostic pop +FOLLY_POP_WARNING diff --git a/folly/small_vector.h b/folly/small_vector.h index 12eba17f..f9c8067d 100644 --- a/folly/small_vector.h +++ b/folly/small_vector.h @@ -55,8 +55,8 @@ #include // Ignore shadowing warnings within this file, so includers can use -Wshadow. -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wshadow" +FOLLY_PUSH_WARNING +FOLLY_GCC_DISABLE_WARNING("-Wshadow") namespace folly { @@ -1146,4 +1146,4 @@ struct IndexableTraits> } // namespace folly -#pragma GCC diagnostic pop +FOLLY_POP_WARNING -- 2.34.1