1 //===- llvm/Support/BuryPointer.h - Memory Manipulation/Leak ----*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_SUPPORT_BURYPOINTER_H
10 #define LLVM_SUPPORT_BURYPOINTER_H
16 // In tools that will exit soon anyway, going through the process of explicitly
17 // deallocating resources can be unnecessary - better to leak the resources and
18 // let the OS clean them up when the process ends. Use this function to ensure
19 // the memory is not misdiagnosed as an unintentional leak by leak detection
20 // tools (this is achieved by preserving pointers to the object in a globally
22 void BuryPointer(const void *Ptr
);
23 template <typename T
> void BuryPointer(std::unique_ptr
<T
> Ptr
) {
24 BuryPointer(Ptr
.release());