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 16, 2022
1 parent 22bda67 commit a65d750
Show file tree
Hide file tree
Showing 22 changed files with 122 additions and 112 deletions.
8 changes: 4 additions & 4 deletions examples/raycast/raycast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ namespace
} // namespace

template<typename T>
struct std::tuple_size<Vector<T>>
struct std::tuple_size<Vector<T>> // NOLINT(cert-dcl58-cpp)
{
static constexpr auto value = 3;
};
Expand Down 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 include/llama/Array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,12 +274,12 @@ namespace llama
namespace std
{
template<typename T, size_t N>
struct tuple_size<llama::Array<T, N>> : integral_constant<size_t, N>
struct tuple_size<llama::Array<T, N>> : integral_constant<size_t, N> // NOLINT(cert-dcl58-cpp)
{
};

template<size_t I, typename T, size_t N>
struct tuple_element<I, llama::Array<T, N>>
struct tuple_element<I, llama::Array<T, N>> // NOLINT(cert-dcl58-cpp)
{
using type = T;
};
Expand Down
9 changes: 5 additions & 4 deletions include/llama/ArrayExtents.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ namespace llama
} // namespace llama

template<typename V, size_t N>
struct std::tuple_size<llama::ArrayIndex<V, N>> : std::integral_constant<size_t, N>
struct std::tuple_size<llama::ArrayIndex<V, N>> : std::integral_constant<size_t, N> // NOLINT(cert-dcl58-cpp)
{
};

template<size_t I, typename V, size_t N>
struct std::tuple_element<I, llama::ArrayIndex<V, N>>
struct std::tuple_element<I, llama::ArrayIndex<V, N>> // NOLINT(cert-dcl58-cpp)
{
using type = V;
};
Expand Down Expand Up @@ -254,12 +254,13 @@ namespace llama
} // namespace llama

template<typename SizeType, SizeType... Sizes>
struct std::tuple_size<llama::ArrayExtents<SizeType, Sizes...>> : std::integral_constant<std::size_t, sizeof...(Sizes)>
struct std::tuple_size<llama::ArrayExtents<SizeType, Sizes...>> // NOLINT(cert-dcl58-cpp)
: std::integral_constant<std::size_t, sizeof...(Sizes)>
{
};

template<typename SizeType, std::size_t I, SizeType... Sizes>
struct std::tuple_element<I, llama::ArrayExtents<SizeType, Sizes...>>
struct std::tuple_element<I, llama::ArrayExtents<SizeType, Sizes...>> // NOLINT(cert-dcl58-cpp)
{
using type = SizeType;
};
4 changes: 2 additions & 2 deletions include/llama/Core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<mp_transform<mp_identity, TypeList>>([&](auto e) constexpr {
using T = typename decltype(e)::type;
if constexpr(Align)
Expand Down Expand Up @@ -516,7 +516,7 @@ namespace llama
return 0;
else
{
std::size_t offset
std::size_t offset // NOLINT(misc-const-correctness)
= flatOffsetOf<TypeList, I - 1, Align> + sizeof(boost::mp11::mp_at_c<TypeList, I - 1>);
if constexpr(Align)
offset = roundUpToMultiple(offset, alignof(boost::mp11::mp_at_c<TypeList, I>));
Expand Down
2 changes: 1 addition & 1 deletion include/llama/RecordCoord.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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--)
Expand Down
6 changes: 3 additions & 3 deletions include/llama/RecordRef.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -986,19 +986,19 @@ namespace llama
} // namespace llama

template<typename View, typename BoundRecordCoord, bool OwnView>
struct std::tuple_size<llama::RecordRef<View, BoundRecordCoord, OwnView>>
struct std::tuple_size<llama::RecordRef<View, BoundRecordCoord, OwnView>> // NOLINT(cert-dcl58-cpp)
: boost::mp11::mp_size<typename llama::RecordRef<View, BoundRecordCoord, OwnView>::AccessibleRecordDim>
{
};

template<std::size_t I, typename View, typename BoundRecordCoord, bool OwnView>
struct std::tuple_element<I, llama::RecordRef<View, BoundRecordCoord, OwnView>>
struct std::tuple_element<I, llama::RecordRef<View, BoundRecordCoord, OwnView>> // NOLINT(cert-dcl58-cpp)
{
using type = decltype(std::declval<llama::RecordRef<View, BoundRecordCoord, OwnView>>().template get<I>());
};

template<std::size_t I, typename View, typename BoundRecordCoord, bool OwnView>
struct std::tuple_element<I, const llama::RecordRef<View, BoundRecordCoord, OwnView>>
struct std::tuple_element<I, const llama::RecordRef<View, BoundRecordCoord, OwnView>> // NOLINT(cert-dcl58-cpp)
{
using type = decltype(std::declval<const llama::RecordRef<View, BoundRecordCoord, OwnView>>().template get<I>());
};
Expand Down
2 changes: 1 addition & 1 deletion include/llama/StructName.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ namespace llama
inline constexpr auto qualifiedTypeName = []
{
constexpr auto& value = internal::typeNameStorage<T>;
return std::string_view{&value[0], value.size()};
return std::string_view{value.data(), value.size()};
}();

namespace internal
Expand Down
4 changes: 2 additions & 2 deletions include/llama/Tuple.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,13 @@ namespace llama
} // namespace llama

