Skip to content

Commit efb4f83

Browse files
Clang Tidy and Sanitizer: Use clang-19 on Ubuntu 24.04 (#1783)
* clang tidy/sanitizer: Ubuntu 24.04, clang-19 * ok, back to clanag-14 * Upgrade spack to 1.0.1 for tidy runs * ??? * Some fixes * sudo: preserve env * Switch back to clang-19 * Specify C and Cxx providers * hmmm * aaaahhhh * Huh? * hehe yes * Use spack-default cache * Remove gcc specification does not work * Fix prefixes, fix gcc * fixes for runs * clang-tidy gespräche * further clang-tidy fixes
1 parent 1b94829 commit efb4f83

File tree

25 files changed

+233
-121
lines changed

25 files changed

+233
-121
lines changed

.clang-tidy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
# FIXME: all performance-* reports
33
# FIXME: all cert-* reports
44
# FIXME: all bugprone-* reports
5-
Checks: -*,bugprone-*,-bugprone-unhandled-self-assignment,-bugprone-parent-virtual-call,-bugprone-narrowing-conversions,-bugprone-exception-escape,-bugprone-string-literal-with-embedded-nul,cppcoreguidelines-slicing,mpi-*,readability-non-const-parameter,performance-*,modernize-*,-modernize-use-trailing-return-type,-modernize-use-bool-literals,-modernize-avoid-c-arrays,-modernize-use-auto,-modernize-return-braced-init-list,-bugprone-easily-swappable-parameters
5+
Checks: -*,bugprone-*,-bugprone-unhandled-self-assignment,-bugprone-parent-virtual-call,-bugprone-narrowing-conversions,-bugprone-exception-escape,-bugprone-string-literal-with-embedded-nul,cppcoreguidelines-slicing,mpi-*,readability-non-const-parameter,performance-*,-performance-avoid-endl,modernize-*,-modernize-use-trailing-return-type,-modernize-use-bool-literals,-modernize-avoid-c-arrays,-modernize-use-auto,-modernize-return-braced-init-list,-bugprone-easily-swappable-parameters,-bugprone-chained-comparison
66
HeaderFilterRegex: '((^(?!\/share\/openPMD\/).*)*include\/openPMD\/.+\.hpp|src\/^(?!binding).+\.cpp$)'

.github/ci/spack-envs/clangtidy_nopy_ompi_h5_ad2/spack.yaml

Lines changed: 45 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,54 +14,78 @@ spack:
1414
packages:
1515
adios2:
1616
variants: ~zfp ~sz ~png ~dataman ~python ~fortran ~ssc ~shared ~bzip2 ~mgard
17+
1718
c-blosc2:
1819
# snappy broken on CMake 4.0
1920
# fixed snappy not yet deployed to a Spack release
2021
variants: ~snappy
22+
2123
cmake:
2224
externals:
23-
- spec: cmake@3.31.5
24-
prefix: /usr
25+
- spec: cmake@3.31.8
26+
prefix: /usr/local
2527
buildable: False
28+
2629
openmpi:
2730
externals:
28-
- spec: openmpi@4.1.2
31+
- spec: openmpi@4.1.6
2932
prefix: /usr
3033
buildable: False
34+
3135
perl:
3236
externals:
33-
- spec: perl@5.34.0
37+
- spec: perl@5.38.2
3438
prefix: /usr
3539
buildable: False
40+
3641
python:
3742
externals:
38-
- spec: python@3.10.12
43+
- spec: python@3.12.3
3944
prefix: /usr
4045
buildable: False
46+
4147
all:
4248
target: [x86_64]
4349
variants: ~fortran
4450
providers:
4551
mpi: [openmpi]
46-
compiler: [clang@14.0.0]
52+
cc: [llvm]
53+
cxx: [llvm]
54+
fortran: [gcc]
55+
56+
llvm:
57+
externals:
58+
- spec: llvm@19.1.1
59+
prefix: /usr
60+
paths:
61+
cc: /usr/bin/clang-19
62+
cxx: /usr/bin/clang++-19
63+
modules: []
64+
environment: {}
65+
extra_rpaths: []
66+
buildable: False
67+
68+
gcc:
69+
externals:
70+
- spec: gcc@13.3.0
71+
prefix: /usr
72+
paths:
73+
cc: /usr/bin/gcc
74+
cxx: /usr/bin/g++
75+
fortran: /usr/bin/gfortran
76+
modules: []
77+
environment: {}
78+
extra_rpaths: []
79+
buildable: False
4780

48-
compilers:
49-
- compiler:
50-
environment: {}
51-
extra_rpaths: []
52-
flags: {}
53-
modules: []
54-
operating_system: ubuntu22.04
55-
paths:
56-
cc: /usr/bin/clang-14
57-
cxx: /usr/bin/clang++-14
58-
f77: /usr/bin/gfortran
59-
fc: /usr/bin/gfortran
60-
spec: clang@14.0.0
61-
target: x86_64
81+
gcc-runtime:
82+
buildable: false
83+
externals:
84+
- spec: gcc-runtime@13.3.0
85+
prefix: /usr
6286

6387
config:
6488
build_jobs: 2
6589

6690
mirrors:
67-
E4S: https://cache.e4s.io
91+
spack-public: https://mirror.spack.io

.github/workflows/dependencies/install_spack

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
set -eu -o pipefail
55

6-
spack_ver="0.22.3"
6+
spack_ver="${SPACK_VER:-0.22.3}"
77

88
cd /opt
99
if [[ -d spack && ! -f spack_${spack_ver} ]]

.github/workflows/tooling.yml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,21 @@ concurrency:
77
cancel-in-progress: true
88

99
jobs:
10-
clangtidy14_nopy_ompi_h5_ad2:
10+
clangtidy19_nopy_ompi_h5_ad2:
1111
name: clang-tidy w/o py
12-
runs-on: ubuntu-22.04
12+
runs-on: ubuntu-24.04
1313
if: github.event.pull_request.draft == false
1414
steps:
1515
- uses: actions/checkout@v4
1616
- name: Spack Cache
1717
uses: actions/cache@v3
18-
with: {path: /opt/spack, key: clangtidy14_nopy_ompi_h5_ad2 }
18+
with: {path: /opt/spack, key: clangtidy19_nopy_ompi_h5_ad2 }
1919
- name: Install
2020
run: |
2121
sudo apt-get update
2222
sudo apt-get install clang clang-tidy gfortran libopenmpi-dev python-is-python3
23-
sudo .github/workflows/dependencies/install_spack
23+
SPACK_VER=1.0.1 sudo -E .github/workflows/dependencies/install_spack
24+
echo "SPACK VERSION: $(spack --version)"
2425
- name: Build
2526
env: {CC: clang, CXX: clang++}
2627
run: |
@@ -36,32 +37,31 @@ jobs:
3637
cat build/clang-tidy.log
3738
if [[ $(wc -m <build/clang-tidy.log) -gt 1 ]]; then exit 1; fi
3839
39-
clangsanitizer14_py38_ompi_h5_ad2:
40+
clangsanitizer19_py38_ompi_h5_ad2:
4041
name: Clang ASAN UBSAN
41-
runs-on: ubuntu-22.04
42+
runs-on: ubuntu-24.04
4243
if: github.event.pull_request.draft == false
4344
steps:
4445
- uses: actions/checkout@v4
4546
- name: Spack Cache
4647
uses: actions/cache@v3
47-
with: {path: /opt/spack, key: clang14_nopy_ompi_h5_ad2 }
48+
with: {path: /opt/spack, key: clang19_nopy_ompi_h5_ad2 }
4849
- name: Install
4950
run: |
5051
sudo apt-get update
51-
sudo apt-get install clang-14 libc++-dev libc++abi-dev python3 gfortran libopenmpi-dev
52-
python3 -m pip install -U pip
53-
python3 -m pip install -U numpy
54-
sudo .github/workflows/dependencies/install_spack
52+
sudo apt-get install clang-19 libc++-dev libc++abi-dev python3 gfortran libopenmpi-dev python3-numpy
53+
SPACK_VER=1.0.1 sudo -E .github/workflows/dependencies/install_spack
54+
echo "SPACK VERSION: $(spack --version)"
5555
- name: Build
56-
env: {CC: mpicc, CXX: mpic++, OMPI_CC: clang-14, OMPI_CXX: clang++-14, CXXFLAGS: -Werror, OPENPMD_HDF5_CHUNKS: none, OPENPMD_TEST_NFILES_MAX: 100}
56+
env: {CC: mpicc, CXX: mpic++, OMPI_CC: clang-19, OMPI_CXX: clang++-19, CXXFLAGS: -Werror, OPENPMD_HDF5_CHUNKS: none, OPENPMD_TEST_NFILES_MAX: 100}
5757
run: |
5858
sudo ln -s "$(which cmake)" /usr/bin/cmake
5959
eval $(spack env activate --sh .github/ci/spack-envs/clangtidy_nopy_ompi_h5_ad2/)
6060
spack install
6161
SOURCEPATH="$(pwd)"
6262
share/openPMD/download_samples.sh build
6363
export LDFLAGS="${LDFLAGS} -fsanitize=address,undefined -shared-libsan"
64-
export CXXFLAGS="${CXXFLAGS} -fsanitize=address,undefined -shared-libsan"
64+
export CXXFLAGS="${CXXFLAGS} -fsanitize=address,undefined -shared-libsan -DOMPI_SKIP_MPICXX"
6565
cmake -S . -B build \
6666
-DopenPMD_USE_MPI=ON \
6767
-DopenPMD_USE_PYTHON=ON \
@@ -72,7 +72,7 @@ jobs:
7272
cmake --build build --parallel 2
7373
export ASAN_OPTIONS=detect_stack_use_after_return=1:detect_leaks=1:check_initialization_order=true:strict_init_order=true:detect_stack_use_after_scope=1:fast_unwind_on_malloc=0
7474
export LSAN_OPTIONS=suppressions="$SOURCEPATH/.github/ci/sanitizer/clang/Leak.supp"
75-
export LD_PRELOAD=/usr/lib/clang/14/lib/linux/libclang_rt.asan-x86_64.so
75+
export LD_PRELOAD=/usr/lib/clang/19/lib/linux/libclang_rt.asan-x86_64.so
7676
ctest --test-dir build -E 3b --output-on-failure
7777
export OPENPMD_HDF5_CHUNKS="auto"
7878
ctest --test-dir build -R 3b --output-on-failure

examples/8b_benchmark_read_parallel.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ class Timer
135135
~Timer()
136136
{
137137
MPI_Barrier(MPI_COMM_WORLD);
138-
std::string tt = "~" + m_Tag;
139138
// MemoryProfiler (m_Rank, tt.c_str());
140139
m_End = std::chrono::system_clock::now();
141140

include/openPMD/IO/HDF5/HDF5IOHandlerImpl.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ class HDF5IOHandlerImpl : public AbstractIOHandlerImpl
132132
hid_t id;
133133
};
134134
std::optional<File> getFile(Writable *);
135+
File
136+
requireFile(std::string const &functionName, Writable *, bool checkParent);
135137
}; // HDF5IOHandlerImpl
136138
#else
137139
class HDF5IOHandlerImpl

