diff options
author | NAKAMURA Takumi <geek4civic@gmail.com> | 2025-01-09 18:31:57 +0900 |
---|---|---|
committer | NAKAMURA Takumi <geek4civic@gmail.com> | 2025-01-09 18:33:27 +0900 |
commit | df025ebf872052c0761d44a3ef9b65e9675af8a8 (patch) | |
tree | 9b4e94583e2536546d6606270bcdf846c95e1ba2 /llvm/unittests/Support | |
parent | 4428c9d0b1344179f85a72e183a44796976521e3 (diff) | |
parent | bdcf47e4bcb92889665825654bb80a8bbe30379e (diff) | |
download | llvm-users/chapuni/cov/single/loop.zip llvm-users/chapuni/cov/single/loop.tar.gz llvm-users/chapuni/cov/single/loop.tar.bz2 |
Merge branch 'users/chapuni/cov/single/base' into users/chapuni/cov/single/loopusers/chapuni/cov/single/loop
Conflicts:
clang/lib/CodeGen/CoverageMappingGen.cpp
Diffstat (limited to 'llvm/unittests/Support')
-rw-r--r-- | llvm/unittests/Support/CMakeLists.txt | 1 | ||||
-rw-r--r-- | llvm/unittests/Support/Path.cpp | 3 | ||||
-rw-r--r-- | llvm/unittests/Support/RecyclerTest.cpp | 47 |
3 files changed, 51 insertions, 0 deletions
diff --git a/llvm/unittests/Support/CMakeLists.txt b/llvm/unittests/Support/CMakeLists.txt index d64f898..6de8165 100644 --- a/llvm/unittests/Support/CMakeLists.txt +++ b/llvm/unittests/Support/CMakeLists.txt @@ -69,6 +69,7 @@ add_llvm_unittest(SupportTests PerThreadBumpPtrAllocatorTest.cpp ProcessTest.cpp ProgramTest.cpp + RecyclerTest.cpp RegexTest.cpp ReverseIterationTest.cpp ReplaceFileTest.cpp diff --git a/llvm/unittests/Support/Path.cpp b/llvm/unittests/Support/Path.cpp index 8dde2fb..187f47d 100644 --- a/llvm/unittests/Support/Path.cpp +++ b/llvm/unittests/Support/Path.cpp @@ -1326,6 +1326,9 @@ TEST_F(FileSystemTest, Remove) { ASSERT_NO_ERROR(fs::remove_directories("D:/footest")); + ASSERT_NO_ERROR(fs::remove_directories(Twine(BaseDir) + "/foo/bar/baz")); + ASSERT_FALSE(fs::exists(Twine(BaseDir) + "/foo/bar/baz")); + ASSERT_NO_ERROR(fs::remove_directories(BaseDir)); ASSERT_FALSE(fs::exists(BaseDir)); } diff --git a/llvm/unittests/Support/RecyclerTest.cpp b/llvm/unittests/Support/RecyclerTest.cpp new file mode 100644 index 0000000..a33506b --- /dev/null +++ b/llvm/unittests/Support/RecyclerTest.cpp @@ -0,0 +1,47 @@ +//===--- unittest/Support/RecyclerTest.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 "llvm/Support/Recycler.h" +#include "llvm/Support/AllocatorBase.h" +#include "gtest/gtest.h" + +using namespace llvm; + +namespace { + +struct Object8 { + char Data[8]; +}; + +class DecoratedMallocAllocator : public MallocAllocator { +public: + int DeallocCount = 0; + + template <typename T> void Deallocate(T *Ptr) { + DeallocCount++; + MallocAllocator::Deallocate(Ptr); + } +}; + +TEST(RecyclerTest, MoveConstructor) { + DecoratedMallocAllocator Allocator; + Recycler<Object8> R; + Object8 *A1 = R.Allocate(Allocator); + Object8 *A2 = R.Allocate(Allocator); + R.Deallocate(Allocator, A1); + R.Deallocate(Allocator, A2); + Recycler<Object8> R2(std::move(R)); + Object8 *A3 = R2.Allocate(Allocator); + R2.Deallocate(Allocator, A3); + R.clear(Allocator); // Should not deallocate anything as it was moved from. + EXPECT_EQ(Allocator.DeallocCount, 0); + R2.clear(Allocator); + EXPECT_EQ(Allocator.DeallocCount, 2); +} + +} // end anonymous namespace |