Commit 9bc01de8 authored by Orvid King's avatar Orvid King Committed by Facebook Github Bot

Rename FOLLY_GCC_DISABLE_WARNING to FOLLY_GNU_DISABLE_WARNING

Summary: This should allow better differentation between compilers in situations where warnings need to be disabled for a specific compiler. I've reclaimed the GCC_DISABLE version to have it now refer to only GCC, rather than GCC+CLANG, and also added a version for clang only.

Reviewed By: yfeldblum

Differential Revision: D7834730

fbshipit-source-id: 7e0b076f5d9bc55870cfb7e67281190b4add82e6
parent fce8cf56
......@@ -76,11 +76,11 @@
FOLLY_PUSH_WARNING
// Ignore shadowing warnings within this file, so includers can use -Wshadow.
FOLLY_GCC_DISABLE_WARNING("-Wshadow")
FOLLY_GNU_DISABLE_WARNING("-Wshadow")
// GCC 4.9 has a false positive in setSmallSize (probably
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59124), disable
// compile-time array bound checking.
FOLLY_GCC_DISABLE_WARNING("-Warray-bounds")
FOLLY_GNU_DISABLE_WARNING("-Warray-bounds")
// FBString cannot use throw when replacing std::string, though it may still
// use folly::throw_exception
......
......@@ -33,7 +33,7 @@
// Ignore -Wformat-nonliteral warnings within this file
FOLLY_PUSH_WARNING
FOLLY_GCC_DISABLE_WARNING("-Wformat-nonliteral")
FOLLY_GNU_DISABLE_WARNING("-Wformat-nonliteral")
namespace folly {
......
......@@ -31,7 +31,7 @@
// Ignore shadowing warnings within this file, so includers can use -Wshadow.
FOLLY_PUSH_WARNING
FOLLY_GCC_DISABLE_WARNING("-Wshadow")
FOLLY_GNU_DISABLE_WARNING("-Wshadow")
namespace folly {
......
......@@ -31,7 +31,7 @@
// Ignore shadowing warnings within this file, so includers can use -Wshadow.
FOLLY_PUSH_WARNING
FOLLY_GCC_DISABLE_WARNING("-Wshadow")
FOLLY_GNU_DISABLE_WARNING("-Wshadow")
namespace folly {
......
......@@ -146,29 +146,41 @@ constexpr bool kIsSanitize = false;
# define FOLLY_PUSH_WARNING __pragma(warning(push))
# define FOLLY_POP_WARNING __pragma(warning(pop))
// Disable the GCC warnings.
# define FOLLY_GNU_DISABLE_WARNING(warningName)
# define FOLLY_GCC_DISABLE_WARNING(warningName)
# define FOLLY_CLANG_DISABLE_WARNING(warningName)
# define FOLLY_MSVC_DISABLE_WARNING(warningNumber) __pragma(warning(disable: warningNumber))
#elif defined(__clang__) || defined(__GNUC__)
#elif defined(__GNUC__)
// Clang & GCC
# define FOLLY_PUSH_WARNING _Pragma("GCC diagnostic push")
# define FOLLY_POP_WARNING _Pragma("GCC diagnostic pop")
# define FOLLY_GCC_DISABLE_WARNING_INTERNAL2(warningName) #warningName
# define FOLLY_GCC_DISABLE_WARNING(warningName) \
# define FOLLY_GNU_DISABLE_WARNING_INTERNAL2(warningName) #warningName
# define FOLLY_GNU_DISABLE_WARNING(warningName) \
_Pragma( \
FOLLY_GCC_DISABLE_WARNING_INTERNAL2(GCC diagnostic ignored warningName))
// Disable the MSVC warnings.
FOLLY_GNU_DISABLE_WARNING_INTERNAL2(GCC diagnostic ignored warningName))
# ifdef __clang__
# define FOLLY_CLANG_DISABLE_WARNING(warningName) FOLLY_GNU_DISABLE_WARNING(warningName)
# define FOLLY_GCC_DISABLE_WARNING(warningName)
# else
# define FOLLY_CLANG_DISABLE_WARNING(warningName)
# define FOLLY_GCC_DISABLE_WARNING(warningName) FOLLY_GNU_DISABLE_WARNING(warningName)
# endif
# define FOLLY_MSVC_DISABLE_WARNING(warningNumber)
#else
# define FOLLY_PUSH_WARNING
# define FOLLY_POP_WARNING
# define FOLLY_GNU_DISABLE_WARNING(warningName)
# define FOLLY_GCC_DISABLE_WARNING(warningName)
# define FOLLY_CLANG_DISABLE_WARNING(warningName)
# define FOLLY_MSVC_DISABLE_WARNING(warningNumber)
#endif
#ifdef FOLLY_HAVE_SHADOW_LOCAL_WARNINGS
#define FOLLY_GCC_DISABLE_NEW_SHADOW_WARNINGS \
FOLLY_GCC_DISABLE_WARNING("-Wshadow-compatible-local") \
FOLLY_GCC_DISABLE_WARNING("-Wshadow-local") \
FOLLY_GCC_DISABLE_WARNING("-Wshadow")
FOLLY_GNU_DISABLE_WARNING("-Wshadow-compatible-local") \
FOLLY_GNU_DISABLE_WARNING("-Wshadow-local") \
FOLLY_GNU_DISABLE_WARNING("-Wshadow")
#else
#define FOLLY_GCC_DISABLE_NEW_SHADOW_WARNINGS /* empty */
#endif
......
......@@ -46,7 +46,7 @@
// Ignore shadowing warnings within this file, so includers can use -Wshadow.
FOLLY_PUSH_WARNING
FOLLY_GCC_DISABLE_WARNING("-Wshadow")
FOLLY_GNU_DISABLE_WARNING("-Wshadow")
namespace folly {
......
......@@ -315,9 +315,7 @@ void Subprocess::spawn(
// vfork.
FOLLY_PUSH_WARNING
#if !defined(__clang__)
FOLLY_GCC_DISABLE_WARNING("-Wclobbered")
#endif
void Subprocess::spawnInternal(
std::unique_ptr<const char*[]> argv,
const char* executable,
......
......@@ -1742,7 +1742,7 @@ void swap(Synchronized<T, M>& lhs, Synchronized<T, M>& rhs) {
*/
#define SYNCHRONIZED(...) \
FOLLY_PUSH_WARNING \
FOLLY_GCC_DISABLE_WARNING("-Wshadow") \
FOLLY_GNU_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 */ \
......
......@@ -599,9 +599,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("-Wsign-compare")
FOLLY_GNU_DISABLE_WARNING("-Wsign-compare")
#if __GNUC_PREREQ(5, 0)
FOLLY_GCC_DISABLE_WARNING("-Wbool-compare")
FOLLY_GNU_DISABLE_WARNING("-Wbool-compare")
#endif
FOLLY_MSVC_DISABLE_WARNING(4388) // sign-compare
FOLLY_MSVC_DISABLE_WARNING(4804) // bool-compare
......
......@@ -57,10 +57,8 @@ struct BitsTraits<Unaligned<T>, typename std::enable_if<
static void store(Unaligned<T>& x, T v) { x.value = v; }
static T loadRMW(const Unaligned<T>& x) {
FOLLY_PUSH_WARNING
FOLLY_GCC_DISABLE_WARNING("-Wuninitialized")
#if !__clang__ // for gcc version [4.8, ?)
FOLLY_GNU_DISABLE_WARNING("-Wuninitialized")
FOLLY_GCC_DISABLE_WARNING("-Wmaybe-uninitialized")
#endif
return x.value;
FOLLY_POP_WARNING
}
......@@ -78,10 +76,8 @@ struct BitsTraits<UnalignedNoASan<T>, typename std::enable_if<
static T FOLLY_DISABLE_ADDRESS_SANITIZER
loadRMW(const UnalignedNoASan<T>& x) {
FOLLY_PUSH_WARNING
FOLLY_GCC_DISABLE_WARNING("-Wuninitialized")
#if !__clang__ // for gcc version [4.8, ?)
FOLLY_GNU_DISABLE_WARNING("-Wuninitialized")
FOLLY_GCC_DISABLE_WARNING("-Wmaybe-uninitialized")
#endif
return x.value;
FOLLY_POP_WARNING
}
......@@ -96,10 +92,8 @@ struct BitsTraits<T, typename std::enable_if<
static void store(T& x, T v) { x = v; }
static T loadRMW(const T& x) {
FOLLY_PUSH_WARNING
FOLLY_GCC_DISABLE_WARNING("-Wuninitialized")
#if !__clang__ // for gcc version [4.8, ?)
FOLLY_GNU_DISABLE_WARNING("-Wuninitialized")
FOLLY_GCC_DISABLE_WARNING("-Wmaybe-uninitialized")
#endif
return x;
FOLLY_POP_WARNING
}
......@@ -205,10 +199,8 @@ struct Bits {
// gcc 4.8 needs more -Wmaybe-uninitialized tickling, as it propagates the
// taint upstream from loadRMW
FOLLY_PUSH_WARNING
FOLLY_GCC_DISABLE_WARNING("-Wuninitialized")
#if !__clang__ // for gcc version [4.8, ?)
FOLLY_GNU_DISABLE_WARNING("-Wuninitialized")
FOLLY_GCC_DISABLE_WARNING("-Wmaybe-uninitialized")
#endif
template <class T, class Traits>
inline void Bits<T, Traits>::set(T* p, size_t bit) {
......
......@@ -144,7 +144,7 @@ TEST(Promise, setException) {
// Calling setException() with an exception_ptr is deprecated,
// but don't complain about this in the test for this function.
FOLLY_PUSH_WARNING
FOLLY_GCC_DISABLE_WARNING("-Wdeprecated-declarations")
FOLLY_GNU_DISABLE_WARNING("-Wdeprecated-declarations")
p.setException(std::make_exception_ptr(eggs));
FOLLY_POP_WARNING
EXPECT_THROW(f.value(), eggs_t);
......
......@@ -23,7 +23,7 @@
// Ignore shadowing warnings within this file, so includers can use -Wshadow.
FOLLY_PUSH_WARNING
FOLLY_GCC_DISABLE_WARNING("-Wshadow")
FOLLY_GNU_DISABLE_WARNING("-Wshadow")
namespace folly {
namespace gen {
......
......@@ -25,7 +25,7 @@
// Ignore shadowing warnings within this file, so includers can use -Wshadow.
FOLLY_PUSH_WARNING
FOLLY_GCC_DISABLE_WARNING("-Wshadow")
FOLLY_GNU_DISABLE_WARNING("-Wshadow")
namespace folly {
namespace gen {
......
......@@ -36,7 +36,7 @@
// Ignore shadowing warnings within this file, so includers can use -Wshadow.
FOLLY_PUSH_WARNING
FOLLY_GCC_DISABLE_WARNING("-Wshadow")
FOLLY_GNU_DISABLE_WARNING("-Wshadow")
namespace folly {
......
......@@ -988,7 +988,7 @@ void AsyncSocket::writeChain(WriteCallback* callback, unique_ptr<IOBuf>&& buf,
if (count <= kSmallSizeMax) {
// suppress "warning: variable length array 'vec' is used [-Wvla]"
FOLLY_PUSH_WARNING
FOLLY_GCC_DISABLE_WARNING("-Wvla")
FOLLY_GNU_DISABLE_WARNING("-Wvla")
iovec vec[BOOST_PP_IF(FOLLY_HAVE_VLA_01, count, kSmallSizeMax)];
FOLLY_POP_WARNING
......
......@@ -219,8 +219,6 @@ const ASN1_TIME* X509_CRL_get0_nextUpdate(const X509_CRL* crl);
} // namespace folly
FOLLY_PUSH_WARNING
#if __CLANG_PREREQ(3, 0)
FOLLY_GCC_DISABLE_WARNING("-Wheader-hygiene")
#endif
FOLLY_CLANG_DISABLE_WARNING("-Wheader-hygiene")
/* using override */ using namespace folly::portability::ssl;
FOLLY_POP_WARNING
......@@ -67,7 +67,7 @@
// Ignore shadowing warnings within this file, so includers can use -Wshadow.
FOLLY_PUSH_WARNING
FOLLY_GCC_DISABLE_WARNING("-Wshadow")
FOLLY_GNU_DISABLE_WARNING("-Wshadow")
namespace folly {
......
......@@ -46,7 +46,7 @@ TEST(Shell, Shellify) {
// Tests for the deprecated shellify() function.
// Don't warn about using this deprecated function in the test for it.
FOLLY_PUSH_WARNING
FOLLY_GCC_DISABLE_WARNING("-Wdeprecated-declarations")
FOLLY_GNU_DISABLE_WARNING("-Wdeprecated-declarations")
TEST(Shell, Shellify_deprecated) {
auto command = shellify("rm -rf /");
EXPECT_EQ(command[0], "/bin/sh");
......
......@@ -24,7 +24,7 @@
#include <folly/Memory.h>
#include <folly/portability/GFlags.h>
FOLLY_GCC_DISABLE_WARNING("-Wdeprecated-declarations")
FOLLY_GNU_DISABLE_WARNING("-Wdeprecated-declarations")
using namespace folly;
......
......@@ -30,7 +30,7 @@
#include <folly/Subprocess.h>
#endif
FOLLY_GCC_DISABLE_WARNING("-Wdeprecated-declarations")
FOLLY_GNU_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("-Wdeprecated-declarations")
FOLLY_GNU_DISABLE_WARNING("-Wdeprecated-declarations")
using namespace folly;
......
......@@ -193,10 +193,10 @@ THOUGHTS:
// We use some pre-processor magic to auto-generate setup and destruct code,
// but it also means we have some parameters that may not be used.
FOLLY_PUSH_WARNING
FOLLY_GCC_DISABLE_WARNING("-Wunused-parameter")
FOLLY_GCC_DISABLE_WARNING("-Wunused-variable")
FOLLY_GNU_DISABLE_WARNING("-Wunused-parameter")
FOLLY_GNU_DISABLE_WARNING("-Wunused-variable")
// Using SCOPED_TRACE repeatedly from within a macro violates -Wshadow
FOLLY_GCC_DISABLE_WARNING("-Wshadow")
FOLLY_GNU_DISABLE_WARNING("-Wshadow")
using namespace std;
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