From a65d7502c9cf6a83123d69b961968b6badddf9e1 Mon Sep 17 00:00:00 2001 From: Third Party Date: Tue, 15 Nov 2022 16:00:49 +0100 Subject: [PATCH] Run clang-tidy-15 -fix --- examples/raycast/raycast.cpp | 8 +-- include/llama/Array.hpp | 4 +- include/llama/ArrayExtents.hpp | 9 +-- include/llama/Core.hpp | 4 +- include/llama/RecordCoord.hpp | 2 +- include/llama/RecordRef.hpp | 6 +- include/llama/StructName.hpp | 2 +- include/llama/Tuple.hpp | 4 +- include/llama/llama.hpp | 3 + .../llama/mapping/tree/TreeFromDimensions.hpp | 2 +- tests/array.cpp | 2 +- tests/arrayextents.cpp | 25 +++---- tests/arrayindexrange.cpp | 2 +- tests/common.hpp | 2 +- tests/core.cpp | 14 ++-- tests/mapping.HeatmapTrace.cpp | 6 +- tests/mapping.cpp | 8 +-- tests/recorddimension.cpp | 8 +-- tests/recordref.cpp | 66 ++++++++++--------- tests/simd.cpp | 6 +- tests/view.cpp | 43 ++++++------ tests/virtualview.cpp | 8 +-- 22 files changed, 122 insertions(+), 112 deletions(-) diff --git a/examples/raycast/raycast.cpp b/examples/raycast/raycast.cpp index fe8883648d..42b77411c3 100644 --- a/examples/raycast/raycast.cpp +++ b/examples/raycast/raycast.cpp @@ -178,7 +178,7 @@ namespace } // namespace template -struct std::tuple_size> +struct std::tuple_size> // NOLINT(cert-dcl58-cpp) { static constexpr auto value = 3; }; @@ -541,7 +541,7 @@ namespace { auto sqr = [](auto x) { return x * x; }; - float r2 = s.radius * s.radius; + const float r2 = s.radius * s.radius; float dmin = 0.0f; for(auto i : {0, 1, 2}) { @@ -572,9 +572,9 @@ namespace { VectorF vmin; VectorF vmax; - for(int q : {0, 1, 2}) + for(const int q : {0, 1, 2}) { - float v = vert[q]; + const float v = vert[q]; if(normal[q] > 0.0f) { vmin[q] = -maxbox[q] - v; diff --git a/include/llama/Array.hpp b/include/llama/Array.hpp index 010a9bdb06..ab89becae0 100644 --- a/include/llama/Array.hpp +++ b/include/llama/Array.hpp @@ -274,12 +274,12 @@ namespace llama namespace std { template - struct tuple_size> : integral_constant + struct tuple_size> : integral_constant // NOLINT(cert-dcl58-cpp) { }; template - struct tuple_element> + struct tuple_element> // NOLINT(cert-dcl58-cpp) { using type = T; }; diff --git a/include/llama/ArrayExtents.hpp b/include/llama/ArrayExtents.hpp index c474bd928f..8d17e07bed 100644 --- a/include/llama/ArrayExtents.hpp +++ b/include/llama/ArrayExtents.hpp @@ -66,12 +66,12 @@ namespace llama } // namespace llama template -struct std::tuple_size> : std::integral_constant +struct std::tuple_size> : std::integral_constant // NOLINT(cert-dcl58-cpp) { }; template -struct std::tuple_element> +struct std::tuple_element> // NOLINT(cert-dcl58-cpp) { using type = V; }; @@ -254,12 +254,13 @@ namespace llama } // namespace llama template -struct std::tuple_size> : std::integral_constant +struct std::tuple_size> // NOLINT(cert-dcl58-cpp) + : std::integral_constant { }; template -struct std::tuple_element> +struct std::tuple_element> // NOLINT(cert-dcl58-cpp) { using type = SizeType; }; diff --git a/include/llama/Core.hpp b/include/llama/Core.hpp index 70a6c15bc3..b4e08df7d8 100644 --- a/include/llama/Core.hpp +++ b/include/llama/Core.hpp @@ -463,7 +463,7 @@ namespace llama using namespace boost::mp11; std::size_t size = 0; - std::size_t maxAlign = 0; + std::size_t maxAlign = 0; // NOLINT(misc-const-correctness) mp_for_each>([&](auto e) constexpr { using T = typename decltype(e)::type; if constexpr(Align) @@ -516,7 +516,7 @@ namespace llama return 0; else { - std::size_t offset + std::size_t offset // NOLINT(misc-const-correctness) = flatOffsetOf + sizeof(boost::mp11::mp_at_c); if constexpr(Align) offset = roundUpToMultiple(offset, alignof(boost::mp11::mp_at_c)); diff --git a/include/llama/RecordCoord.hpp b/include/llama/RecordCoord.hpp index aa58785e48..5aa98ef94e 100644 --- a/include/llama/RecordCoord.hpp +++ b/include/llama/RecordCoord.hpp @@ -81,7 +81,7 @@ namespace llama { constexpr auto coord = []() constexpr { - char digits[] = {(Digits - 48)...}; + const char digits[] = {(Digits - 48)...}; std::size_t acc = 0; std ::size_t powerOf10 = 1; for(int i = sizeof...(Digits) - 1; i >= 0; i--) diff --git a/include/llama/RecordRef.hpp b/include/llama/RecordRef.hpp index 251ef5477b..3e7d716e3e 100644 --- a/include/llama/RecordRef.hpp +++ b/include/llama/RecordRef.hpp @@ -986,19 +986,19 @@ namespace llama } // namespace llama template -struct std::tuple_size> +struct std::tuple_size> // NOLINT(cert-dcl58-cpp) : boost::mp11::mp_size::AccessibleRecordDim> { }; template -struct std::tuple_element> +struct std::tuple_element> // NOLINT(cert-dcl58-cpp) { using type = decltype(std::declval>().template get()); }; template -struct std::tuple_element> +struct std::tuple_element> // NOLINT(cert-dcl58-cpp) { using type = decltype(std::declval>().template get()); }; diff --git a/include/llama/StructName.hpp b/include/llama/StructName.hpp index 15f342f117..fac7cda168 100644 --- a/include/llama/StructName.hpp +++ b/include/llama/StructName.hpp @@ -191,7 +191,7 @@ namespace llama inline constexpr auto qualifiedTypeName = [] { constexpr auto& value = internal::typeNameStorage; - return std::string_view{&value[0], value.size()}; + return std::string_view{value.data(), value.size()}; }(); namespace internal diff --git a/include/llama/Tuple.hpp b/include/llama/Tuple.hpp index 2d5d1836b6..6ae7ec8b75 100644 --- a/include/llama/Tuple.hpp +++ b/include/llama/Tuple.hpp @@ -130,13 +130,13 @@ namespace llama } // namespace llama template -struct std::tuple_size> +struct std::tuple_size> // NOLINT(cert-dcl58-cpp) { static constexpr auto value = sizeof...(Elements); }; template -struct std::tuple_element> +struct std::tuple_element> // NOLINT(cert-dcl58-cpp) { using type = boost::mp11::mp_at_c, I>; }; diff --git a/include/llama/llama.hpp b/include/llama/llama.hpp index 443aecb905..4465ae1a39 100644 --- a/include/llama/llama.hpp +++ b/include/llama/llama.hpp @@ -22,8 +22,11 @@ /// /// LLAMA is licensed under the LGPL3+. +// NOLINTNEXTLINE(modernize-macro-to-enum) #define LLAMA_VERSION_MAJOR 0 +// NOLINTNEXTLINE(modernize-macro-to-enum) #define LLAMA_VERSION_MINOR 4 +// NOLINTNEXTLINE(modernize-macro-to-enum) #define LLAMA_VERSION_PATCH 0 // suppress warnings on missing return statements. we get a lot of these because nvcc/nvc++ have some troubles with if diff --git a/include/llama/mapping/tree/TreeFromDimensions.hpp b/include/llama/mapping/tree/TreeFromDimensions.hpp index c50d3ed20a..b263545474 100644 --- a/include/llama/mapping/tree/TreeFromDimensions.hpp +++ b/include/llama/mapping/tree/TreeFromDimensions.hpp @@ -131,7 +131,7 @@ namespace llama::mapping::tree static_cast(size[N - 1])}; // FIXME(bgruber): propagate index type else { - Tuple inner{createTree(size)}; + Tuple inner{createTree(size)}; // NOLINT(misc-const-correctness) return Node{ static_cast(size[Pos]), inner}; // FIXME(bgruber): propagate index type diff --git a/tests/array.cpp b/tests/array.cpp index c96e194656..0028ceee82 100644 --- a/tests/array.cpp +++ b/tests/array.cpp @@ -35,7 +35,7 @@ TEST_CASE("Array.begin") TEST_CASE("Array.range_for") { - llama::Array a{1, 2, 3}; + const llama::Array a{1, 2, 3}; int i = 1; for(auto e : a) { diff --git a/tests/arrayextents.cpp b/tests/arrayextents.cpp index ce48bd1379..2a13473513 100644 --- a/tests/arrayextents.cpp +++ b/tests/arrayextents.cpp @@ -9,15 +9,16 @@ TEMPLATE_LIST_TEST_CASE("ArrayExtents.CTAD", "", SizeTypes) { TestType one = 1; - [[maybe_unused]] llama::ArrayExtents ad0{}; - llama::ArrayExtents ad1{one}; - llama::ArrayExtents ad2{one, one}; - llama::ArrayExtents ad3{one, one, one}; - - STATIC_REQUIRE(std::is_same_v>); - STATIC_REQUIRE(std::is_same_v>); - STATIC_REQUIRE(std::is_same_v>); - STATIC_REQUIRE(std::is_same_v>); + [[maybe_unused]] const llama::ArrayExtents ad0{}; + const llama::ArrayExtents ad1{one}; + const llama::ArrayExtents ad2{one, one}; + const llama::ArrayExtents ad3{one, one, one}; + + STATIC_REQUIRE(std::is_same_v>); + STATIC_REQUIRE(std::is_same_v>); + STATIC_REQUIRE(std::is_same_v>); + STATIC_REQUIRE( + std::is_same_v>); STATIC_REQUIRE(decltype(ad0)::rank == 0); STATIC_REQUIRE(decltype(ad1)::rank == 1); @@ -170,7 +171,7 @@ TEMPLATE_LIST_TEST_CASE("ArrayExtents.toArray", "", SizeTypes) TEMPLATE_LIST_TEST_CASE("forEachADCoord_1D", "", SizeTypes) { const auto n = TestType{3}; - llama::ArrayExtents extents{n}; + const llama::ArrayExtents extents{n}; std::vector> indices; llama::forEachADCoord(extents, [&](llama::ArrayIndex ai) { indices.push_back(ai); }); @@ -181,7 +182,7 @@ TEMPLATE_LIST_TEST_CASE("forEachADCoord_1D", "", SizeTypes) TEMPLATE_LIST_TEST_CASE("forEachADCoord_2D", "", SizeTypes) { const auto n = TestType{3}; - llama::ArrayExtents extents{n, n}; + const llama::ArrayExtents extents{n, n}; std::vector> indices; llama::forEachADCoord(extents, [&](llama::ArrayIndex ai) { indices.push_back(ai); }); @@ -195,7 +196,7 @@ TEMPLATE_LIST_TEST_CASE("forEachADCoord_2D", "", SizeTypes) TEMPLATE_LIST_TEST_CASE("forEachADCoord_3D", "", SizeTypes) { const auto n = TestType{3}; - llama::ArrayExtents extents{n, n, n}; + const llama::ArrayExtents extents{n, n, n}; std::vector> indices; llama::forEachADCoord(extents, [&](llama::ArrayIndex ai) { indices.push_back(ai); }); diff --git a/tests/arrayindexrange.cpp b/tests/arrayindexrange.cpp index 8959f79203..d305fb219c 100644 --- a/tests/arrayindexrange.cpp +++ b/tests/arrayindexrange.cpp @@ -70,7 +70,7 @@ TEST_CASE("ArrayIndexIterator") TEST_CASE("ArrayIndexIterator.operator+=") { std::vector> indices; - llama::ArrayIndexRange r{llama::ArrayExtentsDynamic{3, 4}}; + const llama::ArrayIndexRange r{llama::ArrayExtentsDynamic{3, 4}}; for(auto it = r.begin(); it != r.end(); it += 2) indices.push_back(*it); diff --git a/tests/common.hpp b/tests/common.hpp index 33ffb86dbb..5e152d816c 100644 --- a/tests/common.hpp +++ b/tests/common.hpp @@ -78,7 +78,7 @@ auto prettyPrintType(const T& t = {}) -> std::string #endif #ifdef __GNUG__ // remove clutter in g++ - static std::regex ulLiteral{"(\\d+)ul"}; + static const std::regex ulLiteral{"(\\d+)ul"}; raw = std::regex_replace(raw, ulLiteral, "$1"); #endif diff --git a/tests/core.cpp b/tests/core.cpp index 8e4c2aa51e..27dfc73f55 100644 --- a/tests/core.cpp +++ b/tests/core.cpp @@ -469,11 +469,11 @@ namespace TEST_CASE("BoxedValue.implicit_ctor") { - [[maybe_unused]] llama::internal::BoxedValue v1{42}; - [[maybe_unused]] llama::internal::BoxedValue v2 = 42; - [[maybe_unused]] WithValue wv{42}; - [[maybe_unused]] WithValueCtor wvc1{1, 2.4, 4}; - [[maybe_unused]] WithValueCtor wvc2{1, 2, 4}; + [[maybe_unused]] const llama::internal::BoxedValue v1{42}; + [[maybe_unused]] const llama::internal::BoxedValue v2 = 42; + [[maybe_unused]] const WithValue wv{42}; + [[maybe_unused]] const WithValueCtor wvc1{1, 2.4, 4}; + [[maybe_unused]] const WithValueCtor wvc2{1, 2, 4}; } namespace @@ -495,13 +495,13 @@ namespace TEST_CASE("BoxedValue.Value") { - ValueConsumer vc{1}; + const ValueConsumer vc{1}; CHECK(vc() == 1); } TEST_CASE("BoxedValue.Constant") { - ValueConsumer> vc{{}}; + const ValueConsumer> vc{{}}; CHECK(vc() == 1); STATIC_REQUIRE(vc() == 1); } diff --git a/tests/mapping.HeatmapTrace.cpp b/tests/mapping.HeatmapTrace.cpp index 3edbfe6d05..b35b4d4369 100644 --- a/tests/mapping.HeatmapTrace.cpp +++ b/tests/mapping.HeatmapTrace.cpp @@ -149,7 +149,7 @@ TEST_CASE("Trace.ctor") // mapping ctor { - Mapping mapping{AE{42}}; + const Mapping mapping{AE{42}}; auto trace = llama::mapping::Trace{mapping}; CHECK(trace.extents() == AE{42}); } @@ -178,7 +178,7 @@ TEMPLATE_LIST_TEST_CASE("Trace.nbody.mem_locs_computed", "", SizeTypes) CHECK(hits[5].memLocsComputed == 400); CHECK(hits[6].memLocsComputed == 10300); - std::stringstream buffer; + const std::stringstream buffer; std::streambuf* old = std::cout.rdbuf(buffer.rdbuf()); particles.mapping().printFieldHits(particles.storageBlobs); std::cout.rdbuf(old); @@ -220,7 +220,7 @@ TEMPLATE_LIST_TEST_CASE("Trace.nbody.reads_writes", "", SizeTypes) CHECK(hits[5].writes == 200); CHECK(hits[6].writes == 200); - std::stringstream buffer; + const std::stringstream buffer; std::streambuf* old = std::cout.rdbuf(buffer.rdbuf()); particles.mapping().printFieldHits(particles.storageBlobs); std::cout.rdbuf(old); diff --git a/tests/mapping.cpp b/tests/mapping.cpp index d2eeebbbfd..422fcd946d 100644 --- a/tests/mapping.cpp +++ b/tests/mapping.cpp @@ -226,7 +226,7 @@ TEST_CASE("mapping.LinearizeArrayDimsCpp.size") TEST_CASE("mapping.LinearizeArrayDimsCpp") { - llama::mapping::LinearizeArrayDimsCpp lin; + const llama::mapping::LinearizeArrayDimsCpp lin; const auto extents = llama::ArrayExtents{}; CHECK(lin(llama::ArrayIndex{0, 0}, extents) == 0); CHECK(lin(llama::ArrayIndex{0, 1}, extents) == 1); @@ -257,7 +257,7 @@ TEST_CASE("mapping.LinearizeArrayDimsFortran.size") TEST_CASE("mapping.LinearizeArrayDimsFortran") { - llama::mapping::LinearizeArrayDimsFortran lin; + const llama::mapping::LinearizeArrayDimsFortran lin; const auto extents = llama::ArrayExtents{}; CHECK(lin(llama::ArrayIndex{0, 0}, extents) == 0); CHECK(lin(llama::ArrayIndex{0, 1}, extents) == 4); @@ -279,7 +279,7 @@ TEST_CASE("mapping.LinearizeArrayDimsFortran") TEST_CASE("mapping.LinearizeArrayDimsMorton.size") { - llama::mapping::LinearizeArrayDimsMorton lin; + const llama::mapping::LinearizeArrayDimsMorton lin; CHECK(lin.size(llama::ArrayExtents{2, 3}) == 4 * 4); CHECK(lin.size(llama::ArrayExtents{2, 4}) == 4 * 4); CHECK(lin.size(llama::ArrayExtents{2, 5}) == 8 * 8); @@ -288,7 +288,7 @@ TEST_CASE("mapping.LinearizeArrayDimsMorton.size") TEST_CASE("mapping.LinearizeArrayDimsMorton") { - llama::mapping::LinearizeArrayDimsMorton lin; + const llama::mapping::LinearizeArrayDimsMorton lin; const auto extents = llama::ArrayExtents{}; CHECK(lin(llama::ArrayIndex{0, 0}, extents) == 0); CHECK(lin(llama::ArrayIndex{0, 1}, extents) == 1); diff --git a/tests/recorddimension.cpp b/tests/recorddimension.cpp index 21d094cb6e..063d15972c 100644 --- a/tests/recorddimension.cpp +++ b/tests/recorddimension.cpp @@ -31,9 +31,9 @@ TEST_CASE("recorddim.record_with_int[3]") using RecordDim = llama::Record>; auto view = llama::allocView(llama::mapping::AoS{llama::ArrayExtents{1}, RecordDim{}}); - [[maybe_unused]] int& e0 = view(0u)(Tag{})(0_RC); - [[maybe_unused]] int& e1 = view(0u)(Tag{})(1_RC); - [[maybe_unused]] int& e2 = view(0u)(Tag{})(2_RC); + [[maybe_unused]] const int& e0 = view(0u)(Tag{})(0_RC); + [[maybe_unused]] const int& e1 = view(0u)(Tag{})(1_RC); + [[maybe_unused]] const int& e2 = view(0u)(Tag{})(2_RC); } TEST_CASE("recorddim.record_with_std::complex") @@ -143,7 +143,7 @@ TEST_CASE("recorddim.record_with_nontrivial_ctor") using RecordDim = llama::Record>; auto view = llama::allocView(llama::mapping::AoS{llama::ArrayExtents{1}, RecordDim{}}); - ElementWithCtor& e = view(0u)(Tag{}); + const ElementWithCtor& e = view(0u)(Tag{}); CHECK(e.value == 42); } diff --git a/tests/recordref.cpp b/tests/recordref.cpp index 2891d49d41..07044bd277 100644 --- a/tests/recordref.cpp +++ b/tests/recordref.cpp @@ -373,9 +373,9 @@ TEST_CASE("RecordRef.asTuple.types") { llama::One record; - std::tuple pos = record(tag::Pos{}).asTuple(); - std::tuple vel = record(tag::Vel{}).asTuple(); - std::tuple, std::tuple, int&> name = record.asTuple(); + const std::tuple pos = record(tag::Pos{}).asTuple(); + const std::tuple vel = record(tag::Vel{}).asTuple(); + const std::tuple, std::tuple, int&> name = record.asTuple(); static_cast(pos); static_cast(vel); static_cast(name); @@ -383,10 +383,11 @@ TEST_CASE("RecordRef.asTuple.types") { const llama::One record; - std::tuple pos = record(tag::Pos{}).asTuple(); - std::tuple vel = record(tag::Vel{}).asTuple(); - std::tuple, std::tuple, const int&> name - = record.asTuple(); + const std::tuple pos = record(tag::Pos{}).asTuple(); + const std::tuple vel = record(tag::Vel{}).asTuple(); + const std:: + tuple, std::tuple, const int&> + name = record.asTuple(); static_cast(pos); static_cast(vel); static_cast(name); @@ -476,9 +477,9 @@ TEST_CASE("RecordRef.asFlatTuple.types") { llama::One record; - std::tuple pos = record(tag::Pos{}).asFlatTuple(); - std::tuple vel = record(tag::Vel{}).asFlatTuple(); - std::tuple name = record.asFlatTuple(); + const std::tuple pos = record(tag::Pos{}).asFlatTuple(); + const std::tuple vel = record(tag::Vel{}).asFlatTuple(); + const std::tuple name = record.asFlatTuple(); static_cast(pos); static_cast(vel); static_cast(name); @@ -486,9 +487,10 @@ TEST_CASE("RecordRef.asFlatTuple.types") { const llama::One record; - std::tuple pos = record(tag::Pos{}).asFlatTuple(); - std::tuple vel = record(tag::Vel{}).asFlatTuple(); - std::tuple name = record.asFlatTuple(); + const std::tuple pos = record(tag::Pos{}).asFlatTuple(); + const std::tuple vel = record(tag::Vel{}).asFlatTuple(); + const std::tuple name + = record.asFlatTuple(); static_cast(pos); static_cast(vel); static_cast(name); @@ -679,19 +681,19 @@ namespace } // namespace template -struct std::tuple_size> +struct std::tuple_size> // NOLINT(cert-dcl58-cpp) { static constexpr std::size_t value = 2; }; template -struct std::tuple_size> +struct std::tuple_size> // NOLINT(cert-dcl58-cpp) { static constexpr std::size_t value = 3; }; template -struct std::tuple_size> +struct std::tuple_size> // NOLINT(cert-dcl58-cpp) { static constexpr std::size_t value = 3; }; @@ -702,18 +704,18 @@ TEST_CASE("RecordRef.load.value") record = 1; { - MyPos pos = record(tag::Pos{}).load(); + const MyPos pos = record(tag::Pos{}).load(); CHECK(pos.a == 1); CHECK(pos.y == 1); } { - MyPos pos = std::as_const(record)(tag::Pos{}).load(); + const MyPos pos = std::as_const(record)(tag::Pos{}).load(); CHECK(pos.a == 1); CHECK(pos.y == 1); } { - MyStruct d = record.load(); + const MyStruct d = record.load(); CHECK(d.pos.a == 1); CHECK(d.pos.y == 1); CHECK(d.vel.x == 1); @@ -722,7 +724,7 @@ TEST_CASE("RecordRef.load.value") CHECK(d.weight == 1); } { - MyStruct d = std::as_const(record).load(); + const MyStruct d = std::as_const(record).load(); CHECK(d.pos.a == 1); CHECK(d.pos.y == 1); CHECK(d.vel.x == 1); @@ -779,22 +781,22 @@ TEST_CASE("RecordRef.load.constref") record = 1; { - MyPos pos = record(tag::Pos{}).load(); + const MyPos pos = record(tag::Pos{}).load(); CHECK(pos.a == 1); CHECK(pos.y == 1); } { - MyPos pos = std::as_const(record)(tag::Pos{}).load(); + const MyPos pos = std::as_const(record)(tag::Pos{}).load(); CHECK(pos.a == 1); CHECK(pos.y == 1); } { - MyStruct d = record.load(); + const MyStruct d = record.load(); CHECK(d.pos.a == 1); CHECK(d.pos.y == 1); } { - MyStruct d = std::as_const(record).load(); + const MyStruct d = std::as_const(record).load(); CHECK(d.pos.a == 1); CHECK(d.pos.y == 1); } @@ -808,18 +810,18 @@ TEST_CASE("RecordRef.load.value.fromproxyref") record = 1; { - MyPos pos = record(tag::Pos{}).load(); + const MyPos pos = record(tag::Pos{}).load(); CHECK(pos.a == 1); CHECK(pos.y == 1); } { - MyPos pos = std::as_const(record)(tag::Pos{}).load(); + const MyPos pos = std::as_const(record)(tag::Pos{}).load(); CHECK(pos.a == 1); CHECK(pos.y == 1); } { - MyStruct d = record.load(); + const MyStruct d = record.load(); CHECK(d.pos.a == 1); CHECK(d.pos.y == 1); CHECK(d.vel.x == 1); @@ -828,7 +830,7 @@ TEST_CASE("RecordRef.load.value.fromproxyref") CHECK(d.weight == 1); } { - MyStruct d = std::as_const(record).load(); + const MyStruct d = std::as_const(record).load(); CHECK(d.pos.a == 1); CHECK(d.pos.y == 1); CHECK(d.vel.x == 1); @@ -844,7 +846,7 @@ TEST_CASE("RecordRef.store") record = 1; { - MyPos pos{2, 3}; + const MyPos pos{2, 3}; record(tag::Pos{}).store(pos); CHECK(record(tag::Pos{}, tag::A{}) == 2); CHECK(record(tag::Pos{}, tag::Y{}) == 3); @@ -856,7 +858,7 @@ TEST_CASE("RecordRef.store") record = 1; { - MyStruct d{{2, 3}, {4, 5, 6}, 7}; + const MyStruct d{{2, 3}, {4, 5, 6}, 7}; record.store(d); CHECK(record(tag::Pos{}, tag::A{}) == 2); CHECK(record(tag::Pos{}, tag::Y{}) == 3); @@ -875,7 +877,7 @@ TEST_CASE("RecordRef.store.toproxyref") record = 1; { - MyPos pos{2, 3}; + const MyPos pos{2, 3}; record(tag::Pos{}).store(pos); CHECK(record(tag::Pos{}, tag::A{}) == 2); CHECK(record(tag::Pos{}, tag::Y{}) == 3); @@ -887,7 +889,7 @@ TEST_CASE("RecordRef.store.toproxyref") record = 1; { - MyStruct d{{2, 3}, {4, 5, 6}, 7}; + const MyStruct d{{2, 3}, {4, 5, 6}, 7}; record.store(d); CHECK(record(tag::Pos{}, tag::A{}) == 2); CHECK(record(tag::Pos{}, tag::Y{}) == 3); diff --git a/tests/simd.cpp b/tests/simd.cpp index 5d8ef59a24..5a4e344559 100644 --- a/tests/simd.cpp +++ b/tests/simd.cpp @@ -169,7 +169,7 @@ TEST_CASE("simd.simdLanes.stdsimd") TEST_CASE("simd.loadSimd.scalar") { - float mem = 3.14f; + const float mem = 3.14f; float s = 0; llama::loadSimd(mem, s); CHECK(s == mem); @@ -262,14 +262,14 @@ TEST_CASE("simd.loadSimd.record.stdsimd") TEST_CASE("simd.storeSimd.scalar") { float mem = 0; - float s = 3.14f; + const float s = 3.14f; llama::storeSimd(s, mem); CHECK(s == mem); } TEST_CASE("simd.storeSimd.simd.stdsimd") { - stdx::fixed_size_simd s([](auto ic) -> float { return ic() + 1; }); + const stdx::fixed_size_simd s([](auto ic) -> float { return ic() + 1; }); std::array a{}; llama::storeSimd(s, a[0]); diff --git a/tests/view.cpp b/tests/view.cpp index 418f84d739..bb509fe196 100644 --- a/tests/view.cpp +++ b/tests/view.cpp @@ -17,14 +17,17 @@ using RecordDim = llama::Record< TEST_CASE("view.default-ctor") { using ArrayExtents = llama::ArrayExtentsDynamic; - [[maybe_unused]] llama::View, std::byte*> view1{}; - [[maybe_unused]] llama::View, std::byte*> view2{}; - [[maybe_unused]] llama::View, std::byte*> view3{}; - [[maybe_unused]] llama::View, std::byte*> view4{}; - [[maybe_unused]] llama::View, std::byte*> view5{}; - [[maybe_unused]] llama::View, std::byte*> view6{}; - [[maybe_unused]] llama::View>, std::byte*> - view7{}; + [[maybe_unused]] const llama::View, std::byte*> view1{}; + [[maybe_unused]] const llama::View, std::byte*> view2{}; + [[maybe_unused]] const llama::View, std::byte*> + view3{}; + [[maybe_unused]] const llama::View, std::byte*> + view4{}; + [[maybe_unused]] const llama::View, std::byte*> view5{}; + [[maybe_unused]] const llama::View, std::byte*> view6{}; + [[maybe_unused]] const llama:: + View>, std::byte*> + view7{}; } TEST_CASE("view.move") @@ -66,10 +69,10 @@ TEST_CASE("view.non-memory-owning") using byte = typename decltype(typeHolder)::type; using ArrayExtents = llama::ArrayExtentsDynamic; - ArrayExtents extents{256}; + const ArrayExtents extents{256}; using Mapping = llama::mapping::SoA; - Mapping mapping{extents}; + const Mapping mapping{extents}; const auto blobSize = mapping.blobSize(0); const auto storage = std::make_unique(blobSize); @@ -89,10 +92,10 @@ TEST_CASE("view.non-memory-owning") TEST_CASE("view.subscript") { using ArrayExtents = llama::ArrayExtentsDynamic; - ArrayExtents extents{16, 16}; + const ArrayExtents extents{16, 16}; using Mapping = llama::mapping::SoA; - Mapping mapping{extents}; + const Mapping mapping{extents}; auto view = llama::allocView(mapping); auto l = [](auto& view) { @@ -122,10 +125,10 @@ TEST_CASE("view.assign-one-record") using namespace llama::literals; using ArrayExtents = llama::ArrayExtentsDynamic; - ArrayExtents extents{16, 16}; + const ArrayExtents extents{16, 16}; using Mapping = llama::mapping::SoA; - Mapping mapping{extents}; + const Mapping mapping{extents}; auto view = llama::allocView(mapping); llama::One record; @@ -159,10 +162,10 @@ TEST_CASE("view.addresses") using namespace llama::literals; using ArrayExtents = llama::ArrayExtentsDynamic; - ArrayExtents extents{16, 16}; + const ArrayExtents extents{16, 16}; using Mapping = llama::mapping::PackedSingleBlobSoA; - Mapping mapping{extents}; + const Mapping mapping{extents}; auto view = llama::allocView(mapping); const llama::ArrayIndex pos{0, 0}; @@ -204,10 +207,10 @@ struct SetZeroFunctor TEST_CASE("view.iteration-and-access") { using ArrayExtents = llama::ArrayExtentsDynamic; - ArrayExtents extents{16, 16}; + const ArrayExtents extents{16, 16}; using Mapping = llama::mapping::SoA; - Mapping mapping{extents}; + const Mapping mapping{extents}; auto view = llama::allocView(mapping); for(int x = 0; x < extents[0]; ++x) @@ -229,10 +232,10 @@ TEST_CASE("view.iteration-and-access") TEST_CASE("view.record-access") { using ArrayExtents = llama::ArrayExtentsDynamic; - ArrayExtents extents{16, 16}; + const ArrayExtents extents{16, 16}; using Mapping = llama::mapping::SoA; - Mapping mapping{extents}; + const Mapping mapping{extents}; auto view = llama::allocView(mapping); for(size_t x = 0; x < extents[0]; ++x) diff --git a/tests/virtualview.cpp b/tests/virtualview.cpp index 8f94126fd2..f33fdacaba 100644 --- a/tests/virtualview.cpp +++ b/tests/virtualview.cpp @@ -10,27 +10,27 @@ TEST_CASE("VirtualView.CTAD") using View = decltype(view); { - llama::VirtualView virtualView{view, {2, 4}}; + const llama::VirtualView virtualView{view, {2, 4}}; STATIC_REQUIRE(std::is_same_v); STATIC_REQUIRE(std::is_same_v); } { auto& viewRef = view; - llama::VirtualView virtualView{viewRef, {2, 4}}; + const llama::VirtualView virtualView{viewRef, {2, 4}}; STATIC_REQUIRE(std::is_same_v); STATIC_REQUIRE(std::is_same_v); } { const auto& viewConstRef = view; - llama::VirtualView virtualView{viewConstRef, {2, 4}}; + const llama::VirtualView virtualView{viewConstRef, {2, 4}}; STATIC_REQUIRE(std::is_same_v); STATIC_REQUIRE(std::is_same_v); } { - llama::VirtualView virtualView{std::move(view), {2, 4}}; + const llama::VirtualView virtualView{std::move(view), {2, 4}}; STATIC_REQUIRE(std::is_same_v); STATIC_REQUIRE(std::is_same_v); }