LLVM 20.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"
21#include <initializer_list>
22#include <iterator>
23
24namespace llvm {
25
26template <typename ValueTy> class StringMapConstIterator;
27template <typename ValueTy> class StringMapIterator;
28template <typename ValueTy> class StringMapKeyIterator;
29
30/// StringMapImpl - This is the base class of StringMap that is shared among
31/// all of its instantiations.
33protected:
34 // Array of NumBuckets pointers to entries, null pointers are holes.
35 // TheTable[NumBuckets] contains a sentinel value for easy iteration. Followed
36 // by an array of the actual hash values as unsigned integers.
38 unsigned NumBuckets = 0;
39 unsigned NumItems = 0;
40 unsigned NumTombstones = 0;
41 unsigned ItemSize;
42
43protected:
44 explicit StringMapImpl(unsigned itemSize) : ItemSize(itemSize) {}
49 RHS.TheTable = nullptr;
50 RHS.NumBuckets = 0;
51 RHS.NumItems = 0;
52 RHS.NumTombstones = 0;
53 }
54
55 StringMapImpl(unsigned InitSize, unsigned ItemSize);
57 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.
64 unsigned LookupBucketFor(StringRef Key) {
65 return LookupBucketFor(Key, hash(Key));
66 }
67
68 /// Overload that explicitly takes precomputed hash(Key).
69 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 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 /// Allocate the table with the specified number of buckets and otherwise
88 /// setup the map as empty.
89 void init(unsigned Size);
90
91public:
92 static constexpr uintptr_t TombstoneIntVal =
93 static_cast<uintptr_t>(-1)
95
97 return reinterpret_cast<StringMapEntryBase *>(TombstoneIntVal);
98 }
99
100 unsigned getNumBuckets() const { return NumBuckets; }
101 unsigned getNumItems() const { return NumItems; }
102
103 bool empty() const { return NumItems == 0; }
104 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 static uint32_t hash(StringRef Key);
112
114 std::swap(TheTable, Other.TheTable);
115 std::swap(NumBuckets, Other.NumBuckets);
116 std::swap(NumItems, Other.NumItems);
117 std::swap(NumTombstones, Other.NumTombstones);
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
152 : StringMapImpl(std::move(RHS)), AllocTy(std::move(RHS.getAllocator())) {}
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 NumTombstones = RHS.NumTombstones;
168 for (unsigned I = 0, E = NumBuckets; I != E; ++I) {
169 StringMapEntryBase *Bucket = RHS.TheTable[I];
170 if (!Bucket || Bucket == getTombstoneVal()) {
171 TheTable[I] = Bucket;
172 continue;
173 }
174
175 TheTable[I] = MapEntryTy::create(
176 static_cast<MapEntryTy *>(Bucket)->getKey(), getAllocator(),
177 static_cast<MapEntryTy *>(Bucket)->getValue());
178 HashTable[I] = RHSHashTable[I];
179 }
180
181 // Note that here we've copied everything from the RHS into this object,
182 // tombstones included. We could, instead, have re-probed for each key to
183 // instantiate this new object without any tombstone buckets. The
184 // assumption here is that items are rarely deleted from most StringMaps,
185 // and so tombstones are rare, so the cost of re-probing for all inputs is
186 // not worthwhile.
187 }
188
190 StringMapImpl::swap(RHS);
191 std::swap(getAllocator(), RHS.getAllocator());
192 return *this;
193 }
194
196 // Delete all the elements in the map, but don't reset the elements
197 // to default values. This is a copy of clear(), but avoids unnecessary
198 // work not required in the destructor.
199 if (!empty()) {
200 for (unsigned I = 0, E = NumBuckets; I != E; ++I) {
201 StringMapEntryBase *Bucket = TheTable[I];
202 if (Bucket && Bucket != getTombstoneVal()) {
203 static_cast<MapEntryTy *>(Bucket)->Destroy(getAllocator());
204 }
205 }
206 }
207 }
208
209 using AllocTy::getAllocator;
210
211 using key_type = const char *;
212 using mapped_type = ValueTy;
214 using size_type = size_t;
215
218
219 iterator begin() { return iterator(TheTable, NumBuckets == 0); }
220 iterator end() { return iterator(TheTable + NumBuckets, true); }
222 return const_iterator(TheTable, NumBuckets == 0);
223 }
225 return const_iterator(TheTable + NumBuckets, true);
226 }
227
231 }
232
233 iterator find(StringRef Key) { return find(Key, hash(Key)); }
234
235 iterator find(StringRef Key, uint32_t FullHashValue) {
236 int Bucket = FindKey(Key, FullHashValue);
237 if (Bucket == -1)
238 return end();
239 return iterator(TheTable + Bucket, true);
240 }
241
242 const_iterator find(StringRef Key) const { return find(Key, hash(Key)); }
243
244 const_iterator find(StringRef Key, uint32_t FullHashValue) const {
245 int Bucket = FindKey(Key, FullHashValue);
246 if (Bucket == -1)
247 return end();
248 return const_iterator(TheTable + Bucket, true);
249 }
250
251 /// lookup - Return the entry for the specified key, or a default
252 /// constructed value if no such entry exists.
253 ValueTy lookup(StringRef Key) const {
254 const_iterator Iter = find(Key);
255 if (Iter != end())
256 return Iter->second;
257 return ValueTy();
258 }
259
260 /// at - Return the entry for the specified key, or abort if no such
261 /// entry exists.
262 const ValueTy &at(StringRef Val) const {
263 auto Iter = this->find(std::move(Val));
264 assert(Iter != this->end() && "StringMap::at failed due to a missing key");
265 return Iter->second;
266 }
267
268 /// Lookup the ValueTy for the \p Key, or create a default constructed value
269 /// if the key is not in the map.
270 ValueTy &operator[](StringRef Key) { return try_emplace(Key).first->second; }
271
272 /// contains - Return true if the element is in the map, false otherwise.
273 bool contains(StringRef Key) const { return find(Key) != end(); }
274
275 /// count - Return 1 if the element is in the map, 0 otherwise.
276 size_type count(StringRef Key) const { return contains(Key) ? 1 : 0; }
277
278 template <typename InputTy>
279 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 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, std::nullopt_t>) {
295 if (!(KeyValue.getValue() == FindInRHS->getValue()))
296 return false;
297 }
298 }
299
300 return true;
301 }
302
303 bool operator!=(const StringMap &RHS) const { return !(*this == RHS); }
304
305 /// insert - Insert the specified key/value pair into the map. If the key
306 /// already exists in the map, return false and ignore the request, otherwise
307 /// insert it and return true.
308 bool insert(MapEntryTy *KeyValue) {
309 unsigned BucketNo = LookupBucketFor(KeyValue->getKey());
310 StringMapEntryBase *&Bucket = TheTable[BucketNo];
311 if (Bucket && Bucket != getTombstoneVal())
312 return false; // Already exists in map.
313
314 if (Bucket == getTombstoneVal())
315 --NumTombstones;
316 Bucket = KeyValue;
317 ++NumItems;
318 assert(NumItems + NumTombstones <= NumBuckets);
319
320 RehashTable();
321 return true;
322 }
323
324 /// insert - Inserts the specified key/value pair into the map if the key
325 /// isn't already in the map. The bool component of the returned pair is true
326 /// if and only if the insertion takes place, and the iterator component of
327 /// the pair points to the element with key equivalent to the key of the pair.
328 std::pair<iterator, bool> insert(std::pair<StringRef, ValueTy> KV) {
329 return try_emplace_with_hash(KV.first, hash(KV.first),
330 std::move(KV.second));
331 }
332
333 std::pair<iterator, bool> insert(std::pair<StringRef, ValueTy> KV,
334 uint32_t FullHashValue) {
335 return try_emplace_with_hash(KV.first, FullHashValue, std::move(KV.second));
336 }
337
338 /// Inserts elements from range [first, last). If multiple elements in the
339 /// range have keys that compare equivalent, it is unspecified which element
340 /// is inserted .
341 template <typename InputIt> void insert(InputIt First, InputIt Last) {
342 for (InputIt It = First; It != Last; ++It)
343 insert(*It);
344 }
345
346 /// Inserts elements from initializer list ilist. If multiple elements in
347 /// the range have keys that compare equivalent, it is unspecified which
348 /// element is inserted
349 void insert(std::initializer_list<std::pair<StringRef, ValueTy>> List) {
350 insert(List.begin(), List.end());
351 }
352
353 /// Inserts an element or assigns to the current element if the key already
354 /// exists. The return type is the same as try_emplace.
355 template <typename V>
356 std::pair<iterator, bool> insert_or_assign(StringRef Key, V &&Val) {
357 auto Ret = try_emplace(Key, std::forward<V>(Val));
358 if (!Ret.second)
359 Ret.first->second = std::forward<V>(Val);
360 return Ret;
361 }
362
363 /// Emplace a new element for the specified key into the map if the key isn't
364 /// already in the map. The bool component of the returned pair is true
365 /// if and only if the insertion takes place, and the iterator component of
366 /// the pair points to the element with key equivalent to the key of the pair.
367 template <typename... ArgsTy>
368 std::pair<iterator, bool> try_emplace(StringRef Key, ArgsTy &&...Args) {
369 return try_emplace_with_hash(Key, hash(Key), std::forward<ArgsTy>(Args)...);
370 }
371
372 template <typename... ArgsTy>
373 std::pair<iterator, bool> try_emplace_with_hash(StringRef Key,
374 uint32_t FullHashValue,
375 ArgsTy &&...Args) {
376 unsigned BucketNo = LookupBucketFor(Key, FullHashValue);
377 StringMapEntryBase *&Bucket = TheTable[BucketNo];
378 if (Bucket && Bucket != getTombstoneVal())
379 return std::make_pair(iterator(TheTable + BucketNo, false),
380 false); // Already exists in map.
381
382 if (Bucket == getTombstoneVal())
383 --NumTombstones;
384 Bucket =
385 MapEntryTy::create(Key, getAllocator(), std::forward<ArgsTy>(Args)...);
386 ++NumItems;
387 assert(NumItems + NumTombstones <= NumBuckets);
388
389 BucketNo = RehashTable(BucketNo);
390 return std::make_pair(iterator(TheTable + BucketNo, false), true);
391 }
392
393 // clear - Empties out the StringMap
394 void clear() {
395 if (empty())
396 return;
397
398 // Zap all values, resetting the keys back to non-present (not tombstone),
399 // which is safe because we're removing all elements.
400 for (unsigned I = 0, E = NumBuckets; I != E; ++I) {
401 StringMapEntryBase *&Bucket = TheTable[I];
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 DerivedTy, typename ValueTy>
433 : public iterator_facade_base<DerivedTy, std::forward_iterator_tag,
434 ValueTy> {
435protected:
437
438public:
439 StringMapIterBase() = default;
440
442 bool NoAdvance = false)
443 : Ptr(Bucket) {
444 if (!NoAdvance)
445 AdvancePastEmptyBuckets();
446 }
447
448 DerivedTy &operator=(const DerivedTy &Other) {
449 Ptr = Other.Ptr;
450 return static_cast<DerivedTy &>(*this);
451 }
452
453 friend bool operator==(const DerivedTy &LHS, const DerivedTy &RHS) {
454 return LHS.Ptr == RHS.Ptr;
455 }
456
457 DerivedTy &operator++() { // Preincrement
458 ++Ptr;
459 AdvancePastEmptyBuckets();
460 return static_cast<DerivedTy &>(*this);
461 }
462
463 DerivedTy operator++(int) { // Post-increment
464 DerivedTy Tmp(Ptr);
465 ++*this;
466 return Tmp;
467 }
468
469private:
470 void AdvancePastEmptyBuckets() {
471 while (*Ptr == nullptr || *Ptr == StringMapImpl::getTombstoneVal())
472 ++Ptr;
473 }
474};
475
476template <typename ValueTy>
478 : public StringMapIterBase<StringMapConstIterator<ValueTy>,
479 const StringMapEntry<ValueTy>> {
482
483public:
486 bool NoAdvance = false)
487 : base(Bucket, NoAdvance) {}
488
490 return *static_cast<const StringMapEntry<ValueTy> *>(*this->Ptr);
491 }
492};
493
494template <typename ValueTy>
495class StringMapIterator : public StringMapIterBase<StringMapIterator<ValueTy>,
496 StringMapEntry<ValueTy>> {
497 using base =
499
500public:
501 StringMapIterator() = default;
503 bool NoAdvance = false)
504 : base(Bucket, NoAdvance) {}
505
507 return *static_cast<StringMapEntry<ValueTy> *>(*this->Ptr);
508 }
509
511 return StringMapConstIterator<ValueTy>(this->Ptr, true);
512 }
513};
514
515template <typename ValueTy>
517 : public iterator_adaptor_base<StringMapKeyIterator<ValueTy>,
518 StringMapConstIterator<ValueTy>,
519 std::forward_iterator_tag, StringRef> {
522 std::forward_iterator_tag, StringRef>;
523
524public:
527 : base(std::move(Iter)) {}
528
529 StringRef operator*() const { return this->wrapped()->getKey(); }
530};
531
532} // end namespace llvm
533
534#endif // LLVM_ADT_STRINGMAP_H
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")
uint64_t Size
#define I(x, y, z)
Definition: MD5.cpp:58
ToRemove erase(NewLastIter, ToRemove.end())
const NodeList & List
Definition: RDFGraph.cpp:200
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
Definition: Value.cpp:469
Value * RHS
Value * LHS
StringMapConstIterator(StringMapEntryBase **Bucket, bool NoAdvance=false)
Definition: StringMap.h:485
const StringMapEntry< ValueTy > & operator*() const
Definition: StringMap.h:489
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:32
void swap(StringMapImpl &Other)
Definition: StringMap.h:113
static StringMapEntryBase * getTombstoneVal()
Definition: StringMap.h:96
unsigned ItemSize
Definition: StringMap.h:41
unsigned LookupBucketFor(StringRef Key)
LookupBucketFor - Look up the bucket that the specified string should end up in.
Definition: StringMap.h:64
unsigned RehashTable(unsigned BucketNo=0)
RehashTable - Grow the table, redistributing values into the buckets with the appropriate mod-of-hash...
Definition: StringMap.cpp:218
unsigned NumItems
Definition: StringMap.h:39
void RemoveKey(StringMapEntryBase *V)
RemoveKey - Remove the specified StringMapEntry from the table, but do not delete it.
Definition: StringMap.cpp:193
StringMapEntryBase ** TheTable
Definition: StringMap.h:37
unsigned getNumBuckets() const
Definition: StringMap.h:100
unsigned size() const
Definition: StringMap.h:104
StringMapImpl(unsigned itemSize)
Definition: StringMap.h:44
void init(unsigned Size)
Allocate the table with the specified number of buckets and otherwise setup the map as empty.
Definition: StringMap.cpp:67
static 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:101
unsigned NumBuckets
Definition: StringMap.h:38
static constexpr uintptr_t TombstoneIntVal
Definition: StringMap.h:92
unsigned NumTombstones
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:45
DerivedTy & operator++()
Definition: StringMap.h:457
StringMapEntryBase ** Ptr
Definition: StringMap.h:436
DerivedTy operator++(int)
Definition: StringMap.h:463
DerivedTy & operator=(const DerivedTy &Other)
Definition: StringMap.h:448
StringMapIterBase(StringMapEntryBase **Bucket, bool NoAdvance=false)
Definition: StringMap.h:441
friend bool operator==(const DerivedTy &LHS, const DerivedTy &RHS)
Definition: StringMap.h:453
StringMapIterator(StringMapEntryBase **Bucket, bool NoAdvance=false)
Definition: StringMap.h:502
StringMapEntry< ValueTy > & operator*() const
Definition: StringMap.h:506
StringRef operator*() const
Definition: StringMap.h:529
StringMapKeyIterator(StringMapConstIterator< ValueTy > Iter)
Definition: StringMap.h:526
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Definition: StringMap.h:128
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:422
iterator end()
Definition: StringMap.h:220
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:219
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:356
iterator find(StringRef Key)
Definition: StringMap.h:233
const_iterator end() const
Definition: StringMap.h:224
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:262
bool contains(StringRef Key) const
contains - Return true if the element is in the map, false otherwise.
Definition: StringMap.h:273
size_t size_type
Definition: StringMap.h:214
ValueTy mapped_type
Definition: StringMap.h:212
iterator find(StringRef Key, uint32_t FullHashValue)
Definition: StringMap.h:235
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:328
iterator_range< StringMapKeyIterator< ValueTy > > keys() const
Definition: StringMap.h:228
const_iterator find(StringRef Key) const
Definition: StringMap.h:242
size_type count(StringRef Key) const
count - Return 1 if the element is in the map, 0 otherwise.
Definition: StringMap.h:276
StringMap(AllocatorTy A)
Definition: StringMap.h:139
StringMap & operator=(StringMap RHS)
Definition: StringMap.h:189
void insert(InputIt First, InputIt Last)
Inserts elements from range [first, last).
Definition: StringMap.h:341
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:253
const_iterator find(StringRef Key, uint32_t FullHashValue) const
Definition: StringMap.h:244
const_iterator begin() const
Definition: StringMap.h:221
std::pair< iterator, bool > try_emplace_with_hash(StringRef Key, uint32_t FullHashValue, ArgsTy &&...Args)
Definition: StringMap.h:373
void erase(iterator I)
Definition: StringMap.h:416
StringMap(unsigned InitialSize)
Definition: StringMap.h:136
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:368
std::pair< iterator, bool > insert(std::pair< StringRef, ValueTy > KV, uint32_t FullHashValue)
Definition: StringMap.h:333
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:270
bool operator==(const StringMap &RHS) const
equal - check whether both of the containers are equal.
Definition: StringMap.h:284
void insert(std::initializer_list< std::pair< StringRef, ValueTy > > List)
Inserts elements from initializer list ilist.
Definition: StringMap.h:349
bool insert(MapEntryTy *KeyValue)
insert - Insert the specified key/value pair into the map.
Definition: StringMap.h:308
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
CRTP base class for adapting an iterator to a different type.
Definition: iterator.h:237
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
Definition: iterator.h:80
A range adaptor for a pair of iterators.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
auto find(R &&Range, const T &Val)
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1759
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:1697
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
@ 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:1938
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:1873
Implement std::hash so that hash_code can be used in STL containers.
Definition: BitVector.h:858
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Definition: BitVector.h:860
A traits type that is used to handle pointer types and things that are just wrappers for pointers as ...