diff options
author | Chris Lattner <sabre@nondot.org> | 2007-09-30 08:31:46 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-09-30 08:31:46 +0000 |
commit | 48f61d10e331027dc22fbc8f0f2a1b280c9e3aa9 (patch) | |
tree | 6331154d1cbc8760f9d1430bcef629db268ffee2 /include | |
parent | 1d0f1c50e76ca2ba753aa00b93712f5529049c52 (diff) | |
download | external_llvm-48f61d10e331027dc22fbc8f0f2a1b280c9e3aa9.zip external_llvm-48f61d10e331027dc22fbc8f0f2a1b280c9e3aa9.tar.gz external_llvm-48f61d10e331027dc22fbc8f0f2a1b280c9e3aa9.tar.bz2 |
Add a helper useful when mapping from a map element to its hash node.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42480 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/ADT/StringMap.h | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/include/llvm/ADT/StringMap.h b/include/llvm/ADT/StringMap.h index 72108e9..fecd61e 100644 --- a/include/llvm/ADT/StringMap.h +++ b/include/llvm/ADT/StringMap.h @@ -166,7 +166,18 @@ public: MallocAllocator A; return Create(KeyStart, KeyEnd, A); } - + + + /// GetStringMapEntryFromValue - Given a value that is known to be embedded + /// into a StringMapEntry, return the StringMapEntry itself. + static StringMapEntry &GetStringMapEntryFromValue(ValueTy &V) { + return *reinterpret_cast<StringMapEntry*>(reinterpret_cast<char*>(&V) - + sizeof(StringMapEntryBase)); + } + static const StringMapEntry &GetStringMapEntryFromValue(const ValueTy &V) { + return GetStringMapEntryFromValue(const_cast<ValueTy&>(V)); + } + /// Destroy - Destroy this StringMapEntry, releasing memory back to the /// specified allocator. template<typename AllocatorTy> |