From 6e3bc74cc4b71c05957a3d14cfe350c00064d382 Mon Sep 17 00:00:00 2001 From: Henri Chataing Date: Wed, 10 Aug 2022 20:09:28 +0000 Subject: [PATCH] all: Pass clang-tidy modernize-unary-static-assert check Change-Id: If8c3e0d150c85713264fccbe6d2aca906b85bd18 Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/56924 Commit-Queue: Henri Chataing Reviewed-by: Wyatt Hepler --- .clang-tidy | 4 +--- pw_kvs/converts_to_span_test.cc | 20 ++++++++++---------- pw_result/statusor_test.cc | 6 +++--- pw_span/span_test.cc | 4 ++++ 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 5cdeb1223..1e43e0768 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -38,6 +38,7 @@ Checks: > modernize-replace-disallow-copy-and-assign-macro, modernize-replace-random-shuffle, modernize-shrink-to-fit, + modernize-unary-static-assert, modernize-use-bool-literals, modernize-use-equals-delete, modernize-use-noexcept, @@ -88,9 +89,6 @@ HeaderFilterRegex: '.*' # Note: added in c++11 # @ modernize-redundant-void-arg: # modernize-return-braced-init-list: -# @ modernize-unary-static-assert: -# Note: added in c++17 -# The message argument can be omitted when it is empty # @ modernize-use-auto: # Advises to use auto when initializing with a cast to # avoid duplicating the type name diff --git a/pw_kvs/converts_to_span_test.cc b/pw_kvs/converts_to_span_test.cc index 898e21d1d..0b83e9d8c 100644 --- a/pw_kvs/converts_to_span_test.cc +++ b/pw_kvs/converts_to_span_test.cc @@ -111,7 +111,7 @@ TEST(SpanTest, MakeSpanFromDataAndSize) { auto made_span = make_span(vector.data(), vector.size()); EXPECT_EQ(expected_span.data(), made_span.data()); EXPECT_EQ(expected_span.size(), made_span.size()); - static_assert(decltype(made_span)::extent == dynamic_extent, ""); + static_assert(decltype(made_span)::extent == dynamic_extent); static_assert( std::is_same::value, "the type of made_span differs from expected_span!"); @@ -127,7 +127,7 @@ TEST(SpanTest, MakeSpanFromPointerPair) { auto made_span = make_span(vector.data(), vector.data() + vector.size()); EXPECT_EQ(expected_span.data(), made_span.data()); EXPECT_EQ(expected_span.size(), made_span.size()); - static_assert(decltype(made_span)::extent == dynamic_extent, ""); + static_assert(decltype(made_span)::extent == dynamic_extent); static_assert( std::is_same::value, "the type of made_span differs from expected_span!"); @@ -139,7 +139,7 @@ TEST(SpanTest, MakeSpanFromConstexprArray) { constexpr auto made_span = make_span(kArray); EXPECT_EQ(expected_span.data(), made_span.data()); EXPECT_EQ(expected_span.size(), made_span.size()); - static_assert(decltype(made_span)::extent == 5, ""); + static_assert(decltype(made_span)::extent == 5); static_assert( std::is_same::value, "the type of made_span differs from expected_span!"); @@ -151,7 +151,7 @@ TEST(SpanTest, MakeSpanFromStdArray) { auto made_span = make_span(kArray); EXPECT_EQ(expected_span.data(), made_span.data()); EXPECT_EQ(expected_span.size(), made_span.size()); - static_assert(decltype(made_span)::extent == 5, ""); + static_assert(decltype(made_span)::extent == 5); static_assert( std::is_same::value, "the type of made_span differs from expected_span!"); @@ -163,7 +163,7 @@ TEST(SpanTest, MakeSpanFromConstContainer) { auto made_span = make_span(vector); EXPECT_EQ(expected_span.data(), made_span.data()); EXPECT_EQ(expected_span.size(), made_span.size()); - static_assert(decltype(made_span)::extent == dynamic_extent, ""); + static_assert(decltype(made_span)::extent == dynamic_extent); static_assert( std::is_same::value, "the type of made_span differs from expected_span!"); @@ -177,7 +177,7 @@ TEST(SpanTest, MakeStaticSpanFromConstContainer) { auto made_span = make_span<5>(vector); EXPECT_EQ(expected_span.data(), made_span.data()); EXPECT_EQ(expected_span.size(), made_span.size()); - static_assert(decltype(made_span)::extent == 5, ""); + static_assert(decltype(made_span)::extent == 5); static_assert( std::is_same::value, "the type of made_span differs from expected_span!"); @@ -191,7 +191,7 @@ TEST(SpanTest, MakeSpanFromContainer) { auto made_span = make_span(vector); EXPECT_EQ(expected_span.data(), made_span.data()); EXPECT_EQ(expected_span.size(), made_span.size()); - static_assert(decltype(made_span)::extent == dynamic_extent, ""); + static_assert(decltype(made_span)::extent == dynamic_extent); static_assert( std::is_same::value, "the type of made_span differs from expected_span!"); @@ -205,7 +205,7 @@ TEST(SpanTest, MakeStaticSpanFromContainer) { auto made_span = make_span<5>(vector); EXPECT_EQ(expected_span.data(), make_span<5>(vector).data()); EXPECT_EQ(expected_span.size(), make_span<5>(vector).size()); - static_assert(decltype(make_span<5>(vector))::extent == 5, ""); + static_assert(decltype(make_span<5>(vector))::extent == 5); static_assert( std::is_same::value, "the type of made_span differs from expected_span!"); @@ -235,7 +235,7 @@ TEST(SpanTest, MakeSpanFromRValueContainer) { auto made_span = make_span(static_cast&&>(vector)); EXPECT_EQ(expected_span.data(), made_span.data()); EXPECT_EQ(expected_span.size(), made_span.size()); - static_assert(decltype(made_span)::extent == dynamic_extent, ""); + static_assert(decltype(made_span)::extent == dynamic_extent); static_assert( std::is_same::value, "the type of made_span differs from expected_span!"); @@ -253,7 +253,7 @@ TEST(SpanTest, MakeStaticSpanFromRValueContainer) { auto made_span = make_span<5>(static_cast&&>(vector)); EXPECT_EQ(expected_span.data(), made_span.data()); EXPECT_EQ(expected_span.size(), made_span.size()); - static_assert(decltype(made_span)::extent == 5, ""); + static_assert(decltype(made_span)::extent == 5); static_assert( std::is_same::value, "the type of made_span differs from expected_span!"); diff --git a/pw_result/statusor_test.cc b/pw_result/statusor_test.cc index 521994542..9f332b712 100644 --- a/pw_result/statusor_test.cc +++ b/pw_result/statusor_test.cc @@ -120,8 +120,8 @@ pw::Result> ReturnUniquePtr() { } TEST(Result, ElementType) { - static_assert(std::is_same::value_type, int>(), ""); - static_assert(std::is_same::value_type, char>(), ""); + static_assert(std::is_same::value_type, int>()); + static_assert(std::is_same::value_type, char>()); } TEST(Result, TestMoveOnlyInitialization) { @@ -1345,7 +1345,7 @@ TEST(Result, TestPointerValueConst) { TEST(Result, ResultVectorOfUniquePointerCanReserveAndResize) { using EvilType = std::vector>; - static_assert(std::is_copy_constructible::value, ""); + static_assert(std::is_copy_constructible::value); std::vector<::pw::Result> v(5); v.reserve(v.capacity() + 10); v.resize(v.capacity() + 10); diff --git a/pw_span/span_test.cc b/pw_span/span_test.cc index 5b9ea689d..11353b8c4 100644 --- a/pw_span/span_test.cc +++ b/pw_span/span_test.cc @@ -21,6 +21,8 @@ // In order to minimize changes from the original, this file does NOT fully // adhere to Pigweed's style guide. +// NOLINTBEGIN(modernize-unary-static-assert) + #ifndef PW_SPAN_TEST_INCLUDE #error "The PW_SPAN_TEST_INCLUDE macro must be defined to compile this test." #endif // PW_SPAN_TEST_INCLUDE @@ -1653,4 +1655,6 @@ TEST(SpanTest, IteratorConversions) { "Error: const iterator should not be convertible to iterator"); } +// NOLINTEND(modernize-unary-static-assert) + } // namespace PW_SPAN_TEST_NAMESPACE