diff --git a/compiler-rt/lib/asan/asan_allocator.h b/compiler-rt/lib/asan/asan_allocator.h --- a/compiler-rt/lib/asan/asan_allocator.h +++ b/compiler-rt/lib/asan/asan_allocator.h @@ -195,10 +195,6 @@ #endif // SANITIZER_CAN_USE_ALLOCATOR64 static const uptr kNumberOfSizeClasses = SizeClassMap::kNumClasses; -template -using AllocatorCacheASVT = - SizeClassAllocatorLocalCache>; -using AllocatorCache = AllocatorCacheASVT; template using SecondaryAllocatorASVT = @@ -207,10 +203,10 @@ template using AsanAllocatorASVT = CombinedAllocator, - AllocatorCacheASVT, SecondaryAllocatorASVT, AddressSpaceView>; using AsanAllocator = AsanAllocatorASVT; +using AllocatorCache = AsanAllocator::AllocatorCache; struct AsanThreadLocalMallocStorage { uptr quarantine_cache[16]; diff --git a/compiler-rt/lib/hwasan/hwasan_allocator.h b/compiler-rt/lib/hwasan/hwasan_allocator.h --- a/compiler-rt/lib/hwasan/hwasan_allocator.h +++ b/compiler-rt/lib/hwasan/hwasan_allocator.h @@ -61,10 +61,9 @@ static const uptr kFlags = 0; }; typedef SizeClassAllocator64 PrimaryAllocator; -typedef SizeClassAllocatorLocalCache AllocatorCache; typedef LargeMmapAllocator SecondaryAllocator; -typedef CombinedAllocator Allocator; +typedef CombinedAllocator Allocator; +typedef Allocator::AllocatorCache AllocatorCache; void AllocatorSwallowThreadLocalCache(AllocatorCache *cache); diff --git a/compiler-rt/lib/lsan/lsan_allocator.h b/compiler-rt/lib/lsan/lsan_allocator.h --- a/compiler-rt/lib/lsan/lsan_allocator.h +++ b/compiler-rt/lib/lsan/lsan_allocator.h @@ -96,11 +96,6 @@ using PrimaryAllocator = PrimaryAllocatorASVT; #endif -template -using AllocatorCacheASVT = - SizeClassAllocatorLocalCache>; -using AllocatorCache = AllocatorCacheASVT; - template using SecondaryAllocatorASVT = LargeMmapAllocator using AllocatorASVT = CombinedAllocator, - AllocatorCacheASVT, SecondaryAllocatorASVT, AddressSpaceView>; using Allocator = AllocatorASVT; +using AllocatorCache = Allocator::AllocatorCache; -AllocatorCache *GetAllocatorCache(); +Allocator::AllocatorCache *GetAllocatorCache(); int lsan_posix_memalign(void **memptr, uptr alignment, uptr size, const StackTrace &stack); diff --git a/compiler-rt/lib/msan/msan_allocator.cc b/compiler-rt/lib/msan/msan_allocator.cc --- a/compiler-rt/lib/msan/msan_allocator.cc +++ b/compiler-rt/lib/msan/msan_allocator.cc @@ -116,10 +116,9 @@ }; typedef SizeClassAllocator32 PrimaryAllocator; #endif -typedef SizeClassAllocatorLocalCache AllocatorCache; typedef LargeMmapAllocator SecondaryAllocator; -typedef CombinedAllocator Allocator; +typedef CombinedAllocator Allocator; +typedef Allocator::AllocatorCache AllocatorCache; static Allocator allocator; static AllocatorCache fallback_allocator_cache; diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_combined.h b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_combined.h --- a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_combined.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_combined.h @@ -19,11 +19,11 @@ // When allocating 2^x bytes it should return 2^x aligned chunk. // PrimaryAllocator is used via a local AllocatorCache. // SecondaryAllocator can allocate anything, but is not efficient. -template // NOLINT class CombinedAllocator { public: + using AllocatorCache = SizeClassAllocatorLocalCache; using AddressSpaceView = AddressSpaceViewTy; static_assert(is_same::value, diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_internal.h b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_internal.h --- a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_internal.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_internal.h @@ -43,15 +43,13 @@ }; typedef SizeClassAllocator32 PrimaryInternalAllocator; -typedef SizeClassAllocatorLocalCache - InternalAllocatorCache; - typedef LargeMmapAllocator SecondaryInternalAllocator; -typedef CombinedAllocator InternalAllocator; +typedef CombinedAllocator + InternalAllocator; +typedef InternalAllocator::AllocatorCache InternalAllocatorCache; void *InternalAlloc(uptr size, InternalAllocatorCache *cache = nullptr, uptr alignment = 0); diff --git a/compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_test.cc b/compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_test.cc --- a/compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_test.cc +++ b/compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_test.cc @@ -619,17 +619,14 @@ a.Deallocate(&stats, p); } -template - +template void TestCombinedAllocator() { - typedef - CombinedAllocator - Allocator; + typedef CombinedAllocator Allocator; Allocator *a = new Allocator; a->Init(kReleaseToOSIntervalNever); std::mt19937 r; - AllocatorCache cache; + typename Allocator::AllocatorCache cache; memset(&cache, 0, sizeof(cache)); a->InitCache(&cache); @@ -690,36 +687,26 @@ #if SANITIZER_CAN_USE_ALLOCATOR64 TEST(SanitizerCommon, CombinedAllocator64) { - TestCombinedAllocator, - SizeClassAllocatorLocalCache > (); + TestCombinedAllocator>(); } TEST(SanitizerCommon, CombinedAllocator64Dynamic) { - TestCombinedAllocator, - SizeClassAllocatorLocalCache > (); + TestCombinedAllocator>(); } #if !SANITIZER_ANDROID TEST(SanitizerCommon, CombinedAllocator64Compact) { - TestCombinedAllocator, - SizeClassAllocatorLocalCache > (); + TestCombinedAllocator>(); } #endif TEST(SanitizerCommon, CombinedAllocator64VeryCompact) { - TestCombinedAllocator, - SizeClassAllocatorLocalCache > (); + TestCombinedAllocator>(); } #endif TEST(SanitizerCommon, CombinedAllocator32Compact) { - TestCombinedAllocator, - SizeClassAllocatorLocalCache > (); + TestCombinedAllocator>(); } template diff --git a/compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_testlib.cc b/compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_testlib.cc --- a/compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_testlib.cc +++ b/compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_testlib.cc @@ -49,10 +49,9 @@ namespace { typedef SizeClassAllocator64<__AP64> PrimaryAllocator; -typedef SizeClassAllocatorLocalCache AllocatorCache; typedef LargeMmapAllocator<> SecondaryAllocator; -typedef CombinedAllocator Allocator; +typedef CombinedAllocator Allocator; +typedef Allocator::AllocatorCache AllocatorCache; static Allocator allocator; static bool global_inited; diff --git a/compiler-rt/lib/scudo/scudo_allocator.h b/compiler-rt/lib/scudo/scudo_allocator.h --- a/compiler-rt/lib/scudo/scudo_allocator.h +++ b/compiler-rt/lib/scudo/scudo_allocator.h @@ -109,9 +109,9 @@ #include "scudo_allocator_secondary.h" #include "scudo_allocator_combined.h" -typedef SizeClassAllocatorLocalCache AllocatorCacheT; typedef LargeMmapAllocator SecondaryT; -typedef CombinedAllocator BackendT; +typedef CombinedAllocator BackendT; +typedef BackendT::AllocatorCache AllocatorCacheT; void initScudo(); diff --git a/compiler-rt/lib/scudo/scudo_allocator_combined.h b/compiler-rt/lib/scudo/scudo_allocator_combined.h --- a/compiler-rt/lib/scudo/scudo_allocator_combined.h +++ b/compiler-rt/lib/scudo/scudo_allocator_combined.h @@ -18,10 +18,10 @@ # error "This file must be included inside scudo_allocator.h." #endif -template +template class CombinedAllocator { public: + using AllocatorCache = typename PrimaryAllocator::AllocatorCache; void init(s32 ReleaseToOSIntervalMs) { Primary.Init(ReleaseToOSIntervalMs); Secondary.Init(); diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl.h b/compiler-rt/lib/tsan/rtl/tsan_rtl.h --- a/compiler-rt/lib/tsan/rtl/tsan_rtl.h +++ b/compiler-rt/lib/tsan/rtl/tsan_rtl.h @@ -84,10 +84,9 @@ }; typedef SizeClassAllocator64 PrimaryAllocator; #endif -typedef SizeClassAllocatorLocalCache AllocatorCache; typedef LargeMmapAllocator SecondaryAllocator; -typedef CombinedAllocator Allocator; +typedef CombinedAllocator Allocator; +typedef Allocator::AllocatorCache AllocatorCache; Allocator *allocator(); #endif