-
Notifications
You must be signed in to change notification settings - Fork 7.1k
add clang-tidy support #19643
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add clang-tidy support #19643
Changes from 3 commits
2cc43a0
2c2fbeb
e253680
e118215
b5dde36
0d996af
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--- | ||
Checks: 'clang-diagnostic-*,clang-analyzer-*,-*,performance-faster-string-find,performance-for-range-copy,' | ||
WarningsAsErrors: '*' | ||
HeaderFilterRegex: '/(?!external)/.*' | ||
AnalyzeTemporaryDtors: false | ||
FormatStyle: none | ||
CheckOptions: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I propose to remove "CheckOptions:". |
||
- key: cert-dcl16-c.NewSuffixes | ||
value: 'L;LL;LU;LLU' | ||
- key: cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic | ||
value: '1' | ||
- key: google-readability-braces-around-statements.ShortStatementLines | ||
value: '1' | ||
- key: google-readability-function-size.StatementThreshold | ||
value: '800' | ||
- key: google-readability-namespace-comments.ShortNamespaceLines | ||
value: '10' | ||
- key: google-readability-namespace-comments.SpacesBeforeComments | ||
value: '2' | ||
- key: modernize-loop-convert.MaxCopySize | ||
value: '16' | ||
- key: modernize-loop-convert.MinConfidence | ||
value: reasonable | ||
- key: modernize-loop-convert.NamingStyle | ||
value: CamelCase | ||
- key: modernize-pass-by-value.IncludeStyle | ||
value: llvm | ||
- key: modernize-replace-auto-ptr.IncludeStyle | ||
value: llvm | ||
- key: modernize-use-nullptr.NullMacros | ||
value: 'NULL' | ||
- key: performance-faster-string-find.StringLikeClasses | ||
value: 'std::basic_string' | ||
- key: performance-for-range-copy.AllowedTypes | ||
value: '' | ||
- key: performance-for-range-copy.WarnOnAllAutoCopies | ||
value: '0' | ||
... |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,16 @@ function build_linux() | |
cmake --build . | ||
} | ||
|
||
function build_linux_clang_tidy() | ||
{ | ||
echo "Building clang tidy test on Linux ..." | ||
cd $COCOS2DX_ROOT/build | ||
mkdir -p clang-tidy-build | ||
cd clang-tidy-build | ||
cmake ../.. -DCMAKE_EXPORT_COMPILE_COMMANDS=on | ||
python /usr/local/clang-7.0.0/share/clang/run-clang-tidy.py | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Don't quite understand these codes. And the python script path is hard coded, it may be a problem when CI changes its environment. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I Or we can just copy one and store it in the repo, if you agree. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @minggo About hard-coded path There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @crazyhappygame Great. It works on Fedora Linux too. I didn't know clang-tidy shares top-level directory with its python script. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @crazyhappygame thanks for the explanation. |
||
} | ||
|
||
function build_mac() | ||
{ | ||
NUM_OF_CORES=`getconf _NPROCESSORS_ONLN` | ||
|
@@ -291,6 +301,12 @@ function run_pull_request() | |
build_linux | ||
fi | ||
|
||
# linux_clang_tidy_test | ||
if [ $BUILD_TARGET == 'linux_clang_tidy' ]; then | ||
genernate_binding_codes | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that genernate_binding_codes should be removed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, it is not needed. |
||
build_linux_clang_tidy | ||
fi | ||
|
||
# android | ||
if [ $BUILD_TARGET == 'android_cpp_ndk-build' ]; then | ||
build_android_cpp_ndk-build | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change to yaml multplie line string https://yaml-multiline.info/. In that way we can easily track changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The configuration above is generated by
clang-tidy -header-filter='/(?!external)/.*' -checks='-*,performance-faster-string-find,performance-for-range-copy,' -warnings-as-errors='*' -dump-config
I just found that the above two are not the same. The order matters.
-*
will disable options ahead of it.In the first config,
clang-diagnostic-*,clang-analyzer-*
is disabled.The second config, placing
-*
at the front, will not disableclang-diagnostic-*,clang-analyzer-*
.