[libcxx-commits] [PATCH] D131364: [libc++][test] Mark `test_comparisons.h` helpers as nodiscard
Adrian Vogelsgesang via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Aug 11 16:18:24 PDT 2022
avogelsgesang updated this revision to Diff 452029.
avogelsgesang added a comment.
use TEST_NODISCARD instead of _LIBCPP_NODISCARD
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D131364/new/
https://reviews.llvm.org/D131364
Files:
libcxx/test/support/test_comparisons.h
libcxx/test/support/test_macros.h
Index: libcxx/test/support/test_macros.h
===================================================================
--- libcxx/test/support/test_macros.h
+++ libcxx/test/support/test_macros.h
@@ -235,6 +235,12 @@
#define LIBCPP_ONLY(...) static_assert(true, "")
#endif
+#if __has_cpp_attribute(nodiscard)
+# define TEST_NODISCARD [[nodiscard]]
+#else
+# define TEST_NODISCARD
+#endif
+
#define TEST_IGNORE_NODISCARD (void)
namespace test_macros_detail {
Index: libcxx/test/support/test_comparisons.h
===================================================================
--- libcxx/test/support/test_comparisons.h
+++ libcxx/test/support/test_comparisons.h
@@ -30,7 +30,7 @@
// Test all six comparison operations for sanity
template <class T, class U = T>
-TEST_CONSTEXPR_CXX14 bool testComparisons(const T& t1, const U& t2, bool isEqual, bool isLess)
+TEST_NODISCARD TEST_CONSTEXPR_CXX14 bool testComparisons(const T& t1, const U& t2, bool isEqual, bool isLess)
{
assert(!(isEqual && isLess) && "isEqual and isLess cannot be both true");
if (isEqual)
@@ -84,7 +84,7 @@
// Easy call when you can init from something already comparable.
template <class T, class Param>
-TEST_CONSTEXPR_CXX14 bool testComparisonsValues(Param val1, Param val2)
+TEST_NODISCARD TEST_CONSTEXPR_CXX14 bool testComparisonsValues(Param val1, Param val2)
{
const bool isEqual = val1 == val2;
const bool isLess = val1 < val2;
@@ -137,7 +137,7 @@
}
template <class Order, class T, class U = T>
-constexpr bool testOrder(const T& t1, const U& t2, Order order) {
+TEST_NODISCARD constexpr bool testOrder(const T& t1, const U& t2, Order order) {
bool equal = order == Order::equivalent;
bool less = order == Order::less;
@@ -145,7 +145,7 @@
}
template <class T, class Param>
-constexpr bool testOrderValues(Param val1, Param val2) {
+TEST_NODISCARD constexpr bool testOrderValues(Param val1, Param val2) {
return testOrder(T(val1), T(val2), val1 <=> val2);
}
@@ -153,7 +153,7 @@
// Test all two comparison operations for sanity
template <class T, class U = T>
-TEST_CONSTEXPR_CXX14 bool testEquality(const T& t1, const U& t2, bool isEqual)
+TEST_NODISCARD TEST_CONSTEXPR_CXX14 bool testEquality(const T& t1, const U& t2, bool isEqual)
{
if (isEqual)
{
@@ -175,7 +175,7 @@
// Easy call when you can init from something already comparable.
template <class T, class Param>
-TEST_CONSTEXPR_CXX14 bool testEqualityValues(Param val1, Param val2)
+TEST_NODISCARD TEST_CONSTEXPR_CXX14 bool testEqualityValues(Param val1, Param val2)
{
const bool isEqual = val1 == val2;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131364.452029.patch
Type: text/x-patch
Size: 2624 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220811/189b2c5c/attachment.bin>
More information about the libcxx-commits
mailing list