Switch unguarded #pragmas to use portability macros
authorChristopher Dykes <cdykes@fb.com>
Thu, 8 Jun 2017 21:50:17 +0000 (14:50 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Thu, 8 Jun 2017 21:51:41 +0000 (14:51 -0700)
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
folly/experimental/Bits.h
folly/gen/Base-inl.h
folly/gen/Core-inl.h
folly/gen/String-inl.h
folly/io/IOBuf.h
folly/small_vector.h

index 5207c71d99b48ae194058d88bec38adf9703a234..3a49b634ff86af471a82dde082c8348872f00bea 100644 (file)
 #include <stdint.h>
 #include <boost/noncopyable.hpp>
 #include <folly/AtomicStruct.h>
+#include <folly/Portability.h>
 #include <folly/detail/CacheLocality.h>
 #include <folly/portability/SysMman.h>
 #include <folly/portability/Unistd.h>
 
 // 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
index 03a18c56d9e5633c398ab0bc55fc15fa853441b2..7e1d19b0c1621d859fe485862bf5759560c4b210 100644 (file)
@@ -55,13 +55,13 @@ struct BitsTraits<Unaligned<T>, typename std::enable_if<
   static T load(const Unaligned<T>& x) { return x.value; }
   static void store(Unaligned<T>& x, T v) { x.value = v; }
   static T loadRMW(const Unaligned<T>& 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<UnalignedNoASan<T>, typename std::enable_if<
   store(UnalignedNoASan<T>& x, T v) { x.value = v; }
   static T FOLLY_DISABLE_ADDRESS_SANITIZER
   loadRMW(const UnalignedNoASan<T>& 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<T, typename std::enable_if<
   static T load(const T& x) { return x; }
   static void store(T& x, T v) { x = v; }
   static T loadRMW(const T& 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;
-#pragma GCC diagnostic pop
+    FOLLY_POP_WARNING
   }
 };
 
@@ -203,11 +203,10 @@ struct Bits {
 
 // gcc 4.8 needs more -Wmaybe-uninitialized tickling, as it propagates the
 // taint upstream from loadRMW
-
-#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
 
 template <class T, class Traits>
@@ -262,7 +261,7 @@ inline void Bits<T, Traits>::innerSet(T* p, size_t offset, size_t count,
   Traits::store(*p, v);
 }
 
-#pragma GCC diagnostic pop
+FOLLY_POP_WARNING
 
 template <class T, class Traits>
 inline bool Bits<T, Traits>::test(const T* p, size_t bit) {
index 959696e8068407e93ad675b378e240d08d19b1fc..716f5aceb37368d36b37c5c7538f85fe3b4fdae6 100644 (file)
 #error This file may only be included from folly/gen/Base.h
 #endif
 
+#include <folly/Portability.h>
+
 // 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
index 87891e360770365d9a0f2b1e336a7fca4ab5cb87..bd66827e791a626b92df7a94848851bc09fcbfd0 100644 (file)
 #include <type_traits>
 #include <utility>
 
+#include <folly/Portability.h>
+
 // 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
index 64e86f9866a4f455499273bb17d01ec672b1deec..bd571a767f4e9fa19b6f29db758687c0c9460862 100644 (file)
@@ -19,6 +19,7 @@
 #endif
 
 #include <folly/Conv.h>
+#include <folly/Portability.h>
 #include <folly/String.h>
 
 namespace folly {
@@ -369,7 +370,7 @@ class UnsplitBuffer : public Operator<UnsplitBuffer<Delimiter, OutputBuffer>> {
 template<class Target, class=void>
 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
 
index 22867091cf22762c83baa9c96324db987cae99f9..238c4ec69059b50dde57e22c718d74e33798beac 100644 (file)
 #include <boost/iterator/iterator_facade.hpp>
 
 #include <folly/FBString.h>
-#include <folly/Range.h>
 #include <folly/FBVector.h>
+#include <folly/Portability.h>
+#include <folly/Range.h>
 #include <folly/portability/SysUio.h>
 
 // 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
index 12eba17f76ea3effee4c62e576460824b0ea1228..f9c8067d7ff5949b1120adc6b2f9fb6d88710d13 100644 (file)
@@ -55,8 +55,8 @@
 #include <folly/portability/TypeTraits.h>
 
 // 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<small_vector<T, M, A, B, C>>
 
 }  // namespace folly
 
-#pragma GCC diagnostic pop
+FOLLY_POP_WARNING