BuryPointer.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- llvm/Support/BuryPointer.h - Memory Manipulation/Leak ----*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_SUPPORT_BURYPOINTER_H
  14. #define LLVM_SUPPORT_BURYPOINTER_H
  15. #include <memory>
  16. namespace llvm {
  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. } // namespace llvm
  28. #endif
  29. #ifdef __GNUC__
  30. #pragma GCC diagnostic pop
  31. #endif