summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2010-01-26 22:03:41 +0000
committerDevang Patel <dpatel@apple.com>2010-01-26 22:03:41 +0000
commit330186e5476167332a191567dbf4dfc3c062ca88 (patch)
tree434b7c4cd52a1ccc3e6f7226fd700b628248af3c
parentc618c8aff46a8ec4d209d041404e780a0caaf77d (diff)
downloadllvm-330186e5476167332a191567dbf4dfc3c062ca88.tar.gz
llvm-330186e5476167332a191567dbf4dfc3c062ca88.tar.bz2
llvm-330186e5476167332a191567dbf4dfc3c062ca88.tar.xz
Before existing NamedMDNode entry in the symbol table, remove any existing entry with the same name.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94600 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/ValueSymbolTable.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/include/llvm/ValueSymbolTable.h b/include/llvm/ValueSymbolTable.h
index 0240696821..7497dae3c4 100644
--- a/include/llvm/ValueSymbolTable.h
+++ b/include/llvm/ValueSymbolTable.h
@@ -194,9 +194,15 @@ public:
/// @name Mutators
/// @{
public:
- /// insert - The method inserts a new entry into the stringmap.
+ /// insert - The method inserts a new entry into the stringmap. This will
+ /// replace existing entry, if any.
void insert(StringRef Name, NamedMDNode *Node) {
- (void) mmap.GetOrCreateValue(Name, Node);
+ StringMapEntry<NamedMDNode *> &Entry =
+ mmap.GetOrCreateValue(Name, Node);
+ if (Entry.getValue() != Node) {
+ mmap.remove(&Entry);
+ (void) mmap.GetOrCreateValue(Name, Node);
+ }
}
/// This method removes a NamedMDNode from the symbol table.