Skip to content

Commit 1f23c00

Browse files
authored
[CPU] Enable clang-tidy-18 checks (#28725)
### Details: - Enable clang-tidy check on clang-18 (default for Ubuntu 24.04) - Fix newly appeared warnings ### Tickets: - N/A
1 parent a1d4566 commit 1f23c00

File tree

19 files changed

+67
-53
lines changed

19 files changed

+67
-53
lines changed

.github/dockerfiles/docker_tag

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
pr-28040
1+
pr-28725

.github/dockerfiles/ov_build/ubuntu_22_04_x64_cc/Dockerfile

+4-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ ENV DEBIAN_FRONTEND="noninteractive" \
1313
TZ="Europe/London"
1414

1515
RUN apt-get update && \
16-
apt-get install software-properties-common && \
16+
apt-get install software-properties-common wget && \
1717
add-apt-repository --yes --no-update ppa:git-core/ppa && \
18+
add-apt-repository --yes --no-update "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main" && \
19+
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | tee /etc/apt/trusted.gpg.d/llvm.asc && \
1820
add-apt-repository --yes --no-update ppa:deadsnakes/ppa && \
1921
apt-get update && \
2022
apt-get install \
@@ -38,7 +40,7 @@ RUN apt-get update && \
3840
# Compiler \
3941
clang-15 \
4042
# Static analyzer
41-
clang-tidy-15 \
43+
clang-tidy-18 \
4244
# clang-tidy uses clang-format as a dependency
4345
clang-format-15 \
4446
&& \

cmake/developer_package/clang_tidy/clang_tidy.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44

55
if(ENABLE_CLANG_TIDY)
6-
set(CLANG_TIDY_REQUIRED_VERSION 15 CACHE STRING "clang-tidy version to use")
6+
set(CLANG_TIDY_REQUIRED_VERSION 18 CACHE STRING "clang-tidy version to use")
77
set(CLANG_TIDY_FILENAME clang-tidy-${CLANG_TIDY_REQUIRED_VERSION} clang-tidy)
88
find_host_program(CLANG_TIDY NAMES ${CLANG_TIDY_FILENAME} PATHS ENV PATH)
99
if(CLANG_TIDY)

cmake/developer_package/plugins/plugins.cmake

+2-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ function(ov_add_plugin)
108108

109109
if (OV_PLUGIN_ADD_CLANG_TIDY)
110110
if (ENABLE_CLANG_TIDY)
111-
set_target_properties(${OV_PLUGIN_NAME} PROPERTIES CXX_CLANG_TIDY clang-tidy-${CLANG_TIDY_REQUIRED_VERSION})
111+
set_target_properties(${OV_PLUGIN_NAME} PROPERTIES
112+
CXX_CLANG_TIDY "clang-tidy-${CLANG_TIDY_REQUIRED_VERSION};--extra-arg=-Wno-unused-command-line-argument")
112113
endif()
113114
endif()
114115

src/plugins/intel_cpu/src/emitters/plugin/x64/debug_capabilities.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ void RegPrinter::print_reg_prc(const char* name, const char* ori_name, T* ptr) {
4646
ss << static_cast<uint64_t>(*ptr);
4747
}
4848
}
49-
ss << std::endl;
49+
ss << '\n';
5050
std::cout << ss.str();
5151
}
5252

@@ -60,7 +60,7 @@ void RegPrinter::print_vmm_prc(const char* name, const char* ori_name, PRC_T* pt
6060
for (size_t i = 1; i < vlen / sizeof(float); i++) {
6161
ss << ", " << ptr[i];
6262
}
63-
ss << "}" << std::endl;
63+
ss << "}" << '\n';
6464
std::cout << ss.str();
6565
}
6666
template void RegPrinter::print_vmm_prc<float, 16>(const char* name, const char* ori_name, float* ptr);

