aboutsummaryrefslogtreecommitdiff
path: root/llvm/include/llvm/Support/AllocatorBase.h
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/include/llvm/Support/AllocatorBase.h')
-rw-r--r--llvm/include/llvm/Support/AllocatorBase.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/llvm/include/llvm/Support/AllocatorBase.h b/llvm/include/llvm/Support/AllocatorBase.h
index eccced1d1ff4..5d05d3f8777b 100644
--- a/llvm/include/llvm/Support/AllocatorBase.h
+++ b/llvm/include/llvm/Support/AllocatorBase.h
@@ -99,6 +99,28 @@ public:
void PrintStats() const {}
};
+namespace detail {
+
+template <typename Alloc> class AllocatorHolder : Alloc {
+public:
+ AllocatorHolder() = default;
+ AllocatorHolder(const Alloc &A) : Alloc(A) {}
+ AllocatorHolder(Alloc &&A) : Alloc(static_cast<Alloc &&>(A)) {}
+ Alloc &getAllocator() { return *this; }
+ const Alloc &getAllocator() const { return *this; }
+};
+
+template <typename Alloc> class AllocatorHolder<Alloc &> {
+ Alloc &A;
+
+public:
+ AllocatorHolder(Alloc &A) : A(A) {}
+ Alloc &getAllocator() { return A; }
+ const Alloc &getAllocator() const { return A; }
+};
+
+} // namespace detail
+
} // namespace llvm
#endif // LLVM_SUPPORT_ALLOCATORBASE_H