diff options
author | Chris Lattner <sabre@nondot.org> | 2006-10-30 03:14:15 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-10-30 03:14:15 +0000 |
commit | 6c1645ce7da8495c79e3d38bbf91ce77bf489c10 (patch) | |
tree | 4fc0a434c7e1e18515c7c950172adc9e0c048534 /include/llvm/ADT | |
parent | 463c4a1ae9af56b6a944b74f0898e17d9a3b52eb (diff) | |
download | llvm-6c1645ce7da8495c79e3d38bbf91ce77bf489c10.tar.gz llvm-6c1645ce7da8495c79e3d38bbf91ce77bf489c10.tar.bz2 llvm-6c1645ce7da8495c79e3d38bbf91ce77bf489c10.tar.xz |
add a method
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31288 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT')
-rw-r--r-- | include/llvm/ADT/CStringMap.h | 8 | ||||
-rw-r--r-- | include/llvm/ADT/StringMap.h | 8 |
2 files changed, 16 insertions, 0 deletions
diff --git a/include/llvm/ADT/CStringMap.h b/include/llvm/ADT/CStringMap.h index d869f66788..d1beb42ebc 100644 --- a/include/llvm/ADT/CStringMap.h +++ b/include/llvm/ADT/CStringMap.h @@ -86,6 +86,14 @@ public: return static_cast<ValueTy*>(TheTable[BucketNo].Item); } + /// GetKeyForValueInMap - Given a value that is inserted into this map, return + /// the string that corresponds to it. This is an efficient operation that + /// is provided by CStringMap. The string is live as long as the value is in + /// the map. + static const char *GetKeyForValueInMap(const ValueTy &Val) { + return reinterpret_cast<const char*>(&Val+1); + } + /// GetOrCreateValue - Look up the specified key in the table. If a value /// exists, return it. Otherwise, default construct a value, insert it, and /// return. diff --git a/include/llvm/ADT/StringMap.h b/include/llvm/ADT/StringMap.h index d869f66788..d1beb42ebc 100644 --- a/include/llvm/ADT/StringMap.h +++ b/include/llvm/ADT/StringMap.h @@ -86,6 +86,14 @@ public: return static_cast<ValueTy*>(TheTable[BucketNo].Item); } + /// GetKeyForValueInMap - Given a value that is inserted into this map, return + /// the string that corresponds to it. This is an efficient operation that + /// is provided by CStringMap. The string is live as long as the value is in + /// the map. + static const char *GetKeyForValueInMap(const ValueTy &Val) { + return reinterpret_cast<const char*>(&Val+1); + } + /// GetOrCreateValue - Look up the specified key in the table. If a value /// exists, return it. Otherwise, default construct a value, insert it, and /// return. |