src/plugins/intel_cpu/src/emitters/snippets/jit_snippets_call_args.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ void jit_snippets_call_args::loop_args_t::init_pointers_and_copy_data(const int6
5858
std::memcpy(m_finalization_offsets, finalization_offsets, chunk_size);
5959
}
6060

61-
void swap(jit_snippets_call_args::loop_args_t& first, jit_snippets_call_args::loop_args_t& second) {
61+
void swap(jit_snippets_call_args::loop_args_t& first, jit_snippets_call_args::loop_args_t& second) noexcept {
6262
std::swap(first.m_work_amount, second.m_work_amount);
6363
std::swap(first.m_num_data_ptrs, second.m_num_data_ptrs);
6464
std::swap(first.m_ptr_increments, second.m_ptr_increments);

src/plugins/intel_cpu/src/emitters/snippets/jit_snippets_call_args.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ struct jit_snippets_call_args::loop_args_t {
5858
~loop_args_t();
5959

6060
loop_args_t& operator=(loop_args_t other);
61-
friend void swap(loop_args_t& first, loop_args_t& second);
61+
friend void swap(loop_args_t& first, loop_args_t& second) noexcept;
6262

6363
void init_pointers_and_copy_data(const int64_t num_elements,
6464
const int64_t* ptr_increments,

src/plugins/intel_cpu/src/graph_dumper.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ void serializeToCout(const Graph& graph) {
267267
<< "/l=" << outConfs.front().getMemDesc()->serializeFormat();
268268
}
269269
}
270-
std::cout << " ]" << std::endl;
270+
std::cout << " ]" << '\n';
271271
}
272272
}
273273

@@ -310,13 +310,13 @@ void summary_perf(const Graph& graph) {
310310
return;
311311
}
312312

313-
std::cout << "======= ENABLE_DEBUG_CAPS:OV_CPU_SUMMARY_PERF ======" << std::endl;
313+
std::cout << "======= ENABLE_DEBUG_CAPS:OV_CPU_SUMMARY_PERF ======" << '\n';
314314
std::cout << "Summary of " << graph.GetName() << " @" << std::hash<uint64_t>{}(reinterpret_cast<uint64_t>(&graph))
315-
<< std::endl;
316-
std::cout << " Total(us): " << (uint64_t)(total) << std::endl;
317-
std::cout << " Total_avg(us): " << (uint64_t)(total_avg) << std::endl;
315+
<< '\n';
316+
std::cout << " Total(us): " << (uint64_t)(total) << '\n';
317+
std::cout << " Total_avg(us): " << (uint64_t)(total_avg) << '\n';
318318
{
319-
std::cout << " perf_by_type:" << std::endl;
319+
std::cout << " perf_by_type:" << '\n';
320320
std::vector<std::pair<std::string, double>> A;
321321
A.reserve(perf_by_type.size());
322322
for (auto& it : perf_by_type) {
@@ -333,12 +333,12 @@ void summary_perf(const Graph& graph) {
333333
break;
334334
}
335335
ss << std::setw(10) << std::right << percentage << " % : " << std::setw(8) << std::right << it.second
336-
<< "(us) " << it.first << std::endl;
336+
<< "(us) " << it.first << '\n';
337337
std::cout << ss.str();
338338
}
339339
}
340340
{
341-
std::cout << " perf_by_node:" << std::endl;
341+
std::cout << " perf_by_node:" << '\n';
342342
std::vector<std::pair<NodePtr, double>> A;
343343
A.reserve(perf_by_node.size());
344344
for (auto& it : perf_by_node) {
@@ -361,7 +361,7 @@ void summary_perf(const Graph& graph) {
361361
ss << std::setw(10) << std::right << std::fixed << std::setprecision(2) << percentage << " % "
362362
<< std::setw(8) << std::right << node->PerfCounter().avg() << "(us)x" << node->PerfCounter().count()
363363
<< " #" << node->getExecIndex() << " " << node->getName() << " "
364-
<< node->getTypeStr() + "_" + node->getPrimitiveDescriptorType() << std::endl;
364+
<< node->getTypeStr() + "_" + node->getPrimitiveDescriptorType() << '\n';
365365
std::cout << ss.str();
366366
}
367367
}

src/plugins/intel_cpu/src/node.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -2090,8 +2090,8 @@ int Node::inPlaceOutPort(int portIdx) const {
20902090
}
20912091

20922092
void Node::resolveInPlaceDirection() {
2093-
enum InplaceDirectionType { UP, DOWN, CYCLIC, NONE };
2094-
enum PortType { INPUT, OUTPUT };
2093+
enum InplaceDirectionType : uint8_t { UP, DOWN, CYCLIC, NONE };
2094+
enum PortType : uint8_t { INPUT, OUTPUT };
20952095

20962096
auto inPlaceDirection = [](const Node* node, PortType portType, int portNum) -> InplaceDirectionType {
20972097
if (PortType::INPUT == portType) {

src/plugins/intel_cpu/src/nodes/common/cpu_convert.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ using namespace dnnl::impl::utils;
2828
using namespace dnnl::impl::cpu::x64;
2929
using namespace Xbyak;
3030

31-
enum f8_type { none, f8e4m3, f8e5m2 };
31+
enum f8_type : uint8_t { none, f8e4m3, f8e5m2 };
3232

3333
template <typename src_t, typename dst_t>
3434
f8_type get_f8_type() {

src/plugins/intel_cpu/src/nodes/eltwise.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1562,7 +1562,7 @@ void Eltwise::initSupportedPrimitiveDescriptors() {
15621562
}
15631563
}
15641564

1565-
enum LayoutType { Planar, ChannelsFirst, Blocked };
1565+
enum LayoutType : uint8_t { Planar, ChannelsFirst, Blocked };
15661566

15671567
auto initDesc = [&](LayoutType lt, const bool useEltwiseExecutor = false, const bool useJit = false) -> NodeDesc {
15681568
auto createMemoryDesc =

src/plugins/intel_cpu/src/nodes/executors/x64/subgraph.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ void SubgraphExecutor::segfault_detector() {
131131
__sighandler_t signal_handler = [](int signal) {
132132
std::lock_guard<std::mutex> guard(err_print_lock);
133133
if (auto segfault_detector_emitter = ov::intel_cpu::g_custom_segfault_handler->local()) {
134-
std::cout << segfault_detector_emitter->info() << std::endl;
134+
std::cout << segfault_detector_emitter->info() << '\n';
135135
}
136136
auto tid = parallel_get_thread_num();
137137
OPENVINO_THROW("Segfault was caught by the signal handler in subgraph node execution on thread " +

src/plugins/intel_cpu/src/nodes/mvn.cpp

+13-2
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,18 @@ struct jit_uni_mvn_mean_variance_kernel_f32 : public jit_uni_mvn_mean_variance_k
233233

234234
size_t src_stride = 0;
235235

236-
enum { VECTOR, TAIL8, TAIL4, TAIL2, TAIL1, TAIL8_FILL, TAIL4_FILL, TAIL2_FILL, TAIL1_FILL, LOAD_EMITTERS_NUM };
236+
enum : uint8_t {
237+
VECTOR,
238+
TAIL8,
239+
TAIL4,
240+
TAIL2,
241+
TAIL1,
242+
TAIL8_FILL,
243+
TAIL4_FILL,
244+
TAIL2_FILL,
245+
TAIL1_FILL,
246+
LOAD_EMITTERS_NUM
247+
};
237248
std::unique_ptr<jit_load_emitter> load_emitter[LOAD_EMITTERS_NUM];
238249
std::vector<size_t> load_pool_gpr_idxs;
239250

@@ -1106,7 +1117,7 @@ struct jit_uni_mvn_kernel_f32 : public jit_uni_mvn_kernel, public jit_generator
11061117
Vmm vmm_d_weights = Vmm(0);
11071118
Vmm vmm_d_bias = Vmm(1);
11081119

1109-
enum { VECTOR, TAIL8, TAIL4, TAIL2, TAIL1, EMITTERS_NUM };
1120+
enum : uint8_t { VECTOR, TAIL8, TAIL4, TAIL2, TAIL1, EMITTERS_NUM };
11101121
std::unique_ptr<jit_load_emitter> load_emitter[EMITTERS_NUM];
11111122
std::unique_ptr<jit_store_emitter> store_emitter[EMITTERS_NUM];
11121123
std::vector<size_t> store_pool_gpr_idxs;

src/plugins/intel_cpu/src/nodes/subgraph.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ void Subgraph::initSupportedPrimitiveDescriptors() {
223223
}
224224
#endif
225225

226-
enum LayoutType { Planar, ChannelsFirst, Blocked };
226+
enum LayoutType : uint8_t { Planar, ChannelsFirst, Blocked };
227227
auto initDesc = [&](LayoutType lt) -> NodeDesc {
228228
auto createMemoryDesc =
229229
[lt](const Shape& shape, ov::element::Type prc, size_t offset) -> std::shared_ptr<CpuBlockedMemoryDesc> {

src/plugins/intel_cpu/src/utils/blob_dump.cpp

+11-11
Original file line numberDiff line numberDiff line change
@@ -175,79 +175,79 @@ void BlobDumper::dumpAsTxt(std::ostream& stream) const {
175175
stream << d << " ";
176176
}
177177
stream << "(" << data_size << ")"
178-
<< " by address 0x" << std::hex << memory->getDataAs<const int64_t>() << std::dec << std::endl;
178+
<< " by address 0x" << std::hex << memory->getDataAs<const int64_t>() << std::dec << '\n';
179179

180180
const void* ptr = memory->getData();
181181

182182
switch (desc.getPrecision()) {
183183
case ov::element::f32: {
184184
auto* blob_ptr = reinterpret_cast<const float*>(ptr);
185185
for (size_t i = 0; i < data_size; i++) {
186-
stream << blob_ptr[desc.getElementOffset(i)] << std::endl;
186+
stream << blob_ptr[desc.getElementOffset(i)] << '\n';
187187
}
188188
break;
189189
}
190190
case ov::element::i32: {
191191
auto* blob_ptr = reinterpret_cast<const int32_t*>(ptr);
192192
for (size_t i = 0; i < data_size; i++) {
193-
stream << blob_ptr[desc.getElementOffset(i)] << std::endl;
193+
stream << blob_ptr[desc.getElementOffset(i)] << '\n';
194194
}
195195
break;
196196
}
197197
case ov::element::bf16: {
198198
auto* blob_ptr = reinterpret_cast<const bfloat16_t*>(ptr);
199199
for (size_t i = 0; i < data_size; i++) {
200200
float fn = static_cast<float>(blob_ptr[desc.getElementOffset(i)]);
201-
stream << fn << std::endl;
201+
stream << fn << '\n';
202202
}
203203
break;
204204
}
205205
case ov::element::f16: {
206206
auto* blob_ptr = reinterpret_cast<const float16*>(ptr);
207207
for (size_t i = 0; i < data_size; i++) {
208-
stream << blob_ptr[desc.getElementOffset(i)] << std::endl;
208+
stream << blob_ptr[desc.getElementOffset(i)] << '\n';
209209
}
210210
break;
211211
}
212212
case ov::element::i8: {
213213
auto* blob_ptr = reinterpret_cast<const int8_t*>(ptr);
214214
for (size_t i = 0; i < data_size; i++) {
215-
stream << static_cast<int>(blob_ptr[desc.getElementOffset(i)]) << std::endl;
215+
stream << static_cast<int>(blob_ptr[desc.getElementOffset(i)]) << '\n';
216216
}
217217
break;
218218
}
219219
case ov::element::u8: {
220220
auto* blob_ptr = reinterpret_cast<const uint8_t*>(ptr);
221221
for (size_t i = 0; i < data_size; i++) {
222-
stream << static_cast<int>(blob_ptr[desc.getElementOffset(i)]) << std::endl;
222+
stream << static_cast<int>(blob_ptr[desc.getElementOffset(i)]) << '\n';
223223
}
224224
break;
225225
}
226226
case ov::element::i64: {
227227
auto* blob_ptr = reinterpret_cast<const int64_t*>(ptr);
228228
for (size_t i = 0; i < data_size; i++) {
229-
stream << blob_ptr[desc.getElementOffset(i)] << std::endl;
229+
stream << blob_ptr[desc.getElementOffset(i)] << '\n';
230230
}
231231
break;
232232
}
233233
case ov::element::u32: {
234234
auto* blob_ptr = reinterpret_cast<const uint32_t*>(ptr);
235235
for (size_t i = 0; i < data_size; i++) {
236-
stream << blob_ptr[desc.getElementOffset(i)] << std::endl;
236+
stream << blob_ptr[desc.getElementOffset(i)] << '\n';
237237
}
238238
break;
239239
}
240240
case ov::element::u16: {
241241
auto* blob_ptr = reinterpret_cast<const uint16_t*>(ptr);
242242
for (size_t i = 0; i < data_size; i++) {
243-
stream << blob_ptr[desc.getElementOffset(i)] << std::endl;
243+
stream << blob_ptr[desc.getElementOffset(i)] << '\n';
244244
}
245245
break;
246246
}
247247
case ov::element::i16: {
248248
auto* blob_ptr = reinterpret_cast<const int16_t*>(ptr);
249249
for (size_t i = 0; i < data_size; i++) {
250-
stream << blob_ptr[desc.getElementOffset(i)] << std::endl;
250+
stream << blob_ptr[desc.getElementOffset(i)] << '\n';
251251
}
252252
break;
253253
}

src/plugins/intel_cpu/src/utils/debug_capabilities.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ void DebugLogEnabled::break_at(const std::string& log) {
107107
static const char* p_brk = std::getenv("OV_CPU_DEBUG_LOG_BRK");
108108
if (p_brk && log.find(p_brk) != std::string::npos) {
109109
std::cout << "[ DEBUG ] "
110-
<< " Debug log breakpoint hit" << std::endl;
110+
<< " Debug log breakpoint hit" << '\n';
111111
# if defined(_MSC_VER)
112112
__debugbreak();
113113
# elif defined(__APPLE__) || defined(OPENVINO_ARCH_ARM) || defined(OPENVINO_ARCH_ARM64) || \
@@ -406,11 +406,11 @@ std::ostream& operator<<(std::ostream& os, const Shape& shape) {
406406

407407
// Print complex data structures in a textualized form to the console is an efficient way to investigate them
408408
std::ostream& operator<<(std::ostream& os, const Graph& g) {
409-
os << "ov::intel_cpu::Graph " << g.GetName() << " {" << std::endl;
409+
os << "ov::intel_cpu::Graph " << g.GetName() << " {" << '\n';
410410
for (auto& graphNode : g.GetNodes()) {
411-
std::cout << *graphNode << std::endl;
411+
std::cout << *graphNode << '\n';
412412
}
413-
os << "};" << std::endl;
413+
os << "};" << '\n';
414414
return os;
415415
}
416416

@@ -556,13 +556,13 @@ std::ostream& operator<<(std::ostream& os, const PrintableModel& model) {
556556

557557
os << ") \t attrs:";
558558
op->visit_attributes(osvis);
559-
os << std::endl;
559+
os << '\n';
560560

561561
// recursively output subgraphs
562562
if (auto msubgraph = ov::as_type_ptr<op::util::MultiSubGraphOp>(op)) {
563563
auto cnt = msubgraph->get_internal_subgraphs_size();
564564
for (size_t i = 0; i < cnt; i++) {
565-
os << "\t\t MultiSubGraphOp " << tag << msubgraph->get_friendly_name() << "[" << i << "]" << std::endl;
565+
os << "\t\t MultiSubGraphOp " << tag << msubgraph->get_friendly_name() << "[" << i << "]" << '\n';
566566
os << PrintableModel(*msubgraph->get_function(i).get(), tag, prefix + "\t\t");
567567
}
568568
}

src/plugins/intel_cpu/src/utils/debug_capabilities.h

+7-7
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ static inline std::ostream& _write_all_to_stream(std::ostream& os, const T& arg,
169169
if (DEBUG_ENABLE_NAME) { \
170170
::std::stringstream ss___; \
171171
ov::intel_cpu::_write_all_to_stream(ss___, prefix, DEBUG_ENABLE_NAME.get_tag(), " ", __VA_ARGS__); \
172-
ostream << ss___.str() << std::endl; \
172+
ostream << ss___.str() << '\n'; \
173173
DEBUG_ENABLE_NAME.break_at(ss___.str()); \
174174
} \
175175
} while (0)
@@ -226,23 +226,23 @@ struct EnforceInferPrcDebug {
226226
~EnforceInferPrcDebug() {
227227
if (pattern_verbose) {
228228
if (str_pos_pattern)
229-
std::cout << "OV_CPU_INFER_PRC_POS_PATTERN=\"" << str_pos_pattern << "\"" << std::endl;
229+
std::cout << "OV_CPU_INFER_PRC_POS_PATTERN=\"" << str_pos_pattern << "\"" << '\n';
230230
if (str_neg_pattern)
231-
std::cout << "OV_CPU_INFER_PRC_NEG_PATTERN=\"" << str_neg_pattern << "\"" << std::endl;
231+
std::cout << "OV_CPU_INFER_PRC_NEG_PATTERN=\"" << str_neg_pattern << "\"" << '\n';
232232
std::cout << "infer precision enforced Types: ";
233233
size_t total_cnt = 0;
234234
for (auto& ent : all_enabled_nodes) {
235235
std::cout << ent.first << ",";
236236
total_cnt += ent.second.size();
237237
}
238-
std::cout << " total number of nodes: " << total_cnt << std::endl;
238+
std::cout << " total number of nodes: " << total_cnt << '\n';
239239
for (auto& ent : all_enabled_nodes) {
240-
std::cout << ent.first << " : " << std::endl;
240+
std::cout << ent.first << " : " << '\n';
241241
for (auto& name : ent.second) {
242-
std::cout << "\t" << name << std::endl;
242+
std::cout << "\t" << name << '\n';
243243
}
244244
}
245-
std::cout << std::endl;
245+
std::cout << '\n';
246246
}
247247
}
248248

src/plugins/intel_cpu/src/utils/node_dumper.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ void dumpInputBlobs(const NodePtr& node, const DebugCapsConfig& config, int coun
153153

154154
std::string dump_file = createDumpFilePath(config.blobDumpDir, file_name, node->getExecIndex());
155155

156-
std::cout << "Dump inputs: " << dump_file << std::endl;
156+
std::cout << "Dump inputs: " << dump_file << '\n';
157157

158158
auto& desc = prEdge->getMemory().getDesc();
159159
if (desc.getPrecision() == ov::element::u1) {
@@ -190,7 +190,7 @@ void dumpOutputBlobs(const NodePtr& node, const DebugCapsConfig& config, int cou
190190

191191
std::string dump_file = createDumpFilePath(config.blobDumpDir, file_name, node->getExecIndex());
192192

193-
std::cout << "Dump outputs: " << dump_file << std::endl;
193+
std::cout << "Dump outputs: " << dump_file << '\n';
194194

195195
auto& desc = childEdge->getMemory().getDesc();
196196
if (desc.getPrecision() == ov::element::u1) {

0 commit comments

Comments
 (0)