Skip to content

Commit

Permalink
Add manualRetain() and manualRelease() to ImmutableMapRef, and add a …
Browse files Browse the repository at this point in the history
…new constructor.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169572 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
tkremenek committed Dec 7, 2012
1 parent 4a0ed9f commit b02ed5b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions include/llvm/ADT/ImmutableMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,13 @@ class ImmutableMapRef {
Factory(F) {
if (Root) { Root->retain(); }
}

explicit ImmutableMapRef(const ImmutableMap<KeyT, ValT> &X,
typename ImmutableMap<KeyT, ValT>::Factory &F)
: Root(X.getRootWithoutRetain()),
Factory(F.getTreeFactory()) {
if (Root) { Root->retain(); }
}

ImmutableMapRef(const ImmutableMapRef &X)
: Root(X.Root),
Expand Down Expand Up @@ -318,6 +325,14 @@ class ImmutableMapRef {
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<key_type, data_type>(K, D));
return ImmutableMapRef(NewT, Factory);
Expand Down

0 comments on commit b02ed5b

Please sign in to comment.