Fix bugprone unhandled self assignment (#25667)

* Add bugprone-unhandled-self-assignment

* Fix bugprone-unhandled-self-assignment
pull/25678/head
Esun Kim 4 years ago committed by GitHub
parent 98e1e620b9
commit 2dc8df9ef6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      .clang-tidy
  2. 3
      include/grpcpp/impl/codegen/call_op_set.h
  3. 1
      include/grpcpp/impl/codegen/string_ref.h
  4. 3
      src/core/ext/filters/client_channel/lb_policy.cc
  5. 3
      src/core/ext/filters/client_channel/resolver.cc
  6. 3
      src/core/ext/filters/client_channel/server_address.cc
  7. 3
      src/core/ext/filters/client_channel/subchannel_pool_interface.cc
  8. 2
      src/core/lib/gprpp/ref_counted_ptr.h

@ -24,7 +24,6 @@
# - bugprone-signed-char-misuse
# - bugprone-sizeof-expression
# - bugprone-too-small-loop-variable
# - bugprone-unhandled-self-assignment
# - clang-diagnostic-deprecated-declarations
# - clang-diagnostic-unused-function
# - google-readability-avoid-underscore-in-googletest-name
@ -62,7 +61,6 @@ Checks: '-*,
-bugprone-signed-char-misuse,
-bugprone-sizeof-expression,
-bugprone-too-small-loop-variable,
-bugprone-unhandled-self-assignment,
google-*,
-google-readability-avoid-underscore-in-googletest-name,
-google-runtime-int,

@ -878,6 +878,9 @@ class CallOpSet : public CallOpSetInterface,
interceptor_methods_(InterceptorBatchMethodsImpl()) {}
CallOpSet& operator=(const CallOpSet& other) {
if (&other == this) {
return *this;
}
core_cq_tag_ = this;
return_tag_ = this;
call_ = other.call_;

@ -51,6 +51,7 @@ class string_ref {
string_ref() : data_(nullptr), length_(0) {}
string_ref(const string_ref& other)
: data_(other.data_), length_(other.length_) {}
// NOLINTNEXTLINE(bugprone-unhandled-self-assignment)
string_ref& operator=(const string_ref& rhs) {
data_ = rhs.data_;
length_ = rhs.length_;

@ -70,6 +70,9 @@ LoadBalancingPolicy::UpdateArgs::UpdateArgs(UpdateArgs&& other) noexcept {
LoadBalancingPolicy::UpdateArgs& LoadBalancingPolicy::UpdateArgs::operator=(
const UpdateArgs& other) {
if (&other == this) {
return *this;
}
addresses = other.addresses;
config = other.config;
grpc_channel_args_destroy(args);

@ -60,6 +60,9 @@ Resolver::Result::Result(Result&& other) noexcept {
}
Resolver::Result& Resolver::Result::operator=(const Result& other) {
if (&other == this) {
return *this;
}
addresses = other.addresses;
service_config = other.service_config;
GRPC_ERROR_UNREF(service_config_error);

@ -61,6 +61,9 @@ ServerAddress::ServerAddress(const ServerAddress& other)
}
}
ServerAddress& ServerAddress::operator=(const ServerAddress& other) {
if (&other == this) {
return *this;
}
address_ = other.address_;
grpc_channel_args_destroy(args_);
args_ = grpc_channel_args_copy(other.args_);

@ -44,6 +44,9 @@ SubchannelKey::SubchannelKey(const SubchannelKey& other) {
}
SubchannelKey& SubchannelKey::operator=(const SubchannelKey& other) {
if (&other == this) {
return *this;
}
grpc_channel_args_destroy(const_cast<grpc_channel_args*>(args_));
Init(other.args_, grpc_channel_args_copy);
return *this;

@ -83,6 +83,7 @@ class RefCountedPtr {
}
// Copy assignment.
// NOLINTNEXTLINE(bugprone-unhandled-self-assignment)
RefCountedPtr& operator=(const RefCountedPtr& other) {
// Note: Order of reffing and unreffing is important here in case value_
// and other.value_ are the same object.
@ -235,6 +236,7 @@ class WeakRefCountedPtr {
}
// Copy assignment.
// NOLINTNEXTLINE(bugprone-unhandled-self-assignment)
WeakRefCountedPtr& operator=(const WeakRefCountedPtr& other) {
// Note: Order of reffing and unreffing is important here in case value_
// and other.value_ are the same object.

Loading…
Cancel
Save