]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/include/llvm/Support/BuryPointer.h
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[FreeBSD/FreeBSD.git] / contrib / llvm / include / llvm / Support / BuryPointer.h
1 //===- llvm/Support/BuryPointer.h - Memory Manipulation/Leak ----*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef LLVM_SUPPORT_BURYPOINTER_H
11 #define LLVM_SUPPORT_BURYPOINTER_H
12
13 #include <memory>
14
15 namespace llvm {
16
17 // In tools that will exit soon anyway, going through the process of explicitly
18 // deallocating resources can be unnecessary - better to leak the resources and
19 // let the OS clean them up when the process ends. Use this function to ensure
20 // the memory is not misdiagnosed as an unintentional leak by leak detection
21 // tools (this is achieved by preserving pointers to the object in a globally
22 // visible array).
23 void BuryPointer(const void *Ptr);
24 template <typename T> void BuryPointer(std::unique_ptr<T> Ptr) {
25   BuryPointer(Ptr.release());
26 }
27
28 } // namespace llvm
29
30 #endif