Skip to content

Commit

Permalink
Use Clang-Tidy 17 in GitHub CI (AMReX-Codes#3845)
Browse files Browse the repository at this point in the history
  • Loading branch information
WeiqunZhang authored Mar 27, 2024
1 parent 82008f8 commit 21a7a66
Show file tree
Hide file tree
Showing 77 changed files with 366 additions and 346 deletions.
3 changes: 3 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Checks: >
clang-diagnostic-*,
cppcoreguidelines-*,
-cppcoreguidelines-avoid-c-arrays,
-cppcoreguidelines-avoid-do-while,
-cppcoreguidelines-avoid-magic-numbers,
-cppcoreguidelines-avoid-non-const-global-variables,
-cppcoreguidelines-init-variables,
Expand All @@ -24,6 +25,7 @@ Checks: >
google-global-names-in-headers,
misc-*,
-misc-const-correctness,
-misc-include-cleaner,
-misc-non-private-member-variables-in-classes,
-misc-no-recursion,
modernize-*,
Expand All @@ -34,6 +36,7 @@ Checks: >
performance-*,
portability-*,
readability-*,
-readability-avoid-unconditional-preprocessor-if,
-readability-else-after-return,
-readability-function-cognitive-complexity,
-readability-function-size,
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/dependencies/dependencies_clang-tidy-apt-llvm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

set -eu -o pipefail

# `man apt.conf`:
# Number of retries to perform. If this is non-zero APT will retry
# failed files the given number of times.
echo 'Acquire::Retries "3";' | sudo tee /etc/apt/apt.conf.d/80-retries

if [[ ! -f /etc/apt/trusted.gpg.d/apt.llvm.org.asc ]]; then
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
fi

source /etc/os-release # set UBUNTU_CODENAME

sudo add-apt-repository "deb http://apt.llvm.org/${UBUNTU_CODENAME}/ llvm-toolchain-${UBUNTU_CODENAME} main"
sudo add-apt-repository "deb http://apt.llvm.org/${UBUNTU_CODENAME}/ llvm-toolchain-${UBUNTU_CODENAME}-$1 main"

sudo apt-get update

sudo apt-get install -y --no-install-recommends \
clang-tidy-$1 libomp-$1-dev
52 changes: 26 additions & 26 deletions .github/workflows/gcc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Dependencies
run: |
.github/workflows/dependencies/dependencies_gcc.sh 8
.github/workflows/dependencies/dependencies_clang-tidy.sh 12
.github/workflows/dependencies/dependencies_clang-tidy-apt-llvm.sh 17
.github/workflows/dependencies/dependencies_ccache.sh
- name: Set Up Cache
uses: actions/cache@v4
Expand Down Expand Up @@ -56,7 +56,7 @@ jobs:
${{github.workspace}}/Tools/C_scripts/mmclt.py --input ${{github.workspace}}/ccache.log.txt
make -j4 -k -f clang-tidy-ccache-misses.mak \
CLANG_TIDY=clang-tidy-12 \
CLANG_TIDY=clang-tidy-17 \
CLANG_TIDY_ARGS="--config-file=${{github.workspace}}/.clang-tidy --warnings-as-errors=*"
export PATH=/tmp/my-amrex/bin:$PATH
Expand All @@ -76,7 +76,7 @@ jobs:
- name: Dependencies
run: |
.github/workflows/dependencies/dependencies.sh
.github/workflows/dependencies/dependencies_clang-tidy.sh 12
.github/workflows/dependencies/dependencies_clang-tidy-apt-llvm.sh 17
.github/workflows/dependencies/dependencies_ccache.sh
- name: Set Up Cache
uses: actions/cache@v4
Expand Down Expand Up @@ -108,7 +108,7 @@ jobs:
${{github.workspace}}/Tools/C_scripts/mmclt.py --input ${{github.workspace}}/ccache.log.txt
make -j4 -k -f clang-tidy-ccache-misses.mak \
CLANG_TIDY=clang-tidy-12 \
CLANG_TIDY=clang-tidy-17 \
CLANG_TIDY_ARGS="--config-file=${{github.workspace}}/.clang-tidy --warnings-as-errors=*"
ctest --test-dir build --output-on-failure
Expand All @@ -124,7 +124,7 @@ jobs:
- name: Dependencies
run: |
.github/workflows/dependencies/dependencies.sh
.github/workflows/dependencies/dependencies_clang-tidy.sh 12
.github/workflows/dependencies/dependencies_clang-tidy-apt-llvm.sh 17
.github/workflows/dependencies/dependencies_ccache.sh
- name: Set Up Cache
uses: actions/cache@v4
Expand Down Expand Up @@ -156,7 +156,7 @@ jobs:
${{github.workspace}}/Tools/C_scripts/mmclt.py --input ${{github.workspace}}/ccache.log.txt
make -j4 -k -f clang-tidy-ccache-misses.mak \
CLANG_TIDY=clang-tidy-12 \
CLANG_TIDY=clang-tidy-17 \
CLANG_TIDY_ARGS="--config-file=${{github.workspace}}/.clang-tidy --warnings-as-errors=*"
ctest --test-dir build --output-on-failure
Expand All @@ -172,7 +172,7 @@ jobs:
- name: Dependencies
run: |
.github/workflows/dependencies/dependencies.sh
.github/workflows/dependencies/dependencies_clang-tidy.sh 12
.github/workflows/dependencies/dependencies_clang-tidy-apt-llvm.sh 17
.github/workflows/dependencies/dependencies_ccache.sh
- name: Set Up Cache
uses: actions/cache@v4
Expand Down Expand Up @@ -205,7 +205,7 @@ jobs:
${{github.workspace}}/Tools/C_scripts/mmclt.py --input ${{github.workspace}}/ccache.log.txt
make -j4 -k -f clang-tidy-ccache-misses.mak \
CLANG_TIDY=clang-tidy-12 \
CLANG_TIDY=clang-tidy-17 \
CLANG_TIDY_ARGS="--config-file=${{github.workspace}}/.clang-tidy --warnings-as-errors=*"
ctest --test-dir build --output-on-failure
Expand All @@ -222,7 +222,7 @@ jobs:
- name: Dependencies
run: |
.github/workflows/dependencies/dependencies_gcc.sh 10
.github/workflows/dependencies/dependencies_clang-tidy.sh 12
.github/workflows/dependencies/dependencies_clang-tidy-apt-llvm.sh 17
.github/workflows/dependencies/dependencies_ccache.sh
- name: Set Up Cache
uses: actions/cache@v4
Expand Down Expand Up @@ -264,7 +264,7 @@ jobs:
# Let's not use clang-tidy for this test because it wants to use C++20.
# ${{github.workspace}}/Tools/C_scripts/mmclt.py --input ${{github.workspace}}/ccache.log.txt
# make -j4 -k -f clang-tidy-ccache-misses.mak \
# CLANG_TIDY=clang-tidy-12 \
# CLANG_TIDY=clang-tidy-17 \
# CLANG_TIDY_ARGS="--config-file=${{github.workspace}}/.clang-tidy --warnings-as-errors=*"
ctest --output-on-failure
Expand All @@ -281,7 +281,7 @@ jobs:
- name: Dependencies
run: |
.github/workflows/dependencies/dependencies_gcc.sh 8
.github/workflows/dependencies/dependencies_clang-tidy.sh 12
.github/workflows/dependencies/dependencies_clang-tidy-apt-llvm.sh 17
.github/workflows/dependencies/dependencies_ccache.sh
- name: Set Up Cache
uses: actions/cache@v4
Expand Down Expand Up @@ -321,7 +321,7 @@ jobs:
${{github.workspace}}/Tools/C_scripts/mmclt.py --input ${{github.workspace}}/ccache.log.txt
make -j4 -k -f clang-tidy-ccache-misses.mak \
CLANG_TIDY=clang-tidy-12 \
CLANG_TIDY=clang-tidy-17 \
CLANG_TIDY_ARGS="--config-file=${{github.workspace}}/.clang-tidy --warnings-as-errors=*"
ctest --output-on-failure
Expand All @@ -338,7 +338,7 @@ jobs:
- name: Dependencies
run: |
.github/workflows/dependencies/dependencies_gcc.sh 12
.github/workflows/dependencies/dependencies_clang-tidy.sh 14
.github/workflows/dependencies/dependencies_clang-tidy-apt-llvm.sh 17
.github/workflows/dependencies/dependencies_ccache.sh
- name: Set Up Cache
uses: actions/cache@v4
Expand Down Expand Up @@ -385,7 +385,7 @@ jobs:
${{github.workspace}}/Tools/C_scripts/mmclt.py --input ${{github.workspace}}/ccache.log.txt
make -j4 -k -f clang-tidy-ccache-misses.mak \
CLANG_TIDY=clang-tidy-14 \
CLANG_TIDY=clang-tidy-17 \
CLANG_TIDY_ARGS="--config-file=${{github.workspace}}/.clang-tidy --warnings-as-errors=*"
ctest --output-on-failure
Expand All @@ -402,7 +402,7 @@ jobs:
- name: Dependencies
run: |
.github/workflows/dependencies/dependencies.sh
.github/workflows/dependencies/dependencies_clang-tidy.sh 12
.github/workflows/dependencies/dependencies_clang-tidy-apt-llvm.sh 17
.github/workflows/dependencies/dependencies_ccache.sh
- name: Set Up Cache
uses: actions/cache@v4
Expand All @@ -427,7 +427,7 @@ jobs:
${{github.workspace}}/Tools/C_scripts/mmclt.py --input ${{github.workspace}}/ccache.log.txt
make -j4 -k -f clang-tidy-ccache-misses.mak \
CLANG_TIDY=clang-tidy-12 \
CLANG_TIDY=clang-tidy-17 \
CLANG_TIDY_ARGS="--config-file=${{github.workspace}}/.clang-tidy --warnings-as-errors=*"
ccache -s
Expand All @@ -442,7 +442,7 @@ jobs:
- name: Dependencies
run: |
.github/workflows/dependencies/dependencies.sh
.github/workflows/dependencies/dependencies_clang-tidy.sh 15
.github/workflows/dependencies/dependencies_clang-tidy-apt-llvm.sh 17
.github/workflows/dependencies/dependencies_ccache.sh
- name: Set Up Cache
uses: actions/cache@v4
Expand All @@ -467,7 +467,7 @@ jobs:
${{github.workspace}}/Tools/C_scripts/mmclt.py --input ${{github.workspace}}/ccache.log.txt
make -j4 -k -f clang-tidy-ccache-misses.mak \
CLANG_TIDY=clang-tidy-15 \
CLANG_TIDY=clang-tidy-17 \
CLANG_TIDY_ARGS="--config-file=${{github.workspace}}/.clang-tidy --warnings-as-errors=*"
ccache -s
Expand All @@ -482,7 +482,7 @@ jobs:
- name: Dependencies
run: |
.github/workflows/dependencies/dependencies.sh
.github/workflows/dependencies/dependencies_clang-tidy.sh 12
.github/workflows/dependencies/dependencies_clang-tidy-apt-llvm.sh 17
.github/workflows/dependencies/dependencies_ccache.sh
- name: Set Up Cache
uses: actions/cache@v4
Expand All @@ -507,7 +507,7 @@ jobs:
${{github.workspace}}/Tools/C_scripts/mmclt.py --input ${{github.workspace}}/ccache.log.txt
make -j4 -k -f clang-tidy-ccache-misses.mak \
CLANG_TIDY=clang-tidy-12 \
CLANG_TIDY=clang-tidy-17 \
CLANG_TIDY_ARGS="--config-file=${{github.workspace}}/.clang-tidy --warnings-as-errors=*"
ccache -s
Expand All @@ -522,7 +522,7 @@ jobs:
- name: Dependencies
run: |
.github/workflows/dependencies/dependencies.sh
.github/workflows/dependencies/dependencies_clang-tidy.sh 12
.github/workflows/dependencies/dependencies_clang-tidy-apt-llvm.sh 17
.github/workflows/dependencies/dependencies_ccache.sh
- name: Set Up Cache
uses: actions/cache@v4
Expand All @@ -547,7 +547,7 @@ jobs:
${{github.workspace}}/Tools/C_scripts/mmclt.py --input ${{github.workspace}}/ccache.log.txt
make -j4 -k -f clang-tidy-ccache-misses.mak \
CLANG_TIDY=clang-tidy-12 \
CLANG_TIDY=clang-tidy-17 \
CLANG_TIDY_ARGS="--config-file=${{github.workspace}}/.clang-tidy --warnings-as-errors=*"
ccache -s
Expand All @@ -562,7 +562,7 @@ jobs:
- name: Dependencies
run: |
.github/workflows/dependencies/dependencies.sh
.github/workflows/dependencies/dependencies_clang-tidy.sh 12
.github/workflows/dependencies/dependencies_clang-tidy-apt-llvm.sh 17
.github/workflows/dependencies/dependencies_ccache.sh
- name: Set Up Cache
uses: actions/cache@v4
Expand All @@ -586,7 +586,7 @@ jobs:
${{github.workspace}}/Tools/C_scripts/mmclt.py --input ${{github.workspace}}/ccache.log.txt
make -j4 -k -f clang-tidy-ccache-misses.mak \
CLANG_TIDY=clang-tidy-12 \
CLANG_TIDY=clang-tidy-17 \
CLANG_TIDY_ARGS="--config-file=${{github.workspace}}/.clang-tidy --warnings-as-errors=*"
ccache -s
Expand All @@ -601,7 +601,7 @@ jobs:
- name: Dependencies
run: |
.github/workflows/dependencies/dependencies.sh
.github/workflows/dependencies/dependencies_clang-tidy.sh 12
.github/workflows/dependencies/dependencies_clang-tidy-apt-llvm.sh 17
.github/workflows/dependencies/dependencies_ccache.sh
- name: Set Up Cache
uses: actions/cache@v4
Expand Down Expand Up @@ -631,7 +631,7 @@ jobs:
${{github.workspace}}/Tools/C_scripts/mmclt.py --input ${{github.workspace}}/ccache.log.txt
make -j4 -k -f clang-tidy-ccache-misses.mak \
CLANG_TIDY=clang-tidy-12 \
CLANG_TIDY=clang-tidy-17 \
CLANG_TIDY_ARGS="--config-file=${{github.workspace}}/.clang-tidy --warnings-as-errors=*"
ccache -s
Expand Down
6 changes: 3 additions & 3 deletions Src/Amr/AMReX_Amr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ Amr::initInSitu()
insitu_bridge = new AmrInSituBridge;
if (insitu_bridge->initialize())
{
amrex::ErrorStream() << "Amr::initInSitu : Failed to initialize." << std::endl;
amrex::ErrorStream() << "Amr::initInSitu : Failed to initialize." << '\n';
amrex::Abort();
}
#endif
Expand All @@ -531,7 +531,7 @@ Amr::updateInSitu() // NOLINT(readability-convert-member-functions-to-static)
#if defined(AMREX_USE_SENSEI_INSITU) && !defined(AMREX_NO_SENSEI_AMR_INST)
if (insitu_bridge && insitu_bridge->update(this))
{
amrex::ErrorStream() << "Amr::updateInSitu : Failed to update." << std::endl;
amrex::ErrorStream() << "Amr::updateInSitu : Failed to update." << '\n';
amrex::Abort();
}
#endif
Expand All @@ -545,7 +545,7 @@ Amr::finalizeInSitu()
if (insitu_bridge)
{
if (insitu_bridge->finalize())
amrex::ErrorStream() << "Amr::finalizeInSitu : Failed to finalize." << std::endl;
amrex::ErrorStream() << "Amr::finalizeInSitu : Failed to finalize." << '\n';

delete insitu_bridge;
insitu_bridge = nullptr;
Expand Down
8 changes: 4 additions & 4 deletions Src/Base/AMReX_BLBackTrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ BLBackTrace::handler(int s)
std::ofstream errfile;
errfile.open(errfilename.c_str(), std::ofstream::out | std::ofstream::app);
if (errfile.is_open()) {
errfile << std::endl;
errfile << '\n';
TinyProfiler::PrintCallStack(errfile);
errfile << std::endl;
errfile << '\n';
}
}
#endif
Expand Down Expand Up @@ -356,7 +356,7 @@ BLBTer::BLBTer(const std::string& s, const char* file, int line)
ss0 << "Proc. " << ParallelDescriptor::MyProc()
<< ", Thread " << omp_get_thread_num()
<< ": \"" << s << "\"";
BLBackTrace::bt_stack.push(std::make_pair(ss0.str(), line_file));
BLBackTrace::bt_stack.emplace(ss0.str(), line_file);
}
else {
#pragma omp parallel
Expand All @@ -365,7 +365,7 @@ BLBTer::BLBTer(const std::string& s, const char* file, int line)
ss0 << "Proc. " << ParallelDescriptor::MyProc()
<< ", Master Thread"
<< ": \"" << s << "\"";
BLBackTrace::bt_stack.push(std::make_pair(ss0.str(), line_file));
BLBackTrace::bt_stack.emplace(ss0.str(), line_file);
}
}
#else
Expand Down
20 changes: 10 additions & 10 deletions Src/Base/AMReX_BLProfiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ void BLProfiler::Initialize() {
procName = cProcName;
procNumber = ParallelDescriptor::MyProc();
}
//amrex::AllPrint() << myProc << ":::: " << procName << " len = " << resultLen << std::endl;
//amrex::AllPrint() << myProc << ":::: " << procName << " len = " << resultLen << '\n';

