Skip to content

Commit 173b8fe

Browse files
committed
[NFC][ASAN] Reformat the file
1 parent 8606e91 commit 173b8fe

File tree

1 file changed

+30
-33
lines changed

1 file changed

+30
-33
lines changed

compiler-rt/lib/asan/asan_thread.cpp

Lines changed: 30 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ namespace __asan {
2828
// AsanThreadContext implementation.
2929

3030
void AsanThreadContext::OnCreated(void *arg) {
31-
CreateThreadContextArgs *args = static_cast<CreateThreadContextArgs*>(arg);
31+
CreateThreadContextArgs *args = static_cast<CreateThreadContextArgs *>(arg);
3232
if (args->stack)
3333
stack_id = StackDepotPut(*args->stack);
3434
thread = args->thread;
@@ -49,7 +49,7 @@ static LowLevelAllocator allocator_for_thread_context;
4949

5050
static ThreadContextBase *GetAsanThreadContext(u32 tid) {
5151
Lock lock(&mu_for_thread_context);
52-
return new(allocator_for_thread_context) AsanThreadContext(tid);
52+
return new (allocator_for_thread_context) AsanThreadContext(tid);
5353
}
5454

5555
ThreadRegistry &asanThreadRegistry() {
@@ -80,7 +80,7 @@ AsanThread *AsanThread::Create(thread_callback_t start_routine, void *arg,
8080
bool detached) {
8181
uptr PageSize = GetPageSizeCached();
8282
uptr size = RoundUpTo(sizeof(AsanThread), PageSize);
83-
AsanThread *thread = (AsanThread*)MmapOrDie(size, __func__);
83+
AsanThread *thread = (AsanThread *)MmapOrDie(size, __func__);
8484
thread->start_routine_ = start_routine;
8585
thread->arg_ = arg;
8686
AsanThreadContext::CreateThreadContextArgs args = {thread, stack};
@@ -90,7 +90,7 @@ AsanThread *AsanThread::Create(thread_callback_t start_routine, void *arg,
9090
}
9191

9292
void AsanThread::TSDDtor(void *tsd) {
93-
AsanThreadContext *context = (AsanThreadContext*)tsd;
93+
AsanThreadContext *context = (AsanThreadContext *)tsd;
9494
VReport(1, "T%d TSDDtor\n", context->tid);
9595
if (context->thread)
9696
context->thread->Destroy();
@@ -144,8 +144,7 @@ void AsanThread::StartSwitchFiber(FakeStack **fake_stack_save, uptr bottom,
144144
current_fake_stack->Destroy(this->tid());
145145
}
146146

147-
void AsanThread::FinishSwitchFiber(FakeStack *fake_stack_save,
148-
uptr *bottom_old,
147+
void AsanThread::FinishSwitchFiber(FakeStack *fake_stack_save, uptr *bottom_old,
149148
uptr *size_old) {
150149
if (!atomic_load(&stack_switching_, memory_order_relaxed)) {
151150
Report("ERROR: finishing a fiber switch that has not started\n");
@@ -171,7 +170,8 @@ void AsanThread::FinishSwitchFiber(FakeStack *fake_stack_save,
171170
inline AsanThread::StackBounds AsanThread::GetStackBounds() const {
172171
if (!atomic_load(&stack_switching_, memory_order_acquire)) {
173172
// Make sure the stack bounds are fully initialized.
174-
if (stack_bottom_ >= stack_top_) return {0, 0};
173+
if (stack_bottom_ >= stack_top_)
174+
return {0, 0};
175175
return {stack_bottom_, stack_top_};
176176
}
177177
char local;
@@ -184,13 +184,9 @@ inline AsanThread::StackBounds AsanThread::GetStackBounds() const {
184184
return {stack_bottom_, stack_top_};
185185
}
186186

187-
uptr AsanThread::stack_top() {
188-
return GetStackBounds().top;
189-
}
187+
uptr AsanThread::stack_top() { return GetStackBounds().top; }
190188

191-
uptr AsanThread::stack_bottom() {
192-
return GetStackBounds().bottom;
193-
}
189+
uptr AsanThread::stack_bottom() { return GetStackBounds().bottom; }
194190

195191
uptr AsanThread::stack_size() {
196192
const auto bounds = GetStackBounds();
@@ -211,8 +207,8 @@ FakeStack *AsanThread::AsyncSignalSafeLazyInitFakeStack() {
211207
// This CAS checks if the state was 0 and if so changes it to state 1,
212208
// if that was successful, it initializes the pointer.
213209
if (atomic_compare_exchange_strong(
214-
reinterpret_cast<atomic_uintptr_t *>(&fake_stack_), &old_val, 1UL,
215-
memory_order_relaxed)) {
210+
reinterpret_cast<atomic_uintptr_t *>(&fake_stack_), &old_val, 1UL,
211+
memory_order_relaxed)) {
216212
uptr stack_size_log = Log2(RoundUpToPowerOfTwo(stack_size));
217213
CHECK_LE(flags()->min_uar_stack_size_log, flags()->max_uar_stack_size_log);
218214
stack_size_log =
@@ -265,7 +261,8 @@ thread_return_t AsanThread::ThreadStart(tid_t os_id) {
265261
Init();
266262
asanThreadRegistry().StartThread(tid(), os_id, ThreadType::Regular, nullptr);
267263

268-
if (common_flags()->use_sigaltstack) SetAlternateSignalStack();
264+
if (common_flags()->use_sigaltstack)
265+
SetAlternateSignalStack();
269266

270267
if (!start_routine_) {
271268
// start_routine_ == 0 if we're on the main thread or on one of the
@@ -341,14 +338,14 @@ bool AsanThread::GetStackFrameAccessByAddr(uptr addr,
341338
bottom = fake_stack->AddrIsInFakeStack(addr);
342339
CHECK(bottom);
343340
access->offset = addr - bottom;
344-
access->frame_pc = ((uptr*)bottom)[2];
345-
access->frame_descr = (const char *)((uptr*)bottom)[1];
341+
access->frame_pc = ((uptr *)bottom)[2];
342+
access->frame_descr = (const char *)((uptr *)bottom)[1];
346343
return true;
347344
}
348345
uptr aligned_addr = RoundDownTo(addr, SANITIZER_WORDSIZE / 8); // align addr.
349346
uptr mem_ptr = RoundDownTo(aligned_addr, ASAN_SHADOW_GRANULARITY);
350-
u8 *shadow_ptr = (u8*)MemToShadow(aligned_addr);
351-
u8 *shadow_bottom = (u8*)MemToShadow(bottom);
347+
u8 *shadow_ptr = (u8 *)MemToShadow(aligned_addr);
348+
u8 *shadow_bottom = (u8 *)MemToShadow(bottom);
352349

353350
while (shadow_ptr >= shadow_bottom &&
354351
*shadow_ptr != kAsanStackLeftRedzoneMagic) {
@@ -370,7 +367,7 @@ bool AsanThread::GetStackFrameAccessByAddr(uptr addr,
370367
CHECK(ptr[0] == kCurrentStackFrameMagic);
371368
access->offset = addr - (uptr)ptr;
372369
access->frame_pc = ptr[2];
373-
access->frame_descr = (const char*)ptr[1];
370+
access->frame_descr = (const char *)ptr[1];
374371
return true;
375372
}
376373

@@ -388,8 +385,8 @@ uptr AsanThread::GetStackVariableShadowStart(uptr addr) {
388385
}
389386

390387
uptr aligned_addr = RoundDownTo(addr, SANITIZER_WORDSIZE / 8); // align addr.
391-
u8 *shadow_ptr = (u8*)MemToShadow(aligned_addr);
392-
u8 *shadow_bottom = (u8*)MemToShadow(bottom);
388+
u8 *shadow_ptr = (u8 *)MemToShadow(aligned_addr);
389+
u8 *shadow_bottom = (u8 *)MemToShadow(bottom);
393390

394391
while (shadow_ptr >= shadow_bottom &&
395392
(*shadow_ptr != kAsanStackLeftRedzoneMagic &&
@@ -473,10 +470,11 @@ void EnsureMainThreadIDIsCorrect() {
473470
__asan::AsanThread *GetAsanThreadByOsIDLocked(tid_t os_id) {
474471
__asan::AsanThreadContext *context = static_cast<__asan::AsanThreadContext *>(
475472
__asan::asanThreadRegistry().FindThreadContextByOsIDLocked(os_id));
476-
if (!context) return nullptr;
473+
if (!context)
474+
return nullptr;
477475
return context->thread;
478476
}
479-
} // namespace __asan
477+
} // namespace __asan
480478

481479
// --- Implementation of LSan-specific functions --- {{{1
482480
namespace __lsan {
@@ -495,7 +493,8 @@ bool GetThreadRangesLocked(tid_t os_id, uptr *stack_begin, uptr *stack_end,
495493
uptr *tls_begin, uptr *tls_end, uptr *cache_begin,
496494
uptr *cache_end, DTLS **dtls) {
497495
__asan::AsanThread *t = __asan::GetAsanThreadByOsIDLocked(os_id);
498-
if (!t) return false;
496+
if (!t)
497+
return false;
499498
*stack_begin = t->stack_bottom();
500499
*stack_end = t->stack_top();
501500
*tls_begin = t->tls_begin();
@@ -579,7 +578,7 @@ void FinishThreadLocked(u32 tid) {
579578
GetAsanThreadRegistryLocked()->FinishThread(tid);
580579
}
581580

582-
} // namespace __lsan
581+
} // namespace __lsan
583582

584583
// ---------------------- Interface ---------------- {{{1
585584
using namespace __asan;
@@ -593,20 +592,18 @@ void __sanitizer_start_switch_fiber(void **fakestacksave, const void *bottom,
593592
VReport(1, "__asan_start_switch_fiber called from unknown thread\n");
594593
return;
595594
}
596-
t->StartSwitchFiber((FakeStack**)fakestacksave, (uptr)bottom, size);
595+
t->StartSwitchFiber((FakeStack **)fakestacksave, (uptr)bottom, size);
597596
}
598597

599598
SANITIZER_INTERFACE_ATTRIBUTE
600-
void __sanitizer_finish_switch_fiber(void* fakestack,
601-
const void **bottom_old,
599+
void __sanitizer_finish_switch_fiber(void *fakestack, const void **bottom_old,
602600
uptr *size_old) {
603601
AsanThread *t = GetCurrentThread();
604602
if (!t) {
605603
VReport(1, "__asan_finish_switch_fiber called from unknown thread\n");
606604
return;
607605
}
608-
t->FinishSwitchFiber((FakeStack*)fakestack,
609-
(uptr*)bottom_old,
610-
(uptr*)size_old);
606+
t->FinishSwitchFiber((FakeStack *)fakestack, (uptr *)bottom_old,
607+
(uptr *)size_old);
611608
}
612609
}

0 commit comments

Comments
 (0)