From 9534b9fe6944f575980059581c600d53692cc8fe Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Wed, 11 Nov 2020 16:16:33 -0800 Subject: [PATCH] Refactor warning suppression --- include/fmt/core.h | 10 +++++----- include/fmt/format.h | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index bad9e8de..936290c4 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -49,10 +49,10 @@ #ifdef _MSC_VER # define FMT_MSC_VER _MSC_VER -# define FMT_SUPPRESS_MSC_WARNING(n) __pragma(warning(suppress : n)) +# define FMT_MSC_WARNING(...) __pragma(warning(__VA_ARGS__)) #else # define FMT_MSC_VER 0 -# define FMT_SUPPRESS_MSC_WARNING(n) +# define FMT_MSC_WARNING(...) #endif #ifdef __has_feature @@ -203,7 +203,7 @@ #endif #if !defined(FMT_HEADER_ONLY) && defined(_WIN32) -# define FMT_CLASS_API FMT_SUPPRESS_MSC_WARNING(4275) +# define FMT_CLASS_API FMT_MSC_WARNING(suppress : 4275) # ifdef FMT_EXPORT # define FMT_API __declspec(dllexport) # define FMT_EXTERN_TEMPLATE_API FMT_API @@ -328,7 +328,7 @@ FMT_CONSTEXPR typename std::make_unsigned::type to_unsigned(Int value) { return static_cast::type>(value); } -FMT_SUPPRESS_MSC_WARNING(4566) constexpr unsigned char micro[] = "\u00B5"; +FMT_MSC_WARNING(suppress : 4566) constexpr unsigned char micro[] = "\u00B5"; template constexpr bool is_unicode() { return FMT_UNICODE || sizeof(Char) != 1 || @@ -671,7 +671,7 @@ template class buffer { protected: // Don't initialize ptr_ since it is not accessed to save a few cycles. - FMT_SUPPRESS_MSC_WARNING(26495) + FMT_MSC_WARNING(suppress : 26495) buffer(size_t sz) FMT_NOEXCEPT : size_(sz), capacity_(sz) {} buffer(T* p = nullptr, size_t sz = 0, size_t cap = 0) FMT_NOEXCEPT diff --git a/include/fmt/format.h b/include/fmt/format.h index adf39d36..9aca3b5d 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -37,9 +37,9 @@ #include #include #include -#include #include #include // std::swap +#include #include "core.h" @@ -223,7 +223,7 @@ inline int clz(uint32_t x) { // Static analysis complains about using uninitialized data // "r", but the only way that can happen is if "x" is 0, // which the callers guarantee to not happen. - FMT_SUPPRESS_MSC_WARNING(6102) + FMT_MSC_WARNING(suppress : 6102) return 31 ^ static_cast(r); } # define FMT_BUILTIN_CLZ(n) detail::clz(n) @@ -239,7 +239,7 @@ inline int clzll(uint64_t x) { _BitScanReverse(&r, static_cast(x)); # endif FMT_ASSERT(x != 0, ""); - FMT_SUPPRESS_MSC_WARNING(6102) // Suppress a bogus static analysis warning. + FMT_MSC_WARNING(suppress : 6102) // Suppress a bogus static analysis warning. return 63 ^ static_cast(r); } # define FMT_BUILTIN_CLZLL(n) detail::clzll(n) @@ -248,7 +248,7 @@ inline int ctz(uint32_t x) { unsigned long r = 0; _BitScanForward(&r, x); FMT_ASSERT(x != 0, ""); - FMT_SUPPRESS_MSC_WARNING(6102) // Suppress a bogus static analysis warning. + FMT_MSC_WARNING(suppress : 6102) // Suppress a bogus static analysis warning. return static_cast(r); } # define FMT_BUILTIN_CTZ(n) detail::ctz(n) @@ -256,7 +256,7 @@ inline int ctz(uint32_t x) { inline int ctzll(uint64_t x) { unsigned long r = 0; FMT_ASSERT(x != 0, ""); - FMT_SUPPRESS_MSC_WARNING(6102) // Suppress a bogus static analysis warning. + FMT_MSC_WARNING(suppress : 6102) // Suppress a bogus static analysis warning. # ifdef _WIN64 _BitScanForward64(&r, x); # else