@@ -448,6 +448,11 @@ class DenseMapBase : public DebugEpochBase {
448
448
static const KeyT getTombstoneKey () { return KeyInfoT::getTombstoneKey (); }
449
449
450
450
private:
451
+ DerivedT &derived () { return *static_cast <DerivedT *>(this ); }
452
+ const DerivedT &derived () const {
453
+ return *static_cast <const DerivedT *>(this );
454
+ }
455
+
451
456
template <typename KeyArgT, typename ... Ts>
452
457
std::pair<BucketT *, bool > lookupOrInsertIntoBucket (KeyArgT &&Key,
453
458
Ts &&...Args) {
@@ -477,39 +482,27 @@ class DenseMapBase : public DebugEpochBase {
477
482
return const_iterator::makeIterator (TheBucket, buckets (), *this );
478
483
}
479
484
480
- unsigned getNumEntries () const {
481
- return static_cast <const DerivedT *>(this )->getNumEntries ();
482
- }
485
+ unsigned getNumEntries () const { return derived ().getNumEntries (); }
483
486
484
- void setNumEntries (unsigned Num) {
485
- static_cast <DerivedT *>(this )->setNumEntries (Num);
486
- }
487
+ void setNumEntries (unsigned Num) { derived ().setNumEntries (Num); }
487
488
488
489
void incrementNumEntries () { setNumEntries (getNumEntries () + 1 ); }
489
490
490
491
void decrementNumEntries () { setNumEntries (getNumEntries () - 1 ); }
491
492
492
- unsigned getNumTombstones () const {
493
- return static_cast <const DerivedT *>(this )->getNumTombstones ();
494
- }
493
+ unsigned getNumTombstones () const { return derived ().getNumTombstones (); }
495
494
496
- void setNumTombstones (unsigned Num) {
497
- static_cast <DerivedT *>(this )->setNumTombstones (Num);
498
- }
495
+ void setNumTombstones (unsigned Num) { derived ().setNumTombstones (Num); }
499
496
500
497
void incrementNumTombstones () { setNumTombstones (getNumTombstones () + 1 ); }
501
498
502
499
void decrementNumTombstones () { setNumTombstones (getNumTombstones () - 1 ); }
503
500
504
- const BucketT *getBuckets () const {
505
- return static_cast <const DerivedT *>(this )->getBuckets ();
506
- }
501
+ const BucketT *getBuckets () const { return derived ().getBuckets (); }
507
502
508
- BucketT *getBuckets () { return static_cast <DerivedT *>( this )-> getBuckets (); }
503
+ BucketT *getBuckets () { return derived (). getBuckets (); }
509
504
510
- unsigned getNumBuckets () const {
511
- return static_cast <const DerivedT *>(this )->getNumBuckets ();
512
- }
505
+ unsigned getNumBuckets () const { return derived ().getNumBuckets (); }
513
506
514
507
BucketT *getBucketsEnd () { return getBuckets () + getNumBuckets (); }
515
508
@@ -525,9 +518,9 @@ class DenseMapBase : public DebugEpochBase {
525
518
return llvm::make_range (getBuckets (), getBucketsEnd ());
526
519
}
527
520
528
- void grow (unsigned AtLeast) { static_cast <DerivedT *>( this )-> grow (AtLeast); }
521
+ void grow (unsigned AtLeast) { derived (). grow (AtLeast); }
529
522
530
- void shrink_and_clear () { static_cast <DerivedT *>( this )-> shrink_and_clear (); }
523
+ void shrink_and_clear () { derived (). shrink_and_clear (); }
531
524
532
525
template <typename LookupKeyT>
533
526
BucketT *findBucketForInsertion (const LookupKeyT &Lookup,
0 commit comments