Skip to content

Commit

Permalink
Run clang-tidy-15 -fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Third Party authored and bernhardmgruber committed Nov 15, 2022
1 parent e99618e commit 7aec5c9
Show file tree
Hide file tree
Showing 12 changed files with 92 additions and 87 deletions.
6 changes: 3 additions & 3 deletions examples/raycast/raycast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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})
{
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions tests/array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ 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)
{
{:wq
CHECK(e == i);
i++;
}
Expand Down
14 changes: 7 additions & 7 deletions tests/arrayextents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ 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};
[[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<decltype(ad0), llama::ArrayExtents<std::size_t>>);
STATIC_REQUIRE(std::is_same_v<decltype(ad1), llama::ArrayExtents<TestType, llama::dyn>>);
Expand Down Expand Up @@ -170,7 +170,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<llama::ArrayIndex<TestType, 1>> indices;
llama::forEachADCoord(extents, [&](llama::ArrayIndex<TestType, 1> ai) { indices.push_back(ai); });
Expand All @@ -181,7 +181,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<llama::ArrayIndex<TestType, 2>> indices;
llama::forEachADCoord(extents, [&](llama::ArrayIndex<TestType, 2> ai) { indices.push_back(ai); });
Expand All @@ -195,7 +195,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<llama::ArrayIndex<TestType, 3>> indices;
llama::forEachADCoord(extents, [&](llama::ArrayIndex<TestType, 3> ai) { indices.push_back(ai); });
Expand Down
2 changes: 1 addition & 1 deletion tests/arrayindexrange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ TEST_CASE("ArrayIndexIterator")
TEST_CASE("ArrayIndexIterator.operator+=")
{
std::vector<llama::ArrayIndex<int, 2>> indices;
llama::ArrayIndexRange r{llama::ArrayExtentsDynamic<int, 2>{3, 4}};
const llama::ArrayIndexRange r{llama::ArrayExtentsDynamic<int, 2>{3, 4}};
for(auto it = r.begin(); it != r.end(); it += 2)
indices.push_back(*it);

Expand Down
14 changes: 7 additions & 7 deletions tests/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -469,11 +469,11 @@ namespace

TEST_CASE("BoxedValue.implicit_ctor")
{
[[maybe_unused]] llama::internal::BoxedValue<unsigned> v1{42};
[[maybe_unused]] llama::internal::BoxedValue<unsigned> 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<unsigned> v1{42};
[[maybe_unused]] const llama::internal::BoxedValue<unsigned> 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
Expand All @@ -495,13 +495,13 @@ namespace

TEST_CASE("BoxedValue.Value")
{
ValueConsumer<unsigned> vc{1};
const ValueConsumer<unsigned> vc{1};
CHECK(vc() == 1);
}

TEST_CASE("BoxedValue.Constant")
{
ValueConsumer<llama::Constant<1>> vc{{}};
const ValueConsumer<llama::Constant<1>> vc{{}};
CHECK(vc() == 1);
STATIC_REQUIRE(vc() == 1);
}
Expand Down
6 changes: 3 additions & 3 deletions tests/mapping.HeatmapTrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>{mapping};
CHECK(trace.extents() == AE{42});
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions tests/mapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int, 4, 4>{};
CHECK(lin(llama::ArrayIndex{0, 0}, extents) == 0);
CHECK(lin(llama::ArrayIndex{0, 1}, extents) == 1);
Expand Down Expand Up @@ -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<int, 4, 4>{};
CHECK(lin(llama::ArrayIndex{0, 0}, extents) == 0);
CHECK(lin(llama::ArrayIndex{0, 1}, extents) == 4);
Expand All @@ -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);
Expand All @@ -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<int, 4, 4>{};
CHECK(lin(llama::ArrayIndex{0, 0}, extents) == 0);
CHECK(lin(llama::ArrayIndex{0, 1}, extents) == 1);
Expand Down
8 changes: 4 additions & 4 deletions tests/recorddimension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ TEST_CASE("recorddim.record_with_int[3]")
using RecordDim = llama::Record<llama::Field<Tag, int[3]>>;
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<float>")
Expand Down Expand Up @@ -143,7 +143,7 @@ TEST_CASE("recorddim.record_with_nontrivial_ctor")
using RecordDim = llama::Record<llama::Field<Tag, ElementWithCtor>>;
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);
}

