From b02ed5b8eafd11500bbefb7206ecbf5bc3fc324a Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Fri, 7 Dec 2012 02:03:00 +0000 Subject: [PATCH] Add manualRetain() and manualRelease() to ImmutableMapRef, and add a new constructor. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169572 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/ImmutableMap.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/llvm/ADT/ImmutableMap.h b/include/llvm/ADT/ImmutableMap.h index 4883c5ba0a6..ce27d0536a5 100644 --- a/include/llvm/ADT/ImmutableMap.h +++ b/include/llvm/ADT/ImmutableMap.h @@ -288,6 +288,13 @@ public: Factory(F) { if (Root) { Root->retain(); } } + + explicit ImmutableMapRef(const ImmutableMap &X, + typename ImmutableMap::Factory &F) + : Root(X.getRootWithoutRetain()), + Factory(F.getTreeFactory()) { + if (Root) { Root->retain(); } + } ImmutableMapRef(const ImmutableMapRef &X) : Root(X.Root), @@ -318,6 +325,14 @@ public: return ImmutableMapRef(0, F); } + void manualRetain() { + if (Root) Root->retain(); + } + + void manualRelease() { + if (Root) Root->release(); + } + ImmutableMapRef add(key_type_ref K, data_type_ref D) { TreeTy *NewT = Factory->add(Root, std::pair(K, D)); return ImmutableMapRef(NewT, Factory);