42
42
43
43
namespace llvm {
44
44
45
- template <typename KeyT, typename ValueT, typename Config>
45
+ template <typename KeyT, typename ValueT, typename Config>
46
46
class ValueMapCallbackVH ;
47
- template <typename DenseMapT, typename KeyT>
48
- class ValueMapIterator ;
49
- template <typename DenseMapT, typename KeyT>
50
- class ValueMapConstIterator ;
47
+ template <typename DenseMapT, typename KeyT> class ValueMapIterator ;
48
+ template <typename DenseMapT, typename KeyT> class ValueMapConstIterator ;
51
49
52
50
// / This class defines the default behavior for configurable aspects of
53
51
// / ValueMap<>. User Configs should inherit from this class to be as compatible
54
52
// / as possible with future versions of ValueMap.
55
- template <typename KeyT, typename MutexT = sys::Mutex>
56
- struct ValueMapConfig {
53
+ template <typename KeyT, typename MutexT = sys::Mutex> struct ValueMapConfig {
57
54
using mutex_type = MutexT;
58
55
59
56
// / If FollowRAUW is true, the ValueMap will update mappings on RAUW. If it's
@@ -66,21 +63,24 @@ struct ValueMapConfig {
66
63
// override all the defaults.
67
64
struct ExtraData {};
68
65
69
- template <typename ExtraDataT>
66
+ template <typename ExtraDataT>
70
67
static void onRAUW (const ExtraDataT & /* Data*/ , KeyT /* Old*/ , KeyT /* New*/ ) {}
71
- template <typename ExtraDataT>
72
- static void onDelete (const ExtraDataT &/* Data*/ , KeyT /* Old*/ ) {}
68
+ template <typename ExtraDataT>
69
+ static void onDelete (const ExtraDataT & /* Data*/ , KeyT /* Old*/ ) {}
73
70
74
71
// / Returns a mutex that should be acquired around any changes to the map.
75
72
// / This is only acquired from the CallbackVH (and held around calls to onRAUW
76
73
// / and onDelete) and not inside other ValueMap methods. NULL means that no
77
74
// / mutex is necessary.
78
- template <typename ExtraDataT>
79
- static mutex_type *getMutex (const ExtraDataT &/* Data*/ ) { return nullptr ; }
75
+ template <typename ExtraDataT>
76
+ static mutex_type *getMutex (const ExtraDataT & /* Data*/ ) {
77
+ return nullptr ;
78
+ }
80
79
};
81
80
82
81
// / See the file comment.
83
- template <typename KeyT, typename ValueT, typename Config =ValueMapConfig<KeyT>>
82
+ template <typename KeyT, typename ValueT,
83
+ typename Config = ValueMapConfig<KeyT>>
84
84
class ValueMap {
85
85
friend class ValueMapCallbackVH <KeyT, ValueT, Config>;
86
86
@@ -157,9 +157,7 @@ class ValueMap {
157
157
return Map.find_as (Val) == Map.end () ? 0 : 1 ;
158
158
}
159
159
160
- iterator find (const KeyT &Val) {
161
- return iterator (Map.find_as (Val));
162
- }
160
+ iterator find (const KeyT &Val) { return iterator (Map.find_as (Val)); }
163
161
const_iterator find (const KeyT &Val) const {
164
162
return const_iterator (Map.find_as (Val));
165
163
}
@@ -186,8 +184,7 @@ class ValueMap {
186
184
}
187
185
188
186
// / insert - Range insertion of pairs.
189
- template <typename InputIt>
190
- void insert (InputIt I, InputIt E) {
187
+ template <typename InputIt> void insert (InputIt I, InputIt E) {
191
188
for (; I != E; ++I)
192
189
insert (*I);
193
190
}
@@ -200,17 +197,13 @@ class ValueMap {
200
197
Map.erase (I);
201
198
return true ;
202
199
}
203
- void erase (iterator I) {
204
- return Map.erase (I.base ());
205
- }
200
+ void erase (iterator I) { return Map.erase (I.base ()); }
206
201
207
- value_type& FindAndConstruct (const KeyT &Key) {
202
+ value_type & FindAndConstruct (const KeyT &Key) {
208
203
return Map.FindAndConstruct (Wrap (Key));
209
204
}
210
205
211
- ValueT &operator [](const KeyT &Key) {
212
- return Map[Wrap (Key)];
213
- }
206
+ ValueT &operator [](const KeyT &Key) { return Map[Wrap (Key)]; }
214
207
215
208
// / isPointerIntoBucketsArray - Return true if the specified pointer points
216
209
// / somewhere into the ValueMap's array of buckets (i.e. either to a key or
@@ -235,7 +228,7 @@ class ValueMap {
235
228
// the const_cast incorrect) is if it gets inserted into the map. But then
236
229
// this function must have been called from a non-const method, making the
237
230
// const_cast ok.
238
- return ValueMapCVH (key, const_cast <ValueMap*>(this ));
231
+ return ValueMapCVH (key, const_cast <ValueMap *>(this ));
239
232
}
240
233
};
241
234
@@ -252,7 +245,7 @@ class ValueMapCallbackVH final : public CallbackVH {
252
245
ValueMapT *Map;
253
246
254
247
ValueMapCallbackVH (KeyT Key, ValueMapT *Map)
255
- : CallbackVH(const_cast <Value*>(static_cast <const Value*>(Key))),
248
+ : CallbackVH(const_cast <Value *>(static_cast <const Value *>(Key))),
256
249
Map (Map) {}
257
250
258
251
// Private constructor used to create empty/tombstone DenseMap keys.
@@ -268,8 +261,8 @@ class ValueMapCallbackVH final : public CallbackVH {
268
261
std::unique_lock<typename Config::mutex_type> Guard;
269
262
if (M)
270
263
Guard = std::unique_lock<typename Config::mutex_type>(*M);
271
- Config::onDelete (Copy.Map ->Data , Copy.Unwrap ()); // May destroy *this.
272
- Copy.Map ->Map .erase (Copy); // Definitely destroys *this.
264
+ Config::onDelete (Copy.Map ->Data , Copy.Unwrap ()); // May destroy *this.
265
+ Copy.Map ->Map .erase (Copy); // Definitely destroys *this.
273
266
}
274
267
275
268
void allUsesReplacedWith (Value *new_key) override {
@@ -291,14 +284,14 @@ class ValueMapCallbackVH final : public CallbackVH {
291
284
// removed the old mapping.
292
285
if (I != Copy.Map ->Map .end ()) {
293
286
ValueT Target (std::move (I->second ));
294
- Copy.Map ->Map .erase (I); // Definitely destroys *this.
287
+ Copy.Map ->Map .erase (I); // Definitely destroys *this.
295
288
Copy.Map ->insert (std::make_pair (typed_new_key, std::move (Target)));
296
289
}
297
290
}
298
291
}
299
292
};
300
293
301
- template <typename KeyT, typename ValueT, typename Config>
294
+ template <typename KeyT, typename ValueT, typename Config>
302
295
struct DenseMapInfo <ValueMapCallbackVH<KeyT, ValueT, Config>> {
303
296
using VH = ValueMapCallbackVH<KeyT, ValueT, Config>;
304
297
@@ -318,9 +311,7 @@ struct DenseMapInfo<ValueMapCallbackVH<KeyT, ValueT, Config>> {
318
311
return DenseMapInfo<KeyT>::getHashValue (Val);
319
312
}
320
313
321
- static bool isEqual (const VH &LHS, const VH &RHS) {
322
- return LHS == RHS;
323
- }
314
+ static bool isEqual (const VH &LHS, const VH &RHS) { return LHS == RHS; }
324
315
325
316
static bool isEqual (const KeyT &LHS, const VH &RHS) {
326
317
return LHS == RHS.getValPtr ();
@@ -347,7 +338,7 @@ template <typename DenseMapT, typename KeyT> class ValueMapIterator {
347
338
348
339
struct ValueTypeProxy {
349
340
const KeyT first;
350
- ValueT& second;
341
+ ValueT & second;
351
342
352
343
ValueTypeProxy *operator ->() { return this ; }
353
344
@@ -361,23 +352,19 @@ template <typename DenseMapT, typename KeyT> class ValueMapIterator {
361
352
return Result;
362
353
}
363
354
364
- ValueTypeProxy operator ->() const {
365
- return operator *();
366
- }
355
+ ValueTypeProxy operator ->() const { return operator *(); }
367
356
368
- bool operator ==(const ValueMapIterator &RHS) const {
369
- return I == RHS.I ;
370
- }
371
- bool operator !=(const ValueMapIterator &RHS) const {
372
- return I != RHS.I ;
373
- }
357
+ bool operator ==(const ValueMapIterator &RHS) const { return I == RHS.I ; }
358
+ bool operator !=(const ValueMapIterator &RHS) const { return I != RHS.I ; }
374
359
375
- inline ValueMapIterator& operator ++() { // Preincrement
360
+ inline ValueMapIterator & operator ++() { // Preincrement
376
361
++I;
377
362
return *this ;
378
363
}
379
- ValueMapIterator operator ++(int ) { // Postincrement
380
- ValueMapIterator tmp = *this ; ++*this ; return tmp;
364
+ ValueMapIterator operator ++(int ) { // Postincrement
365
+ ValueMapIterator tmp = *this ;
366
+ ++*this ;
367
+ return tmp;
381
368
}
382
369
};
383
370
@@ -397,13 +384,13 @@ template <typename DenseMapT, typename KeyT> class ValueMapConstIterator {
397
384
ValueMapConstIterator () : I() {}
398
385
ValueMapConstIterator (BaseT I) : I(I) {}
399
386
ValueMapConstIterator (ValueMapIterator<DenseMapT, KeyT> Other)
400
- : I(Other.base()) {}
387
+ : I(Other.base()) {}
401
388
402
389
BaseT base () const { return I; }
403
390
404
391
struct ValueTypeProxy {
405
392
const KeyT first;
406
- const ValueT& second;
393
+ const ValueT & second;
407
394
ValueTypeProxy *operator ->() { return this ; }
408
395
operator std::pair<KeyT, ValueT>() const {
409
396
return std::make_pair (first, second);
@@ -415,23 +402,19 @@ template <typename DenseMapT, typename KeyT> class ValueMapConstIterator {
415
402
return Result;
416
403
}
417
404
418
- ValueTypeProxy operator ->() const {
419
- return operator *();
420
- }
405
+ ValueTypeProxy operator ->() const { return operator *(); }
421
406
422
- bool operator ==(const ValueMapConstIterator &RHS) const {
423
- return I == RHS.I ;
424
- }
425
- bool operator !=(const ValueMapConstIterator &RHS) const {
426
- return I != RHS.I ;
427
- }
407
+ bool operator ==(const ValueMapConstIterator &RHS) const { return I == RHS.I ; }
408
+ bool operator !=(const ValueMapConstIterator &RHS) const { return I != RHS.I ; }
428
409
429
- inline ValueMapConstIterator& operator ++() { // Preincrement
410
+ inline ValueMapConstIterator & operator ++() { // Preincrement
430
411
++I;
431
412
return *this ;
432
413
}
433
- ValueMapConstIterator operator ++(int ) { // Postincrement
434
- ValueMapConstIterator tmp = *this ; ++*this ; return tmp;
414
+ ValueMapConstIterator operator ++(int ) { // Postincrement
415
+ ValueMapConstIterator tmp = *this ;
416
+ ++*this ;
417
+ return tmp;
435
418
}
436
419
};
437
420
0 commit comments