diff options
| author | Chris Lattner <sabre@nondot.org> | 2010-09-04 18:45:02 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2010-09-04 18:45:02 +0000 |
| commit | f20ca8028d68f3a08025a068dcc60b192ba07c19 (patch) | |
| tree | a2c2dd250ac96cdbed6dd34cd522c2641e55a69e | |
| parent | 096304818569a6d465e69c7f56a46f195a894277 (diff) | |
| download | bcm5719-llvm-f20ca8028d68f3a08025a068dcc60b192ba07c19.tar.gz bcm5719-llvm-f20ca8028d68f3a08025a068dcc60b192ba07c19.zip | |
fix this to work with allocators that have reference type with compilers
that diagnose invalid references to references.
llvm-svn: 113078
| -rw-r--r-- | llvm/include/llvm/ADT/StringMap.h | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/llvm/include/llvm/ADT/StringMap.h b/llvm/include/llvm/ADT/StringMap.h index 59ff6aa4f6a..1b20f4fdd9c 100644 --- a/llvm/include/llvm/ADT/StringMap.h +++ b/llvm/include/llvm/ADT/StringMap.h @@ -242,6 +242,9 @@ public: }; +template <typename T> struct ReferenceAdder { typedef T& result; }; +template <typename T> struct ReferenceAdder<T&> { typedef T result; }; + /// StringMap - This is an unconventional map that is specialized for handling /// keys that are "strings", which are basically ranges of bytes. This does some /// funky memory allocation and hashing things to make it extremely efficient, @@ -269,9 +272,10 @@ public: clear(); } - - AllocatorTy &getAllocator() { return Allocator; } - const AllocatorTy &getAllocator() const { return Allocator; } + typedef typename ReferenceAdder<AllocatorTy>::result AllocatorRefTy; + typedef typename ReferenceAdder<const AllocatorTy>::result AllocatorCRefTy; + AllocatorRefTy getAllocator() { return Allocator; } + AllocatorCRefTy getAllocator() const { return Allocator; } typedef const char* key_type; typedef ValueTy mapped_type; |

