[llvm] Prevent copying of ArenaAllocator (PR #97935)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 6 20:03:04 PDT 2024
https://github.com/smanna12 created https://github.com/llvm/llvm-project/pull/97935
This patch removes copy constructor and assignment operator from ArenaAllocator class to prevent resource duplication and ensure it remains non-copyable as per design intent.
>From 2aea2cf8d428dc643c7512edc6d5b4a322e8d1d5 Mon Sep 17 00:00:00 2001
From: "Manna, Soumi" <soumi.manna at intel.com>
Date: Sat, 6 Jul 2024 19:57:09 -0700
Subject: [PATCH] Prevent copying of ArenaAllocator
This patch removes copy constructor and assignment operator from ArenaAllocator class
to prevent resource duplication and ensure it remains non-copyable as per design intent.
---
llvm/include/llvm/Demangle/MicrosoftDemangle.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/llvm/include/llvm/Demangle/MicrosoftDemangle.h b/llvm/include/llvm/Demangle/MicrosoftDemangle.h
index 1529b803debe5..6891185a28e57 100644
--- a/llvm/include/llvm/Demangle/MicrosoftDemangle.h
+++ b/llvm/include/llvm/Demangle/MicrosoftDemangle.h
@@ -54,6 +54,10 @@ class ArenaAllocator {
}
}
+ // Delete the copy constructor and the copy assignment operator.
+ ArenaAllocator(const ArenaAllocator &) = delete;
+ ArenaAllocator &operator=(const ArenaAllocator &) = delete;
+
char *allocUnalignedBuffer(size_t Size) {
assert(Head && Head->Buf);
More information about the llvm-commits
mailing list