@@ -448,6 +448,11 @@ class DenseMapBase : public DebugEpochBase {
448448 static const KeyT getTombstoneKey () { return KeyInfoT::getTombstoneKey (); }
449449
450450private:
451+ DerivedT &derived () { return *static_cast <DerivedT *>(this ); }
452+ const DerivedT &derived () const {
453+ return *static_cast <const DerivedT *>(this );
454+ }
455+
451456 template <typename KeyArgT, typename ... Ts>
452457 std::pair<BucketT *, bool > lookupOrInsertIntoBucket (KeyArgT &&Key,
453458 Ts &&...Args) {
@@ -477,39 +482,27 @@ class DenseMapBase : public DebugEpochBase {
477482 return const_iterator::makeIterator (TheBucket, buckets (), *this );
478483 }
479484
480- unsigned getNumEntries () const {
481- return static_cast <const DerivedT *>(this )->getNumEntries ();
482- }
485+ unsigned getNumEntries () const { return derived ().getNumEntries (); }
483486
484- void setNumEntries (unsigned Num) {
485- static_cast <DerivedT *>(this )->setNumEntries (Num);
486- }
487+ void setNumEntries (unsigned Num) { derived ().setNumEntries (Num); }
487488
488489 void incrementNumEntries () { setNumEntries (getNumEntries () + 1 ); }
489490
490491 void decrementNumEntries () { setNumEntries (getNumEntries () - 1 ); }
491492
492- unsigned getNumTombstones () const {
493- return static_cast <const DerivedT *>(this )->getNumTombstones ();
494- }
493+ unsigned getNumTombstones () const { return derived ().getNumTombstones (); }
495494
496- void setNumTombstones (unsigned Num) {
497- static_cast <DerivedT *>(this )->setNumTombstones (Num);
498- }
495+ void setNumTombstones (unsigned Num) { derived ().setNumTombstones (Num); }
499496
500497 void incrementNumTombstones () { setNumTombstones (getNumTombstones () + 1 ); }
501498
502499 void decrementNumTombstones () { setNumTombstones (getNumTombstones () - 1 ); }
503500
504- const BucketT *getBuckets () const {
505- return static_cast <const DerivedT *>(this )->getBuckets ();
506- }
501+ const BucketT *getBuckets () const { return derived ().getBuckets (); }
507502
508- BucketT *getBuckets () { return static_cast <DerivedT *>( this )-> getBuckets (); }
503+ BucketT *getBuckets () { return derived (). getBuckets (); }
509504
510- unsigned getNumBuckets () const {
511- return static_cast <const DerivedT *>(this )->getNumBuckets ();
512- }
505+ unsigned getNumBuckets () const { return derived ().getNumBuckets (); }
513506
514507 BucketT *getBucketsEnd () { return getBuckets () + getNumBuckets (); }
515508
@@ -525,9 +518,9 @@ class DenseMapBase : public DebugEpochBase {
525518 return llvm::make_range (getBuckets (), getBucketsEnd ());
526519 }
527520
528- void grow (unsigned AtLeast) { static_cast <DerivedT *>( this )-> grow (AtLeast); }
521+ void grow (unsigned AtLeast) { derived (). grow (AtLeast); }
529522
530- void shrink_and_clear () { static_cast <DerivedT *>( this )-> shrink_and_clear (); }
523+ void shrink_and_clear () { derived (). shrink_and_clear (); }
531524
532525 template <typename LookupKeyT>
533526 BucketT *findBucketForInsertion (const LookupKeyT &Lookup,
0 commit comments