template<typename... Elements>
struct std::tuple_size<llama::Tuple<Elements...>>
struct std::tuple_size<llama::Tuple<Elements...>> // NOLINT(cert-dcl58-cpp)
{
static constexpr auto value = sizeof...(Elements);
};

template<std::size_t I, typename... Elements>
struct std::tuple_element<I, llama::Tuple<Elements...>>
struct std::tuple_element<I, llama::Tuple<Elements...>> // NOLINT(cert-dcl58-cpp)
{
using type = boost::mp11::mp_at_c<llama::Tuple<Elements...>, I>;
};
Expand Down
3 changes: 3 additions & 0 deletions include/llama/llama.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion include/llama/mapping/tree/TreeFromDimensions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ namespace llama::mapping::tree
static_cast<std::size_t>(size[N - 1])}; // FIXME(bgruber): propagate index type
else
{
Tuple inner{createTree<RecordDim, V, N, Pos + 1>(size)};
Tuple inner{createTree<RecordDim, V, N, Pos + 1>(size)}; // NOLINT(misc-const-correctness)
return Node<NoName, decltype(inner)>{
static_cast<std::size_t>(size[Pos]),
inner}; // FIXME(bgruber): propagate index type
Expand Down
2 changes: 1 addition & 1 deletion tests/array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
25 changes: 13 additions & 12 deletions tests/arrayextents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<decltype(ad0), llama::ArrayExtents<std::size_t>>);
STATIC_REQUIRE(std::is_same_v<decltype(ad1), llama::ArrayExtents<TestType, llama::dyn>>);
STATIC_REQUIRE(std::is_same_v<decltype(ad2), llama::ArrayExtents<TestType, llama::dyn, llama::dyn>>);
STATIC_REQUIRE(std::is_same_v<decltype(ad3), llama::ArrayExtents<TestType, llama::dyn, llama::dyn, llama::dyn>>);
[[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), const llama::ArrayExtents<std::size_t>>);
STATIC_REQUIRE(std::is_same_v<decltype(ad1), const llama::ArrayExtents<TestType, llama::dyn>>);
STATIC_REQUIRE(std::is_same_v<decltype(ad2), const llama::ArrayExtents<TestType, llama::dyn, llama::dyn>>);
STATIC_REQUIRE(
std::is_same_v<decltype(ad3), const llama::ArrayExtents<TestType, llama::dyn, llama::dyn, llama::dyn>>);

STATIC_REQUIRE(decltype(ad0)::rank == 0);
STATIC_REQUIRE(decltype(ad1)::rank == 1);
Expand Down Expand Up @@ -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<llama::ArrayIndex<TestType, 1>> indices;
llama::forEachADCoord(extents, [&](llama::ArrayIndex<TestType, 1> ai) { indices.push_back(ai); });
Expand All @@ -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<llama::ArrayIndex<TestType, 2>> indices;
llama::forEachADCoord(extents, [&](llama::ArrayIndex<TestType, 2> ai) { indices.push_back(ai); });
Expand All @@ -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<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
2 changes: 1 addition & 1 deletion tests/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

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
Loading

0 comments on commit a65d750

Please sign in to comment.