Real t0, t1;
int nTimerTimes(1000);
Expand Down Expand Up @@ -684,7 +684,7 @@ void WriteStats(std::ostream &ios,
<< '\n';
}
ios << std::setfill(' ');
ios << std::endl;
ios << '\n';


#ifdef BL_TRACE_PROFILING
Expand Down Expand Up @@ -755,7 +755,7 @@ void WriteStats(std::ostream &ios,
ios << std::setfill('=') << std::setw(maxlen+4 + 1 * (colWidth+2)) << ""
<< '\n';
ios << std::setfill(' ');
ios << std::endl;
ios << '\n';
}

#endif
Expand Down Expand Up @@ -1341,24 +1341,24 @@ void BLProfiler::WriteFortProfErrors() {
// report any fortran errors. should really check with all procs, just iop for now
if(ParallelDescriptor::IOProcessor()) {
if(BLProfiler::mFortProfs.size() > 0) {
amrex::Print() << "FFFFFFFF -------- FORTRAN PROFILING UNSTOPPED ERRORS" << std::endl;
amrex::Print() << "FFFFFFFF -------- FORTRAN PROFILING UNSTOPPED ERRORS" << '\n';
for(std::map<std::string, BLProfiler *>::iterator it = BLProfiler::mFortProfs.begin();
it != BLProfiler::mFortProfs.end(); ++it)
{
amrex::Print() << "FFFF function not stopped: fname ptr = " << it->first
<< " ---->" << it->second << "<----" << std::endl;
<< " ---->" << it->second << "<----" << '\n';
}
amrex::Print() << "FFFFFFFF -------- END FORTRAN PROFILING UNSTOPPED ERRORS" << std::endl;
amrex::Print() << "FFFFFFFF -------- END FORTRAN PROFILING UNSTOPPED ERRORS" << '\n';
}
if(BLProfiler::mFortProfsErrors.size() > 0) {
amrex::Print() << "FFFFFFFF FORTRAN PROFILING ERRORS" << std::endl;
amrex::Print() << "FFFFFFFF FORTRAN PROFILING ERRORS" << '\n';
if(BLProfiler::mFortProfsErrors.size() >= mFortProfMaxErrors) {
amrex::Print() << "FFFFFFFF -------- MAX FORTRAN ERRORS EXCEEDED" << std::endl;
amrex::Print() << "FFFFFFFF -------- MAX FORTRAN ERRORS EXCEEDED" << '\n';
}
for(int i(0); i < BLProfiler::mFortProfsErrors.size(); ++i) {
amrex::Print() << "FFFF " << BLProfiler::mFortProfsErrors[i] << std::endl;
amrex::Print() << "FFFF " << BLProfiler::mFortProfsErrors[i] << '\n';
}
amrex::Print() << "FFFFFFFF -------- END FORTRAN PROFILING ERRORS" << std::endl;
amrex::Print() << "FFFFFFFF -------- END FORTRAN PROFILING ERRORS" << '\n';
}
}
}
Expand Down
Loading

0 comments on commit 21a7a66

Please sign in to comment.