未验证 提交 b185adf8 编写于 作者: G gouzil 提交者: GitHub

[clang-tidy] enable bugprone-unhandled-self-assignment check (#56640)

上级 a8bb416f
...@@ -40,7 +40,7 @@ bugprone-integer-division, ...@@ -40,7 +40,7 @@ bugprone-integer-division,
-bugprone-too-small-loop-variable, -bugprone-too-small-loop-variable,
-bugprone-undefined-memory-manipulation, -bugprone-undefined-memory-manipulation,
-bugprone-undelegated-constructor, -bugprone-undelegated-constructor,
-bugprone-unhandled-self-assignment, bugprone-unhandled-self-assignment,
bugprone-unused-raii, bugprone-unused-raii,
-bugprone-unused-return-value, -bugprone-unused-return-value,
-bugprone-use-after-move, -bugprone-use-after-move,
......
...@@ -56,6 +56,9 @@ void DistModelDataBuf::Resize(size_t length) { ...@@ -56,6 +56,9 @@ void DistModelDataBuf::Resize(size_t length) {
} }
DistModelDataBuf& DistModelDataBuf::operator=(const DistModelDataBuf& other) { DistModelDataBuf& DistModelDataBuf::operator=(const DistModelDataBuf& other) {
if (this == &other) {
return *this;
}
if (!other.memory_owned_) { if (!other.memory_owned_) {
data_ = other.data_; data_ = other.data_;
length_ = other.length_; length_ = other.length_;
......
...@@ -513,6 +513,9 @@ OpDesc::OpDesc(const proto::OpDesc &desc, BlockDesc *block) ...@@ -513,6 +513,9 @@ OpDesc::OpDesc(const proto::OpDesc &desc, BlockDesc *block)
// Explicitly implement the assign operator, Since the added // Explicitly implement the assign operator, Since the added
// unique_ptr data member does not have the implicit assign operator. // unique_ptr data member does not have the implicit assign operator.
OpDesc &OpDesc::operator=(const OpDesc &other) { OpDesc &OpDesc::operator=(const OpDesc &other) {
if (this == &other) {
return *this;
}
CopyFrom(other); CopyFrom(other);
block_ = other.block_; block_ = other.block_;
need_update_ = true; need_update_ = true;
......
...@@ -52,6 +52,7 @@ PaddleBuf::PaddleBuf(PaddleBuf &&other) ...@@ -52,6 +52,7 @@ PaddleBuf::PaddleBuf(PaddleBuf &&other)
PaddleBuf::PaddleBuf(const PaddleBuf &other) { *this = other; } PaddleBuf::PaddleBuf(const PaddleBuf &other) { *this = other; }
PaddleBuf &PaddleBuf::operator=(const PaddleBuf &other) { PaddleBuf &PaddleBuf::operator=(const PaddleBuf &other) {
if (this == &other) return *this;
if (!other.memory_owned_) { if (!other.memory_owned_) {
data_ = other.data_; data_ = other.data_;
length_ = other.length_; length_ = other.length_;
......
...@@ -259,6 +259,9 @@ Status::Status(const Status& status) : impl_(std::make_shared<Impl>()) { ...@@ -259,6 +259,9 @@ Status::Status(const Status& status) : impl_(std::make_shared<Impl>()) {
} }
Status& Status::operator=(const Status& status) noexcept { Status& Status::operator=(const Status& status) noexcept {
if (this == &status) {
return *this;
}
*impl_ = *status.impl_; *impl_ = *status.impl_;
return *this; return *this;
} }
......
...@@ -65,6 +65,9 @@ DenseTensor::DenseTensor(const DenseTensor& other) { ...@@ -65,6 +65,9 @@ DenseTensor::DenseTensor(const DenseTensor& other) {
} }
DenseTensor& DenseTensor::operator=(const DenseTensor& other) { DenseTensor& DenseTensor::operator=(const DenseTensor& other) {
if (this == &other) {
return *this;
}
meta_ = other.meta(); meta_ = other.meta();
holder_ = other.holder_; holder_ = other.holder_;
storage_properties_ = storage_properties_ =
......
...@@ -43,6 +43,7 @@ StringTensor::StringTensor(const StringTensor& other) { ...@@ -43,6 +43,7 @@ StringTensor::StringTensor(const StringTensor& other) {
} }
StringTensor& StringTensor::operator=(const StringTensor& other) { StringTensor& StringTensor::operator=(const StringTensor& other) {
if (this == &other) return *this;
meta_ = other.meta(); meta_ = other.meta();
holder_ = other.holder_; holder_ = other.holder_;
return *this; return *this;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册