llvm/compiler-rt/lib/memprof/memprof_new_delete.cpp

//===-- memprof_interceptors.cpp -----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file is a part of MemProfiler, a memory profiler.
//
// Interceptors for operators new and delete.
//===----------------------------------------------------------------------===//

#include "memprof_allocator.h"
#include "memprof_internal.h"
#include "memprof_stack.h"
#include "sanitizer_common/sanitizer_allocator_report.h"

#include "interception/interception.h"

#include <stddef.h>

#define CXX_OPERATOR_ATTRIBUTE

usingnamespace__memprof;

// Fake std::nothrow_t and std::align_val_t to avoid including <new>.
namespace std {
struct nothrow_t {};
enum class align_val_t : size_t {};
} // namespace std

#define OPERATOR_NEW_BODY(type, nothrow)
#define OPERATOR_NEW_BODY_ALIGN(type, nothrow)

CXX_OPERATOR_ATTRIBUTE
void *operator new(size_t size) {}
CXX_OPERATOR_ATTRIBUTE
void *operator new[](size_t size) {}
CXX_OPERATOR_ATTRIBUTE
void *operator new(size_t size, std::nothrow_t const &) {}
CXX_OPERATOR_ATTRIBUTE
void *operator new[](size_t size, std::nothrow_t const &) {}
CXX_OPERATOR_ATTRIBUTE
void *operator new(size_t size, std::align_val_t align) {}
CXX_OPERATOR_ATTRIBUTE
void *operator new[](size_t size, std::align_val_t align) {}
CXX_OPERATOR_ATTRIBUTE
void *operator new(size_t size, std::align_val_t align,
                   std::nothrow_t const &) {}
CXX_OPERATOR_ATTRIBUTE
void *operator new[](size_t size, std::align_val_t align,
                     std::nothrow_t const &) {}

#define OPERATOR_DELETE_BODY(type)

#define OPERATOR_DELETE_BODY_SIZE(type)

#define OPERATOR_DELETE_BODY_ALIGN(type)

#define OPERATOR_DELETE_BODY_SIZE_ALIGN(type)

CXX_OPERATOR_ATTRIBUTE
void operator delete(void *ptr)NOEXCEPT {}
CXX_OPERATOR_ATTRIBUTE
void operator delete[](void *ptr) NOEXCEPT {}
CXX_OPERATOR_ATTRIBUTE
void operator delete(void *ptr, std::nothrow_t const &) {}
CXX_OPERATOR_ATTRIBUTE
void operator delete[](void *ptr, std::nothrow_t const &) {}
CXX_OPERATOR_ATTRIBUTE
void operator delete(void *ptr, size_t size)NOEXCEPT {}
CXX_OPERATOR_ATTRIBUTE
void operator delete[](void *ptr, size_t size) NOEXCEPT {}
CXX_OPERATOR_ATTRIBUTE
void operator delete(void *ptr, std::align_val_t align)NOEXCEPT {}
CXX_OPERATOR_ATTRIBUTE
void operator delete[](void *ptr, std::align_val_t align) NOEXCEPT {}
CXX_OPERATOR_ATTRIBUTE
void operator delete(void *ptr, std::align_val_t align,
                     std::nothrow_t const &) {}
CXX_OPERATOR_ATTRIBUTE
void operator delete[](void *ptr, std::align_val_t align,
                       std::nothrow_t const &) {}
CXX_OPERATOR_ATTRIBUTE
void operator delete(void *ptr, size_t size, std::align_val_t align)NOEXCEPT {}
CXX_OPERATOR_ATTRIBUTE
void operator delete[](void *ptr, size_t size,
                       std::align_val_t align) NOEXCEPT {}