LLVM 23.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
19#include "llvm/ADT/iterator.h"
23#include <initializer_list>
24#include <iterator>
25#include <type_traits>
26
27namespace llvm {
28
29template <typename ValueTy, bool IsConst> class StringMapIterBase;
30template <typename ValueTy> class StringMapKeyIterator;
31
32/// StringMapImpl - This is the base class of StringMap that is shared among
33/// all of its instantiations.
35protected:
36 // Array of NumBuckets pointers to entries, null pointers are holes.
37 // TheTable[NumBuckets] contains a sentinel value for easy iteration. Followed
38 // by an array of the actual hash values as unsigned integers.
40 unsigned NumBuckets = 0;
41 unsigned NumItems = 0;
42 unsigned ItemSize;
43
44protected:
45 explicit StringMapImpl(unsigned itemSize) : ItemSize(itemSize) {}
49 RHS.TheTable = nullptr;
50 RHS.NumBuckets = 0;
51 RHS.NumItems = 0;
52 }
53
54 LLVM_ABI StringMapImpl(unsigned InitSize, unsigned ItemSize);
56 LLVM_ABI unsigned RehashTable(unsigned BucketNo = 0);
57
58 /// LookupBucketFor - Look up the bucket that the specified string should end
59 /// up in. If it already exists as a key in the map, the Item pointer for the
60 /// specified bucket will be non-null. Otherwise, it will be null. In either
61 /// case, the FullHashValue field of the bucket will be set to the hash value
62 /// of the string.
64 return LookupBucketFor(Key, hash(Key));
65 }
66
67 /// Overload that explicitly takes precomputed hash(Key).
68 LLVM_ABI unsigned LookupBucketFor(StringRef Key, uint32_t FullHashValue);
69
70 /// FindKey - Look up the bucket that contains the specified key. If it exists
71 /// in the map, return the bucket number of the key. Otherwise return -1.
72 /// This does not modify the map.
73 int FindKey(StringRef Key) const { return FindKey(Key, hash(Key)); }
74
75 /// Overload that explicitly takes precomputed hash(Key).
76 LLVM_ABI int FindKey(StringRef Key, uint32_t FullHashValue) const;
77
78 /// RemoveKey - Remove the specified StringMapEntry from the table, but do not
79 /// delete it. This aborts if the value isn't in the table.
81
82 /// RemoveKey - Remove the StringMapEntry for the specified key from the
83 /// table, returning it. If the key is not in the table, this returns null.
85
86 /// Remove the entry pointer at the given (live) bucket without destroying
87 /// the entry, and close the hole via Algorithm R backward shifting.
88 LLVM_ABI void removeBucket(unsigned Bucket);
89
90 /// Allocate the table with the specified number of buckets and otherwise
91 /// setup the map as empty.
92 LLVM_ABI void init(unsigned Size);
93
97
98public:
99 [[nodiscard]] unsigned getNumBuckets() const { return NumBuckets; }
100 [[nodiscard]] unsigned getNumItems() const { return NumItems; }
101
102 [[nodiscard]] bool empty() const { return NumItems == 0; }
103 [[nodiscard]] unsigned size() const { return NumItems; }
104
105 /// Returns the hash value that will be used for the given string.
106 /// This allows precomputing the value and passing it explicitly
107 /// to some of the functions.
108 /// The implementation of this function is not guaranteed to be stable
109 /// and may change.
110 [[nodiscard]] LLVM_ABI static uint32_t hash(StringRef Key);
111
114 Other.incrementEpoch();
115 std::swap(TheTable, Other.TheTable);
116 std::swap(NumBuckets, Other.NumBuckets);
117 std::swap(NumItems, Other.NumItems);
118 }
119};
120
121/// StringMap - This is an unconventional map that is specialized for handling
122/// keys that are "strings", which are basically ranges of bytes. This does some
123/// funky memory allocation and hashing things to make it extremely efficient,
124/// storing the string data *after* the value in the map.
125template <typename ValueTy, typename AllocatorTy = MallocAllocator>
127 : public StringMapImpl,
128 private detail::AllocatorHolder<AllocatorTy> {
130
131public:
133
134 StringMap() : StringMapImpl(static_cast<unsigned>(sizeof(MapEntryTy))) {}
135
136 explicit StringMap(unsigned InitialSize)
137 : StringMapImpl(InitialSize, static_cast<unsigned>(sizeof(MapEntryTy))) {}
138
139 explicit StringMap(AllocatorTy A)
140 : StringMapImpl(static_cast<unsigned>(sizeof(MapEntryTy))), AllocTy(A) {}
141
142 StringMap(unsigned InitialSize, AllocatorTy A)
143 : StringMapImpl(InitialSize, static_cast<unsigned>(sizeof(MapEntryTy))),
144 AllocTy(A) {}
145
146 StringMap(std::initializer_list<std::pair<StringRef, ValueTy>> List)
147 : StringMapImpl(List.size(), static_cast<unsigned>(sizeof(MapEntryTy))) {
148 insert(List);
149 }
150
153
155 : StringMapImpl(static_cast<unsigned>(sizeof(MapEntryTy))),
156 AllocTy(RHS.getAllocator()) {
157 if (RHS.empty())
158 return;
159
160 // Allocate TheTable of the same size as RHS's TheTable, and set the
161 // sentinel appropriately (and NumBuckets).
162 init(RHS.NumBuckets);
163 unsigned *HashTable = (unsigned *)(TheTable + NumBuckets + 1),
164 *RHSHashTable = (unsigned *)(RHS.TheTable + NumBuckets + 1);
165
166 NumItems = RHS.NumItems;
167 // Copy the bucket layout verbatim. Preserving each entry's slot keeps
168 // the probe-sequence invariant intact without re-probing.
169 for (unsigned I = 0, E = NumBuckets; I != E; ++I) {
170 StringMapEntryBase *Bucket = RHS.TheTable[I];
171 if (!Bucket)
172 continue;
173
175 static_cast<MapEntryTy *>(Bucket)->getKey(), getAllocator(),
176 static_cast<MapEntryTy *>(Bucket)->getValue());
177 HashTable[I] = RHSHashTable[I];
178 }
179 }
180
183 std::swap(getAllocator(), RHS.getAllocator());
184 return *this;
185 }
186
188 // Delete all the elements in the map, but don't reset the elements
189 // to default values. This is a copy of clear(), but avoids unnecessary
190 // work not required in the destructor.
191 if (!empty()) {
192 for (StringMapEntryBase *Bucket : buckets()) {
193 if (Bucket) {
194 static_cast<MapEntryTy *>(Bucket)->Destroy(getAllocator());
195 }
196 }
197 }
198 }
199
200 using AllocTy::getAllocator;
201
202 using key_type = const char *;
203 using mapped_type = ValueTy;
206
209
210 [[nodiscard]] iterator begin() {
211 return iterator(this, TheTable, NumBuckets != 0);
212 }
213 [[nodiscard]] iterator end() { return iterator(this, TheTable + NumBuckets); }
214 [[nodiscard]] const_iterator begin() const {
215 return const_iterator(this, TheTable, NumBuckets != 0);
216 }
217 [[nodiscard]] const_iterator end() const {
218 return const_iterator(this, TheTable + NumBuckets);
219 }
220
225
226 [[nodiscard]] iterator find(StringRef Key) { return find(Key, hash(Key)); }
227
228 [[nodiscard]] iterator find(StringRef Key, uint32_t FullHashValue) {
229 int Bucket = FindKey(Key, FullHashValue);
230 if (Bucket == -1)
231 return end();
232 return iterator(this, TheTable + Bucket);
233 }
234
235 [[nodiscard]] const_iterator find(StringRef Key) const {
236 return find(Key, hash(Key));
237 }
238
240 uint32_t FullHashValue) const {
241 int Bucket = FindKey(Key, FullHashValue);
242 if (Bucket == -1)
243 return end();
244 return const_iterator(this, TheTable + Bucket);
245 }
246
247 /// lookup - Return the entry for the specified key, or a default
248 /// constructed value if no such entry exists.
249 [[nodiscard]] ValueTy lookup(StringRef Key) const {
250 const_iterator Iter = find(Key);
251 if (Iter != end())
252 return Iter->second;
253 return ValueTy();
254 }
255
256 /// at - Return the entry for the specified key, or abort if no such
257 /// entry exists.
258 [[nodiscard]] const ValueTy &at(StringRef Val) const {
259 auto Iter = this->find(Val);
260 assert(Iter != this->end() && "StringMap::at failed due to a missing key");
261 return Iter->second;
262 }
263
264 /// Lookup the ValueTy for the \p Key, or create a default constructed value
265 /// if the key is not in the map.
266 ValueTy &operator[](StringRef Key) { return try_emplace(Key).first->second; }
267
268 /// contains - Return true if the element is in the map, false otherwise.
269 [[nodiscard]] bool contains(StringRef Key) const {
270 return find(Key) != end();
271 }
272
273 /// count - Return 1 if the element is in the map, 0 otherwise.
274 [[nodiscard]] size_type count(StringRef Key) const {
275 return contains(Key) ? 1 : 0;
276 }
277
278 template <typename InputTy>
279 [[nodiscard]] size_type count(const StringMapEntry<InputTy> &MapEntry) const {
280 return count(MapEntry.getKey());
281 }
282
283 /// equal - check whether both of the containers are equal.
284 [[nodiscard]] bool operator==(const StringMap &RHS) const {
285 if (size() != RHS.size())
286 return false;
287
288 for (const auto &KeyValue : *this) {
289 auto FindInRHS = RHS.find(KeyValue.getKey());
290
291 if (FindInRHS == RHS.end())
292 return false;
293
294 if constexpr (!std::is_same_v<ValueTy, EmptyStringSetTag>) {
295 if (!(KeyValue.getValue() == FindInRHS->getValue()))
296 return false;
297 }
298 }
299
300 return true;
301 }
302
303 [[nodiscard]] bool operator!=(const StringMap &RHS) const {
304 return !(*this == RHS);
305 }
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)
314 return false; // Already exists in map.
315
317 Bucket = KeyValue;
318 ++NumItems;
320
321 RehashTable();
322 return true;
323 }
324
325 /// insert - Inserts the specified key/value pair into the map if the key
326 /// isn't already in the map. The bool component of the returned pair is true
327 /// if and only if the insertion takes place, and the iterator component of
328 /// the pair points to the element with key equivalent to the key of the pair.
329 std::pair<iterator, bool> insert(std::pair<StringRef, ValueTy> KV) {
330 return try_emplace_with_hash(KV.first, hash(KV.first),
331 std::move(KV.second));
332 }
333
334 std::pair<iterator, bool> insert(std::pair<StringRef, ValueTy> KV,
335 uint32_t FullHashValue) {
336 return try_emplace_with_hash(KV.first, FullHashValue, std::move(KV.second));
337 }
338
339 /// Inserts elements from range [first, last). If multiple elements in the
340 /// range have keys that compare equivalent, it is unspecified which element
341 /// is inserted .
342 template <typename InputIt> void insert(InputIt First, InputIt Last) {
343 for (InputIt It = First; It != Last; ++It)
344 insert(*It);
345 }
346
347 /// Inserts elements from initializer list ilist. If multiple elements in
348 /// the range have keys that compare equivalent, it is unspecified which
349 /// element is inserted
350 void insert(std::initializer_list<std::pair<StringRef, ValueTy>> List) {
351 insert(List.begin(), List.end());
352 }
353
354 /// Inserts an element or assigns to the current element if the key already
355 /// exists. The return type is the same as try_emplace.
356 template <typename V>
357 std::pair<iterator, bool> insert_or_assign(StringRef Key, V &&Val) {
358 auto Ret = try_emplace(Key, std::forward<V>(Val));
359 if (!Ret.second)
360 Ret.first->second = std::forward<V>(Val);
361 return Ret;
362 }
363
364 /// Emplace a new element for the specified key into the map if the key isn't
365 /// already in the map. The bool component of the returned pair is true
366 /// if and only if the insertion takes place, and the iterator component of
367 /// the pair points to the element with key equivalent to the key of the pair.
368 template <typename... ArgsTy>
369 std::pair<iterator, bool> try_emplace(StringRef Key, ArgsTy &&...Args) {
370 return try_emplace_with_hash(Key, hash(Key), std::forward<ArgsTy>(Args)...);
371 }
372
373 template <typename... ArgsTy>
374 std::pair<iterator, bool> try_emplace_with_hash(StringRef Key,
375 uint32_t FullHashValue,
376 ArgsTy &&...Args) {
377 unsigned BucketNo = LookupBucketFor(Key, FullHashValue);
378 StringMapEntryBase *&Bucket = TheTable[BucketNo];
379 if (Bucket)
380 return {iterator(this, TheTable + BucketNo), false}; // Already in map.
381
383 Bucket =
384 MapEntryTy::create(Key, getAllocator(), std::forward<ArgsTy>(Args)...);
385 ++NumItems;
387
388 BucketNo = RehashTable(BucketNo);
389 return {iterator(this, TheTable + BucketNo), true};
390 }
391
392 // clear - Empties out the StringMap
393 void clear() {
395 if (empty())
396 return;
397
398 // Zap all values, resetting the keys back to non-present, which is safe
399 // because we're removing all elements.
400 for (StringMapEntryBase *&Bucket : buckets()) {
401 if (Bucket) {
402 static_cast<MapEntryTy *>(Bucket)->Destroy(getAllocator());
403 }
404 Bucket = nullptr;
405 }
406
407 NumItems = 0;
408 }
409
410 /// remove - Remove the specified key/value pair from the map, but do not
411 /// erase it. This aborts if the key is not in the map.
412 void remove(MapEntryTy *KeyValue) {
414 RemoveKey(KeyValue);
415 }
416
418 MapEntryTy &V = *I;
419 remove(&V);
420 V.Destroy(getAllocator());
421 }
422
424 iterator I = find(Key);
425 if (I == end())
426 return false;
427 erase(I);
428 return true;
429 }
430
431 /// Remove entries that match the given predicate. \p Pred is invoked with a
432 /// reference to each live entry and must not access the map being modified.
433 /// This is the safe replacement for erase-while-iterating.
434 ///
435 /// Returns whether anything was removed. If so, all iterators and references
436 /// into the map are invalidated.
437 template <typename Predicate> bool remove_if(Predicate Pred) {
438 bool Removed = false;
439 for (unsigned I = 0; I != NumBuckets;) {
440 StringMapEntryBase *Bucket = TheTable[I];
441 if (!Bucket) {
442 ++I;
443 continue;
444 }
445 auto *Entry = static_cast<MapEntryTy *>(Bucket);
446 if (!Pred(*Entry)) {
447 ++I;
448 continue;
449 }
450 Entry->Destroy(getAllocator());
451 // This may relocate a following entry into this slot to close the hole,
452 // so re-examine the same index rather than advancing past it.
454 Removed = true;
455 }
456 if (Removed)
458 return Removed;
459 }
460};
461
462template <typename ValueTy, bool IsConst>
464 friend class StringMapIterBase<ValueTy, true>;
465 friend class StringMapIterBase<ValueTy, false>;
466
467 StringMapEntryBase **Ptr = nullptr;
468
469public:
470 using iterator_category = std::forward_iterator_tag;
472 using difference_type = std::ptrdiff_t;
473 using pointer = std::conditional_t<IsConst, const value_type *, value_type *>;
474 using reference =
475 std::conditional_t<IsConst, const value_type &, value_type &>;
476
477 StringMapIterBase() = default;
478
479 explicit StringMapIterBase(const DebugEpochBase *Epoch,
480 StringMapEntryBase **Bucket, bool Advance = false)
481 : DebugEpochBase::HandleBase(Epoch), Ptr(Bucket) {
482 if (Advance)
483 AdvancePastEmptyBuckets();
484 }
485
486 // Converting ctor from non-const to const iterators. SFINAE'd out for const
487 // sources so it doesn't shadow the implicit copy constructor.
488 template <bool IsConstSrc,
489 typename = std::enable_if_t<!IsConstSrc && IsConst>>
492
493 [[nodiscard]] reference operator*() const {
494 assert(isHandleInSync() && "invalid iterator access!");
495 return *static_cast<value_type *>(*Ptr);
496 }
497 [[nodiscard]] pointer operator->() const {
498 assert(isHandleInSync() && "invalid iterator access!");
499 return static_cast<value_type *>(*Ptr);
500 }
501
502 StringMapIterBase &operator++() { // Preincrement
503 assert(isHandleInSync() && "invalid iterator access!");
504 ++Ptr;
505 AdvancePastEmptyBuckets();
506 return *this;
507 }
508
509 StringMapIterBase operator++(int) { // Post-increment
510 StringMapIterBase Tmp(*this);
511 ++*this;
512 return Tmp;
513 }
514
515 friend bool operator==(const StringMapIterBase &LHS,
516 const StringMapIterBase &RHS) {
517 assert((!LHS.getEpochAddress() || LHS.isHandleInSync()) &&
518 "handle not in sync!");
519 assert((!RHS.getEpochAddress() || RHS.isHandleInSync()) &&
520 "handle not in sync!");
521 return LHS.Ptr == RHS.Ptr;
522 }
523
524 friend bool operator!=(const StringMapIterBase &LHS,
525 const StringMapIterBase &RHS) {
526 return !(LHS == RHS);
527 }
528
529private:
530 void AdvancePastEmptyBuckets() {
531 while (*Ptr == nullptr)
532 ++Ptr;
533 }
534};
535
536template <typename ValueTy>
538 : public iterator_adaptor_base<StringMapKeyIterator<ValueTy>,
539 StringMapIterBase<ValueTy, true>,
540 std::forward_iterator_tag, StringRef> {
543 std::forward_iterator_tag, StringRef>;
544
545public:
548 : base(std::move(Iter)) {}
549
550 StringRef operator*() const { return this->wrapped()->getKey(); }
551};
552
553} // end namespace llvm
554
555#endif // LLVM_ADT_STRINGMAP_H
for(const MachineOperand &MO :llvm::drop_begin(OldMI.operands(), Desc.getNumOperands()))
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
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
This file defines the DebugEpochBase and DebugEpochBase::HandleBase classes.
static constexpr Value * getValue(Ty &ValueOrUse)
#define I(x, y, z)
Definition MD5.cpp:57
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
Definition Value.cpp:484
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.
static StringMapEntry * create(StringRef key, AllocatorTy &allocator, InitTy &&...initVals)
StringRef getKey() const
iterator_range< StringMapEntryBase ** > buckets()
Definition StringMap.h:94
void swap(StringMapImpl &Other)
Definition StringMap.h:112
unsigned LookupBucketFor(StringRef Key)
LookupBucketFor - Look up the bucket that the specified string should end up in.
Definition StringMap.h:63
LLVM_ABI unsigned RehashTable(unsigned BucketNo=0)
RehashTable - Grow the table, redistributing values into the buckets with the appropriate mod-of-hash...
LLVM_ABI void RemoveKey(StringMapEntryBase *V)
RemoveKey - Remove the specified StringMapEntry from the table, but do not delete it.
StringMapEntryBase ** TheTable
Definition StringMap.h:39
unsigned getNumBuckets() const
Definition StringMap.h:99
LLVM_ABI void removeBucket(unsigned Bucket)
Remove the entry pointer at the given (live) bucket without destroying the entry, and close the hole ...
unsigned size() const
Definition StringMap.h:103
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:100
unsigned NumBuckets
Definition StringMap.h:40
int FindKey(StringRef Key) const
FindKey - Look up the bucket that contains the specified key.
Definition StringMap.h:73
bool empty() const
Definition StringMap.h:102
StringMapImpl(StringMapImpl &&RHS)
Definition StringMap.h:46
std::forward_iterator_tag iterator_category
Definition StringMap.h:470
StringMapIterBase & operator++()
Definition StringMap.h:502
pointer operator->() const
Definition StringMap.h:497
StringMapEntry< ValueTy > value_type
Definition StringMap.h:471
StringMapIterBase operator++(int)
Definition StringMap.h:509
reference operator*() const
Definition StringMap.h:493
StringMapIterBase(const DebugEpochBase *Epoch, StringMapEntryBase **Bucket, bool Advance=false)
Definition StringMap.h:479
std::conditional_t< IsConst, const value_type *, value_type * > pointer
Definition StringMap.h:473
friend bool operator==(const StringMapIterBase &LHS, const StringMapIterBase &RHS)
Definition StringMap.h:515
StringMapIterBase(const StringMapIterBase< ValueTy, IsConstSrc > &I)
Definition StringMap.h:490
friend bool operator!=(const StringMapIterBase &LHS, const StringMapIterBase &RHS)
Definition StringMap.h:524
std::conditional_t< IsConst, const value_type &, value_type & > reference
Definition StringMap.h:474
StringRef operator*() const
Definition StringMap.h:550
StringMapKeyIterator(StringMapIterBase< ValueTy, true > Iter)
Definition StringMap.h:547
size_type count(const StringMapEntry< InputTy > &MapEntry) const
Definition StringMap.h:279
StringMap(StringMap &&RHS)
Definition StringMap.h:151
bool erase(StringRef Key)
Definition StringMap.h:423
iterator end()
Definition StringMap.h:213
StringMap(std::initializer_list< std::pair< StringRef, ValueTy > > List)
Definition StringMap.h:146
bool operator!=(const StringMap &RHS) const
Definition StringMap.h:303
iterator begin()
Definition StringMap.h:210
void remove(MapEntryTy *KeyValue)
remove - Remove the specified key/value pair from the map, but do not erase it.
Definition StringMap.h:412
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:357
iterator find(StringRef Key)
Definition StringMap.h:226
const_iterator end() const
Definition StringMap.h:217
StringMap(const StringMap &RHS)
Definition StringMap.h:154
const ValueTy & at(StringRef Val) const
at - Return the entry for the specified key, or abort if no such entry exists.
Definition StringMap.h:258
bool contains(StringRef Key) const
contains - Return true if the element is in the map, false otherwise.
Definition StringMap.h:269
StringMapIterBase< ValueTy, false > iterator
Definition StringMap.h:208
ValueTy mapped_type
Definition StringMap.h:203
bool remove_if(Predicate Pred)
Remove entries that match the given predicate.
Definition StringMap.h:437
const char * key_type
Definition StringMap.h:202
iterator find(StringRef Key, uint32_t FullHashValue)
Definition StringMap.h:228
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:329
iterator_range< StringMapKeyIterator< ValueTy > > keys() const
Definition StringMap.h:221
const_iterator find(StringRef Key) const
Definition StringMap.h:235
size_type count(StringRef Key) const
count - Return 1 if the element is in the map, 0 otherwise.
Definition StringMap.h:274
StringMap(AllocatorTy A)
Definition StringMap.h:139
StringMap & operator=(StringMap RHS)
Definition StringMap.h:181
void insert(InputIt First, InputIt Last)
Inserts elements from range [first, last).
Definition StringMap.h:342
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:249
StringMapEntry< ValueTy > value_type
Definition StringMap.h:204
const_iterator find(StringRef Key, uint32_t FullHashValue) const
Definition StringMap.h:239
StringMapIterBase< ValueTy, true > const_iterator
Definition StringMap.h:207
const_iterator begin() const
Definition StringMap.h:214
std::pair< iterator, bool > try_emplace_with_hash(StringRef Key, uint32_t FullHashValue, ArgsTy &&...Args)
Definition StringMap.h:374
void erase(iterator I)
Definition StringMap.h:417
StringMap(unsigned InitialSize)
Definition StringMap.h:136
std::pair< iterator, bool > try_emplace(StringRef Key, ArgsTy &&...Args)
Definition StringMap.h:369
std::pair< iterator, bool > insert(std::pair< StringRef, ValueTy > KV, uint32_t FullHashValue)
Definition StringMap.h:334
StringMap(unsigned InitialSize, AllocatorTy A)
Definition StringMap.h:142
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:266
bool operator==(const StringMap &RHS) const
equal - check whether both of the containers are equal.
Definition StringMap.h:284
StringMapEntry< ValueTy > MapEntryTy
Definition StringMap.h:132
void insert(std::initializer_list< std::pair< StringRef, ValueTy > > List)
Inserts elements from initializer list ilist.
Definition StringMap.h:350
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
A range adaptor for a pair of iterators.
This is an optimization pass for GlobalISel generic memory operations.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
@ Other
Any other memory.
Definition ModRef.h:68
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
Definition ModRef.h:74
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:1916
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:860
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Definition BitVector.h:862