[libcxx-commits] [libcxx] 8cf5319 - [libc++][test] Use = delete over DELETE_FUNCTION. NFC.
Joe Loser via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Oct 5 11:09:34 PDT 2021
Author: Joe Loser
Date: 2021-10-05T14:08:48-04:00
New Revision: 8cf5319affc2441c2901908140c14f7153078199
URL: https://github.com/llvm/llvm-project/commit/8cf5319affc2441c2901908140c14f7153078199
DIFF: https://github.com/llvm/llvm-project/commit/8cf5319affc2441c2901908140c14f7153078199.diff
LOG: [libc++][test] Use = delete over DELETE_FUNCTION. NFC.
Some tests repeat the definition of `DELETE_FUNCTION` macro locally.
However, it's not even requred to guard against in the C++03 case since
Clang supports `= delete;` in C++03 mode. A warning is issued but
`libc++` tests run with `-Wno-c++11-extensions`, so this isn't an issue.
Since we don't support other compilers in C++03 mode, `= delete;` is
always available for use. As such, inline all calls of `DELETE_FUNCTION`
to use `= delete;`.
Reviewed By: ldionne, #libc
Differential Revision: https://reviews.llvm.org/D111148
Added:
Modified:
libcxx/test/libcxx/iterators/contiguous_iterators.pass.cpp
libcxx/test/std/utilities/memory/storage.iterator/raw_storage_iterator.pass.cpp
libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.pass.cpp
libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp
libcxx/test/support/test_allocator.h
libcxx/test/support/test_iterators.h
Removed:
################################################################################
diff --git a/libcxx/test/libcxx/iterators/contiguous_iterators.pass.cpp b/libcxx/test/libcxx/iterators/contiguous_iterators.pass.cpp
index 8899ffcd35624..71407bac49f03 100644
--- a/libcxx/test/libcxx/iterators/contiguous_iterators.pass.cpp
+++ b/libcxx/test/libcxx/iterators/contiguous_iterators.pass.cpp
@@ -35,12 +35,6 @@
#include <span>
#endif
-#if TEST_STD_VER >= 11
-#define DELETE_FUNCTION = delete
-#else
-#define DELETE_FUNCTION
-#endif
-
class T; // incomplete
class my_input_iterator
diff --git a/libcxx/test/std/utilities/memory/storage.iterator/raw_storage_iterator.pass.cpp b/libcxx/test/std/utilities/memory/storage.iterator/raw_storage_iterator.pass.cpp
index 33e416bb64f82..4fbbbb1e54c21 100644
--- a/libcxx/test/std/utilities/memory/storage.iterator/raw_storage_iterator.pass.cpp
+++ b/libcxx/test/std/utilities/memory/storage.iterator/raw_storage_iterator.pass.cpp
@@ -18,12 +18,6 @@
#include "test_macros.h"
#include <MoveOnly.h>
-#if TEST_STD_VER >= 11
-#define DELETE_FUNCTION = delete
-#else
-#define DELETE_FUNCTION
-#endif
-
int A_constructed = 0;
struct A
@@ -36,7 +30,7 @@ struct A
~A() {--A_constructed; data_ = 0;}
bool operator==(int i) const {return data_ == i;}
- A* operator& () DELETE_FUNCTION;
+ A* operator& () = delete;
};
int main(int, char**)
diff --git a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.pass.cpp b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.pass.cpp
index f7a96d8d24d04..b892fb4fd9b15 100644
--- a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.pass.cpp
+++ b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.pass.cpp
@@ -21,12 +21,6 @@
#include "test_allocator.h"
#include "min_allocator.h"
-#if TEST_STD_VER >= 11
-#define DELETE_FUNCTION = delete
-#else
-#define DELETE_FUNCTION
-#endif
-
int new_count = 0;
struct A
@@ -42,7 +36,7 @@ struct A
int get_int() const {return int_;}
char get_char() const {return char_;}
- A* operator& () DELETE_FUNCTION;
+ A* operator& () = delete;
private:
int int_;
char char_;
diff --git a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp
index e29ae08ce423e..e835b6263efac 100644
--- a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp
+++ b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp
@@ -18,12 +18,6 @@
#include "test_macros.h"
#include "count_new.h"
-#if TEST_STD_VER >= 11
-#define DELETE_FUNCTION = delete
-#else
-#define DELETE_FUNCTION
-#endif
-
struct A
{
static int count;
@@ -37,7 +31,7 @@ struct A
int get_int() const {return int_;}
char get_char() const {return char_;}
- A* operator& () DELETE_FUNCTION;
+ A* operator& () = delete;
private:
int int_;
diff --git a/libcxx/test/support/test_allocator.h b/libcxx/test/support/test_allocator.h
index 5b6fac64ee389..79f24f9043c26 100644
--- a/libcxx/test/support/test_allocator.h
+++ b/libcxx/test/support/test_allocator.h
@@ -419,10 +419,8 @@ class limited_allocator
explicit limited_allocator(limited_allocator<U, N> const& other)
: handle_(other.handle_) {}
-private:
- limited_allocator& operator=(const limited_allocator&);// = delete;
+ limited_allocator& operator=(const limited_allocator&) = delete;
-public:
pointer allocate(size_type n) { return handle_->template allocate<T>(n); }
void deallocate(pointer p, size_type n) { handle_->deallocate(p, n); }
size_type max_size() const {return N;}
diff --git a/libcxx/test/support/test_iterators.h b/libcxx/test/support/test_iterators.h
index e59e6d8dbb07c..f0e83b46aa635 100644
--- a/libcxx/test/support/test_iterators.h
+++ b/libcxx/test/support/test_iterators.h
@@ -16,12 +16,6 @@
#include "test_macros.h"
-#if TEST_STD_VER >= 11
-#define DELETE_FUNCTION = delete
-#else
-#define DELETE_FUNCTION
-#endif
-
template <class It>
class output_iterator
{
@@ -49,7 +43,7 @@ class output_iterator
{output_iterator tmp(*this); ++(*this); return tmp;}
template <class T>
- void operator,(T const &) DELETE_FUNCTION;
+ void operator,(T const &) = delete;
};
// This is the Cpp17InputIterator requirement as described in Table 87 ([input.iterators]),
@@ -88,7 +82,7 @@ class cpp17_input_iterator
{return !(x == y);}
template <class T>
- void operator,(T const &) DELETE_FUNCTION;
+ void operator,(T const &) = delete;
};
template <class T, class TV, class U, class UV>
@@ -136,7 +130,7 @@ class forward_iterator
{return !(x == y);}
template <class T>
- void operator,(T const &) DELETE_FUNCTION;
+ void operator,(T const &) = delete;
};
template <class T, class U>
@@ -187,7 +181,7 @@ class non_default_constructible_iterator
{return !(x == y);}
template <class T>
- void operator,(T const &) DELETE_FUNCTION;
+ void operator,(T const &) = delete;
};
template <class T, class U>
@@ -236,7 +230,7 @@ class bidirectional_iterator
{bidirectional_iterator tmp(*this); --(*this); return tmp;}
template <class T>
- void operator,(T const &) DELETE_FUNCTION;
+ void operator,(T const &) = delete;
};
template <class T, class U>
@@ -296,7 +290,7 @@ class random_access_iterator
TEST_CONSTEXPR_CXX14 reference operator[](
diff erence_type n) const {return it_[n];}
template <class T>
- void operator,(T const &) DELETE_FUNCTION;
+ void operator,(T const &) = delete;
};
template <class T, class U>
@@ -426,7 +420,7 @@ class contiguous_iterator
}
template <class T>
- void operator,(T const &) DELETE_FUNCTION;
+ void operator,(T const &) = delete;
};
#endif
@@ -553,7 +547,7 @@ struct ThrowingIterator {
}
template <class T2>
- void operator,(T2 const &) DELETE_FUNCTION;
+ void operator,(T2 const &) = delete;
private:
const T* begin_;
@@ -624,7 +618,7 @@ struct NonThrowingIterator {
}
template <class T2>
- void operator,(T2 const &) DELETE_FUNCTION;
+ void operator,(T2 const &) = delete;
private:
const T *begin_;
@@ -664,7 +658,7 @@ struct cpp20_input_iterator {
constexpr I base() && { return std::move(base_); }
template <class T>
- void operator,(T const &) DELETE_FUNCTION;
+ void operator,(T const &) = delete;
private:
I base_ = I();
@@ -853,7 +847,7 @@ class stride_counting_iterator {
}
template <class T>
- void operator,(T const &) DELETE_FUNCTION;
+ void operator,(T const &) = delete;
private:
I base_;
@@ -932,7 +926,7 @@ class three_way_contiguous_iterator
constexpr reference operator[](
diff erence_type n) const {return it_[n];}
template <class T>
- void operator,(T const &) DELETE_FUNCTION;
+ void operator,(T const &) = delete;
friend constexpr
diff erence_type operator-(const three_way_contiguous_iterator& x, const three_way_contiguous_iterator& y) {
@@ -944,6 +938,4 @@ class three_way_contiguous_iterator
#endif // TEST_STD_VER > 17 && defined(__cpp_lib_concepts)
-#undef DELETE_FUNCTION
-
#endif // SUPPORT_TEST_ITERATORS_H
More information about the libcxx-commits
mailing list