diff options
author | Chris Lattner <sabre@nondot.org> | 2010-03-24 00:53:27 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-03-24 00:53:27 +0000 |
commit | 8ee076961219c9066b651ff686c450d92e81c27a (patch) | |
tree | b1b36a726273ab87784d98b4d5c0bee4e621fe7a /include/llvm/ADT | |
parent | 1aec4d759641fdc4a7751933453ba3db54c4b98e (diff) | |
download | external_llvm-8ee076961219c9066b651ff686c450d92e81c27a.zip external_llvm-8ee076961219c9066b651ff686c450d92e81c27a.tar.gz external_llvm-8ee076961219c9066b651ff686c450d92e81c27a.tar.bz2 |
Add a method to get a StringMapEntry from a pointer to the string
data it contains (similar to GetStringMapEntryFromValue).
Patch by Greg Clayton!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99371 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT')
-rw-r--r-- | include/llvm/ADT/StringMap.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/include/llvm/ADT/StringMap.h b/include/llvm/ADT/StringMap.h index 86e8546..4821938 100644 --- a/include/llvm/ADT/StringMap.h +++ b/include/llvm/ADT/StringMap.h @@ -216,6 +216,14 @@ public: static const StringMapEntry &GetStringMapEntryFromValue(const ValueTy &V) { return GetStringMapEntryFromValue(const_cast<ValueTy&>(V)); } + + /// GetStringMapEntryFromKeyData - Given key data that is known to be embedded + /// into a StringMapEntry, return the StringMapEntry itself. + static StringMapEntry &GetStringMapEntryFromKeyData(const char *KeyData) { + char *Ptr = const_cast<char*>(KeyData) - sizeof(StringMapEntry<ValueTy>); + return *reinterpret_cast<StringMapEntry*>(Ptr); + } + /// Destroy - Destroy this StringMapEntry, releasing memory back to the /// specified allocator. |