include/openPMD/IO/JSON/JSONIOHandlerImpl.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -525,9 +525,7 @@ class JSONIOHandlerImpl : public AbstractIOHandlerImpl
525525
};
526526

527527
template <typename T>
528-
struct JsonToCpp<
529-
T,
530-
typename std::enable_if<std::is_floating_point<T>::value>::type>
528+
struct JsonToCpp<T, typename std::enable_if_t<std::is_floating_point_v<T>>>
531529
{
532530
T operator()(nlohmann::json const &);
533531
};

include/openPMD/backend/BaseRecord.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ class BaseRecord
317317
template <class InputIt>
318318
void insert(InputIt first, InputIt last);
319319
void insert(std::initializer_list<value_type> ilist);
320-
void swap(BaseRecord &other);
320+
void swap(BaseRecord &other) noexcept;
321321
bool contains(key_type const &key) const;
322322
template <class... Args>
323323
auto emplace(Args &&...args) -> std::pair<iterator, bool>;

src/IO/ADIOS/ADIOS2File.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "openPMD/auxiliary/Environment.hpp"
2929
#include "openPMD/auxiliary/StringManip.hpp"
3030

31+
#include <cstdint>
3132
#include <optional>
3233
#include <stdexcept>
3334

@@ -317,7 +318,7 @@ namespace
317318
return false;
318319
}
319320

