From ae9d0400283229032fb3795b7b50920bf9be38dc Mon Sep 17 00:00:00 2001 From: Kostya Kortchinsky Date: Mon, 19 Oct 2020 11:54:43 -0700 Subject: [PATCH] [GWP-ASan] Cleanup (NFC) Cleaning up some of the GWP-ASan code base: - lots of headers didn't have the correct file name - adding `#ifdef` guard to `utilities.h` - correcting an `#ifdef` guard based on actual file name - removing an extra `;` - clang-format'ing the code (`-style=llvm`) Differential Revision: https://reviews.llvm.org/D89721 --- compiler-rt/lib/gwp_asan/crash_handler.cpp | 2 +- compiler-rt/lib/gwp_asan/crash_handler.h | 2 +- compiler-rt/lib/gwp_asan/definitions.h | 2 +- compiler-rt/lib/gwp_asan/guarded_pool_allocator.h | 2 +- compiler-rt/lib/gwp_asan/optional/segv_handler.h | 8 ++++---- compiler-rt/lib/gwp_asan/optional/segv_handler_posix.cpp | 2 +- compiler-rt/lib/gwp_asan/platform_specific/common_posix.cpp | 2 +- compiler-rt/lib/gwp_asan/platform_specific/utilities_posix.cpp | 4 ++-- compiler-rt/lib/gwp_asan/random.cpp | 4 +--- compiler-rt/lib/gwp_asan/utilities.h | 5 +++++ 10 files changed, 18 insertions(+), 15 deletions(-) diff --git a/compiler-rt/lib/gwp_asan/crash_handler.cpp b/compiler-rt/lib/gwp_asan/crash_handler.cpp index 3c64025..b9baace 100644 --- a/compiler-rt/lib/gwp_asan/crash_handler.cpp +++ b/compiler-rt/lib/gwp_asan/crash_handler.cpp @@ -1,4 +1,4 @@ -//===-- crash_handler_interface.cpp -----------------------------*- C++ -*-===// +//===-- crash_handler.cpp ---------------------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/compiler-rt/lib/gwp_asan/crash_handler.h b/compiler-rt/lib/gwp_asan/crash_handler.h index 631c319..4a95069 100644 --- a/compiler-rt/lib/gwp_asan/crash_handler.h +++ b/compiler-rt/lib/gwp_asan/crash_handler.h @@ -1,4 +1,4 @@ -//===-- crash_handler_interface.h -------------------------------*- C++ -*-===// +//===-- crash_handler.h -----------------------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/compiler-rt/lib/gwp_asan/definitions.h b/compiler-rt/lib/gwp_asan/definitions.h index 563c408..bec0290 100644 --- a/compiler-rt/lib/gwp_asan/definitions.h +++ b/compiler-rt/lib/gwp_asan/definitions.h @@ -1,4 +1,4 @@ -//===-- gwp_asan_definitions.h ----------------------------------*- C++ -*-===// +//===-- definitions.h -------------------------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/compiler-rt/lib/gwp_asan/guarded_pool_allocator.h b/compiler-rt/lib/gwp_asan/guarded_pool_allocator.h index ae00506..12049e1 100644 --- a/compiler-rt/lib/gwp_asan/guarded_pool_allocator.h +++ b/compiler-rt/lib/gwp_asan/guarded_pool_allocator.h @@ -37,7 +37,7 @@ public: // GWP-ASan. The constructor value-initialises the class such that if no // further initialisation takes place, calls to shouldSample() and // pointerIsMine() will return false. - constexpr GuardedPoolAllocator(){}; + constexpr GuardedPoolAllocator() {} GuardedPoolAllocator(const GuardedPoolAllocator &) = delete; GuardedPoolAllocator &operator=(const GuardedPoolAllocator &) = delete; diff --git a/compiler-rt/lib/gwp_asan/optional/segv_handler.h b/compiler-rt/lib/gwp_asan/optional/segv_handler.h index 0fed4f2..e1d96a6 100644 --- a/compiler-rt/lib/gwp_asan/optional/segv_handler.h +++ b/compiler-rt/lib/gwp_asan/optional/segv_handler.h @@ -1,4 +1,4 @@ -//===-- crash_handler.h -----------------------------------------*- C++ -*-===// +//===-- segv_handler.h ------------------------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef GWP_ASAN_OPTIONAL_CRASH_HANDLER_H_ -#define GWP_ASAN_OPTIONAL_CRASH_HANDLER_H_ +#ifndef GWP_ASAN_OPTIONAL_SEGV_HANDLER_H_ +#define GWP_ASAN_OPTIONAL_SEGV_HANDLER_H_ #include "gwp_asan/guarded_pool_allocator.h" #include "gwp_asan/options.h" @@ -87,4 +87,4 @@ void dumpReport(uintptr_t ErrorPtr, const gwp_asan::AllocatorState *State, } // namespace crash_handler } // namespace gwp_asan -#endif // GWP_ASAN_OPTIONAL_CRASH_HANDLER_H_ +#endif // GWP_ASAN_OPTIONAL_SEGV_HANDLER_H_ diff --git a/compiler-rt/lib/gwp_asan/optional/segv_handler_posix.cpp b/compiler-rt/lib/gwp_asan/optional/segv_handler_posix.cpp index 9a80436..8d9f39a 100644 --- a/compiler-rt/lib/gwp_asan/optional/segv_handler_posix.cpp +++ b/compiler-rt/lib/gwp_asan/optional/segv_handler_posix.cpp @@ -1,4 +1,4 @@ -//===-- crash_handler_posix.cpp ---------------------------------*- C++ -*-===// +//===-- segv_handler_posix.cpp ----------------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/compiler-rt/lib/gwp_asan/platform_specific/common_posix.cpp b/compiler-rt/lib/gwp_asan/platform_specific/common_posix.cpp index e44e629..813882a 100644 --- a/compiler-rt/lib/gwp_asan/platform_specific/common_posix.cpp +++ b/compiler-rt/lib/gwp_asan/platform_specific/common_posix.cpp @@ -1,4 +1,4 @@ -//===-- common_posix.cpp ---------------------------------*- C++ -*-===// +//===-- common_posix.cpp ----------------------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/compiler-rt/lib/gwp_asan/platform_specific/utilities_posix.cpp b/compiler-rt/lib/gwp_asan/platform_specific/utilities_posix.cpp index 0e60598..98f74e0 100644 --- a/compiler-rt/lib/gwp_asan/platform_specific/utilities_posix.cpp +++ b/compiler-rt/lib/gwp_asan/platform_specific/utilities_posix.cpp @@ -28,7 +28,7 @@ void Check(bool Condition, const char *Message) { android_set_abort_message(Message); abort(); } -#else // __BIONIC__ +#else // __BIONIC__ void Check(bool Condition, const char *Message) { if (Condition) return; @@ -63,7 +63,7 @@ static size_t alignPowerOfTwo(size_t RealAllocationSize) { #ifdef __BIONIC__ static constexpr AlignmentStrategy PlatformDefaultAlignment = AlignmentStrategy::BIONIC; -#else // __BIONIC__ +#else // __BIONIC__ static constexpr AlignmentStrategy PlatformDefaultAlignment = AlignmentStrategy::POWER_OF_TWO; #endif // __BIONIC__ diff --git a/compiler-rt/lib/gwp_asan/random.cpp b/compiler-rt/lib/gwp_asan/random.cpp index 2180f92..927709a 100644 --- a/compiler-rt/lib/gwp_asan/random.cpp +++ b/compiler-rt/lib/gwp_asan/random.cpp @@ -18,9 +18,7 @@ GWP_ASAN_TLS_INITIAL_EXEC uint32_t RandomState = 0xff82eb50; namespace gwp_asan { -void initPRNG() { - RandomState = time(nullptr) + getThreadID(); -} +void initPRNG() { RandomState = time(nullptr) + getThreadID(); } uint32_t getRandomUnsigned32() { RandomState ^= RandomState << 13; diff --git a/compiler-rt/lib/gwp_asan/utilities.h b/compiler-rt/lib/gwp_asan/utilities.h index 71d525f..8aeefe1 100644 --- a/compiler-rt/lib/gwp_asan/utilities.h +++ b/compiler-rt/lib/gwp_asan/utilities.h @@ -6,6 +6,9 @@ // //===----------------------------------------------------------------------===// +#ifndef GWP_ASAN_UTILITIES_H_ +#define GWP_ASAN_UTILITIES_H_ + #include "gwp_asan/definitions.h" #include @@ -29,3 +32,5 @@ size_t rightAlignedAllocationSize( size_t RealAllocationSize, AlignmentStrategy Align = AlignmentStrategy::DEFAULT); } // namespace gwp_asan + +#endif // GWP_ASAN_UTILITIES_H_ -- 2.7.4