forked from OSchip/llvm-project
[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
This commit is contained in:
parent
b03ae74319
commit
ae9d040028
compiler-rt/lib/gwp_asan
|
@ -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.
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||||
// See https://llvm.org/LICENSE.txt for license information.
|
// See https://llvm.org/LICENSE.txt for license information.
|
||||||
|
|
|
@ -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.
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||||
// See https://llvm.org/LICENSE.txt for license information.
|
// See https://llvm.org/LICENSE.txt for license information.
|
||||||
|
|
|
@ -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.
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||||
// See https://llvm.org/LICENSE.txt for license information.
|
// See https://llvm.org/LICENSE.txt for license information.
|
||||||
|
|
|
@ -37,7 +37,7 @@ public:
|
||||||
// GWP-ASan. The constructor value-initialises the class such that if no
|
// GWP-ASan. The constructor value-initialises the class such that if no
|
||||||
// further initialisation takes place, calls to shouldSample() and
|
// further initialisation takes place, calls to shouldSample() and
|
||||||
// pointerIsMine() will return false.
|
// pointerIsMine() will return false.
|
||||||
constexpr GuardedPoolAllocator(){};
|
constexpr GuardedPoolAllocator() {}
|
||||||
GuardedPoolAllocator(const GuardedPoolAllocator &) = delete;
|
GuardedPoolAllocator(const GuardedPoolAllocator &) = delete;
|
||||||
GuardedPoolAllocator &operator=(const GuardedPoolAllocator &) = delete;
|
GuardedPoolAllocator &operator=(const GuardedPoolAllocator &) = delete;
|
||||||
|
|
||||||
|
|
|
@ -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.
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||||
// See https://llvm.org/LICENSE.txt for license information.
|
// See https://llvm.org/LICENSE.txt for license information.
|
||||||
|
@ -6,8 +6,8 @@
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#ifndef GWP_ASAN_OPTIONAL_CRASH_HANDLER_H_
|
#ifndef GWP_ASAN_OPTIONAL_SEGV_HANDLER_H_
|
||||||
#define GWP_ASAN_OPTIONAL_CRASH_HANDLER_H_
|
#define GWP_ASAN_OPTIONAL_SEGV_HANDLER_H_
|
||||||
|
|
||||||
#include "gwp_asan/guarded_pool_allocator.h"
|
#include "gwp_asan/guarded_pool_allocator.h"
|
||||||
#include "gwp_asan/options.h"
|
#include "gwp_asan/options.h"
|
||||||
|
@ -87,4 +87,4 @@ void dumpReport(uintptr_t ErrorPtr, const gwp_asan::AllocatorState *State,
|
||||||
} // namespace crash_handler
|
} // namespace crash_handler
|
||||||
} // namespace gwp_asan
|
} // namespace gwp_asan
|
||||||
|
|
||||||
#endif // GWP_ASAN_OPTIONAL_CRASH_HANDLER_H_
|
#endif // GWP_ASAN_OPTIONAL_SEGV_HANDLER_H_
|
||||||
|
|
|
@ -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.
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||||
// See https://llvm.org/LICENSE.txt for license information.
|
// See https://llvm.org/LICENSE.txt for license information.
|
||||||
|
|
|
@ -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.
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||||
// See https://llvm.org/LICENSE.txt for license information.
|
// See https://llvm.org/LICENSE.txt for license information.
|
||||||
|
|
|
@ -28,7 +28,7 @@ void Check(bool Condition, const char *Message) {
|
||||||
android_set_abort_message(Message);
|
android_set_abort_message(Message);
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
#else // __BIONIC__
|
#else // __BIONIC__
|
||||||
void Check(bool Condition, const char *Message) {
|
void Check(bool Condition, const char *Message) {
|
||||||
if (Condition)
|
if (Condition)
|
||||||
return;
|
return;
|
||||||
|
@ -63,7 +63,7 @@ static size_t alignPowerOfTwo(size_t RealAllocationSize) {
|
||||||
#ifdef __BIONIC__
|
#ifdef __BIONIC__
|
||||||
static constexpr AlignmentStrategy PlatformDefaultAlignment =
|
static constexpr AlignmentStrategy PlatformDefaultAlignment =
|
||||||
AlignmentStrategy::BIONIC;
|
AlignmentStrategy::BIONIC;
|
||||||
#else // __BIONIC__
|
#else // __BIONIC__
|
||||||
static constexpr AlignmentStrategy PlatformDefaultAlignment =
|
static constexpr AlignmentStrategy PlatformDefaultAlignment =
|
||||||
AlignmentStrategy::POWER_OF_TWO;
|
AlignmentStrategy::POWER_OF_TWO;
|
||||||
#endif // __BIONIC__
|
#endif // __BIONIC__
|
||||||
|
|
|
@ -18,9 +18,7 @@
|
||||||
GWP_ASAN_TLS_INITIAL_EXEC uint32_t RandomState = 0xff82eb50;
|
GWP_ASAN_TLS_INITIAL_EXEC uint32_t RandomState = 0xff82eb50;
|
||||||
|
|
||||||
namespace gwp_asan {
|
namespace gwp_asan {
|
||||||
void initPRNG() {
|
void initPRNG() { RandomState = time(nullptr) + getThreadID(); }
|
||||||
RandomState = time(nullptr) + getThreadID();
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t getRandomUnsigned32() {
|
uint32_t getRandomUnsigned32() {
|
||||||
RandomState ^= RandomState << 13;
|
RandomState ^= RandomState << 13;
|
||||||
|
|
|
@ -6,6 +6,9 @@
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#ifndef GWP_ASAN_UTILITIES_H_
|
||||||
|
#define GWP_ASAN_UTILITIES_H_
|
||||||
|
|
||||||
#include "gwp_asan/definitions.h"
|
#include "gwp_asan/definitions.h"
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
@ -29,3 +32,5 @@ size_t rightAlignedAllocationSize(
|
||||||
size_t RealAllocationSize,
|
size_t RealAllocationSize,
|
||||||
AlignmentStrategy Align = AlignmentStrategy::DEFAULT);
|
AlignmentStrategy Align = AlignmentStrategy::DEFAULT);
|
||||||
} // namespace gwp_asan
|
} // namespace gwp_asan
|
||||||
|
|
||||||
|
#endif // GWP_ASAN_UTILITIES_H_
|
||||||
|
|
Loading…
Reference in New Issue