320-
enum class PerstepParsing
321+
enum class PerstepParsing : std::uint8_t
321322
{
322323
Supported,
323324
Unsupported,
@@ -1086,7 +1087,7 @@ void ADIOS2File::flush_impl(ADIOS2FlushParams flushParams, bool writeLatePuts)
10861087
#if ADIOS2_VERSION_MAJOR * 1000000000 + ADIOS2_VERSION_MINOR * 100000000 + \
10871088
ADIOS2_VERSION_PATCH * 1000000 + ADIOS2_VERSION_TWEAK >= \
10881089
2701001223
1089-
enum class CleanedFlushTarget
1090+
enum class CleanedFlushTarget : std::uint8_t
10901091
{
10911092
Buffer,
10921093
Disk,

src/IO/ADIOS/ADIOS2IOHandler.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,7 +1371,7 @@ namespace
13711371
*/
13721372
using rep = detail::AttributeTypes<bool>::rep;
13731373

1374-
if constexpr (std::is_same<T, rep>::value)
1374+
if constexpr (std::is_same_v<T, rep>)
13751375
{
13761376
auto attr = getAttribute.template call<rep>(name);
13771377
if (!attr)
@@ -2239,7 +2239,6 @@ namespace detail
22392239
auto file = impl->refreshFileFromParent(
22402240
writable, /* preferParentFile = */ false);
22412241
auto fullName = impl->nameOfAttribute(writable, parameters.name);
2242-
auto prefix = impl->filePositionToString(pos);
22432242

22442243
auto &filedata = impl->getFileData(
22452244
file, ADIOS2IOHandlerImpl::IfFileNotOpen::ThrowError);

0 commit comments

Comments
 (0)