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 77df91642c4186037d8ece6cf6575884d96dfd22..1792abf5966c4172b2415132b7b26ec1d68a6037 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 5b6f9fc0e6b6372f9b132f2e6aed469f83fc66cb..5d912034b3342db94f8c1b411a860ca173d08989 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 ec4671806b164ebd1e48bce96e158cf212d7bdcb..4be2282c96c4b2f8f9c08a2c4c102dda9dc1280b 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 ddbab294ab94152eb6a5c4f273e109b79a70f197..013813f92d0eef971e1b84fcb76796beb813c93a 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 77216766a4264370b473c7a3ca6cd1c46ecd00d1..5c8cd2a0a72906caed152eaaed75c845b919c441 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 cf50c6876c0d12613b08a07c429d622525075dda..782f039887d9815cc3c76f133667268dd2ca6d52 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 b3a0cf6de7f14113739308c5c406756ca78766f4..07ede20ac057c24f30993de44fccff14c0faf2c5 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;