[compiler-rt] r349960 - Fix `static_assert()` scope in `CombinedAllocator`.
Dan Liew via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 21 13:41:37 PST 2018
Author: delcypher
Date: Fri Dec 21 13:41:37 2018
New Revision: 349960
URL: http://llvm.org/viewvc/llvm-project?rev=349960&view=rev
Log:
Fix `static_assert()` scope in `CombinedAllocator`.
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 r349957.
rdar://problem/45284065
Modified:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_combined.h
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_combined.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_combined.h?rev=349960&r1=349959&r2=349960&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_combined.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_combined.h Fri Dec 21 13:41:37 2018
@@ -26,6 +26,13 @@ template <class PrimaryAllocator, class
class CombinedAllocator {
public:
using AddressSpaceView = AddressSpaceViewTy;
+ static_assert(is_same<AddressSpaceView,
+ typename PrimaryAllocator::AddressSpaceView>::value,
+ "PrimaryAllocator is using wrong AddressSpaceView");
+ static_assert(is_same<AddressSpaceView,
+ typename SecondaryAllocator::AddressSpaceView>::value,
+ "SecondaryAllocator is using wrong AddressSpaceView");
+
void InitLinkerInitialized(s32 release_to_os_interval_ms) {
primary_.Init(release_to_os_interval_ms);
secondary_.InitLinkerInitialized();
@@ -33,12 +40,6 @@ class CombinedAllocator {
}
void Init(s32 release_to_os_interval_ms) {
- static_assert(is_same<AddressSpaceView,
- typename PrimaryAllocator::AddressSpaceView>::value,
- "PrimaryAllocator is using wrong AddressSpaceView");
- static_assert(is_same<AddressSpaceView,
- typename SecondaryAllocator::AddressSpaceView>::value,
- "SecondaryAllocator is using wrong AddressSpaceView");
primary_.Init(release_to_os_interval_ms);
secondary_.Init();
stats_.Init();
More information about the llvm-commits
mailing list