Skip to content

Commit 5e1ae3a

Browse files
committed
[NFC][hwasan] Clang-format the file
1 parent dcc4feb commit 5e1ae3a

File tree

1 file changed

+33
-30
lines changed

1 file changed

+33
-30
lines changed

compiler-rt/lib/hwasan/hwasan_new_delete.cpp

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,32 @@
2222
#if HWASAN_REPLACE_OPERATORS_NEW_AND_DELETE
2323

2424
// TODO(alekseys): throw std::bad_alloc instead of dying on OOM.
25-
#define OPERATOR_NEW_BODY(nothrow) \
26-
GET_MALLOC_STACK_TRACE; \
27-
void *res = hwasan_malloc(size, &stack);\
28-
if (!nothrow && UNLIKELY(!res)) ReportOutOfMemory(size, &stack);\
29-
return res
30-
#define OPERATOR_NEW_ALIGN_BODY(nothrow) \
31-
GET_MALLOC_STACK_TRACE; \
32-
void *res = hwasan_aligned_alloc(static_cast<uptr>(align), size, &stack); \
33-
if (!nothrow && UNLIKELY(!res)) \
34-
ReportOutOfMemory(size, &stack); \
35-
return res
36-
37-
#define OPERATOR_DELETE_BODY \
38-
GET_MALLOC_STACK_TRACE; \
39-
if (ptr) hwasan_free(ptr, &stack)
25+
# define OPERATOR_NEW_BODY(nothrow) \
26+
GET_MALLOC_STACK_TRACE; \
27+
void *res = hwasan_malloc(size, &stack); \
28+
if (!nothrow && UNLIKELY(!res)) \
29+
ReportOutOfMemory(size, &stack); \
30+
return res
31+
# define OPERATOR_NEW_ALIGN_BODY(nothrow) \
32+
GET_MALLOC_STACK_TRACE; \
33+
void *res = hwasan_aligned_alloc(static_cast<uptr>(align), size, &stack); \
34+
if (!nothrow && UNLIKELY(!res)) \
35+
ReportOutOfMemory(size, &stack); \
36+
return res
37+
38+
# define OPERATOR_DELETE_BODY \
39+
GET_MALLOC_STACK_TRACE; \
40+
if (ptr) \
41+
hwasan_free(ptr, &stack)
4042

4143
#elif defined(__ANDROID__)
4244

4345
// We don't actually want to intercept operator new and delete on Android, but
4446
// since we previously released a runtime that intercepted these functions,
4547
// removing the interceptors would break ABI. Therefore we simply forward to
4648
// malloc and free.
47-
#define OPERATOR_NEW_BODY(nothrow) return malloc(size)
48-
#define OPERATOR_DELETE_BODY free(ptr)
49+
# define OPERATOR_NEW_BODY(nothrow) return malloc(size)
50+
# define OPERATOR_DELETE_BODY free(ptr)
4951

5052
#endif
5153

@@ -55,26 +57,27 @@ using namespace __hwasan;
5557

5658
// Fake std::nothrow_t to avoid including <new>.
5759
namespace std {
58-
struct nothrow_t {};
60+
struct nothrow_t {};
5961
} // namespace std
6062

61-
62-
63-
INTERCEPTOR_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
64-
void *operator new(size_t size) { OPERATOR_NEW_BODY(false /*nothrow*/); }
65-
INTERCEPTOR_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
66-
void *operator new[](size_t size) { OPERATOR_NEW_BODY(false /*nothrow*/); }
67-
INTERCEPTOR_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
68-
void *operator new(size_t size, std::nothrow_t const&) {
63+
INTERCEPTOR_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void *operator new(size_t size) {
64+
OPERATOR_NEW_BODY(false /*nothrow*/);
65+
}
66+
INTERCEPTOR_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void *operator new[](
67+
size_t size) {
68+
OPERATOR_NEW_BODY(false /*nothrow*/);
69+
}
70+
INTERCEPTOR_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void *operator new(
71+
size_t size, std::nothrow_t const &) {
6972
OPERATOR_NEW_BODY(true /*nothrow*/);
7073
}
71-
INTERCEPTOR_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
72-
void *operator new[](size_t size, std::nothrow_t const&) {
74+
INTERCEPTOR_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void *operator new[](
75+
size_t size, std::nothrow_t const &) {
7376
OPERATOR_NEW_BODY(true /*nothrow*/);
7477
}
7578

76-
INTERCEPTOR_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void operator delete(void *ptr)
77-
NOEXCEPT {
79+
INTERCEPTOR_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void operator delete(
80+
void *ptr) NOEXCEPT {
7881
OPERATOR_DELETE_BODY;
7982
}
8083
INTERCEPTOR_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void operator delete[](

0 commit comments

Comments
 (0)