From 156b18d1d020c4861573c5e1bc741e9be11b12fa Mon Sep 17 00:00:00 2001 From: Dan Wang Date: Fri, 8 Nov 2024 15:05:46 +0800 Subject: [PATCH] fix clang-tidy --- .../duplication/meta_duplication_service.h | 2 +- .../test/meta_state/meta_state_service.cpp | 4 +++- src/rpc/rpc_stream.h | 4 ++++ src/utils/binary_writer.h | 3 +++ src/utils/ports.h | 18 +++++++++++++++--- 5 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/meta/duplication/meta_duplication_service.h b/src/meta/duplication/meta_duplication_service.h index 1bc3edf7c4..4f4b9af740 100644 --- a/src/meta/duplication/meta_duplication_service.h +++ b/src/meta/duplication/meta_duplication_service.h @@ -17,7 +17,7 @@ #pragma once -#include +#include #include #include #include diff --git a/src/meta/test/meta_state/meta_state_service.cpp b/src/meta/test/meta_state/meta_state_service.cpp index 7c1db06621..ae0d1f3f43 100644 --- a/src/meta/test/meta_state/meta_state_service.cpp +++ b/src/meta/test/meta_state/meta_state_service.cpp @@ -118,7 +118,9 @@ void provider_basic_test(const service_creator_func &service_creator, CHECK_EQ(0xdeadbeef, read_value); }) ->wait(); - writer = dsn::binary_writer(); + } + { + dsn::binary_writer writer; writer.write(0xbeefdead); service ->set_data( diff --git a/src/rpc/rpc_stream.h b/src/rpc/rpc_stream.h index 023d6fb501..0d85960315 100644 --- a/src/rpc/rpc_stream.h +++ b/src/rpc/rpc_stream.h @@ -136,6 +136,10 @@ class rpc_write_stream : public binary_writer message_ex *_msg; bool _last_write_next_committed; int _last_write_next_total_size; + + rpc_write_stream() = delete; }; + typedef ::dsn::ref_ptr rpc_write_stream_ptr; + } // namespace dsn diff --git a/src/utils/binary_writer.h b/src/utils/binary_writer.h index 9fc957de76..816bec18ee 100644 --- a/src/utils/binary_writer.h +++ b/src/utils/binary_writer.h @@ -97,6 +97,9 @@ class binary_writer int _total_size; int _reserved_size_per_buffer; static const int kReservedSizePerBuffer; + + DISALLOW_COPY_AND_ASSIGN(binary_writer); + DISALLOW_MOVE_AND_ASSIGN(binary_writer); }; //--------------- inline implementation ------------------- diff --git a/src/utils/ports.h b/src/utils/ports.h index 718810f052..7e76e2c4a0 100644 --- a/src/utils/ports.h +++ b/src/utils/ports.h @@ -63,9 +63,21 @@ #define dsn_likely(pred) (__builtin_expect((pred), 1)) #define dsn_unlikely(pred) (__builtin_expect((pred), 0)) -#define DISALLOW_COPY_AND_ASSIGN(TypeName) \ - TypeName(const TypeName &) = delete; \ - void operator=(const TypeName &) = delete +#define DECLARE_COPY_AND_ASSIGN(type, action) \ + type(const type &) = action; \ + type &operator=(const type &) = action + +#define DECLARE_MOVE_AND_ASSIGN(type, action) \ + type(type &&) = action; \ + type &operator=(type &&) = action + +#define DEFAULT_COPY_AND_ASSIGN(type) DECLARE_COPY_AND_ASSIGN(type, default) + +#define DEFAULT_MOVE_AND_ASSIGN(type) DECLARE_MOVE_AND_ASSIGN(type, default) + +#define DISALLOW_COPY_AND_ASSIGN(type) DECLARE_COPY_AND_ASSIGN(type, delete) + +#define DISALLOW_MOVE_AND_ASSIGN(type) DECLARE_MOVE_AND_ASSIGN(type, delete) #if defined OS_LINUX || defined OS_CYGWIN