[PATCH] D119580: [LLVM][Support] Delete "copy" constructor of BumpPtrAllocatorImpl
Zixu Wang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 11 13:03:01 PST 2022
zixuw created this revision.
Herald added a subscriber: dexonsmith.
zixuw requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Though the implicit copy constructor of BumpPtrAllocatorImpl is deleted
because of the presence of a user-defined move constructor, the
perfect-forwarding constructor will still match for lvalue reference of
BumpPtrAllocatorImpl, silently "copying" a BumpPtrAllocatorImpl
(actually just copy-constructing an underlying AllocatorT and
blank-constructing a BumpPtrAllocatorImpl).
This patch explicitly deletes the problematic specialization of the
forwarding constructor.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D119580
Files:
llvm/include/llvm/Support/Allocator.h
Index: llvm/include/llvm/Support/Allocator.h
===================================================================
--- llvm/include/llvm/Support/Allocator.h
+++ llvm/include/llvm/Support/Allocator.h
@@ -79,6 +79,11 @@
BumpPtrAllocatorImpl(T &&Allocator)
: AllocatorT(std::forward<T &&>(Allocator)) {}
+ // BumpPtrAllocator shouldn't be copyable. Explicitly delete this
+ // specialization of the perfect-forwarding constructor above.
+ template <typename T>
+ BumpPtrAllocatorImpl(BumpPtrAllocatorImpl<T> &) = delete;
+
// Manually implement a move constructor as we must clear the old allocator's
// slabs as a matter of correctness.
BumpPtrAllocatorImpl(BumpPtrAllocatorImpl &&Old)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119580.408009.patch
Type: text/x-patch
Size: 707 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220211/484ce66e/attachment.bin>
More information about the llvm-commits
mailing list