[llvm] [Support] Add SpecificBumpPtrAllocator::identifyObject (PR #100475)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 25 02:03:57 PDT 2024


================
@@ -208,6 +208,19 @@ TEST(AllocatorTest, TestSlowerSlabGrowthDelay) {
   EXPECT_EQ(SlabSize * GrowthDelay + SlabSize * 2, Alloc.getTotalMemory());
 }
 
+TEST(AllocatorTest, TestIdentifyObject) {
+  BumpPtrAllocator Alloc;
+
+  uint64_t *a = (uint64_t *)Alloc.Allocate(sizeof(uint64_t), alignof(uint64_t));
+  std::optional<int64_t> maybe_a_belongs = Alloc.identifyObject(a);
+  EXPECT_TRUE(maybe_a_belongs.has_value());
+  EXPECT_TRUE(*maybe_a_belongs >= 0);
----------------
nikic wrote:

Also test the custom sized slab case with negative return while you're here?

https://github.com/llvm/llvm-project/pull/100475


More information about the llvm-commits mailing list