diff options
author | bulatman <bulatman@yandex-team.com> | 2023-06-08 20:05:16 +0300 |
---|---|---|
committer | bulatman <bulatman@yandex-team.com> | 2023-06-08 20:05:16 +0300 |
commit | df6af3ee4741c667cf0c449696f768186bdc5752 (patch) | |
tree | 21ad8fed13c87e0ebec4bb5456f667a79d11c745 | |
parent | 8642bc755ab5b51752619694224388b2d247c737 (diff) | |
download | ydb-df6af3ee4741c667cf0c449696f768186bdc5752.tar.gz |
Require semicolon after saveload macroses
-rw-r--r-- | library/cpp/accurate_accumulate/accurate_accumulate.h | 2 | ||||
-rw-r--r-- | library/cpp/binsaver/bin_saver.h | 9 | ||||
-rw-r--r-- | library/cpp/netliba/v6/ib_collective.h | 4 | ||||
-rw-r--r-- | util/system/compiler.h | 4 | ||||
-rw-r--r-- | util/ysafeptr.h | 5 | ||||
-rw-r--r-- | util/ysaveload.h | 7 | ||||
-rw-r--r-- | util/ysaveload_ut.cpp | 2 |
7 files changed, 22 insertions, 11 deletions
diff --git a/library/cpp/accurate_accumulate/accurate_accumulate.h b/library/cpp/accurate_accumulate/accurate_accumulate.h index dacced17e9..3a3d4009e5 100644 --- a/library/cpp/accurate_accumulate/accurate_accumulate.h +++ b/library/cpp/accurate_accumulate/accurate_accumulate.h @@ -83,7 +83,7 @@ public: return *this = TValueType(*this) / TValueType(x); } - Y_SAVELOAD_DEFINE(Sum_, Compensation_) + Y_SAVELOAD_DEFINE(Sum_, Compensation_); private: TValueType Sum_; diff --git a/library/cpp/binsaver/bin_saver.h b/library/cpp/binsaver/bin_saver.h index 412424889f..117ee0fd78 100644 --- a/library/cpp/binsaver/bin_saver.h +++ b/library/cpp/binsaver/bin_saver.h @@ -14,6 +14,7 @@ #include <util/generic/ylimits.h> #include <util/memory/blob.h> #include <util/digest/murmur.h> +#include <util/system/compiler.h> #include <array> #include <bitset> @@ -623,24 +624,24 @@ struct TRegisterSaveLoadType { int operator&(IBinSaver& f) { \ f.AddMulti(__VA_ARGS__); \ return 0; \ - } + } Y_SEMICOLON_GUARD #define SAVELOAD_OVERRIDE_WITHOUT_BASE(...) \ int operator&(IBinSaver& f) override { \ f.AddMulti(__VA_ARGS__); \ return 0; \ - } + } Y_SEMICOLON_GUARD #define SAVELOAD_OVERRIDE(base, ...) \ int operator&(IBinSaver& f) override { \ base::operator&(f); \ f.AddMulti(__VA_ARGS__); \ return 0; \ - } + } Y_SEMICOLON_GUARD #define SAVELOAD_BASE(...) \ int operator&(IBinSaver& f) { \ TBase::operator&(f); \ f.AddMulti(__VA_ARGS__); \ return 0; \ - } + } Y_SEMICOLON_GUARD diff --git a/library/cpp/netliba/v6/ib_collective.h b/library/cpp/netliba/v6/ib_collective.h index 48ffd29b34..2ce790e960 100644 --- a/library/cpp/netliba/v6/ib_collective.h +++ b/library/cpp/netliba/v6/ib_collective.h @@ -6,7 +6,7 @@ namespace NNetliba { struct TCollectiveInit { int Size, Rank; - SAVELOAD(Size, Rank) + SAVELOAD(Size, Rank); }; struct TCollectiveLinkSet { @@ -17,7 +17,7 @@ namespace NNetliba { TVector<TVector<int>> HostGroup; // HostGroup[0] - switchId, HostGroup[1] - hostId within the switch TVector<TLinkInfo> Links; - SAVELOAD(Hosts, HostGroup, Links) + SAVELOAD(Hosts, HostGroup, Links); }; struct IAllDataSync: public TThrRefBase { diff --git a/util/system/compiler.h b/util/system/compiler.h index 32acd43488..953837f919 100644 --- a/util/system/compiler.h +++ b/util/system/compiler.h @@ -613,6 +613,10 @@ _YandexAbort(); #define Y_REINITIALIZES_OBJECT #endif +// Use at the end of macros declaration. It allows macros usage only with semicolon at the end. +// It prevents from warnings for extra semicolons when building with flag `-Wextra-semi`. +#define Y_SEMICOLON_GUARD static_assert(true, "") + #ifdef __cplusplus void UseCharPointerImpl(volatile const char*); diff --git a/util/ysafeptr.h b/util/ysafeptr.h index af7dfd4bed..c33f66db84 100644 --- a/util/ysafeptr.h +++ b/util/ysafeptr.h @@ -1,6 +1,7 @@ #pragma once #include <stddef.h> +#include <util/system/compiler.h> #include <util/system/yassert.h> #include <util/system/defaults.h> #include <util/system/tls.h> @@ -209,7 +210,9 @@ protected: \ this->ObjData += nHoldObjs; \ } \ \ -private: +private: \ + Y_SEMICOLON_GUARD + #define OBJECT_NOCOPY_METHODS(classname) OBJECT_METHODS(classname) #define BASIC_REGISTER_CLASS(classname) \ Y_PRAGMA_DIAGNOSTIC_PUSH \ diff --git a/util/ysaveload.h b/util/ysaveload.h index 02efb4049b..f3451e2ad5 100644 --- a/util/ysaveload.h +++ b/util/ysaveload.h @@ -8,6 +8,7 @@ #include <util/generic/algorithm.h> #include <util/stream/output.h> #include <util/stream/input.h> +#include <util/system/compiler.h> #ifndef __NVCC__ // cuda is compiled in C++14 mode at the time @@ -710,7 +711,8 @@ static inline void LoadMany(S* s, Ts&... t) { \ inline void Load(IInputStream* s) { \ ::LoadMany(s, __VA_ARGS__); \ - } + } \ + Y_SEMICOLON_GUARD #define Y_SAVELOAD_DEFINE_OVERRIDE(...) \ void Save(IOutputStream* s) const override { \ @@ -719,7 +721,8 @@ static inline void LoadMany(S* s, Ts&... t) { \ void Load(IInputStream* s) override { \ ::LoadMany(s, __VA_ARGS__); \ - } + } \ + Y_SEMICOLON_GUARD template <class T> struct TNonVirtualSaver { diff --git a/util/ysaveload_ut.cpp b/util/ysaveload_ut.cpp index c241ed0ee1..7656f8e941 100644 --- a/util/ysaveload_ut.cpp +++ b/util/ysaveload_ut.cpp @@ -57,7 +57,7 @@ class TSaveLoadTest: public TTestBase { TString Str; ui32 Int; - Y_SAVELOAD_DEFINE(Str, Int) + Y_SAVELOAD_DEFINE(Str, Int); }; private: |