Commit e15da103 authored by Christopher Dykes's avatar Christopher Dykes Committed by Facebook Github Bot

Refactor FOLLY_GCC_DISABLE_WARNING to play nice with clang-format

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
parent 1f52e58c
......@@ -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
......
......@@ -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 */ \
......
......@@ -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
......
......@@ -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 {
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment