LLVM 22.0.0git
StringMap.h
Go to the documentation of this file.
1//===- StringMap.h - String Hash table map interface ------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8///
9/// \file
10/// This file defines the StringMap class.
11///
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_ADT_STRINGMAP_H
15#define LLVM_ADT_STRINGMAP_H
16
18#include "llvm/ADT/iterator.h"
22#include <initializer_list>
23#include <iterator>
24#include <type_traits>
25
26namespace llvm {
27
28template <typename ValueTy, bool IsConst> class StringMapIterBase;
29template <typename ValueTy> class StringMapKeyIterator;
30
31/// StringMapImpl - This is the base class of StringMap that is shared among
32/// all of its instantiations.
34protected:
35 // Array of NumBuckets pointers to entries, null pointers are holes.
36 // TheTable[NumBuckets] contains a sentinel value for easy iteration. Followed
37 // by an array of the actual hash values as unsigned integers.
39 unsigned NumBuckets = 0;
40 unsigned NumItems = 0;
41 unsigned NumTombstones = 0;
42 unsigned ItemSize;
43
44protected:
45 explicit StringMapImpl(unsigned itemSize) : ItemSize(itemSize) {}
50 RHS.TheTable = nullptr;
51 RHS.NumBuckets = 0;
52 RHS.NumItems = 0;
53 RHS.NumTombstones = 0;
54 }
55
56 LLVM_ABI StringMapImpl(unsigned InitSize, unsigned ItemSize);
58 LLVM_ABI unsigned RehashTable(unsigned BucketNo = 0);
59
60 /// LookupBucketFor - Look up the bucket that the specified string should end
61 /// up in. If it already exists as a key in the map, the Item pointer for the
62 /// specified bucket will be non-null. Otherwise, it will be null. In either
63 /// case, the FullHashValue field of the bucket will be set to the hash value
64 /// of the string.
65 unsigned LookupBucketFor(StringRef Key) {
66 return LookupBucketFor(Key, hash(Key));
67 }
68
69 /// Overload that explicitly takes precomputed hash(Key).
70 LLVM_ABI unsigned LookupBucketFor(StringRef Key, uint32_t FullHashValue);
71
72 /// FindKey - Look up the bucket that contains the specified key. If it exists
73 /// in the map, return the bucket number of the key. Otherwise return -1.
74 /// This does not modify the map.
75 int FindKey(StringRef Key) const { return FindKey(Key, hash(Key)); }
76
77 /// Overload that explicitly takes precomputed hash(Key).
78 LLVM_ABI int FindKey(StringRef Key, uint32_t FullHashValue) const;
79
80 /// RemoveKey - Remove the specified StringMapEntry from the table, but do not
81 /// delete it. This aborts if the value isn't in the table.
83
84 /// RemoveKey - Remove the StringMapEntry for the specified key from the
85 /// table, returning it. If the key is not in the table, this returns null.
87
88 /// Allocate the table with the specified number of buckets and otherwise
89 /// setup the map as empty.
90 LLVM_ABI void init(unsigned Size);
91
94 }
95
96public:
97 static constexpr uintptr_t TombstoneIntVal =
98 static_cast<uintptr_t>(-1)
100
102 return reinterpret_cast<StringMapEntryBase *>(TombstoneIntVal);
103 }
104
105 unsigned getNumBuckets() const { return NumBuckets; }
106 unsigned getNumItems() const { return NumItems; }
107
108 bool empty() const { return NumItems == 0; }
109 unsigned size() const { return NumItems; }
110
111 /// Returns the hash value that will be used for the given string.
112 /// This allows precomputing the value and passing it explicitly
113 /// to some of the functions.
114 /// The implementation of this function is not guaranteed to be stable
115 /// and may change.
116 LLVM_ABI static uint32_t hash(StringRef Key);
117
119 std::swap(TheTable, Other.TheTable);
120 std::swap(NumBuckets, Other.NumBuckets);
121 std::swap(NumItems, Other.NumItems);
122 std::swap(NumTombstones, Other.NumTombstones);
123 }
124};
125
126/// StringMap - This is an unconventional map that is specialized for handling
127/// keys that are "strings", which are basically ranges of bytes. This does some
128/// funky memory allocation and hashing things to make it extremely efficient,
129/// storing the string data *after* the value in the map.
130template <typename ValueTy, typename AllocatorTy = MallocAllocator>
132 : public StringMapImpl,
133 private detail::AllocatorHolder<AllocatorTy> {
135
136public:
138
139 StringMap() : StringMapImpl(static_cast<unsigned>(sizeof(MapEntryTy))) {}
140
141 explicit StringMap(unsigned InitialSize)
142 : StringMapImpl(InitialSize, static_cast<unsigned>(sizeof(MapEntryTy))) {}
143
144 explicit StringMap(AllocatorTy A)
145 : StringMapImpl(static_cast<unsigned>(sizeof(MapEntryTy))), AllocTy(A) {}
146
147 StringMap(unsigned InitialSize, AllocatorTy A)
148 : StringMapImpl(InitialSize, static_cast<unsigned>(sizeof(MapEntryTy))),
149 AllocTy(A) {}
150
151 StringMap(std::initializer_list<std::pair<StringRef, ValueTy>> List)
152 : StringMapImpl(List.size(), static_cast<unsigned>(sizeof(MapEntryTy))) {
153 insert(List);
154 }
155
157 : StringMapImpl(std::move(RHS)), AllocTy(std::move(RHS.getAllocator())) {}
158
160 : StringMapImpl(static_cast<unsigned>(sizeof(MapEntryTy))),
161 AllocTy(RHS.getAllocator()) {
162 if (RHS.empty())
163 return;
164
165 // Allocate TheTable of the same size as RHS's TheTable, and set the
166 // sentinel appropriately (and NumBuckets).
167 init(RHS.NumBuckets);
168 unsigned *HashTable = (unsigned *)(TheTable + NumBuckets + 1),
169 *RHSHashTable = (unsigned *)(RHS.TheTable + NumBuckets + 1);
170
171 NumItems = RHS.NumItems;
172 NumTombstones = RHS.NumTombstones;
173 for (unsigned I = 0, E = NumBuckets; I != E; ++I) {
174 StringMapEntryBase *Bucket = RHS.TheTable[I];
175 if (!Bucket || Bucket == getTombstoneVal()) {
176 TheTable[I] = Bucket;
177 continue;
178 }
179
180 TheTable[I] = MapEntryTy::create(
181 static_cast<MapEntryTy *>(Bucket)->getKey(), getAllocator(),
182 static_cast<MapEntryTy *>(Bucket)->getValue());
183 HashTable[I] = RHSHashTable[I];
184 }
185
186 // Note that here we've copied everything from the RHS into this object,
187 // tombstones included. We could, instead, have re-probed for each key to
188 // instantiate this new object without any tombstone buckets. The
189 // assumption here is that items are rarely deleted from most StringMaps,
190 // and so tombstones are rare, so the cost of re-probing for all inputs is
191 // not worthwhile.
192 }
193
195 StringMapImpl::swap(RHS);
196 std::swap(getAllocator(), RHS.getAllocator());
197 return *this;
198 }
199
201 // Delete all the elements in the map, but don't reset the elements
202 // to default values. This is a copy of clear(), but avoids unnecessary
203 // work not required in the destructor.
204 if (!empty()) {
205 for (StringMapEntryBase *Bucket : buckets()) {
206 if (Bucket && Bucket != getTombstoneVal()) {
207 static_cast<MapEntryTy *>(Bucket)->Destroy(getAllocator());
208 }
209 }
210 }
211 }
212
213 using AllocTy::getAllocator;
214
215 using key_type = const char *;
216 using mapped_type = ValueTy;
218 using size_type = size_t;
219
222
223 iterator begin() { return iterator(TheTable, NumBuckets != 0); }
224 iterator end() { return iterator(TheTable + NumBuckets); }
226 return const_iterator(TheTable, NumBuckets != 0);
227 }
228 const_iterator end() const { return const_iterator(TheTable + NumBuckets); }
229
233 }
234
235 iterator find(StringRef Key) { return find(Key, hash(Key)); }
236
237 iterator find(StringRef Key, uint32_t FullHashValue) {
238 int Bucket = FindKey(Key, FullHashValue);
239 if (Bucket == -1)
240 return end();
241 return iterator(TheTable + Bucket);
242 }
243
244 const_iterator find(StringRef Key) const { return find(Key, hash(Key)); }
245
246 const_iterator find(StringRef Key, uint32_t FullHashValue) const {
247 int Bucket = FindKey(Key, FullHashValue);
248 if (Bucket == -1)
249 return end();
250 return const_iterator(TheTable + Bucket);
251 }
252
253 /// lookup - Return the entry for the specified key, or a default
254 /// constructed value if no such entry exists.
255 ValueTy lookup(StringRef Key) const {
256 const_iterator Iter = find(Key);
257 if (Iter != end())
258 return Iter->second;
259 return ValueTy();
260 }
261
262 /// at - Return the entry for the specified key, or abort if no such
263 /// entry exists.
264 const ValueTy &at(StringRef Val) const {
265 auto Iter = this->find(Val);
266 assert(Iter != this->end() && "StringMap::at failed due to a missing key");
267 return Iter->second;
268 }
269
270 /// Lookup the ValueTy for the \p Key, or create a default constructed value
271 /// if the key is not in the map.
272 ValueTy &operator[](StringRef Key) { return try_emplace(Key).first->second; }
273
274 /// contains - Return true if the element is in the map, false otherwise.
275 bool contains(StringRef Key) const { return find(Key) != end(); }
276
277 /// count - Return 1 if the element is in the map, 0 otherwise.
278 size_type count(StringRef Key) const { return contains(Key) ? 1 : 0; }
279
280 template <typename InputTy>
281 size_type count(const StringMapEntry<InputTy> &MapEntry) const {
282 return count(MapEntry.getKey());
283 }
284
285 /// equal - check whether both of the containers are equal.
286 bool operator==(const StringMap &RHS) const {
287 if (size() != RHS.size())
288 return false;
289
290 for (const auto &KeyValue : *this) {
291 auto FindInRHS = RHS.find(KeyValue.getKey());
292
293 if (FindInRHS == RHS.end())
294 return false;
295
296 if constexpr (!std::is_same_v<ValueTy, std::nullopt_t>) {
297 if (!(KeyValue.getValue() == FindInRHS->getValue()))
298 return false;
299 }
300 }
301
302 return true;
303 }
304
305 bool operator!=(const StringMap &RHS) const { return !(*this == RHS); }
306
307 /// insert - Insert the specified key/value pair into the map. If the key
308 /// already exists in the map, return false and ignore the request, otherwise
309 /// insert it and return true.
310 bool insert(MapEntryTy *KeyValue) {
311 unsigned BucketNo = LookupBucketFor(KeyValue->getKey());
312 StringMapEntryBase *&Bucket = TheTable[BucketNo];
313 if (Bucket && Bucket != getTombstoneVal())
314 return false; // Already exists in map.
315
316 if (Bucket == getTombstoneVal())
317 --NumTombstones;
318 Bucket = KeyValue;
319 ++NumItems;
320 assert(NumItems + NumTombstones <= NumBuckets);
321
322 RehashTable();
323 return true;
324 }
325
326 /// insert - Inserts the specified key/value pair into the map if the key
327 /// isn't already in the map. The bool component of the returned pair is true
328 /// if and only if the insertion takes place, and the iterator component of
329 /// the pair points to the element with key equivalent to the key of the pair.
330 std::pair<iterator, bool> insert(std::pair<StringRef, ValueTy> KV) {
331 return try_emplace_with_hash(KV.first, hash(KV.first),
332 std::move(KV.second));
333 }
334
335 std::pair<iterator, bool> insert(std::pair<StringRef, ValueTy> KV,
336 uint32_t FullHashValue) {
337 return try_emplace_with_hash(KV.first, FullHashValue, std::move(KV.second));
338 }
339
340 /// Inserts elements from range [first, last). If multiple elements in the
341 /// range have keys that compare equivalent, it is unspecified which element
342 /// is inserted .
343 template <typename InputIt> void insert(InputIt First, InputIt Last) {
344 for (InputIt It = First; It != Last; ++It)
345 insert(*It);
346 }
347
348 /// Inserts elements from initializer list ilist. If multiple elements in
349 /// the range have keys that compare equivalent, it is unspecified which
350 /// element is inserted
351 void insert(std::initializer_list<std::pair<StringRef, ValueTy>> List) {
352 insert(List.begin(), List.end());
353 }
354
355 /// Inserts an element or assigns to the current element if the key already
356 /// exists. The return type is the same as try_emplace.
357 template <typename V>
358 std::pair<iterator, bool> insert_or_assign(StringRef Key, V &&Val) {
359 auto Ret = try_emplace(Key, std::forward<V>(Val));
360 if (!Ret.second)
361 Ret.first->second = std::forward<V>(Val);
362 return Ret;
363 }
364
365 /// Emplace a new element for the specified key into the map if the key isn't
366 /// already in the map. The bool component of the returned pair is true
367 /// if and only if the insertion takes place, and the iterator component of
368 /// the pair points to the element with key equivalent to the key of the pair.
369 template <typename... ArgsTy>
370 std::pair<iterator, bool> try_emplace(StringRef Key, ArgsTy &&...Args) {
371 return try_emplace_with_hash(Key, hash(Key), std::forward<ArgsTy>(Args)...);
372 }
373
374 template <typename... ArgsTy>
375 std::pair<iterator, bool> try_emplace_with_hash(StringRef Key,
376 uint32_t FullHashValue,
377 ArgsTy &&...Args) {
378 unsigned BucketNo = LookupBucketFor(Key, FullHashValue);
379 StringMapEntryBase *&Bucket = TheTable[BucketNo];
380 if (Bucket && Bucket != getTombstoneVal())
381 return {iterator(TheTable + BucketNo), false}; // Already exists in map.
382
383 if (Bucket == getTombstoneVal())
384 --NumTombstones;
385 Bucket =
386 MapEntryTy::create(Key, getAllocator(), std::forward<ArgsTy>(Args)...);
387 ++NumItems;
388 assert(NumItems + NumTombstones <= NumBuckets);
389
390 BucketNo = RehashTable(BucketNo);
391 return {iterator(TheTable + BucketNo), true};
392 }
393
394 // clear - Empties out the StringMap
395 void clear() {
396 if (empty())
397 return;
398
399 // Zap all values, resetting the keys back to non-present (not tombstone),
400 // which is safe because we're removing all elements.
401 for (StringMapEntryBase *&Bucket : buckets()) {
402 if (Bucket && Bucket != getTombstoneVal()) {
403 static_cast<MapEntryTy *>(Bucket)->Destroy(getAllocator());
404 }
405 Bucket = nullptr;
406 }
407
408 NumItems = 0;
409 NumTombstones = 0;
410 }
411
412 /// remove - Remove the specified key/value pair from the map, but do not
413 /// erase it. This aborts if the key is not in the map.
414 void remove(MapEntryTy *KeyValue) { RemoveKey(KeyValue); }
415
417 MapEntryTy &V = *I;
418 remove(&V);
419 V.Destroy(getAllocator());
420 }
421
422 bool erase(StringRef Key) {
423 iterator I = find(Key);
424 if (I == end())
425 return false;
426 erase(I);
427 return true;
428 }
429};
430
431template <typename ValueTy, bool IsConst> class StringMapIterBase {
432 StringMapEntryBase **Ptr = nullptr;
433
434public:
435 using iterator_category = std::forward_iterator_tag;
437 using difference_type = std::ptrdiff_t;
438 using pointer = std::conditional_t<IsConst, const value_type *, value_type *>;
439 using reference =
440 std::conditional_t<IsConst, const value_type &, value_type &>;
441
442 StringMapIterBase() = default;
443
444 explicit StringMapIterBase(StringMapEntryBase **Bucket, bool Advance = false)
445 : Ptr(Bucket) {
446 if (Advance)
447 AdvancePastEmptyBuckets();
448 }
449
450 reference operator*() const { return *static_cast<value_type *>(*Ptr); }
451 pointer operator->() const { return static_cast<value_type *>(*Ptr); }
452
453 StringMapIterBase &operator++() { // Preincrement
454 ++Ptr;
455 AdvancePastEmptyBuckets();
456 return *this;
457 }
458
459 StringMapIterBase operator++(int) { // Post-increment
460 StringMapIterBase Tmp(*this);
461 ++*this;
462 return Tmp;
463 }
464
465 template <bool ToConst,
466 typename = typename std::enable_if<!IsConst && ToConst>::type>
469 }
470
471 friend bool operator==(const StringMapIterBase &LHS,
472 const StringMapIterBase &RHS) {
473 return LHS.Ptr == RHS.Ptr;
474 }
475
476 friend bool operator!=(const StringMapIterBase &LHS,
477 const StringMapIterBase &RHS) {
478 return !(LHS == RHS);
479 }
480
481private:
482 void AdvancePastEmptyBuckets() {
483 while (*Ptr == nullptr || *Ptr == StringMapImpl::getTombstoneVal())
484 ++Ptr;
485 }
486};
487
488template <typename ValueTy>
490 : public iterator_adaptor_base<StringMapKeyIterator<ValueTy>,
491 StringMapIterBase<ValueTy, true>,
492 std::forward_iterator_tag, StringRef> {
495 std::forward_iterator_tag, StringRef>;
496
497public:
500 : base(std::move(Iter)) {}
501
502 StringRef operator*() const { return this->wrapped()->getKey(); }
503};
504
505} // end namespace llvm
506
507#endif // LLVM_ADT_STRINGMAP_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the StringMapEntry class - it is intended to be a low dependency implementation det...
This file defines MallocAllocator.
#define LLVM_ALLOCATORHOLDER_EMPTYBASE
Definition: AllocatorBase.h:25
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define LLVM_ABI
Definition: Compiler.h:213
uint64_t Size
#define I(x, y, z)
Definition: MD5.cpp:58
const NodeList & List
Definition: RDFGraph.cpp:200
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
Definition: Value.cpp:480
static const BasicSubtargetSubTypeKV * find(StringRef S, ArrayRef< BasicSubtargetSubTypeKV > A)
Find KV in array using binary search.
Value * RHS
Value * LHS
StringMapEntryBase - Shared base class of StringMapEntry instances.
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
StringRef getKey() const
StringMapImpl - This is the base class of StringMap that is shared among all of its instantiations.
Definition: StringMap.h:33
iterator_range< StringMapEntryBase ** > buckets()
Definition: StringMap.h:92
void swap(StringMapImpl &Other)
Definition: StringMap.h:118
static StringMapEntryBase * getTombstoneVal()
Definition: StringMap.h:101
unsigned ItemSize
Definition: StringMap.h:42
unsigned LookupBucketFor(StringRef Key)
LookupBucketFor - Look up the bucket that the specified string should end up in.
Definition: StringMap.h:65
LLVM_ABI unsigned RehashTable(unsigned BucketNo=0)
RehashTable - Grow the table, redistributing values into the buckets with the appropriate mod-of-hash...
Definition: StringMap.cpp:210
unsigned NumItems
Definition: StringMap.h:40
LLVM_ABI void RemoveKey(StringMapEntryBase *V)
RemoveKey - Remove the specified StringMapEntry from the table, but do not delete it.
Definition: StringMap.cpp:185
StringMapEntryBase ** TheTable
Definition: StringMap.h:38
unsigned getNumBuckets() const
Definition: StringMap.h:105
unsigned size() const
Definition: StringMap.h:109
StringMapImpl(unsigned itemSize)
Definition: StringMap.h:45
LLVM_ABI void init(unsigned Size)
Allocate the table with the specified number of buckets and otherwise setup the map as empty.
Definition: StringMap.cpp:59
static LLVM_ABI uint32_t hash(StringRef Key)
Returns the hash value that will be used for the given string.
Definition: StringMap.cpp:46
unsigned getNumItems() const
Definition: StringMap.h:106
unsigned NumBuckets
Definition: StringMap.h:39
static constexpr uintptr_t TombstoneIntVal
Definition: StringMap.h:97
unsigned NumTombstones
Definition: StringMap.h:41
int FindKey(StringRef Key) const
FindKey - Look up the bucket that contains the specified key.
Definition: StringMap.h:75
bool empty() const
Definition: StringMap.h:108
StringMapImpl(StringMapImpl &&RHS)
Definition: StringMap.h:46
std::conditional_t< IsConst, const value_type &, value_type & > reference
Definition: StringMap.h:440
std::forward_iterator_tag iterator_category
Definition: StringMap.h:435
StringMapIterBase & operator++()
Definition: StringMap.h:453
pointer operator->() const
Definition: StringMap.h:451
StringMapIterBase(StringMapEntryBase **Bucket, bool Advance=false)
Definition: StringMap.h:444
StringMapIterBase operator++(int)
Definition: StringMap.h:459
reference operator*() const
Definition: StringMap.h:450
std::conditional_t< IsConst, const value_type *, value_type * > pointer
Definition: StringMap.h:438
friend bool operator==(const StringMapIterBase &LHS, const StringMapIterBase &RHS)
Definition: StringMap.h:471
friend bool operator!=(const StringMapIterBase &LHS, const StringMapIterBase &RHS)
Definition: StringMap.h:476
std::ptrdiff_t difference_type
Definition: StringMap.h:437
StringRef operator*() const
Definition: StringMap.h:502
StringMapKeyIterator(StringMapIterBase< ValueTy, true > Iter)
Definition: StringMap.h:499
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Definition: StringMap.h:133
size_type count(const StringMapEntry< InputTy > &MapEntry) const
Definition: StringMap.h:281
StringMap(StringMap &&RHS)
Definition: StringMap.h:156
bool erase(StringRef Key)
Definition: StringMap.h:422
iterator end()
Definition: StringMap.h:224
StringMap(std::initializer_list< std::pair< StringRef, ValueTy > > List)
Definition: StringMap.h:151
bool operator!=(const StringMap &RHS) const
Definition: StringMap.h:305
iterator begin()
Definition: StringMap.h:223
void remove(MapEntryTy *KeyValue)
remove - Remove the specified key/value pair from the map, but do not erase it.
Definition: StringMap.h:414
std::pair< iterator, bool > insert_or_assign(StringRef Key, V &&Val)
Inserts an element or assigns to the current element if the key already exists.
Definition: StringMap.h:358
iterator find(StringRef Key)
Definition: StringMap.h:235
const_iterator end() const
Definition: StringMap.h:228
StringMap(const StringMap &RHS)
Definition: StringMap.h:159
const ValueTy & at(StringRef Val) const
at - Return the entry for the specified key, or abort if no such entry exists.
Definition: StringMap.h:264
bool contains(StringRef Key) const
contains - Return true if the element is in the map, false otherwise.
Definition: StringMap.h:275
size_t size_type
Definition: StringMap.h:218
ValueTy mapped_type
Definition: StringMap.h:216
iterator find(StringRef Key, uint32_t FullHashValue)
Definition: StringMap.h:237
std::pair< iterator, bool > insert(std::pair< StringRef, ValueTy > KV)
insert - Inserts the specified key/value pair into the map if the key isn't already in the map.
Definition: StringMap.h:330
iterator_range< StringMapKeyIterator< ValueTy > > keys() const
Definition: StringMap.h:230
const_iterator find(StringRef Key) const
Definition: StringMap.h:244
size_type count(StringRef Key) const
count - Return 1 if the element is in the map, 0 otherwise.
Definition: StringMap.h:278
StringMap(AllocatorTy A)
Definition: StringMap.h:144
StringMap & operator=(StringMap RHS)
Definition: StringMap.h:194
void insert(InputIt First, InputIt Last)
Inserts elements from range [first, last).
Definition: StringMap.h:343
ValueTy lookup(StringRef Key) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
Definition: StringMap.h:255
const_iterator find(StringRef Key, uint32_t FullHashValue) const
Definition: StringMap.h:246
const_iterator begin() const
Definition: StringMap.h:225
std::pair< iterator, bool > try_emplace_with_hash(StringRef Key, uint32_t FullHashValue, ArgsTy &&...Args)
Definition: StringMap.h:375
void erase(iterator I)
Definition: StringMap.h:416
StringMap(unsigned InitialSize)
Definition: StringMap.h:141
std::pair< iterator, bool > try_emplace(StringRef Key, ArgsTy &&...Args)
Emplace a new element for the specified key into the map if the key isn't already in the map.
Definition: StringMap.h:370
std::pair< iterator, bool > insert(std::pair< StringRef, ValueTy > KV, uint32_t FullHashValue)
Definition: StringMap.h:335
StringMap(unsigned InitialSize, AllocatorTy A)
Definition: StringMap.h:147
ValueTy & operator[](StringRef Key)
Lookup the ValueTy for the Key, or create a default constructed value if the key is not in the map.
Definition: StringMap.h:272
bool operator==(const StringMap &RHS) const
equal - check whether both of the containers are equal.
Definition: StringMap.h:286
void insert(std::initializer_list< std::pair< StringRef, ValueTy > > List)
Inserts elements from initializer list ilist.
Definition: StringMap.h:351
bool insert(MapEntryTy *KeyValue)
insert - Insert the specified key/value pair into the map.
Definition: StringMap.h:310
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:55
CRTP base class for adapting an iterator to a different type.
Definition: iterator.h:237
A range adaptor for a pair of iterators.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
Definition: STLExtras.h:1702
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
void erase(Container &C, ValueType V)
Wrapper function to remove a value from a container:
Definition: STLExtras.h:2147
@ Other
Any other memory.
auto count(R &&Range, const E &Element)
Wrapper function around std::count to count the number of times an element Element occurs in the give...
Definition: STLExtras.h:1973
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1886
Implement std::hash so that hash_code can be used in STL containers.
Definition: BitVector.h:851
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Definition: BitVector.h:853
A traits type that is used to handle pointer types and things that are just wrappers for pointers as ...