From ba9bb6bca8a590648792d39df82de6c0b1eb4207 Mon Sep 17 00:00:00 2001 From: cyberslack_lee Date: Mon, 14 Aug 2023 17:40:18 +0800 Subject: [PATCH] [clang-tidy] No.51 enable bugprone-copy-constructor-init (#56219) --- .clang-tidy | 2 +- paddle/phi/core/dense_tensor.cc | 3 ++- paddle/phi/core/sparse_coo_tensor.cc | 6 +++--- paddle/phi/core/sparse_csr_tensor.cc | 8 ++++---- paddle/phi/core/string_tensor.cc | 3 ++- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index e073b75ae07..38957a23d1d 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -5,7 +5,7 @@ Checks: ' -bugprone-bad-signal-to-kill-thread, -bugprone-bool-pointer-implicit-conversion, -bugprone-branch-clone, --bugprone-copy-constructor-init, +bugprone-copy-constructor-init, -bugprone-dangling-handle, -bugprone-dynamic-static-initializers, -bugprone-exception-escape, diff --git a/paddle/phi/core/dense_tensor.cc b/paddle/phi/core/dense_tensor.cc index 598875a15fa..afb2f585716 100644 --- a/paddle/phi/core/dense_tensor.cc +++ b/paddle/phi/core/dense_tensor.cc @@ -52,7 +52,8 @@ DenseTensor::DenseTensor(const std::shared_ptr& holder, const DenseTensorMeta& meta) : meta_(meta), holder_(holder) {} -DenseTensor::DenseTensor(const DenseTensor& other) : meta_(other.meta()) { +DenseTensor::DenseTensor(const DenseTensor& other) { + this->meta_ = other.meta(); holder_ = other.holder_; storage_properties_ = std::move(CopyStorageProperties(other.storage_properties_)); diff --git a/paddle/phi/core/sparse_coo_tensor.cc b/paddle/phi/core/sparse_coo_tensor.cc index 6e7543016f0..f1568eacc08 100644 --- a/paddle/phi/core/sparse_coo_tensor.cc +++ b/paddle/phi/core/sparse_coo_tensor.cc @@ -50,9 +50,9 @@ SparseCooTensor::SparseCooTensor(DenseTensor&& non_zero_indices, meta_.dtype = non_zero_elements.dtype(); } -SparseCooTensor::SparseCooTensor(const SparseCooTensor& other) - : non_zero_indices_(other.non_zero_indices_), - non_zero_elements_(other.non_zero_elements_) { +SparseCooTensor::SparseCooTensor(const SparseCooTensor& other) { + this->non_zero_indices_ = other.non_zero_indices_; + this->non_zero_elements_ = other.non_zero_elements_; this->coalesced_ = other.coalesced_; set_meta(other.meta()); } diff --git a/paddle/phi/core/sparse_csr_tensor.cc b/paddle/phi/core/sparse_csr_tensor.cc index ab31a63f4a0..0dc0807a36b 100644 --- a/paddle/phi/core/sparse_csr_tensor.cc +++ b/paddle/phi/core/sparse_csr_tensor.cc @@ -66,10 +66,10 @@ SparseCsrTensor::SparseCsrTensor(const DenseTensor& non_zero_crows, meta_.dtype = non_zero_elements.dtype(); } -SparseCsrTensor::SparseCsrTensor(const SparseCsrTensor& other) - : non_zero_crows_(other.non_zero_crows_), - non_zero_cols_(other.non_zero_cols_), - non_zero_elements_(other.non_zero_elements_) { +SparseCsrTensor::SparseCsrTensor(const SparseCsrTensor& other) { + this->non_zero_crows_ = other.non_zero_crows_; + this->non_zero_cols_ = other.non_zero_cols_; + this->non_zero_elements_ = other.non_zero_elements_; set_meta(other.meta()); } diff --git a/paddle/phi/core/string_tensor.cc b/paddle/phi/core/string_tensor.cc index 0e465982ba4..e30754ad7fd 100644 --- a/paddle/phi/core/string_tensor.cc +++ b/paddle/phi/core/string_tensor.cc @@ -37,7 +37,8 @@ StringTensor::StringTensor(const std::shared_ptr& holder, const StringTensorMeta& meta) : meta_(meta), holder_(holder) {} -StringTensor::StringTensor(const StringTensor& other) : meta_(other.meta()) { +StringTensor::StringTensor(const StringTensor& other) { + this->meta_ = other.meta(); holder_ = other.holder_; } -- GitLab