-
Notifications
You must be signed in to change notification settings - Fork 25
Add clang tidy CI test & tools to use it locally #1303
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
Merged
AlexanderSinn
merged 38 commits into
Hi-PACE:development
from
lucafedeli88:add_tools_to_use_clang_tidy
Dec 9, 2025
Merged
Changes from 3 commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
1eb5a10
make FFTPoissonSolver's destructor = default
lucafedeli88 4cad3e6
add tool to run clang-tidy locally
lucafedeli88 8eb630a
Merge remote-tracking branch 'origin/development' into add_tools_to_u…
lucafedeli88 18077c4
Update tools/runClangTidy.sh
lucafedeli88 63e426d
Merge remote-tracking branch 'upstream/development' into add_tools_to…
lucafedeli88 5e015c9
Merge remote-tracking branch 'origin/development' into add_tools_to_u…
lucafedeli88 a44e221
add clang-tidy in CI
lucafedeli88 8d81667
add missing dependency
lucafedeli88 77e124a
update runClangTidy script
lucafedeli88 a169d14
add missing dependency
lucafedeli88 cc675d9
add missing dependency
lucafedeli88 8674d76
silence two warnings
lucafedeli88 99e0b9a
disable vectorization warnings in CI
lucafedeli88 949465f
disable vectorization errors also for the linking step
lucafedeli88 dafc962
fix env. variables bug
lucafedeli88 6238b6e
add clearer messages and exit with code 1 if clang-tidy finds issues
lucafedeli88 e8b0780
check file size
lucafedeli88 0d5d04d
add checks of the cert-* family
lucafedeli88 8555a3d
fix bug
lucafedeli88 5826dee
only keep cert-err58-cpp for the moment
lucafedeli88 542090f
remove cert checks and enable most checks of the bugprone family
lucafedeli88 884c2b5
update rules
lucafedeli88 b05306f
implement fixes
lucafedeli88 f308ac3
fix bug introduced in previous commit
lucafedeli88 e769987
fix bug introduced in previous commit
lucafedeli88 cf3857b
Merge remote-tracking branch 'origin/development' into add_tools_to_u…
lucafedeli88 a5b63ae
remove unused phys_const from 2 files
lucafedeli88 ccda6b6
fix bug
lucafedeli88 2ff0b94
fix bug
lucafedeli88 fccf114
address issue found with clang-tidy
lucafedeli88 0af034b
change how the has_value check is done
lucafedeli88 b4d7e2f
Merge remote-tracking branch 'origin/development' into add_tools_to_u…
lucafedeli88 5ff5a6b
Update .github/workflows/clangtidy.yml
lucafedeli88 f88aac3
revert changes in MultiBuffer.cpp
lucafedeli88 3d70f1f
revert last change to .clang-tidy
lucafedeli88 07639ad
delete check option
lucafedeli88 e2db756
use NOLINT
lucafedeli88 929df68
add comment to clang-tidy configuration file
lucafedeli88 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,6 @@ | ||
| Checks: ' | ||
| -*, | ||
| cppcoreguidelines-avoid-goto | ||
| ' | ||
|
|
||
| HeaderFilterRegex: 'src[a-z_A-Z0-9\/]+\.H$' |
This file contains hidden or 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,107 @@ | ||
| #! /usr/bin/env bash | ||
|
|
||
| # Copyright 2025 | ||
| # | ||
| # This file is part of HiPACE++. | ||
| # | ||
| # Authors: Luca Fedeli | ||
| # License: BSD-3-Clause-LBNL | ||
|
|
||
| # This script is a developer's tool to perform | ||
| # checks with clang-tidy. | ||
| # | ||
| # Note: this script is only tested on Linux | ||
|
|
||
| echo "=============================================" | ||
| echo | ||
| echo "This script is a developer's tool to perform" | ||
| echo "checks with clang-tidy." | ||
| echo "_____________________________________________" | ||
|
|
||
| # Check source dir | ||
| REPO_DIR=$(cd $(dirname ${BASH_SOURCE})/../ && pwd) | ||
| echo | ||
| echo "Your current source directory is: ${REPO_DIR}" | ||
| echo "_____________________________________________" | ||
|
|
||
| # Set number of jobs to use for compilation | ||
| PARALLEL="${WARPX_TOOLS_LINTER_PARALLEL:-4}" | ||
| echo | ||
| echo "${PARALLEL} jobs will be used for compilation." | ||
| echo "This can be overridden by setting the environment" | ||
| echo "variable HIPACE_TOOLS_LINTER_PARALLEL, e.g.: " | ||
| echo | ||
| echo "$ export HIPACE_TOOLS_LINTER_PARALLEL=8" | ||
| echo "$ ./tools/runClangTidy.sh" | ||
| echo "_____________________________________________" | ||
|
|
||
| # Check clang version | ||
| export CC="${CLANG:-"clang"}" | ||
| export CXX="${CLANGXX:-"clang++"}" | ||
| export CTIDY="${CLANGTIDY:-"clang-tidy"}" | ||
| echo | ||
| echo "The following versions of the clang compiler and" | ||
| echo "of the clang-tidy linter will be used:" | ||
| echo | ||
| echo "clang version:" | ||
| which ${CC} | ||
| ${CC} --version | ||
| echo | ||
| echo "clang++ version:" | ||
| which ${CXX} | ||
| ${CXX} --version | ||
| echo | ||
| echo "clang-tidy version:" | ||
| which ${CTIDY} | ||
| ${CTIDY} --version | ||
| echo | ||
| echo "This can be overridden by setting the environment" | ||
| echo "variables CLANG, CLANGXX, and CLANGTIDY e.g.: " | ||
| echo "$ export CLANG=clang-20" | ||
| echo "$ export CLANGXX=clang++-20" | ||
| echo "$ export CTIDCLANGTIDYY=clang-tidy-20" | ||
| echo "$ ./tools/runClangTidy.sh" | ||
| echo "_____________________________________________" | ||
|
|
||
| # Prepare clang-tidy wrapper | ||
| echo | ||
| echo "Prepare clang-tidy wrapper" | ||
| echo "The following wrapper ensures that only source files" | ||
| echo "in hipace/src/* are actually processed by clang-tidy" | ||
| echo | ||
| cat > ${REPO_DIR}/clang_tidy_wrapper << EOF | ||
| #!/bin/bash | ||
| REGEX="[a-z_A-Z0-9\/]*hipace\/src[a-z_A-Z0-9\/]+.cpp" | ||
| if [[ \$4 =~ \$REGEX ]];then | ||
| ${CTIDY} \$@ | ||
| fi | ||
| EOF | ||
| chmod +x ${REPO_DIR}/clang_tidy_wrapper | ||
| echo "clang_tidy_wrapper: " | ||
| cat ${REPO_DIR}/clang_tidy_wrapper | ||
| echo "_____________________________________________" | ||
|
|
||
| # Compile HiPACE++ using clang-tidy | ||
| echo | ||
| echo "*******************************************" | ||
| echo "* Compile HiPACE++ using clang-tidy *" | ||
| echo "* Please ensure that all the dependencies *" | ||
| echo "* required to compile HiPACE++ are met *" | ||
| echo "*******************************************" | ||
| echo | ||
|
|
||
| rm -rf ${REPO_DIR}/build_clang_tidy | ||
|
|
||
| cmake -S ${REPO_DIR} -B ${REPO_DIR}/build_clang_tidy \ | ||
| -DCMAKE_CXX_CLANG_TIDY="${REPO_DIR}/clang_tidy_wrapper;--system-headers=0;--config-file=${REPO_DIR}/.clang-tidy" \ | ||
| -DCMAKE_VERBOSE_MAKEFILE=ON \ | ||
| -DHiPACE_MPI=ON \ | ||
| -DHiPACE_COMPUTE=OMP \ | ||
| -DHiPACE_OPENPMD=ON \ | ||
| -DHiPACE_PRECISION=SINGLE | ||
|
|
||
| cmake --build ${REPO_DIR}/build_clang_tidy -j ${PARALLEL} 2> ${REPO_DIR}/build_clang_tidy/clang-tidy.log | ||
|
|
||
| cat ${REPO_DIR}/build_clang_tidy/clang-tidy.log | ||
| echo | ||
| echo "=============================================" | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.