[compiler-rt] r349959 - Fix `static_assert()` scope in `SizeClassAllocator32`.
Dan Liew via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 21 13:41:31 PST 2018
Author: delcypher
Date: Fri Dec 21 13:41:31 2018
New Revision: 349959
URL: http://llvm.org/viewvc/llvm-project?rev=349959&view=rev
Log:
Fix `static_assert()` scope in `SizeClassAllocator32`.
It should be at the class scope and not inside the `Init(...)` function
because we want to error out as soon as the wrong type is constructed.
At the function scope the `static_assert` is only checked if the
function might be called.
This is a follow up to r349138.
rdar://problem/45284065
Modified:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_primary32.h
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_primary32.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_primary32.h?rev=349959&r1=349958&r2=349959&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_primary32.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_primary32.h Fri Dec 21 13:41:31 2018
@@ -57,6 +57,10 @@ class SizeClassAllocator32 {
typedef typename Params::ByteMap ByteMap;
typedef typename Params::MapUnmapCallback MapUnmapCallback;
+ static_assert(
+ is_same<typename ByteMap::AddressSpaceView, AddressSpaceView>::value,
+ "AddressSpaceView type mismatch");
+
static const bool kRandomShuffleChunks = Params::kFlags &
SizeClassAllocator32FlagMasks::kRandomShuffleChunks;
static const bool kUseSeparateSizeClassForBatch = Params::kFlags &
@@ -109,9 +113,6 @@ class SizeClassAllocator32 {
typedef SizeClassAllocator32LocalCache<ThisT> AllocatorCache;
void Init(s32 release_to_os_interval_ms) {
- static_assert(
- is_same<typename ByteMap::AddressSpaceView, AddressSpaceView>::value,
- "AddressSpaceView type mismatch");
possible_regions.Init();
internal_memset(size_class_info_array, 0, sizeof(size_class_info_array));
}
More information about the llvm-commits
mailing list