[libcxx-commits] [libcxx] 10ef00f - [libc++][NFC] Run clang-format on test_allocator.h
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Dec 9 08:47:27 PST 2024
Author: Louis Dionne
Date: 2024-12-09T11:47:14-05:00
New Revision: 10ef00faf1964716c2c91a26ddaa14b55dc95b0b
URL: https://github.com/llvm/llvm-project/commit/10ef00faf1964716c2c91a26ddaa14b55dc95b0b
DIFF: https://github.com/llvm/llvm-project/commit/10ef00faf1964716c2c91a26ddaa14b55dc95b0b.diff
LOG: [libc++][NFC] Run clang-format on test_allocator.h
Added:
Modified:
libcxx/test/support/test_allocator.h
Removed:
################################################################################
diff --git a/libcxx/test/support/test_allocator.h b/libcxx/test/support/test_allocator.h
index dcd15332ca304f..cf6952fcd788e6 100644
--- a/libcxx/test/support/test_allocator.h
+++ b/libcxx/test/support/test_allocator.h
@@ -27,45 +27,45 @@ TEST_CONSTEXPR_CXX20 inline typename std::allocator_traits<Alloc>::size_type all
}
struct test_allocator_statistics {
- int time_to_throw = 0;
- int throw_after = INT_MAX;
+ int time_to_throw = 0;
+ int throw_after = INT_MAX;
int count = 0; // the number of active instances
int alloc_count = 0; // the number of allocations not deallocating
int allocated_size = 0; // the size of allocated elements
int construct_count = 0; // the number of times that ::construct was called
- int destroy_count = 0; // the number of times that ::destroy was called
- int copied = 0;
- int moved = 0;
- int converted = 0;
+ int destroy_count = 0; // the number of times that ::destroy was called
+ int copied = 0;
+ int moved = 0;
+ int converted = 0;
TEST_CONSTEXPR_CXX14 void clear() {
assert(count == 0 && "clearing leaking allocator data?");
- count = 0;
- time_to_throw = 0;
- alloc_count = 0;
+ count = 0;
+ time_to_throw = 0;
+ alloc_count = 0;
allocated_size = 0;
construct_count = 0;
- destroy_count = 0;
- throw_after = INT_MAX;
+ destroy_count = 0;
+ throw_after = INT_MAX;
clear_ctor_counters();
}
TEST_CONSTEXPR_CXX14 void clear_ctor_counters() {
- copied = 0;
- moved = 0;
+ copied = 0;
+ moved = 0;
converted = 0;
}
};
struct test_alloc_base {
TEST_CONSTEXPR static const int destructed_value = -1;
- TEST_CONSTEXPR static const int moved_value = INT_MAX;
+ TEST_CONSTEXPR static const int moved_value = INT_MAX;
};
template <class T>
class test_allocator {
- int data_ = 0; // participates in equality
- int id_ = 0; // unique identifier, doesn't participate in equality
+ int data_ = 0; // participates in equality
+ int id_ = 0; // unique identifier, doesn't participate in equality
test_allocator_statistics* stats_ = nullptr;
template <class U>
@@ -95,7 +95,8 @@ class test_allocator {
TEST_CONSTEXPR explicit test_allocator(int data) TEST_NOEXCEPT : data_(data) {}
TEST_CONSTEXPR_CXX14 explicit test_allocator(int data, test_allocator_statistics* stats) TEST_NOEXCEPT
- : data_(data), stats_(stats) {
+ : data_(data),
+ stats_(stats) {
if (stats != nullptr)
++stats_->count;
}
@@ -103,13 +104,17 @@ class test_allocator {
TEST_CONSTEXPR explicit test_allocator(int data, int id) TEST_NOEXCEPT : data_(data), id_(id) {}
TEST_CONSTEXPR_CXX14 explicit test_allocator(int data, int id, test_allocator_statistics* stats) TEST_NOEXCEPT
- : data_(data), id_(id), stats_(stats) {
+ : data_(data),
+ id_(id),
+ stats_(stats) {
if (stats_ != nullptr)
++stats_->count;
}
TEST_CONSTEXPR_CXX14 test_allocator(const test_allocator& a) TEST_NOEXCEPT
- : data_(a.data_), id_(a.id_), stats_(a.stats_) {
+ : data_(a.data_),
+ id_(a.id_),
+ stats_(a.stats_) {
assert(a.data_ != test_alloc_base::destructed_value && a.id_ != test_alloc_base::destructed_value &&
"copying from destroyed allocator");
if (stats_ != nullptr) {
@@ -130,7 +135,9 @@ class test_allocator {
template <class U>
TEST_CONSTEXPR_CXX14 test_allocator(const test_allocator<U>& a) TEST_NOEXCEPT
- : data_(a.data_), id_(a.id_), stats_(a.stats_) {
+ : data_(a.data_),
+ id_(a.id_),
+ stats_(a.stats_) {
if (stats_ != nullptr) {
++stats_->count;
++stats_->converted;
@@ -143,7 +150,7 @@ class test_allocator {
if (stats_ != nullptr)
--stats_->count;
data_ = test_alloc_base::destructed_value;
- id_ = test_alloc_base::destructed_value;
+ id_ = test_alloc_base::destructed_value;
}
TEST_CONSTEXPR pointer address(reference x) const { return &x; }
@@ -197,8 +204,8 @@ class test_allocator {
template <>
class test_allocator<void> {
- int data_ = 0;
- int id_ = 0;
+ int data_ = 0;
+ int id_ = 0;
test_allocator_statistics* stats_ = nullptr;
template <class U>
@@ -223,27 +230,30 @@ class test_allocator<void> {
TEST_CONSTEXPR explicit test_allocator(int data) TEST_NOEXCEPT : data_(data) {}
TEST_CONSTEXPR explicit test_allocator(int data, test_allocator_statistics* stats) TEST_NOEXCEPT
- : data_(data), stats_(stats)
- {}
+ : data_(data),
+ stats_(stats) {}
TEST_CONSTEXPR explicit test_allocator(int data, int id) : data_(data), id_(id) {}
TEST_CONSTEXPR_CXX14 explicit test_allocator(int data, int id, test_allocator_statistics* stats) TEST_NOEXCEPT
- : data_(data), id_(id), stats_(stats)
- {}
+ : data_(data),
+ id_(id),
+ stats_(stats) {}
TEST_CONSTEXPR_CXX14 explicit test_allocator(const test_allocator& a) TEST_NOEXCEPT
- : data_(a.data_), id_(a.id_), stats_(a.stats_)
- {}
+ : data_(a.data_),
+ id_(a.id_),
+ stats_(a.stats_) {}
template <class U>
TEST_CONSTEXPR_CXX14 test_allocator(const test_allocator<U>& a) TEST_NOEXCEPT
- : data_(a.data_), id_(a.id_), stats_(a.stats_)
- {}
+ : data_(a.data_),
+ id_(a.id_),
+ stats_(a.stats_) {}
TEST_CONSTEXPR_CXX20 ~test_allocator() TEST_NOEXCEPT {
data_ = test_alloc_base::destructed_value;
- id_ = test_alloc_base::destructed_value;
+ id_ = test_alloc_base::destructed_value;
}
TEST_CONSTEXPR int get_id() const { return id_; }
@@ -310,9 +320,9 @@ struct Tag_X {
TEST_CONSTEXPR Tag_X(Ctor_Tag, Args&&...) {}
// not DefaultConstructible, CopyConstructible or MoveConstructible.
- Tag_X() = delete;
+ Tag_X() = delete;
Tag_X(const Tag_X&) = delete;
- Tag_X(Tag_X&&) = delete;
+ Tag_X(Tag_X&&) = delete;
// CopyAssignable.
TEST_CONSTEXPR_CXX14 Tag_X& operator=(const Tag_X&) { return *this; };
@@ -329,7 +339,7 @@ struct Tag_X {
template <typename T>
class TaggingAllocator {
public:
- using value_type = T;
+ using value_type = T;
TaggingAllocator() = default;
template <typename U>
@@ -356,13 +366,13 @@ class TaggingAllocator {
template <std::size_t MaxAllocs>
struct limited_alloc_handle {
std::size_t outstanding_ = 0;
- void* last_alloc_ = nullptr;
+ void* last_alloc_ = nullptr;
template <class T>
TEST_CONSTEXPR_CXX20 T* allocate(std::size_t N) {
if (N + outstanding_ > MaxAllocs)
TEST_THROW(std::bad_alloc());
- auto alloc = std::allocator<T>().allocate(N);
+ auto alloc = std::allocator<T>().allocate(N);
last_alloc_ = alloc;
outstanding_ += N;
return alloc;
More information about the libcxx-commits
mailing list