LLVM 24.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 RHS.incrementEpoch();
53 }
54
55 LLVM_ABI StringMapImpl(unsigned InitSize, unsigned ItemSize);
57 LLVM_ABI unsigned RehashTable(unsigned BucketNo = 0);
58
59 /// LookupBucketFor - Look up the bucket that the specified string should end
60 /// up in. If it already exists as a key in the map, the Item pointer for the
61 /// specified bucket will be non-null. Otherwise, it will be null. In either
62 /// case, the FullHashValue field of the bucket will be set to the hash value
63 /// of the string.
65 return LookupBucketFor(Key, hash(Key));
66 }
67
68 /// Overload that explicitly takes precomputed hash(Key).
69 LLVM_ABI unsigned LookupBucketFor(StringRef Key, uint32_t FullHashValue);
70
71 /// FindKey - Look up the bucket that contains the specified key. If it exists
72 /// in the map, return the bucket number of the key. Otherwise return -1.
73 /// This does not modify the map.
74 int FindKey(StringRef Key) const { return FindKey(Key, hash(Key)); }
75
76 /// Overload that explicitly takes precomputed hash(Key).
77 LLVM_ABI int FindKey(StringRef Key, uint32_t FullHashValue) const;
78
79 /// RemoveKey - Remove the specified StringMapEntry from the table, but do not
80 /// delete it. This aborts if the value isn't in the table.
82
83 /// RemoveKey - Remove the StringMapEntry for the specified key from the
84 /// table, returning it. If the key is not in the table, this returns null.
86
87 /// Remove the entry pointer at the given (live) bucket without destroying
88 /// the entry, and close the hole via Algorithm R backward shifting.
89 LLVM_ABI void removeBucket(unsigned Bucket);
90
91 /// Allocate the table with the specified number of buckets and otherwise
92 /// setup the map as empty.
93 LLVM_ABI void init(unsigned Size);
94
98
99public:
100 [[nodiscard]] unsigned getNumBuckets() const { return NumBuckets; }
101 [[nodiscard]] unsigned getNumItems() const { return NumItems; }
102
103 [[nodiscard]] bool empty() const { return NumItems == 0; }
104 [[nodiscard]] unsigned size() const { return NumItems; }
105
106 /// Returns the hash value that will be used for the given string.
107 /// This allows precomputing the value and passing it explicitly
108 /// to some of the functions.
109 /// The implementation of this function is not guaranteed to be stable
110 /// and may change.
111 [[nodiscard]] LLVM_ABI static uint32_t hash(StringRef Key);
112
115 Other.incrementEpoch();
116 std::swap(TheTable, Other.TheTable);
117 std::swap(NumBuckets, Other.NumBuckets);
118 std::swap(NumItems, Other.NumItems);
119 }
120};
121
122/// StringMap - This is an unconventional map that is specialized for handling
123/// keys that are "strings", which are basically ranges of bytes. This does some
124/// funky memory allocation and hashing things to make it extremely efficient,
125/// storing the string data *after* the value in the map.
126template <typename ValueTy, typename AllocatorTy = MallocAllocator>
128 : public StringMapImpl,
129 private detail::AllocatorHolder<AllocatorTy> {
131
132public:
134
135 StringMap() : StringMapImpl(static_cast<unsigned>(sizeof(MapEntryTy))) {}
136
137 explicit StringMap(unsigned InitialSize)
138 : StringMapImpl(InitialSize, static_cast<unsigned>(sizeof(MapEntryTy))) {}
139
140 explicit StringMap(AllocatorTy A)
141 : StringMapImpl(static_cast<unsigned>(sizeof(MapEntryTy))), AllocTy(A) {}
142
143 StringMap(unsigned InitialSize, AllocatorTy A)
144 : StringMapImpl(InitialSize, static_cast<unsigned>(sizeof(MapEntryTy))),
145 AllocTy(A) {}
146
147 StringMap(std::initializer_list<std::pair<StringRef, ValueTy>> List)
148 : StringMapImpl(List.size(), static_cast<unsigned>(sizeof(MapEntryTy))) {
149 insert(List);
150 }
151
154
156 : StringMapImpl(static_cast<unsigned>(sizeof(MapEntryTy))),
157 AllocTy(RHS.getAllocator()) {
158 if (RHS.empty())
159 return;
160
161 // Allocate TheTable of the same size as RHS's TheTable, and set the
162 // sentinel appropriately (and NumBuckets).
163 init(RHS.NumBuckets);
164 unsigned *HashTable = (unsigned *)(TheTable + NumBuckets + 1),
165 *RHSHashTable = (unsigned *)(RHS.TheTable + NumBuckets + 1);
166
167 NumItems = RHS.NumItems;
168 // Copy the bucket layout verbatim. Preserving each entry's slot keeps
169 // the probe-sequence invariant intact without re-probing.
170 for (unsigned I = 0, E = NumBuckets; I != E; ++I) {
171 StringMapEntryBase *Bucket = RHS.TheTable[I];
172 if (!Bucket)
173 continue;
174
176 static_cast<MapEntryTy *>(Bucket)->getKey(), getAllocator(),
177 static_cast<MapEntryTy *>(Bucket)->getValue());
178 HashTable[I] = RHSHashTable[I];
179 }
180 }
181
184 std::swap(getAllocator(), RHS.getAllocator());
185 return *this;
186 }
187
189 // Delete all the elements in the map, but don't reset the elements
190 // to default values. This is a copy of clear(), but avoids unnecessary
191 // work not required in the destructor.
192 if (!empty()) {
193 for (StringMapEntryBase *Bucket : buckets()) {
194 if (Bucket) {
195 static_cast<MapEntryTy *>(Bucket)->Destroy(getAllocator());
196 }
197 }
198 }
199 }
200
201 using AllocTy::getAllocator;
202
203 using key_type = const char *;
204 using mapped_type = ValueTy;
207
210
211 [[nodiscard]] iterator begin() {
212 return iterator(this, TheTable, NumBuckets != 0);
213 }
214 [[nodiscard]] iterator end() { return iterator(this, TheTable + NumBuckets); }
215 [[nodiscard]] const_iterator begin() const {
216 return const_iterator(this, TheTable, NumBuckets != 0);
217 }
218 [[nodiscard]] const_iterator end() const {
219 return const_iterator(this, TheTable + NumBuckets);
220 }
221
226
227 [[nodiscard]] iterator find(StringRef Key) { return find(Key, hash(Key)); }
228
229 [[nodiscard]] iterator find(StringRef Key, uint32_t FullHashValue) {
230 int Bucket = FindKey(Key, FullHashValue);
231 if (Bucket == -1)
232 return end();
233 return iterator(this, TheTable + Bucket);
234 }
235
236 [[nodiscard]] const_iterator find(StringRef Key) const {
237 return find(Key, hash(Key));
238 }
239
241 uint32_t FullHashValue) const {
242 int Bucket = FindKey(Key, FullHashValue);
243 if (Bucket == -1)
244 return end();
245 return const_iterator(this, TheTable + Bucket);
246 }
247
248 /// lookup - Return the entry for the specified key, or a default
249 /// constructed value if no such entry exists.
250 [[nodiscard]] ValueTy lookup(StringRef Key) const {
251 const_iterator Iter = find(Key);
252 if (Iter != end())
253 return Iter->second;
254 return ValueTy();
255 }
256
257 /// at - Return the entry for the specified key, or abort if no such
258 /// entry exists.
259 [[nodiscard]] const ValueTy &at(StringRef Val) const {
260 auto Iter = this->find(Val);
261 assert(Iter != this->end() && "StringMap::at failed due to a missing key");
262 return Iter->second;
263 }
264
265 /// Lookup the ValueTy for the \p Key, or create a default constructed value
266 /// if the key is not in the map.
267 ValueTy &operator[](StringRef Key) { return try_emplace(Key).first->second; }
268
269 /// contains - Return true if the element is in the map, false otherwise.
270 [[nodiscard]] bool contains(StringRef Key) const {
271 return find(Key) != end();
272 }
273
274 /// count - Return 1 if the element is in the map, 0 otherwise.
275 [[nodiscard]] size_type count(StringRef Key) const {
276 return contains(Key) ? 1 : 0;
277 }
278
279 template <typename InputTy>
280 [[nodiscard]] size_type count(const StringMapEntry<InputTy> &MapEntry) const {
281 return count(MapEntry.getKey());
282 }
283
284 /// equal - check whether both of the containers are equal.
285 [[nodiscard]] bool operator==(const StringMap &RHS) const {
286 if (size() != RHS.size())
287 return false;
288
289 for (const auto &KeyValue : *this) {
290 auto FindInRHS = RHS.find(KeyValue.getKey());
291
292 if (FindInRHS == RHS.end())
293 return false;
294
295 if constexpr (!std::is_same_v<ValueTy, EmptyStringSetTag>) {
296 if (!(KeyValue.getValue() == FindInRHS->getValue()))
297 return false;
298 }
299 }
300
301 return true;
302 }
303
304 [[nodiscard]] bool operator!=(const StringMap &RHS) const {
305 return !(*this == RHS);
306 }
307
308 /// insert - Insert the specified key/value pair into the map. If the key
309 /// already exists in the map, return false and ignore the request, otherwise
310 /// insert it and return true.
311 bool insert(MapEntryTy *KeyValue) {
312 unsigned BucketNo = LookupBucketFor(KeyValue->getKey());
313 StringMapEntryBase *&Bucket = TheTable[BucketNo];
314 if (Bucket)
315 return false; // Already exists in map.
316
318 Bucket = KeyValue;
319 ++NumItems;
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)
381 return {iterator(this, TheTable + BucketNo), false}; // Already in map.
382
384 Bucket =
385 MapEntryTy::create(Key, getAllocator(), std::forward<ArgsTy>(Args)...);
386 ++NumItems;
388
389 BucketNo = RehashTable(BucketNo);
390 return {iterator(this, TheTable + BucketNo), true};
391 }
392
393 // clear - Empties out the StringMap
394 void clear() {
396 if (empty())
397 return;
398
399 // Zap all values, resetting the keys back to non-present, which is safe
400 // because we're removing all elements.
401 for (StringMapEntryBase *&Bucket : buckets()) {
402 if (Bucket) {
403 static_cast<MapEntryTy *>(Bucket)->Destroy(getAllocator());
404 }
405 Bucket = nullptr;
406 }
407
408 NumItems = 0;
409 }
410
411 /// remove - Remove the specified key/value pair from the map, but do not
412 /// erase it. This aborts if the key is not in the map.
413 void remove(MapEntryTy *KeyValue) {
415 RemoveKey(KeyValue);
416 }
417
419 MapEntryTy &V = *I;
420 remove(&V);
421 V.Destroy(getAllocator());
422 }
423
425 iterator I = find(Key);
426 if (I == end())
427 return false;
428 erase(I);
429 return true;
430 }
431
432 /// Remove entries that match the given predicate. \p Pred is invoked with a
433 /// reference to each live entry and must not access the map being modified.
434 /// This is the safe replacement for erase-while-iterating.
435 ///
436 /// Returns whether anything was removed. If so, all iterators and references
437 /// into the map are invalidated.
438 template <typename Predicate> bool remove_if(Predicate Pred) {
439 bool Removed = false;
440 for (unsigned I = 0; I != NumBuckets;) {
441 StringMapEntryBase *Bucket = TheTable[I];
442 if (!Bucket) {
443 ++I;
444 continue;
445 }
446 auto *Entry = static_cast<MapEntryTy *>(Bucket);
447 if (!Pred(*Entry)) {
448 ++I;
449 continue;
450 }
451 Entry->Destroy(getAllocator());
452 // This may relocate a following entry into this slot to close the hole,
453 // so re-examine the same index rather than advancing past it.
455 Removed = true;
456 }
457 if (Removed)
459 return Removed;
460 }
461};
462
463template <typename ValueTy, bool IsConst>
465 friend class StringMapIterBase<ValueTy, true>;
466 friend class StringMapIterBase<ValueTy, false>;
467
468 StringMapEntryBase **Ptr = nullptr;
469
470public:
471 using iterator_category = std::forward_iterator_tag;
473 using difference_type = std::ptrdiff_t;
474 using pointer = std::conditional_t<IsConst, const value_type *, value_type *>;
475 using reference =
476 std::conditional_t<IsConst, const value_type &, value_type &>;
477
478 StringMapIterBase() = default;
479
480 explicit StringMapIterBase(const DebugEpochBase *Epoch,
481 StringMapEntryBase **Bucket, bool Advance = false)
482 : DebugEpochBase::HandleBase(Epoch), Ptr(Bucket) {
483 if (Advance)
484 AdvancePastEmptyBuckets();
485 }
486
487 // Converting ctor from non-const to const iterators. SFINAE'd out for const
488 // sources so it doesn't shadow the implicit copy constructor.
489 template <bool IsConstSrc,
490 typename = std::enable_if_t<!IsConstSrc && IsConst>>
493
494 [[nodiscard]] reference operator*() const {
495 assert(isHandleInSync() && "invalid iterator access!");
496 return *static_cast<value_type *>(*Ptr);
497 }
498 [[nodiscard]] pointer operator->() const {
499 assert(isHandleInSync() && "invalid iterator access!");
500 return static_cast<value_type *>(*Ptr);
501 }
502
503 StringMapIterBase &operator++() { // Preincrement
504 assert(isHandleInSync() && "invalid iterator access!");
505 ++Ptr;
506 AdvancePastEmptyBuckets();
507 return *this;
508 }
509
510 StringMapIterBase operator++(int) { // Post-increment
511 StringMapIterBase Tmp(*this);
512 ++*this;
513 return Tmp;
514 }
515
516 friend bool operator==(const StringMapIterBase &LHS,
517 const StringMapIterBase &RHS) {
518 assert(LHS.isComparableWith(RHS) && "incomparable iterators!");
519 return LHS.Ptr == RHS.Ptr;
520 }
521
522 friend bool operator!=(const StringMapIterBase &LHS,
523 const StringMapIterBase &RHS) {
524 return !(LHS == RHS);
525 }
526
527private:
528 void AdvancePastEmptyBuckets() {
529 while (*Ptr == nullptr)
530 ++Ptr;
531 }
532};
533
534template <typename ValueTy>
536 : public iterator_adaptor_base<StringMapKeyIterator<ValueTy>,
537 StringMapIterBase<ValueTy, true>,
538 std::forward_iterator_tag, StringRef> {
541 std::forward_iterator_tag, StringRef>;
542
543public:
546 : base(std::move(Iter)) {}
547
548 StringRef operator*() const { return this->wrapped()->getKey(); }
549};
550
551} // end namespace llvm
552
553#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:215
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:95
void swap(StringMapImpl &Other)
Definition StringMap.h:113
unsigned LookupBucketFor(StringRef Key)
LookupBucketFor - Look up the bucket that the specified string should end up in.
Definition StringMap.h:64
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:100
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:104
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:58
static LLVM_ABI uint32_t hash(StringRef Key)
Returns the hash value that will be used for the given string.
Definition StringMap.cpp:45
unsigned getNumItems() const
Definition StringMap.h:101
unsigned NumBuckets
Definition StringMap.h:40
int FindKey(StringRef Key) const
FindKey - Look up the bucket that contains the specified key.
Definition StringMap.h:74
bool empty() const
Definition StringMap.h:103
StringMapImpl(StringMapImpl &&RHS)
Definition StringMap.h:46
std::forward_iterator_tag iterator_category
Definition StringMap.h:471
StringMapIterBase & operator++()
Definition StringMap.h:503
pointer operator->() const
Definition StringMap.h:498
StringMapEntry< ValueTy > value_type
Definition StringMap.h:472
StringMapIterBase operator++(int)
Definition StringMap.h:510
reference operator*() const
Definition StringMap.h:494
StringMapIterBase(const DebugEpochBase *Epoch, StringMapEntryBase **Bucket, bool Advance=false)
Definition StringMap.h:480
std::conditional_t< IsConst, const value_type *, value_type * > pointer
Definition StringMap.h:474
friend bool operator==(const StringMapIterBase &LHS, const StringMapIterBase &RHS)
Definition StringMap.h:516
StringMapIterBase(const StringMapIterBase< ValueTy, IsConstSrc > &I)
Definition StringMap.h:491
friend bool operator!=(const StringMapIterBase &LHS, const StringMapIterBase &RHS)
Definition StringMap.h:522
std::conditional_t< IsConst, const value_type &, value_type & > reference
Definition StringMap.h:475
StringRef operator*() const
Definition StringMap.h:548
StringMapKeyIterator(StringMapIterBase< ValueTy, true > Iter)
Definition StringMap.h:545
size_type count(const StringMapEntry< InputTy > &MapEntry) const
Definition StringMap.h:280
StringMap(StringMap &&RHS)
Definition StringMap.h:152
bool erase(StringRef Key)
Definition StringMap.h:424
iterator end()
Definition StringMap.h:214
StringMap(std::initializer_list< std::pair< StringRef, ValueTy > > List)
Definition StringMap.h:147
bool operator!=(const StringMap &RHS) const
Definition StringMap.h:304
iterator begin()
Definition StringMap.h:211
void remove(MapEntryTy *KeyValue)
remove - Remove the specified key/value pair from the map, but do not erase it.
Definition StringMap.h:413
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:227
const_iterator end() const
Definition StringMap.h:218
StringMap(const StringMap &RHS)
Definition StringMap.h:155
const ValueTy & at(StringRef Val) const
at - Return the entry for the specified key, or abort if no such entry exists.
Definition StringMap.h:259
bool contains(StringRef Key) const
contains - Return true if the element is in the map, false otherwise.
Definition StringMap.h:270
StringMapIterBase< ValueTy, false > iterator
Definition StringMap.h:209
ValueTy mapped_type
Definition StringMap.h:204
bool remove_if(Predicate Pred)
Remove entries that match the given predicate.
Definition StringMap.h:438
const char * key_type
Definition StringMap.h:203
iterator find(StringRef Key, uint32_t FullHashValue)
Definition StringMap.h:229
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:222
const_iterator find(StringRef Key) const
Definition StringMap.h:236
size_type count(StringRef Key) const
count - Return 1 if the element is in the map, 0 otherwise.
Definition StringMap.h:275
StringMap(AllocatorTy A)
Definition StringMap.h:140
StringMap & operator=(StringMap RHS)
Definition StringMap.h:182
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:250
StringMapEntry< ValueTy > value_type
Definition StringMap.h:205
const_iterator find(StringRef Key, uint32_t FullHashValue) const
Definition StringMap.h:240
StringMapIterBase< ValueTy, true > const_iterator
Definition StringMap.h:208
const_iterator begin() const
Definition StringMap.h:215
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:418
StringMap(unsigned InitialSize)
Definition StringMap.h:137
std::pair< iterator, bool > try_emplace(StringRef Key, ArgsTy &&...Args)
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:143
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:267
bool operator==(const StringMap &RHS) const
equal - check whether both of the containers are equal.
Definition StringMap.h:285
StringMapEntry< ValueTy > MapEntryTy
Definition StringMap.h:133
void insert(std::initializer_list< std::pair< StringRef, ValueTy > > List)
Inserts elements from initializer list ilist.
Definition StringMap.h:351
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
A range adaptor for a pair of iterators.
FollowingPoolPopCache erase(Autorelease)
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:1917
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:878
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Definition BitVector.h:880