[llvm] [cmake] Add possibility to use ChooseMSVCCRT.cmake when include LLVM library
[llvm-core.git] / include / llvm / Support / BuryPointer.h
blob276a5b7089c3e7e89327f5efa4ce70097ba8f238
1 //===- llvm/Support/BuryPointer.h - Memory Manipulation/Leak ----*- C++ -*-===//
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 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_SUPPORT_BURYPOINTER_H
10 #define LLVM_SUPPORT_BURYPOINTER_H
12 #include <memory>
14 namespace llvm {
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
21 // visible array).
22 void BuryPointer(const void *Ptr);
23 template <typename T> void BuryPointer(std::unique_ptr<T> Ptr) {
24 BuryPointer(Ptr.release());
27 } // namespace llvm
29 #endif