forked from openvinotoolkit/openvino
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CPU] Introduce clang-tidy (openvinotoolkit#28040)
For now .clang-tidy file is placed into intel_cpu/src plugin folded, since if we put it into root src folder, this would show clang-tidy warnings in IDEs for every source file of the openvino project. From cmake configuration point of view clang-tidy check is implemented as a generic one. Regarding clang-tidy checks, for now only `performance-*` checks are enabled and fixed. Additionally, the following two checks were enabled, since they are conflicting with the `performance-unnecessary-value-param` check ``` modernize-pass-by-value, cppcoreguidelines-prefer-member-initializer, ``` The idea is to enable the check scopes one by one, since fixing them is quite time consuming. As for pre-commit check, the clang-tidy is enabled in scope of `linux_conditional_compilation` check to avoid an additional build execution. Only x64 arch is covered aarch64 will be enabled next
- Loading branch information
1 parent
4b1f824
commit 08d8755
Showing
407 changed files
with
1,899 additions
and
1,636 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
pr-28380 | ||
pr-28040 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Copyright (C) 2018-2024 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
if(ENABLE_CLANG_TIDY) | ||
set(CLANG_TIDY_REQUIRED_VERSION 15 CACHE STRING "clang-tidy version to use") | ||
set(CLANG_TIDY_FILENAME clang-tidy-${CLANG_TIDY_REQUIRED_VERSION} clang-tidy) | ||
find_host_program(CLANG_TIDY NAMES ${CLANG_TIDY_FILENAME} PATHS ENV PATH) | ||
if(CLANG_TIDY) | ||
execute_process(COMMAND ${CLANG_TIDY} ${CMAKE_CURRENT_SOURCE_DIR} ARGS --version OUTPUT_VARIABLE CLANG_VERSION) | ||
if(NOT CLANG_VERSION) | ||
message(WARNING "Supported clang-tidy version is ${CLANG_TIDY_REQUIRED_VERSION}!") | ||
set(ENABLE_CLANG_TIDY OFF) | ||
else() | ||
string(REGEX REPLACE "[^0-9]+([0-9]+)\\..*" "\\1" CLANG_TIDY_MAJOR_VERSION ${CLANG_VERSION}) | ||
if(NOT CLANG_TIDY_MAJOR_VERSION EQUAL CLANG_TIDY_REQUIRED_VERSION) | ||
message(WARNING "Supported clang-tidy version is ${CLANG_TIDY_REQUIRED_VERSION}! Provided version ${CLANG_TIDY_MAJOR_VERSION}") | ||
set(ENABLE_CLANG_TIDY OFF) | ||
endif() | ||
endif() | ||
else() | ||
message(WARNING "Supported clang-tidy-${CLANG_TIDY_REQUIRED_VERSION} is not found!") | ||
set(ENABLE_CLANG_TIDY OFF) | ||
endif() | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
--- | ||
|
||
### NOTE: | ||
# The 'Checks: >' is a multiline string here. Comment must not be moved into the string. | ||
# | ||
### Scopes to be enabled: | ||
# | ||
# cppcoreguidelines-*, | ||
# google-*, | ||
# readability-*, | ||
# modernize-*, | ||
# bugprone-*, | ||
# misc-*, | ||
# | ||
### Checks that are turned off for a reason: | ||
# | ||
# -cppcoreguidelines-pro-bounds-pointer-arithmetic | ||
# -google-readability-todo. No big reason to enforce | ||
# -modernize-use-trailing-return-type. Just stylistic preference | ||
# -readability-identifier-length. A lot of code use short names for readability, i.e. 'B' for batch | ||
# -readability-uppercase-literal-suffix. | ||
# | ||
### Checks that are turned off but better be enabled later: | ||
# -bugprone-narrowing-conversions | ||
# -bugprone-easily-swappable-parameters | ||
# -bugprone-fold-init-type | ||
# -bugprone-implicit-widening-of-multiplication-result | ||
# -cppcoreguidelines-narrowing-conversions | ||
# -google-readability-braces-around-statements | ||
# -readability-implicit-bool-conversion, | ||
# -readability-magic-numbers, cppcoreguidelines-avoid-magic-numbers | ||
# -readability-function-cognitive-complexity. Reasonable way to enforce splitting complex code into simple functions | ||
# -modernize-concat-nested-namespaces. More compact way when C++17 is available | ||
|
||
Checks: > | ||
-*, | ||
performance-*, | ||
modernize-pass-by-value, | ||
cppcoreguidelines-prefer-member-initializer, | ||
-bugprone-easily-swappable-parameters, | ||
-bugprone-fold-init-type, | ||
-bugprone-implicit-widening-of-multiplication-result, | ||
-bugprone-narrowing-conversions, | ||
-cppcoreguidelines-narrowing-conversions, | ||
-cppcoreguidelines-pro-bounds-pointer-arithmetic, | ||
-google-build-using-namespace, | ||
-google-readability-todo, | ||
-readability-braces-around-statements, | ||
-google-readability-braces-around-statements, | ||
-modernize-use-trailing-return-type, | ||
-readability-identifier-length, | ||
-readability-implicit-bool-conversion, | ||
-readability-magic-numbers, | ||
-cppcoreguidelines-avoid-magic-numbers, | ||
-readability-uppercase-literal-suffix, | ||
-readability-function-cognitive-complexity, | ||
-modernize-concat-nested-namespaces, | ||
# Treat warnings as errors | ||
WarningsAsErrors: '*' | ||
# Use clang-format for applied fixes | ||
FormatStyle: file | ||
HeaderFilterRegex: '' | ||
CheckOptions: | ||
- key: cppcoreguidelines-avoid-do-while.IgnoreMacros | ||
value: true | ||
# matches with corresponding cpplink check | ||
- key: google-readability-namespace-comments.ShortNamespaceLines | ||
value: "10" | ||
# matches with corresponding cpplink check | ||
- key: google-readability-namespace-comments.SpacesBeforeComments | ||
value: "2" | ||
- key: modernize-loop-convert.MinConfidence | ||
value: reasonable | ||
- key: modernize-pass-by-value.IncludeStyle | ||
value: google | ||
### To be considered to enable: | ||
# # Unifies the usage of the statements | ||
# - key: readability-braces-around-statements.ShortStatementLines | ||
# value: "1" | ||
# Reasonable way to enforce splitting complex code into simple functions | ||
# - key: google-readability-function-size.StatementThreshold | ||
# value: "800" | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.