Skip to content

Commit c73606e

Browse files
vitalybukaAdvenamTacet
authored andcommitted
renames in test
1 parent f8f91c4 commit c73606e

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

compiler-rt/test/asan/TestCases/copy_container_annotations.cpp

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static void RandomPoison(char *beg, char *end) {
4848
}
4949
}
5050

51-
static size_t count_unpoisoned(std::deque<int> &poison_states, size_t n) {
51+
static size_t CountUnpoisoned(std::deque<int> &poison_states, size_t n) {
5252
size_t result = 0;
5353
for (size_t i = 0; i < n && !poison_states.empty(); ++i) {
5454
if (!poison_states.front()) {
@@ -61,7 +61,8 @@ static size_t count_unpoisoned(std::deque<int> &poison_states, size_t n) {
6161
}
6262

6363
void TestNonOverlappingContainers(size_t capacity, size_t off_old,
64-
size_t off_new, int poison_buffers) {
64+
size_t off_new, bool poison_old,
65+
bool poison_new) {
6566
size_t old_buffer_size = capacity + off_old + kGranularity * 2;
6667
size_t new_buffer_size = capacity + off_new + kGranularity * 2;
6768

@@ -72,8 +73,6 @@ void TestNonOverlappingContainers(size_t capacity, size_t off_old,
7273

7374
char *old_buffer_end = old_buffer.get() + old_buffer_size;
7475
char *new_buffer_end = new_buffer.get() + new_buffer_size;
75-
bool poison_old = poison_buffers % 2 == 1;
76-
bool poison_new = poison_buffers / 2 == 1;
7776
char *old_beg = old_buffer.get() + off_old;
7877
char *new_beg = new_buffer.get() + off_new;
7978
char *old_end = old_beg + capacity;
@@ -118,7 +117,7 @@ void TestNonOverlappingContainers(size_t capacity, size_t off_old,
118117
char *next;
119118
for (cur = new_beg; cur + kGranularity <= new_end; cur = next) {
120119
next = RoundUp(cur + 1);
121-
size_t unpoisoned = count_unpoisoned(poison_states, next - cur);
120+
size_t unpoisoned = CountUnpoisoned(poison_states, next - cur);
122121
if (unpoisoned > 0) {
123122
assert(!__asan_address_is_poisoned(cur + unpoisoned - 1));
124123
}
@@ -130,7 +129,7 @@ void TestNonOverlappingContainers(size_t capacity, size_t off_old,
130129
// If new_buffer were not poisoned, it cannot be poisoned.
131130
// If new_buffer were poisoned, it should be same as earlier.
132131
if (cur < new_end) {
133-
size_t unpoisoned = count_unpoisoned(poison_states, new_end - cur);
132+
size_t unpoisoned = CountUnpoisoned(poison_states, new_end - cur);
134133
if (unpoisoned > 0) {
135134
assert(!__asan_address_is_poisoned(cur + unpoisoned - 1));
136135
}
@@ -149,15 +148,13 @@ void TestNonOverlappingContainers(size_t capacity, size_t off_old,
149148
}
150149

151150
void TestOverlappingContainers(size_t capacity, size_t off_old, size_t off_new,
152-
int poison_buffers) {
151+
bool poison_whole, bool poison_new) {
153152
size_t buffer_size = capacity + off_old + off_new + kGranularity * 3;
154153

155154
// Use unique_ptr with a custom deleter to manage the buffer
156155
std::unique_ptr<char[]> buffer = std::make_unique<char[]>(buffer_size);
157156

158157
char *buffer_end = buffer.get() + buffer_size;
159-
bool poison_whole = poison_buffers % 2 == 1;
160-
bool poison_new = poison_buffers / 2 == 1;
161158
char *old_beg = buffer.get() + kGranularity + off_old;
162159
char *new_beg = buffer.get() + kGranularity + off_new;
163160
char *old_end = old_beg + capacity;
@@ -170,7 +167,7 @@ void TestOverlappingContainers(size_t capacity, size_t off_old, size_t off_new,
170167
__asan_poison_memory_region(new_beg, new_end - new_beg);
171168

172169
RandomPoison(old_beg, old_end);
173-
std::deque<int> poison_states = GetPoisonedState(old_beg, old_end);
170+
auto poison_states = GetPoisonedState(old_beg, old_end);
174171
__sanitizer_copy_contiguous_container_annotations(old_beg, old_end, new_beg,
175172
new_end);
176173
// This variable is used only when buffer ends in the middle of a granule.
@@ -195,7 +192,7 @@ void TestOverlappingContainers(size_t capacity, size_t off_old, size_t off_new,
195192
char *next;
196193
for (cur = new_beg; cur + kGranularity <= new_end; cur = next) {
197194
next = RoundUp(cur + 1);
198-
size_t unpoisoned = count_unpoisoned(poison_states, next - cur);
195+
size_t unpoisoned = CountUnpoisoned(poison_states, next - cur);
199196
if (unpoisoned > 0) {
200197
assert(!__asan_address_is_poisoned(cur + unpoisoned - 1));
201198
}
@@ -207,7 +204,7 @@ void TestOverlappingContainers(size_t capacity, size_t off_old, size_t off_new,
207204
// It can be poisoned, only if non-container bytes in that granule were poisoned.
208205
// Otherwise, it should be unpoisoned.
209206
if (cur < new_end) {
210-
size_t unpoisoned = count_unpoisoned(poison_states, new_end - cur);
207+
size_t unpoisoned = CountUnpoisoned(poison_states, new_end - cur);
211208
if (unpoisoned > 0) {
212209
assert(!__asan_address_is_poisoned(cur + unpoisoned - 1));
213210
}
@@ -222,12 +219,16 @@ void TestOverlappingContainers(size_t capacity, size_t off_old, size_t off_new,
222219

223220
int main(int argc, char **argv) {
224221
int n = argc == 1 ? 64 : atoi(argv[1]);
225-
for (size_t j = 0; j < kGranularity + 2; j++) {
226-
for (size_t k = 0; k < kGranularity + 2; k++) {
227-
for (int i = 0; i <= n; i++) {
228-
for (int poison = 0; poison < 4; ++poison) {
229-
TestNonOverlappingContainers(i, j, k, poison);
230-
TestOverlappingContainers(i, j, k, poison);
222+
for (size_t off_old = 0; off_old < kGranularity + 2; off_old++) {
223+
for (size_t off_new = 0; off_new < kGranularity + 2; off_new++) {
224+
for (int capacity = 0; capacity <= n; capacity++) {
225+
for (int poison_old = 0; poison_old < 2; ++poison_old) {
226+
for (int poison_new = 0; poison_new < 2; ++poison_new) {
227+
TestNonOverlappingContainers(capacity, off_old, off_new, poison_old,
228+
poison_new);
229+
TestOverlappingContainers(capacity, off_old, off_new, poison_old,
230+
poison_new);
231+
}
231232
}
232233
}
233234
}

0 commit comments

Comments
 (0)