Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[CPU] Apply 'cppcoreguidelines-rvalue-reference-param-not-moved' clang-tidy remarks (#32098)

Arseniy Obolenskiyd0b89c6c6179
diff --git a/src/plugins/intel_cpu/src/.clang-tidy b/src/plugins/intel_cpu/src/.clang-tidy
index 1bbfa7d60a4..262006a28cf 100644
--- a/src/plugins/intel_cpu/src/.clang-tidy
+++ b/src/plugins/intel_cpu/src/.clang-tidy
@@ -20,7 +20,6 @@
# -cppcoreguidelines-pro-type-static-cast-downcast. Performance impact
# -cppcoreguidelines-pro-type-union-access. There are a lot of code which uses unions
# -cppcoreguidelines-pro-type-vararg. There are a lot of code which uses vararg functions
-# -cppcoreguidelines-rvalue-reference-param-not-moved. There are a lot of code which uses rvalue references
# -cppcoreguidelines-special-member-functions. There are a lot of code which does not define all copy/move constructors/assignment operators
# -google-readability-todo. No big reason to enforce
# -modernize-use-trailing-return-type. Just stylistic preference
@@ -81,7 +80,6 @@ Checks: >
-cppcoreguidelines-pro-type-static-cast-downcast,
-cppcoreguidelines-pro-type-union-access,
-cppcoreguidelines-pro-type-vararg,
- -cppcoreguidelines-rvalue-reference-param-not-moved,
-cppcoreguidelines-special-member-functions,
-google-build-using-namespace,
-google-explicit-constructor,
diff --git a/src/plugins/intel_cpu/src/emitters/plugin/x64/utils.cpp b/src/plugins/intel_cpu/src/emitters/plugin/x64/utils.cpp
index eebbab1038b..cf1bed1d968 100644
--- a/src/plugins/intel_cpu/src/emitters/plugin/x64/utils.cpp
+++ b/src/plugins/intel_cpu/src/emitters/plugin/x64/utils.cpp
@@ -51,7 +51,7 @@ template <cpu_isa_t isa,
struct regs_to_spill {
static std::vector<Xbyak::Reg> get(const std::set<snippets::Reg>& live_regs) {
std::vector<Xbyak::Reg> regs_to_spill;
- auto push_if_live = [&live_regs, &regs_to_spill](Xbyak::Reg&& reg) {
+ auto push_if_live = [&live_regs, &regs_to_spill](Xbyak::Reg reg) {
if (live_regs.empty() || (live_regs.count(Xbyak2SnippetsReg(reg)) != 0U)) {
regs_to_spill.emplace_back(reg);
}
diff --git a/src/plugins/intel_cpu/src/nodes/input.cpp b/src/plugins/intel_cpu/src/nodes/input.cpp
index a3e5bbb3f10..b31a80a9069 100644
--- a/src/plugins/intel_cpu/src/nodes/input.cpp
+++ b/src/plugins/intel_cpu/src/nodes/input.cpp
@@ -88,7 +88,7 @@ protected:
void foreach (const Xbyak::Reg64& idx,
size_t step,
const Xbyak::Reg64& end,
- std::function<void(const Xbyak::Reg64&)> && fn) {
+ const std::function<void(const Xbyak::Reg64&)>& fn) {
Label loop;
Label exit;
diff --git a/src/plugins/intel_cpu/src/nodes/kernels/x64/jit_kernel.hpp b/src/plugins/intel_cpu/src/nodes/kernels/x64/jit_kernel.hpp
index 62eb343aff0..c63cbde340a 100644
--- a/src/plugins/intel_cpu/src/nodes/kernels/x64/jit_kernel.hpp
+++ b/src/plugins/intel_cpu/src/nodes/kernels/x64/jit_kernel.hpp
@@ -665,7 +665,10 @@ struct jit_kernel : public dnnl::impl::cpu::x64::jit_generator_t {
void store(const variable<DstT>& dst, const variable<SrcT[N]>& src, const variable<size_t>& length);
template <typename B, typename E, typename S = size_t>
- void foreach (const B& begin, const E& end, std::function<void(const variable<size_t>&)> && fn, const S& step = 1);
+ void foreach (const B& begin,
+ const E& end,
+ const std::function<void(const variable<size_t>&)>& fn,
+ const S& step = 1);
template <typename T>
variable<T> var();
@@ -814,7 +817,7 @@ void jit_kernel::store(const variable<DstT>& dst, const variable<SrcT[N]>& src,
template <typename B, typename E, typename S>
void jit_kernel::foreach (const B& begin,
const E& end,
- std::function<void(const variable<size_t>&)> && fn,
+ const std::function<void(const variable<size_t>&)>& fn,
const S& step) {
using namespace Xbyak;
diff --git a/src/plugins/intel_cpu/src/shape_inference/static_shape.cpp b/src/plugins/intel_cpu/src/shape_inference/static_shape.cpp
index 570908be5b2..94c63cf1d8a 100644
--- a/src/plugins/intel_cpu/src/shape_inference/static_shape.cpp
+++ b/src/plugins/intel_cpu/src/shape_inference/static_shape.cpp
@@ -183,11 +183,13 @@ void NodeValidationFailure::create(const char* file,
const char* check_string,
std::pair<const Node*, const std::vector<intel_cpu::StaticShape>*>&& ctx,
const std::string& explanation) {
- throw ov::NodeValidationFailure(make_what(file,
- line,
- check_string,
- node_validation_failure_loc_string(ctx.first),
- ov::op::validate::shape_infer_explanation_str(*ctx.second, explanation)));
+ auto context = std::move(ctx);
+ throw ov::NodeValidationFailure(
+ make_what(file,
+ line,
+ check_string,
+ node_validation_failure_loc_string(context.first),
+ ov::op::validate::shape_infer_explanation_str(*context.second, explanation)));
}
template <>
@@ -196,10 +198,12 @@ void NodeValidationFailure::create(const char* file,
const char* check_string,
std::pair<const Node*, const std::vector<intel_cpu::StaticShapeRef>*>&& ctx,
const std::string& explanation) {
- throw ov::NodeValidationFailure(make_what(file,
- line,
- check_string,
- node_validation_failure_loc_string(ctx.first),
- ov::op::validate::shape_infer_explanation_str(*ctx.second, explanation)));
+ auto context = std::move(ctx);
+ throw ov::NodeValidationFailure(
+ make_what(file,
+ line,
+ check_string,
+ node_validation_failure_loc_string(context.first),
+ ov::op::validate::shape_infer_explanation_str(*context.second, explanation)));
}
} // namespace ov