Expand Down
60 changes: 31 additions & 29 deletions tests/recordref.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,20 +373,21 @@ TEST_CASE("RecordRef.asTuple.types")
{
llama::One<ParticleInt> record;

std::tuple<int&, int&> pos = record(tag::Pos{}).asTuple();
std::tuple<int&, int&, int&> vel = record(tag::Vel{}).asTuple();
std::tuple<std::tuple<int&, int&>, std::tuple<int&, int&, int&>, int&> name = record.asTuple();
const std::tuple<int&, int&> pos = record(tag::Pos{}).asTuple();
const std::tuple<int&, int&, int&> vel = record(tag::Vel{}).asTuple();
const std::tuple<std::tuple<int&, int&>, std::tuple<int&, int&, int&>, int&> name = record.asTuple();
static_cast<void>(pos);
static_cast<void>(vel);
static_cast<void>(name);
}
{
const llama::One<ParticleInt> record;

std::tuple<const int&, const int&> pos = record(tag::Pos{}).asTuple();
std::tuple<const int&, const int&, const int&> vel = record(tag::Vel{}).asTuple();
std::tuple<std::tuple<const int&, const int&>, std::tuple<const int&, const int&, const int&>, const int&> name
= record.asTuple();
const std::tuple<const int&, const int&> pos = record(tag::Pos{}).asTuple();
const std::tuple<const int&, const int&, const int&> vel = record(tag::Vel{}).asTuple();
const std::
tuple<std::tuple<const int&, const int&>, std::tuple<const int&, const int&, const int&>, const int&>
name = record.asTuple();
static_cast<void>(pos);
static_cast<void>(vel);
static_cast<void>(name);
Expand Down Expand Up @@ -476,19 +477,20 @@ TEST_CASE("RecordRef.asFlatTuple.types")
{
llama::One<ParticleInt> record;

std::tuple<int&, int&> pos = record(tag::Pos{}).asFlatTuple();
std::tuple<int&, int&, int&> vel = record(tag::Vel{}).asFlatTuple();
std::tuple<int&, int&, int&, int&, int&, int&> name = record.asFlatTuple();
const std::tuple<int&, int&> pos = record(tag::Pos{}).asFlatTuple();
const std::tuple<int&, int&, int&> vel = record(tag::Vel{}).asFlatTuple();
const std::tuple<int&, int&, int&, int&, int&, int&> name = record.asFlatTuple();
static_cast<void>(pos);
static_cast<void>(vel);
static_cast<void>(name);
}
{
const llama::One<ParticleInt> record;

std::tuple<const int&, const int&> pos = record(tag::Pos{}).asFlatTuple();
std::tuple<const int&, const int&, const int&> vel = record(tag::Vel{}).asFlatTuple();
std::tuple<const int&, const int&, const int&, const int&, const int&, const int&> name = record.asFlatTuple();
const std::tuple<const int&, const int&> pos = record(tag::Pos{}).asFlatTuple();
const std::tuple<const int&, const int&, const int&> vel = record(tag::Vel{}).asFlatTuple();
const std::tuple<const int&, const int&, const int&, const int&, const int&, const int&> name
= record.asFlatTuple();
static_cast<void>(pos);
static_cast<void>(vel);
static_cast<void>(name);
Expand Down Expand Up @@ -702,18 +704,18 @@ TEST_CASE("RecordRef.load.value")
record = 1;

{
MyPos<int> pos = record(tag::Pos{}).load();
const MyPos<int> pos = record(tag::Pos{}).load();
CHECK(pos.a == 1);
CHECK(pos.y == 1);
}
{
MyPos<int> pos = std::as_const(record)(tag::Pos{}).load();
const MyPos<int> pos = std::as_const(record)(tag::Pos{}).load();
CHECK(pos.a == 1);
CHECK(pos.y == 1);
}

{
MyStruct<int> d = record.load();
const MyStruct<int> d = record.load();
CHECK(d.pos.a == 1);
CHECK(d.pos.y == 1);
CHECK(d.vel.x == 1);
Expand All @@ -722,7 +724,7 @@ TEST_CASE("RecordRef.load.value")
CHECK(d.weight == 1);
}
{
MyStruct<int> d = std::as_const(record).load();
const MyStruct<int> d = std::as_const(record).load();
CHECK(d.pos.a == 1);
CHECK(d.pos.y == 1);
CHECK(d.vel.x == 1);
Expand Down Expand Up @@ -779,22 +781,22 @@ TEST_CASE("RecordRef.load.constref")
record = 1;

{
MyPos<const int&> pos = record(tag::Pos{}).load();
const MyPos<const int&> pos = record(tag::Pos{}).load();
CHECK(pos.a == 1);
CHECK(pos.y == 1);
}
{
MyPos<const int&> pos = std::as_const(record)(tag::Pos{}).load();
const MyPos<const int&> pos = std::as_const(record)(tag::Pos{}).load();
CHECK(pos.a == 1);
CHECK(pos.y == 1);
}
{
MyStruct<const int&> d = record.load();
const MyStruct<const int&> d = record.load();
CHECK(d.pos.a == 1);
CHECK(d.pos.y == 1);
}
{
MyStruct<const int&> d = std::as_const(record).load();
const MyStruct<const int&> d = std::as_const(record).load();
CHECK(d.pos.a == 1);
CHECK(d.pos.y == 1);
}
Expand All @@ -808,18 +810,18 @@ TEST_CASE("RecordRef.load.value.fromproxyref")
record = 1;

{
MyPos<int> pos = record(tag::Pos{}).load();
const MyPos<int> pos = record(tag::Pos{}).load();
CHECK(pos.a == 1);
CHECK(pos.y == 1);
}
{
MyPos<int> pos = std::as_const(record)(tag::Pos{}).load();
const MyPos<int> pos = std::as_const(record)(tag::Pos{}).load();
CHECK(pos.a == 1);
CHECK(pos.y == 1);
}

{
MyStruct<int> d = record.load();
const MyStruct<int> d = record.load();
CHECK(d.pos.a == 1);
CHECK(d.pos.y == 1);
CHECK(d.vel.x == 1);
Expand All @@ -828,7 +830,7 @@ TEST_CASE("RecordRef.load.value.fromproxyref")
CHECK(d.weight == 1);
}
{
MyStruct<int> d = std::as_const(record).load();
const MyStruct<int> d = std::as_const(record).load();
CHECK(d.pos.a == 1);
CHECK(d.pos.y == 1);
CHECK(d.vel.x == 1);
Expand All @@ -844,7 +846,7 @@ TEST_CASE("RecordRef.store")

record = 1;
{
MyPos<int> pos{2, 3};
const MyPos<int> pos{2, 3};
record(tag::Pos{}).store(pos);
CHECK(record(tag::Pos{}, tag::A{}) == 2);
CHECK(record(tag::Pos{}, tag::Y{}) == 3);
Expand All @@ -856,7 +858,7 @@ TEST_CASE("RecordRef.store")

record = 1;
{
MyStruct<int> d{{2, 3}, {4, 5, 6}, 7};
const MyStruct<int> d{{2, 3}, {4, 5, 6}, 7};
record.store(d);
CHECK(record(tag::Pos{}, tag::A{}) == 2);
CHECK(record(tag::Pos{}, tag::Y{}) == 3);
Expand All @@ -875,7 +877,7 @@ TEST_CASE("RecordRef.store.toproxyref")

record = 1;
{
MyPos<int> pos{2, 3};
const MyPos<int> pos{2, 3};
record(tag::Pos{}).store(pos);
CHECK(record(tag::Pos{}, tag::A{}) == 2);
CHECK(record(tag::Pos{}, tag::Y{}) == 3);
Expand All @@ -887,7 +889,7 @@ TEST_CASE("RecordRef.store.toproxyref")

record = 1;
{
MyStruct<int> d{{2, 3}, {4, 5, 6}, 7};
const MyStruct<int> d{{2, 3}, {4, 5, 6}, 7};
record.store(d);
CHECK(record(tag::Pos{}, tag::A{}) == 2);
CHECK(record(tag::Pos{}, tag::Y{}) == 3);
Expand Down
Loading

0 comments on commit 7aec5c9

Please sign in to comment.