Skip to content

Commit 05bbff0

Browse files
committed
temporarily Merge branch 'clang-tidy-sanitizer-ubuntu-24.04' into dont-require-shape-for-constant-components
2 parents 64d6995 + 370fddf commit 05bbff0

File tree

19 files changed

+131
-69
lines changed

19 files changed

+131
-69
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-
24-
prefix: /usr
25+
26+
prefix: /usr/local
2527
buildable: False
28+
2629
openmpi:
2730
externals:
28-
31+
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: [[email protected]]
52+
cc: [llvm]
53+
cxx: [llvm]
54+
fortran: [gcc]
55+
56+
llvm:
57+
externals:
58+
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+
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-
61-
target: x86_64
81+
gcc-runtime:
82+
buildable: false
83+
externals:
84+
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: 15 additions & 16 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 \
@@ -73,8 +73,7 @@ jobs:
7373
cmake --build build --parallel 2
7474
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
7575
export LSAN_OPTIONS=suppressions="$SOURCEPATH/.github/ci/sanitizer/clang/Leak.supp"
76-
export LD_PRELOAD=/usr/lib/clang/14/lib/linux/libclang_rt.asan-x86_64.so
77-
ASAN_OPTIONS="abort_on_error=1:halt_on_error=1:fast_unwind_on_malloc=0:$ASAN_OPTIONS" LSAN_OPTIONS="verbosity=1:log_threads=1:$LSAN_OPTIONS" ctest --test-dir build -R MPI.8a_benchmark_write_parallel
78-
ASAN_OPTIONS="abort_on_error=1:halt_on_error=1:fast_unwind_on_malloc=0:$ASAN_OPTIONS" LSAN_OPTIONS="verbosity=1:log_threads=1:$LSAN_OPTIONS" ctest --test-dir build -E 3b --output-on-failure
76+
export LD_PRELOAD=/usr/lib/clang/19/lib/linux/libclang_rt.asan-x86_64.so
77+
ctest --test-dir build -E 3b --output-on-failure
7978
export OPENPMD_HDF5_CHUNKS="auto"
8079
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/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/AbstractIOHandlerHelper.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ std::unique_ptr<AbstractIOHandler> createIOHandler<json::TracingJSON>(
8181
return constructIOHandler<ParallelHDF5IOHandler, openPMD_HAVE_HDF5>(
8282
"HDF5",
8383
std::move(initialize_from),
84-
path,
84+
std::move(path),
8585
access,
8686
comm,
8787
std::move(options));
@@ -139,7 +139,7 @@ std::unique_ptr<AbstractIOHandler> createIOHandler<json::TracingJSON>(
139139
return constructIOHandler<JSONIOHandler, openPMD_HAVE_JSON>(
140140
"JSON",
141141
std::move(initialize_from),
142-
path,
142+
std::move(path),
143143
access,
144144
comm,
145145
std::move(options),
@@ -149,7 +149,7 @@ std::unique_ptr<AbstractIOHandler> createIOHandler<json::TracingJSON>(
149149
return constructIOHandler<JSONIOHandler, openPMD_HAVE_JSON>(
150150
"JSON",
151151
std::move(initialize_from),
152-
path,
152+
std::move(path),
153153
access,
154154
comm,
155155
std::move(options),
@@ -181,7 +181,7 @@ std::unique_ptr<AbstractIOHandler> createIOHandler<json::TracingJSON>(
181181
return constructIOHandler<HDF5IOHandler, openPMD_HAVE_HDF5>(
182182
"HDF5",
183183
std::move(initialize_from),
184-
path,
184+
std::move(path),
185185
access,
186186
std::move(options));
187187
case Format::ADIOS2_BP:

src/IO/JSON/JSONIOHandlerImpl.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,13 +1203,13 @@ void JSONIOHandlerImpl::writeAttribute(
12031203
switch (m_attributeMode.m_mode)
12041204
{
12051205
case AttributeMode::Long:
1206-
(*jsonVal)[filePosition->id]["attributes"][parameter.name] = {
1206+
(*jsonVal)[filePosition->id]["attributes"][name] = {
12071207
{"datatype", jsonDatatypeToString(parameter.dtype)},
12081208
{"value", value}};
12091209
break;
12101210
case AttributeMode::Short:
12111211
// short form
1212-
(*jsonVal)[filePosition->id]["attributes"][parameter.name] = value;
1212+
(*jsonVal)[filePosition->id]["attributes"][name] = value;
12131213
break;
12141214
}
12151215
writable->written = true;
@@ -1540,7 +1540,6 @@ void JSONIOHandlerImpl::readAttribute(
15401540
auto const &jsonContents = obtainJsonContents(writable);
15411541
auto const &jsonLoc = jsonContents["attributes"];
15421542
setAndGetFilePosition(writable);
1543-
std::string error_msg("[JSON] No such attribute '");
15441543
if (!hasKey(jsonLoc, name))
15451544
{
15461545
throw error::ReadError(
@@ -2365,9 +2364,9 @@ nlohmann::json JSONIOHandlerImpl::platformSpecifics()
23652364
Datatype::CDOUBLE,
23662365
Datatype::CLONG_DOUBLE,
23672366
Datatype::BOOL};
2368-
for (auto it = std::begin(datatypes); it != std::end(datatypes); it++)
2367+
for (auto &datatype : datatypes)
23692368
{
2370-
res[jsonDatatypeToString(*it)] = toBytes(*it);
2369+
res[jsonDatatypeToString(datatype)] = toBytes(datatype);
23712370
}
23722371
return res;
23732372
}
@@ -2483,10 +2482,9 @@ std::array<T, n> JSONIOHandlerImpl::JsonToCpp<std::array<T, n>>::operator()(
24832482
}
24842483

24852484
template <typename T>
2486-
T JSONIOHandlerImpl::JsonToCpp<
2487-
T,
2488-
typename std::enable_if<std::is_floating_point<T>::value>::type>::
2489-
operator()(nlohmann::json const &j)
2485+
T JSONIOHandlerImpl::
2486+
JsonToCpp<T, std::enable_if_t<std::is_floating_point_v<T>>>::operator()(
2487+
nlohmann::json const &j)
24902488
{
24912489
try
24922490
{

src/RecordComponent.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,12 @@ RecordComponent &RecordComponent::resetDataset(Dataset d)
251251
rc.m_isEmpty = false;
252252
if (written())
253253
{
254+
if (!rc.m_dataset.has_value())
255+
{
256+
throw error::Internal(
257+
"Internal control flow error: Written record component must "
258+
"have defined datatype and extent.");
259+
}
254260
rc.m_dataset.value().extend(std::move(d.extent));
255261
}
256262
else

0 commit comments

Comments
 (0)