Skip to content

Commit 668138b

Browse files
committed
rename
Created using spr 1.3.4
1 parent cc3f8f7 commit 668138b

File tree

1 file changed

+26
-25
lines changed

1 file changed

+26
-25
lines changed

compiler-rt/lib/lsan/lsan_common.cpp

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -289,9 +289,9 @@ static inline bool MaybeUserPointer(uptr p) {
289289
}
290290

291291
namespace {
292-
struct DirectLoader {
292+
struct DirectMemoryAccessor {
293293
void Init(uptr begin, uptr end) {};
294-
void *operator()(uptr p) const { return *reinterpret_cast<void **>(p); }
294+
void *LoadPtr(uptr p) const { return *reinterpret_cast<void **>(p); }
295295
};
296296
} // namespace
297297

@@ -301,19 +301,20 @@ struct DirectLoader {
301301
// (|tag| = kReachable) and finding indirectly leaked chunks
302302
// (|tag| = kIndirectlyLeaked). In the second case, there's no flood fill,
303303
// so |frontier| = 0.
304-
template <class S>
304+
template <class Accessor>
305305
void ScanForPointers(uptr begin, uptr end, Frontier *frontier,
306-
const char *region_type, ChunkTag tag, S &scanner) {
306+
const char *region_type, ChunkTag tag,
307+
Accessor &accessor) {
307308
CHECK(tag == kReachable || tag == kIndirectlyLeaked);
308309
const uptr alignment = flags()->pointer_alignment();
309310
LOG_POINTERS("Scanning %s range %p-%p.\n", region_type, (void *)begin,
310311
(void *)end);
311-
scanner.Init(begin, end);
312+
accessor.Init(begin, end);
312313
uptr pp = begin;
313314
if (pp % alignment)
314315
pp = pp + alignment - pp % alignment;
315316
for (; pp + sizeof(void *) <= end; pp += alignment) {
316-
void *p = scanner(pp);
317+
void *p = accessor.LoadPtr(pp);
317318
# if SANITIZER_APPLE
318319
p = TransformPointer(p);
319320
# endif
@@ -350,8 +351,8 @@ void ScanForPointers(uptr begin, uptr end, Frontier *frontier,
350351

351352
void ScanRangeForPointers(uptr begin, uptr end, Frontier *frontier,
352353
const char *region_type, ChunkTag tag) {
353-
DirectLoader scanner;
354-
ScanForPointers(begin, end, frontier, region_type, tag, scanner);
354+
DirectMemoryAccessor accessor;
355+
ScanForPointers(begin, end, frontier, region_type, tag, accessor);
355356
}
356357

357358
// Scans a global range for pointers
@@ -371,19 +372,19 @@ void ScanGlobalRange(uptr begin, uptr end, Frontier *frontier) {
371372
}
372373
}
373374

374-
template <class S>
375+
template <class Accessor>
375376
void ScanExtraStack(const InternalMmapVector<Range> &ranges, Frontier *frontier,
376-
S &scanner) {
377+
Accessor &accessor) {
377378
for (uptr i = 0; i < ranges.size(); i++) {
378379
ScanForPointers(ranges[i].begin, ranges[i].end, frontier, "FAKE STACK",
379-
kReachable, scanner);
380+
kReachable, accessor);
380381
}
381382
}
382383

383384
void ScanExtraStackRanges(const InternalMmapVector<Range> &ranges,
384385
Frontier *frontier) {
385-
DirectLoader scanner;
386-
ScanExtraStack(ranges, frontier, scanner);
386+
DirectMemoryAccessor accessor;
387+
ScanExtraStack(ranges, frontier, accessor);
387388
}
388389

389390
# if SANITIZER_FUCHSIA
@@ -421,11 +422,11 @@ static void ProcessThreadRegistry(Frontier *frontier) {
421422
}
422423

423424
// Scans thread data (stacks and TLS) for heap pointers.
424-
template <class S>
425+
template <class Accessor>
425426
static void ProcessThread(tid_t os_id, uptr sp,
426427
const InternalMmapVector<uptr> &registers,
427428
InternalMmapVector<Range> &extra_ranges,
428-
Frontier *frontier, S &scanner) {
429+
Frontier *frontier, Accessor &accessor) {
429430
// `extra_ranges` is outside of the function and the loop to reused mapped
430431
// memory.
431432
CHECK(extra_ranges.empty());
@@ -450,7 +451,7 @@ static void ProcessThread(tid_t os_id, uptr sp,
450451
uptr registers_end =
451452
reinterpret_cast<uptr>(registers.data() + registers.size());
452453
ScanForPointers(registers_begin, registers_end, frontier, "REGISTERS",
453-
kReachable, scanner);
454+
kReachable, accessor);
454455
}
455456

456457
if (flags()->use_stacks) {
@@ -475,9 +476,9 @@ static void ProcessThread(tid_t os_id, uptr sp,
475476
stack_begin = sp;
476477
}
477478
ScanForPointers(stack_begin, stack_end, frontier, "STACK", kReachable,
478-
scanner);
479+
accessor);
479480
GetThreadExtraStackRangesLocked(os_id, &extra_ranges);
480-
ScanExtraStack(extra_ranges, frontier, scanner);
481+
ScanExtraStack(extra_ranges, frontier, accessor);
481482
}
482483

483484
if (flags()->use_tls) {
@@ -488,22 +489,22 @@ static void ProcessThread(tid_t os_id, uptr sp,
488489
if (cache_begin == cache_end || tls_end < cache_begin ||
489490
tls_begin > cache_end) {
490491
ScanForPointers(tls_begin, tls_end, frontier, "TLS", kReachable,
491-
scanner);
492+
accessor);
492493
} else {
493494
if (tls_begin < cache_begin)
494495
ScanForPointers(tls_begin, cache_begin, frontier, "TLS", kReachable,
495-
scanner);
496+
accessor);
496497
if (tls_end > cache_end)
497498
ScanForPointers(cache_end, tls_end, frontier, "TLS", kReachable,
498-
scanner);
499+
accessor);
499500
}
500501
}
501502
# if SANITIZER_ANDROID
502503
auto *cb = +[](void *dtls_begin, void *dtls_end, uptr /*dso_idd*/,
503504
void *arg) -> void {
504505
ScanForPointers(
505506
reinterpret_cast<uptr>(dtls_begin), reinterpret_cast<uptr>(dtls_end),
506-
reinterpret_cast<Frontier *>(arg), "DTLS", kReachable, scanner);
507+
reinterpret_cast<Frontier *>(arg), "DTLS", kReachable, accessor);
507508
};
508509

509510
// FIXME: There might be a race-condition here (and in Bionic) if the
@@ -519,7 +520,7 @@ static void ProcessThread(tid_t os_id, uptr sp,
519520
LOG_THREADS("DTLS %d at %p-%p.\n", id, (void *)dtls_beg,
520521
(void *)dtls_end);
521522
ScanForPointers(dtls_beg, dtls_end, frontier, "DTLS", kReachable,
522-
scanner);
523+
accessor);
523524
}
524525
});
525526
} else {
@@ -556,8 +557,8 @@ static void ProcessThreads(SuspendedThreadsList const &suspended_threads,
556557
if (os_id == caller_tid)
557558
sp = caller_sp;
558559

559-
DirectLoader scanner;
560-
ProcessThread(os_id, sp, registers, extra_ranges, frontier, scanner);
560+
DirectMemoryAccessor accessor;
561+
ProcessThread(os_id, sp, registers, extra_ranges, frontier, accessor);
561562
}
562563

563564
// Add pointers reachable from ThreadContexts

0 commit comments

Comments
 (0)