Refactor FOLLY_GCC_DISABLE_WARNING to play nice with clang-format v2017.04.10.00
authorChristopher Dykes <cdykes@fb.com>
Mon, 10 Apr 2017 01:02:53 +0000 (18:02 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Mon, 10 Apr 2017 01:06:42 +0000 (18:06 -0700)
Summary: Currently clang-format cannot be run on any file using the macro because it breaks it. By putting the warning name in a string clang-format no longer breaks it.

Reviewed By: yfeldblum

Differential Revision: D4856945

fbshipit-source-id: ebd2d223dd97f66224e9e2912610057e36287dae

folly/Portability.h
folly/Synchronized.h
folly/Traits.h
folly/io/async/AsyncSocket.cpp
folly/test/SingletonBenchmark.cpp
folly/test/SingletonTest.cpp
folly/test/SubprocessTest.cpp

index 77df916..1792abf 100644 (file)
@@ -151,12 +151,10 @@ constexpr bool kIsSanitizeThread = false;
 #elif defined(__clang__) || defined(__GNUC__)
 # define FOLLY_PUSH_WARNING _Pragma("GCC diagnostic push")
 # define FOLLY_POP_WARNING _Pragma("GCC diagnostic pop")
-#define FOLLY_GCC_DISABLE_WARNING_INTERNAL3(warningName) #warningName
-#define FOLLY_GCC_DISABLE_WARNING_INTERNAL2(warningName) \
-  FOLLY_GCC_DISABLE_WARNING_INTERNAL3(warningName)
-#define FOLLY_GCC_DISABLE_WARNING(warningName)                       \
-  _Pragma(FOLLY_GCC_DISABLE_WARNING_INTERNAL2(GCC diagnostic ignored \
-          FOLLY_GCC_DISABLE_WARNING_INTERNAL3(-W##warningName)))
+# define FOLLY_GCC_DISABLE_WARNING_INTERNAL2(warningName) #warningName
+# define FOLLY_GCC_DISABLE_WARNING(warningName) \
+  _Pragma(                                      \
+  FOLLY_GCC_DISABLE_WARNING_INTERNAL2(GCC diagnostic ignored warningName))
 // Disable the MSVC warnings.
 # define FOLLY_MSVC_DISABLE_WARNING(warningNumber)
 #else
@@ -168,8 +166,8 @@ constexpr bool kIsSanitizeThread = false;
 
 #ifdef HAVE_SHADOW_LOCAL_WARNINGS
 #define FOLLY_GCC_DISABLE_NEW_SHADOW_WARNINGS        \
-  FOLLY_GCC_DISABLE_WARNING(shadow-compatible-local) \
-  FOLLY_GCC_DISABLE_WARNING(shadow-local)
+  FOLLY_GCC_DISABLE_WARNING("-Wshadow-compatible-local") \
+  FOLLY_GCC_DISABLE_WARNING("-Wshadow-local")
 #else
 #define FOLLY_GCC_DISABLE_NEW_SHADOW_WARNINGS /* empty */
 #endif
index 5b6f9fc..5d91203 100644 (file)
@@ -1320,7 +1320,7 @@ void swap(Synchronized<T, M>& lhs, Synchronized<T, M>& rhs) {
  */
 #define SYNCHRONIZED(...)                                             \
   FOLLY_PUSH_WARNING                                                  \
-  FOLLY_GCC_DISABLE_WARNING(shadow)                                   \
+  FOLLY_GCC_DISABLE_WARNING("-Wshadow")                               \
   FOLLY_MSVC_DISABLE_WARNING(4189) /* initialized but unreferenced */ \
   FOLLY_MSVC_DISABLE_WARNING(4456) /* declaration hides local */      \
   FOLLY_MSVC_DISABLE_WARNING(4457) /* declaration hides parameter */  \
index ec46718..4be2282 100644 (file)
@@ -546,9 +546,9 @@ struct is_negative_impl<T, false> {
 // types) that violate -Wsign-compare and/or -Wbool-compare so suppress them
 // in order to not prevent all calling code from using it.
 FOLLY_PUSH_WARNING
-FOLLY_GCC_DISABLE_WARNING(sign-compare)
+FOLLY_GCC_DISABLE_WARNING("-Wsign-compare")
 #if __GNUC_PREREQ(5, 0)
-FOLLY_GCC_DISABLE_WARNING(bool-compare)
+FOLLY_GCC_DISABLE_WARNING("-Wbool-compare")
 #endif
 FOLLY_MSVC_DISABLE_WARNING(4388) // sign-compare
 FOLLY_MSVC_DISABLE_WARNING(4804) // bool-compare
index ddbab29..013813f 100644 (file)
@@ -776,10 +776,10 @@ void AsyncSocket::writeChain(WriteCallback* callback, unique_ptr<IOBuf>&& buf,
   size_t count = buf->countChainElements();
   if (count <= kSmallSizeMax) {
     // suppress "warning: variable length array 'vec' is used [-Wvla]"
-    FOLLY_PUSH_WARNING;
-    FOLLY_GCC_DISABLE_WARNING(vla);
+    FOLLY_PUSH_WARNING
+    FOLLY_GCC_DISABLE_WARNING("-Wvla")
     iovec vec[BOOST_PP_IF(FOLLY_HAVE_VLA, count, kSmallSizeMax)];
-    FOLLY_POP_WARNING;
+    FOLLY_POP_WARNING
 
     writeChainImpl(callback, vec, count, std::move(buf), flags);
   } else {
index 7721676..5c8cd2a 100644 (file)
@@ -24,7 +24,7 @@
 #include <folly/Memory.h>
 #include <folly/portability/GFlags.h>
 
-FOLLY_GCC_DISABLE_WARNING(deprecated-declarations)
+FOLLY_GCC_DISABLE_WARNING("-Wdeprecated-declarations")
 
 using namespace folly;
 
index cf50c68..782f039 100644 (file)
@@ -30,7 +30,7 @@
 #include <glog/logging.h>
 #include <boost/thread/barrier.hpp>
 
-FOLLY_GCC_DISABLE_WARNING(deprecated-declarations)
+FOLLY_GCC_DISABLE_WARNING("-Wdeprecated-declarations")
 
 using namespace folly;
 
index b3a0cf6..07ede20 100644 (file)
@@ -33,7 +33,7 @@
 #include <folly/portability/GTest.h>
 #include <folly/portability/Unistd.h>
 
-FOLLY_GCC_DISABLE_WARNING(deprecated-declarations)
+FOLLY_GCC_DISABLE_WARNING("-Wdeprecated-declarations")
 
 using namespace folly;