[compiler-rt] r294370 - [asan] replace std::random_shuffle with std::shuffle in tests since std::random_shuffle is being deprecated in C++17; NFC
Kostya Serebryany via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 7 15:13:11 PST 2017
Author: kcc
Date: Tue Feb 7 17:13:10 2017
New Revision: 294370
URL: http://llvm.org/viewvc/llvm-project?rev=294370&view=rev
Log:
[asan] replace std::random_shuffle with std::shuffle in tests since std::random_shuffle is being deprecated in C++17; NFC
Modified:
compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_allocator_test.cc
compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_bitvector_test.cc
compiler-rt/trunk/test/asan/TestCases/Linux/release_to_os_test.cc
Modified: compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_allocator_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_allocator_test.cc?rev=294370&r1=294369&r2=294370&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_allocator_test.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_allocator_test.cc Tue Feb 7 17:13:10 2017
@@ -23,6 +23,7 @@
#include <stdlib.h>
#include <algorithm>
#include <vector>
+#include <random>
#include <set>
using namespace __sanitizer;
@@ -539,6 +540,7 @@ void TestCombinedAllocator() {
Allocator;
Allocator *a = new Allocator;
a->Init(/* may_return_null */ true, kReleaseToOSIntervalNever);
+ std::mt19937 r;
AllocatorCache cache;
memset(&cache, 0, sizeof(cache));
@@ -570,7 +572,7 @@ void TestCombinedAllocator() {
allocated.push_back(x);
}
- random_shuffle(allocated.begin(), allocated.end());
+ std::shuffle(allocated.begin(), allocated.end(), r);
for (uptr i = 0; i < kNumAllocs; i++) {
void *x = allocated[i];
Modified: compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_bitvector_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_bitvector_test.cc?rev=294370&r1=294369&r2=294370&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_bitvector_test.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_bitvector_test.cc Tue Feb 7 17:13:10 2017
@@ -19,6 +19,7 @@
#include <algorithm>
#include <vector>
+#include <random>
#include <set>
using namespace __sanitizer;
@@ -75,6 +76,7 @@ void Print(const set<uptr> &s) {
template <class BV>
void TestBitVector(uptr expected_size) {
+ std::mt19937 r;
BV bv, bv1, t_bv;
EXPECT_EQ(expected_size, BV::kSize);
bv.clear();
@@ -112,7 +114,7 @@ void TestBitVector(uptr expected_size) {
for (uptr it = 0; it < 30; it++) {
// iota
for (size_t j = 0; j < bits.size(); j++) bits[j] = j;
- random_shuffle(bits.begin(), bits.end());
+ std::shuffle(bits.begin(), bits.end(), r);
set<uptr> s, s1, t_s;
bv.clear();
bv1.clear();
Modified: compiler-rt/trunk/test/asan/TestCases/Linux/release_to_os_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Linux/release_to_os_test.cc?rev=294370&r1=294369&r2=294370&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Linux/release_to_os_test.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/Linux/release_to_os_test.cc Tue Feb 7 17:13:10 2017
@@ -11,6 +11,7 @@
#include <algorithm>
#include <stdint.h>
#include <assert.h>
+#include <random>
#include <sanitizer/asan_interface.h>
@@ -19,9 +20,10 @@ void MallocReleaseStress() {
const size_t kAllocSize = 100;
const size_t kNumIter = 100;
uintptr_t *chunks[kNumChunks] = {0};
+ std::mt19937 r;
for (size_t iter = 0; iter < kNumIter; iter++) {
- std::random_shuffle(chunks, chunks + kNumChunks);
+ std::shuffle(chunks, chunks + kNumChunks, r);
size_t to_replace = rand() % kNumChunks;
for (size_t i = 0; i < kNumChunks; i++) {
if (chunks[i])
More information about the llvm-commits
mailing list