[llvm-commits] [llvm] r99371 - /llvm/trunk/include/llvm/ADT/StringMap.h
Chris Lattner
sabre at nondot.org
Tue Mar 23 17:53:27 PDT 2010
Author: lattner
Date: Tue Mar 23 19:53:27 2010
New Revision: 99371
URL: http://llvm.org/viewvc/llvm-project?rev=99371&view=rev
Log:
Add a method to get a StringMapEntry from a pointer to the string
data it contains (similar to GetStringMapEntryFromValue).
Patch by Greg Clayton!
Modified:
llvm/trunk/include/llvm/ADT/StringMap.h
Modified: llvm/trunk/include/llvm/ADT/StringMap.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/StringMap.h?rev=99371&r1=99370&r2=99371&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/StringMap.h (original)
+++ llvm/trunk/include/llvm/ADT/StringMap.h Tue Mar 23 19:53:27 2010
@@ -216,6 +216,14 @@
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.
More information about the llvm-commits
mailing list