| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| //===-- Implementation of stdc_trailing_ones_uc ---------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/stdbit/stdc_trailing_ones_uc.h" | ||
|
|
||
| #include "src/__support/CPP/bit.h" | ||
| #include "src/__support/common.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(unsigned, stdc_trailing_ones_uc, (unsigned char value)) { | ||
| return static_cast<unsigned>(cpp::countr_one(value)); | ||
| } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| //===-- Implementation header for stdc_trailing_ones_uc --------*- C++ -*-===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #ifndef LLVM_LIBC_SRC_STDBIT_STDC_TRAILING_ONES_UC_H | ||
| #define LLVM_LIBC_SRC_STDBIT_STDC_TRAILING_ONES_UC_H | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| unsigned stdc_trailing_ones_uc(unsigned char value); | ||
|
|
||
| } // namespace LIBC_NAMESPACE | ||
|
|
||
| #endif // LLVM_LIBC_SRC_STDBIT_STDC_TRAILING_ONES_UC_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| //===-- Implementation of stdc_trailing_ones_ui ---------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/stdbit/stdc_trailing_ones_ui.h" | ||
|
|
||
| #include "src/__support/CPP/bit.h" | ||
| #include "src/__support/common.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(unsigned, stdc_trailing_ones_ui, (unsigned value)) { | ||
| return static_cast<unsigned>(cpp::countr_one(value)); | ||
| } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| //===-- Implementation header for stdc_trailing_ones_ui --------*- C++ -*-===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #ifndef LLVM_LIBC_SRC_STDBIT_STDC_TRAILING_ONES_UI_H | ||
| #define LLVM_LIBC_SRC_STDBIT_STDC_TRAILING_ONES_UI_H | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| unsigned stdc_trailing_ones_ui(unsigned value); | ||
|
|
||
| } // namespace LIBC_NAMESPACE | ||
|
|
||
| #endif // LLVM_LIBC_SRC_STDBIT_STDC_TRAILING_ONES_UI_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| //===-- Implementation of stdc_trailing_ones_ul ---------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/stdbit/stdc_trailing_ones_ul.h" | ||
|
|
||
| #include "src/__support/CPP/bit.h" | ||
| #include "src/__support/common.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(unsigned, stdc_trailing_ones_ul, (unsigned long value)) { | ||
| return static_cast<unsigned>(cpp::countr_one(value)); | ||
| } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| //===-- Implementation header for stdc_trailing_ones_ul --------*- C++ -*-===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #ifndef LLVM_LIBC_SRC_STDBIT_STDC_TRAILING_ONES_UL_H | ||
| #define LLVM_LIBC_SRC_STDBIT_STDC_TRAILING_ONES_UL_H | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| unsigned stdc_trailing_ones_ul(unsigned long value); | ||
|
|
||
| } // namespace LIBC_NAMESPACE | ||
|
|
||
| #endif // LLVM_LIBC_SRC_STDBIT_STDC_TRAILING_ONES_UL_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| //===-- Implementation of stdc_trailing_ones_ull --------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/stdbit/stdc_trailing_ones_ull.h" | ||
|
|
||
| #include "src/__support/CPP/bit.h" | ||
| #include "src/__support/common.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(unsigned, stdc_trailing_ones_ull, | ||
| (unsigned long long value)) { | ||
| return static_cast<unsigned>(cpp::countr_one(value)); | ||
| } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| //===-- Implementation header for stdc_trailing_ones_ull --------*- C++ -*-===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #ifndef LLVM_LIBC_SRC_STDBIT_STDC_TRAILING_ONES_ULL_H | ||
| #define LLVM_LIBC_SRC_STDBIT_STDC_TRAILING_ONES_ULL_H | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| unsigned stdc_trailing_ones_ull(unsigned long long value); | ||
|
|
||
| } // namespace LIBC_NAMESPACE | ||
|
|
||
| #endif // LLVM_LIBC_SRC_STDBIT_STDC_TRAILING_ONES_ULL_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| //===-- Implementation of stdc_trailing_ones_us ---------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/stdbit/stdc_trailing_ones_us.h" | ||
|
|
||
| #include "src/__support/CPP/bit.h" | ||
| #include "src/__support/common.h" | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| LLVM_LIBC_FUNCTION(unsigned, stdc_trailing_ones_us, (unsigned short value)) { | ||
| return static_cast<unsigned>(cpp::countr_one(value)); | ||
| } | ||
|
|
||
| } // namespace LIBC_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| //===-- Implementation header for stdc_trailing_ones_us --------*- C++ -*-===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #ifndef LLVM_LIBC_SRC_STDBIT_STDC_TRAILING_ONES_US_H | ||
| #define LLVM_LIBC_SRC_STDBIT_STDC_TRAILING_ONES_US_H | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
| unsigned stdc_trailing_ones_us(unsigned short value); | ||
|
|
||
| } // namespace LIBC_NAMESPACE | ||
|
|
||
| #endif // LLVM_LIBC_SRC_STDBIT_STDC_TRAILING_ONES_US_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| //===-- Unittests for stdc_trailing_ones_uc -------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/__support/CPP/limits.h" | ||
| #include "src/stdbit/stdc_trailing_ones_uc.h" | ||
| #include "test/UnitTest/Test.h" | ||
|
|
||
| TEST(LlvmLibcStdcTrailingOnesUcTest, ALL) { | ||
| EXPECT_EQ(LIBC_NAMESPACE::stdc_trailing_ones_uc(UCHAR_MAX), | ||
| static_cast<unsigned>(UCHAR_WIDTH)); | ||
| } | ||
|
|
||
| TEST(LlvmLibcStdcTrailingOnesUcTest, ZeroHot) { | ||
| for (unsigned i = 0U; i != UCHAR_WIDTH; ++i) | ||
| EXPECT_EQ(LIBC_NAMESPACE::stdc_trailing_ones_uc(~(1U << i)), i); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| //===-- Unittests for stdc_trailing_ones_ui -------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/__support/CPP/limits.h" | ||
| #include "src/stdbit/stdc_trailing_ones_ui.h" | ||
| #include "test/UnitTest/Test.h" | ||
|
|
||
| TEST(LlvmLibcStdcTrailingOnesUiTest, ALL) { | ||
| EXPECT_EQ(LIBC_NAMESPACE::stdc_trailing_ones_ui(UINT_MAX), | ||
| static_cast<unsigned>(UINT_WIDTH)); | ||
| } | ||
|
|
||
| TEST(LlvmLibcStdcTrailingOnesUiTest, ZeroHot) { | ||
| for (unsigned i = 0U; i != UINT_WIDTH; ++i) | ||
| EXPECT_EQ(LIBC_NAMESPACE::stdc_trailing_ones_ui(~(1U << i)), i); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| //===-- Unittests for stdc_trailing_ones_ul -------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/__support/CPP/limits.h" | ||
| #include "src/stdbit/stdc_trailing_ones_ul.h" | ||
| #include "test/UnitTest/Test.h" | ||
|
|
||
| TEST(LlvmLibcStdcTrailingOnesUlTest, ALL) { | ||
| EXPECT_EQ(LIBC_NAMESPACE::stdc_trailing_ones_ul(ULONG_MAX), | ||
| static_cast<unsigned>(ULONG_WIDTH)); | ||
| } | ||
|
|
||
| TEST(LlvmLibcStdcTrailingOnesUlTest, ZeroHot) { | ||
| for (unsigned i = 0U; i != ULONG_WIDTH; ++i) | ||
| EXPECT_EQ(LIBC_NAMESPACE::stdc_trailing_ones_ul(~(1UL << i)), i); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| //===-- Unittests for stdc_trailing_ones_ull ------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/__support/CPP/limits.h" | ||
| #include "src/stdbit/stdc_trailing_ones_ull.h" | ||
| #include "test/UnitTest/Test.h" | ||
|
|
||
| TEST(LlvmLibcStdcTrailingOnesUllTest, ALL) { | ||
| EXPECT_EQ(LIBC_NAMESPACE::stdc_trailing_ones_ull(ULLONG_MAX), | ||
| static_cast<unsigned>(ULLONG_WIDTH)); | ||
| } | ||
|
|
||
| TEST(LlvmLibcStdcTrailingOnesUllTest, ZeroHot) { | ||
| for (unsigned i = 0U; i != ULLONG_WIDTH; ++i) | ||
| EXPECT_EQ(LIBC_NAMESPACE::stdc_trailing_ones_ull(~(1ULL << i)), i); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| //===-- Unittests for stdc_trailing_ones_us -------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/__support/CPP/limits.h" | ||
| #include "src/stdbit/stdc_trailing_ones_us.h" | ||
| #include "test/UnitTest/Test.h" | ||
|
|
||
| TEST(LlvmLibcStdcTrailingOnesUsTest, ALL) { | ||
| EXPECT_EQ(LIBC_NAMESPACE::stdc_trailing_ones_us(USHRT_MAX), | ||
| static_cast<unsigned>(USHRT_WIDTH)); | ||
| } | ||
|
|
||
| TEST(LlvmLibcStdcTrailingOnesUsTest, ZeroHot) { | ||
| for (unsigned i = 0U; i != USHRT_WIDTH; ++i) | ||
| EXPECT_EQ(LIBC_NAMESPACE::stdc_trailing_ones_us(~(1U << i)), i); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include <list> | ||
|
|
||
| #include "min_allocator.h" | ||
| #include "test_allocator.h" | ||
| #include "test_macros.h" | ||
|
|
||
| template <class T> | ||
| class small_pointer { | ||
| std::uint16_t offset; | ||
| }; | ||
|
|
||
| template <class T> | ||
| class small_iter_allocator { | ||
| public: | ||
| using value_type = T; | ||
| using pointer = small_pointer<T>; | ||
| using size_type = std::int16_t; | ||
| using difference_type = std::int16_t; | ||
|
|
||
| small_iter_allocator() TEST_NOEXCEPT {} | ||
|
|
||
| template <class U> | ||
| small_iter_allocator(small_iter_allocator<U>) TEST_NOEXCEPT {} | ||
|
|
||
| T* allocate(std::size_t n); | ||
| void deallocate(T* p, std::size_t); | ||
|
|
||
| friend bool operator==(small_iter_allocator, small_iter_allocator) { return true; } | ||
| friend bool operator!=(small_iter_allocator, small_iter_allocator) { return false; } | ||
| }; | ||
|
|
||
| #if __SIZE_WIDTH__ == 64 | ||
|
|
||
| static_assert(sizeof(std::list<int>) == 24, ""); | ||
| static_assert(sizeof(std::list<int, min_allocator<int> >) == 24, ""); | ||
| static_assert(sizeof(std::list<int, test_allocator<int> >) == 40, ""); | ||
| static_assert(sizeof(std::list<int, small_iter_allocator<int> >) == 6, ""); | ||
|
|
||
| static_assert(sizeof(std::list<char>) == 24, ""); | ||
| static_assert(sizeof(std::list<char, min_allocator<char> >) == 24, ""); | ||
| static_assert(sizeof(std::list<char, test_allocator<char> >) == 40, ""); | ||
| static_assert(sizeof(std::list<char, small_iter_allocator<char> >) == 6, ""); | ||
|
|
||
| static_assert(TEST_ALIGNOF(std::list<int>) == 8, ""); | ||
| static_assert(TEST_ALIGNOF(std::list<int, min_allocator<int> >) == 8, ""); | ||
| static_assert(TEST_ALIGNOF(std::list<int, test_allocator<int> >) == 8, ""); | ||
| static_assert(TEST_ALIGNOF(std::list<int, small_iter_allocator<int> >) == 2, ""); | ||
|
|
||
| static_assert(TEST_ALIGNOF(std::list<char>) == 8, ""); | ||
| static_assert(TEST_ALIGNOF(std::list<char, min_allocator<char> >) == 8, ""); | ||
| static_assert(TEST_ALIGNOF(std::list<char, test_allocator<char> >) == 8, ""); | ||
| static_assert(TEST_ALIGNOF(std::list<char, small_iter_allocator<char> >) == 2, ""); | ||
|
|
||
| #elif __SIZE_WIDTH__ == 32 | ||
|
|
||
| static_assert(sizeof(std::list<int>) == 12, ""); | ||
| static_assert(sizeof(std::list<int, min_allocator<int> >) == 12, ""); | ||
| static_assert(sizeof(std::list<int, test_allocator<int> >) == 24, ""); | ||
| static_assert(sizeof(std::list<int, small_iter_allocator<int> >) == 6, ""); | ||
|
|
||
| static_assert(sizeof(std::list<char>) == 12, ""); | ||
| static_assert(sizeof(std::list<char, min_allocator<char> >) == 12, ""); | ||
| static_assert(sizeof(std::list<char, test_allocator<char> >) == 24, ""); | ||
| static_assert(sizeof(std::list<char, small_iter_allocator<char> >) == 6, ""); | ||
|
|
||
| static_assert(TEST_ALIGNOF(std::list<int>) == 4, ""); | ||
| static_assert(TEST_ALIGNOF(std::list<int, min_allocator<int> >) == 4, ""); | ||
| static_assert(TEST_ALIGNOF(std::list<int, test_allocator<int> >) == 4, ""); | ||
| static_assert(TEST_ALIGNOF(std::list<int, small_iter_allocator<int> >) == 2, ""); | ||
|
|
||
| static_assert(TEST_ALIGNOF(std::list<char>) == 4, ""); | ||
| static_assert(TEST_ALIGNOF(std::list<char, min_allocator<char> >) == 4, ""); | ||
| static_assert(TEST_ALIGNOF(std::list<char, test_allocator<char> >) == 4, ""); | ||
| static_assert(TEST_ALIGNOF(std::list<char, small_iter_allocator<char> >) == 2, ""); | ||
|
|
||
| #else | ||
| # error std::size_t has an unexpected size | ||
| #endif |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include <vector> | ||
|
|
||
| #include "min_allocator.h" | ||
| #include "test_allocator.h" | ||
| #include "test_macros.h" | ||
|
|
||
| template <class T> | ||
| class small_pointer { | ||
| std::uint16_t offset; | ||
| }; | ||
|
|
||
| template <class T> | ||
| class small_iter_allocator { | ||
| public: | ||
| using value_type = T; | ||
| using pointer = small_pointer<T>; | ||
| using size_type = std::int16_t; | ||
| using difference_type = std::int16_t; | ||
|
|
||
| small_iter_allocator() TEST_NOEXCEPT {} | ||
|
|
||
| template <class U> | ||
| small_iter_allocator(small_iter_allocator<U>) TEST_NOEXCEPT {} | ||
|
|
||
| T* allocate(std::size_t n); | ||
| void deallocate(T* p, std::size_t); | ||
|
|
||
| friend bool operator==(small_iter_allocator, small_iter_allocator) { return true; } | ||
| friend bool operator!=(small_iter_allocator, small_iter_allocator) { return false; } | ||
| }; | ||
|
|
||
| #if __SIZE_WIDTH__ == 64 | ||
|
|
||
| static_assert(sizeof(std::vector<bool>) == 24, ""); | ||
| static_assert(sizeof(std::vector<bool, min_allocator<bool> >) == 24, ""); | ||
| static_assert(sizeof(std::vector<bool, test_allocator<bool> >) == 40, ""); | ||
| static_assert(sizeof(std::vector<bool, small_iter_allocator<bool> >) == 6, ""); | ||
|
|
||
| static_assert(TEST_ALIGNOF(std::vector<bool>) == 8, ""); | ||
| static_assert(TEST_ALIGNOF(std::vector<bool, min_allocator<bool> >) == 8, ""); | ||
| static_assert(TEST_ALIGNOF(std::vector<bool, test_allocator<bool> >) == 8, ""); | ||
| static_assert(TEST_ALIGNOF(std::vector<bool, small_iter_allocator<bool> >) == 2, ""); | ||
|
|
||
| #elif __SIZE_WIDTH__ == 32 | ||
|
|
||
| static_assert(sizeof(std::vector<bool>) == 12, ""); | ||
| static_assert(sizeof(std::vector<bool, min_allocator<bool> >) == 12, ""); | ||
| static_assert(sizeof(std::vector<bool, test_allocator<bool> >) == 24, ""); | ||
| static_assert(sizeof(std::vector<bool, small_iter_allocator<bool> >) == 6, ""); | ||
|
|
||
| static_assert(TEST_ALIGNOF(std::vector<bool>) == 4, ""); | ||
| static_assert(TEST_ALIGNOF(std::vector<bool, min_allocator<bool> >) == 4, ""); | ||
| static_assert(TEST_ALIGNOF(std::vector<bool, test_allocator<bool> >) == 4, ""); | ||
| static_assert(TEST_ALIGNOF(std::vector<bool, small_iter_allocator<bool> >) == 2, ""); | ||
|
|
||
| #else | ||
| # error std::size_t has an unexpected size | ||
| #endif |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include <vector> | ||
|
|
||
| #include "min_allocator.h" | ||
| #include "test_allocator.h" | ||
| #include "test_macros.h" | ||
|
|
||
| template <class T> | ||
| class small_pointer { | ||
| std::uint16_t offset; | ||
| }; | ||
|
|
||
| template <class T> | ||
| class small_iter_allocator { | ||
| public: | ||
| using value_type = T; | ||
| using pointer = small_pointer<T>; | ||
| using size_type = std::int16_t; | ||
| using difference_type = std::int16_t; | ||
|
|
||
| small_iter_allocator() TEST_NOEXCEPT {} | ||
|
|
||
| template <class U> | ||
| small_iter_allocator(small_iter_allocator<U>) TEST_NOEXCEPT {} | ||
|
|
||
| T* allocate(std::size_t n); | ||
| void deallocate(T* p, std::size_t); | ||
|
|
||
| friend bool operator==(small_iter_allocator, small_iter_allocator) { return true; } | ||
| friend bool operator!=(small_iter_allocator, small_iter_allocator) { return false; } | ||
| }; | ||
|
|
||
| #if __SIZE_WIDTH__ == 64 | ||
|
|
||
| static_assert(sizeof(std::vector<int>) == 24, ""); | ||
| static_assert(sizeof(std::vector<int, min_allocator<int> >) == 24, ""); | ||
| static_assert(sizeof(std::vector<int, test_allocator<int> >) == 40, ""); | ||
| static_assert(sizeof(std::vector<int, small_iter_allocator<int> >) == 6, ""); | ||
|
|
||
| static_assert(sizeof(std::vector<char>) == 24, ""); | ||
| static_assert(sizeof(std::vector<char, min_allocator<char> >) == 24, ""); | ||
| static_assert(sizeof(std::vector<char, test_allocator<char> >) == 40, ""); | ||
| static_assert(sizeof(std::vector<char, small_iter_allocator<char> >) == 6, ""); | ||
|
|
||
| static_assert(TEST_ALIGNOF(std::vector<int>) == 8, ""); | ||
| static_assert(TEST_ALIGNOF(std::vector<int, min_allocator<int> >) == 8, ""); | ||
| static_assert(TEST_ALIGNOF(std::vector<int, test_allocator<int> >) == 8, ""); | ||
| static_assert(TEST_ALIGNOF(std::vector<int, small_iter_allocator<int> >) == 2, ""); | ||
|
|
||
| static_assert(TEST_ALIGNOF(std::vector<char>) == 8, ""); | ||
| static_assert(TEST_ALIGNOF(std::vector<char, min_allocator<char> >) == 8, ""); | ||
| static_assert(TEST_ALIGNOF(std::vector<char, test_allocator<char> >) == 8, ""); | ||
| static_assert(TEST_ALIGNOF(std::vector<char, small_iter_allocator<char> >) == 2, ""); | ||
|
|
||
| #elif __SIZE_WIDTH__ == 32 | ||
|
|
||
| static_assert(sizeof(std::vector<int>) == 12, ""); | ||
| static_assert(sizeof(std::vector<int, min_allocator<int> >) == 12, ""); | ||
| static_assert(sizeof(std::vector<int, test_allocator<int> >) == 24, ""); | ||
| static_assert(sizeof(std::vector<int, small_iter_allocator<int> >) == 6, ""); | ||
|
|
||
| static_assert(sizeof(std::vector<char>) == 12, ""); | ||
| static_assert(sizeof(std::vector<char, min_allocator<char> >) == 12, ""); | ||
| static_assert(sizeof(std::vector<char, test_allocator<char> >) == 24, ""); | ||
| static_assert(sizeof(std::vector<char, small_iter_allocator<char> >) == 6, ""); | ||
|
|
||
| static_assert(TEST_ALIGNOF(std::vector<int>) == 4, ""); | ||
| static_assert(TEST_ALIGNOF(std::vector<int, min_allocator<int> >) == 4, ""); | ||
| static_assert(TEST_ALIGNOF(std::vector<int, test_allocator<int> >) == 4, ""); | ||
| static_assert(TEST_ALIGNOF(std::vector<int, small_iter_allocator<int> >) == 2, ""); | ||
|
|
||
| static_assert(TEST_ALIGNOF(std::vector<char>) == 4, ""); | ||
| static_assert(TEST_ALIGNOF(std::vector<char, min_allocator<char> >) == 4, ""); | ||
| static_assert(TEST_ALIGNOF(std::vector<char, test_allocator<char> >) == 4, ""); | ||
| static_assert(TEST_ALIGNOF(std::vector<char, small_iter_allocator<char> >) == 2, ""); | ||
|
|
||
| #else | ||
| # error std::size_t has an unexpected size | ||
| #endif |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| %feature("docstring", | ||
| "A container for options to use when dumping statistics." | ||
| ) lldb::SBStatisticsOptions; | ||
|
|
||
| %feature("docstring", "Sets whether the statistics should only dump a summary." | ||
| ) lldb::SBStatisticsOptions::SetSummaryOnly; | ||
| %feature("docstring", "Gets whether the statistics only dump a summary." | ||
| ) lldb::SBStatisticsOptions::GetSummaryOnly; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| //===-- SBStatisticsOptions.h -----------------------------------*- C++ -*-===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #ifndef LLDB_API_SBSTATISTICSOPTIONS_H | ||
| #define LLDB_API_SBSTATISTICSOPTIONS_H | ||
|
|
||
| #include "lldb/API/SBDefines.h" | ||
|
|
||
| namespace lldb { | ||
|
|
||
| /// This class handles the verbosity when dumping statistics | ||
| class LLDB_API SBStatisticsOptions { | ||
| public: | ||
| SBStatisticsOptions(); | ||
| SBStatisticsOptions(const lldb::SBStatisticsOptions &rhs); | ||
| ~SBStatisticsOptions(); | ||
|
|
||
| const SBStatisticsOptions &operator=(const lldb::SBStatisticsOptions &rhs); | ||
|
|
||
| void SetSummaryOnly(bool b); | ||
| bool GetSummaryOnly(); | ||
|
|
||
| protected: | ||
| friend class SBTarget; | ||
| const lldb_private::StatisticsOptions &ref() const; | ||
|
|
||
| private: | ||
| std::unique_ptr<lldb_private::StatisticsOptions> m_opaque_up; | ||
| }; | ||
| } // namespace lldb | ||
| #endif // LLDB_API_SBSTATISTICSOPTIONS_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| //===-- SBStatisticsOptions.cpp -------------------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "lldb/API/SBStatisticsOptions.h" | ||
| #include "lldb/Target/Statistics.h" | ||
| #include "lldb/Utility/Instrumentation.h" | ||
|
|
||
| #include "Utils.h" | ||
|
|
||
| using namespace lldb; | ||
| using namespace lldb_private; | ||
|
|
||
| SBStatisticsOptions::SBStatisticsOptions() | ||
| : m_opaque_up(new StatisticsOptions()) { | ||
| LLDB_INSTRUMENT_VA(this); | ||
| m_opaque_up->summary_only = false; | ||
| } | ||
|
|
||
| SBStatisticsOptions::SBStatisticsOptions(const SBStatisticsOptions &rhs) { | ||
| LLDB_INSTRUMENT_VA(this, rhs); | ||
|
|
||
| m_opaque_up = clone(rhs.m_opaque_up); | ||
| } | ||
|
|
||
| SBStatisticsOptions::~SBStatisticsOptions() = default; | ||
|
|
||
| const SBStatisticsOptions & | ||
| SBStatisticsOptions::operator=(const SBStatisticsOptions &rhs) { | ||
| LLDB_INSTRUMENT_VA(this, rhs); | ||
|
|
||
| if (this != &rhs) | ||
| m_opaque_up = clone(rhs.m_opaque_up); | ||
| return *this; | ||
| } | ||
|
|
||
| void SBStatisticsOptions::SetSummaryOnly(bool b) { | ||
| m_opaque_up->summary_only = b; | ||
| } | ||
|
|
||
| bool SBStatisticsOptions::GetSummaryOnly() { return m_opaque_up->summary_only; } | ||
|
|
||
| const lldb_private::StatisticsOptions &SBStatisticsOptions::ref() const { | ||
| return *m_opaque_up; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| int main(void) { | ||
| return 0; // break here | ||
| } |