LLVM  15.0.0git
MemAlloc.cpp
Go to the documentation of this file.
1 //===- MemAlloc.cpp - Memory allocation functions -------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
10 #include <new>
11 
12 // These are out of line to have __cpp_aligned_new not affect ABI.
13 
15 llvm::allocate_buffer(size_t Size, size_t Alignment) {
16  return ::operator new(Size
17 #ifdef __cpp_aligned_new
18  ,
19  std::align_val_t(Alignment)
20 #endif
21  );
22 }
23 
24 void llvm::deallocate_buffer(void *Ptr, size_t Size, size_t Alignment) {
25  ::operator delete(Ptr
26 #ifdef __cpp_sized_deallocation
27  ,
28  Size
29 #endif
30 #ifdef __cpp_aligned_new
31  ,
32  std::align_val_t(Alignment)
33 #endif
34  );
35 }
llvm::Check::Size
@ Size
Definition: FileCheck.h:77
LLVM_ATTRIBUTE_RETURNS_NOALIAS
#define LLVM_ATTRIBUTE_RETURNS_NOALIAS
\macro LLVM_ATTRIBUTE_RETURNS_NOALIAS Used to mark a function as returning a pointer that does not al...
Definition: Compiler.h:267
llvm::allocate_buffer
LLVM_ATTRIBUTE_RETURNS_NONNULL LLVM_ATTRIBUTE_RETURNS_NOALIAS void * allocate_buffer(size_t Size, size_t Alignment)
Allocate a buffer of memory with the given size and alignment.
Definition: MemAlloc.cpp:15
llvm::deallocate_buffer
void deallocate_buffer(void *Ptr, size_t Size, size_t Alignment)
Deallocate a buffer of memory with the given size and alignment.
Definition: MemAlloc.cpp:24
MemAlloc.h
LLVM_ATTRIBUTE_RETURNS_NONNULL
#define LLVM_ATTRIBUTE_RETURNS_NONNULL
Definition: Compiler.h:257