[TySan] Don't report globals with incomplete types. (#121922)
[llvm-project.git] / libcxx / include / __cxx03 / __memory / destruct_n.h
bloba7dd2abd55980f6b02c4080927a3547a22b7dcb7
1 //===----------------------------------------------------------------------===//
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 _LIBCPP___CXX03___MEMORY_DESTRUCT_N_H
10 #define _LIBCPP___CXX03___MEMORY_DESTRUCT_N_H
12 #include <__cxx03/__config>
13 #include <__cxx03/__type_traits/integral_constant.h>
14 #include <__cxx03/__type_traits/is_trivially_destructible.h>
15 #include <__cxx03/cstddef>
17 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18 # pragma GCC system_header
19 #endif
21 _LIBCPP_BEGIN_NAMESPACE_STD
23 struct __destruct_n {
24 private:
25 size_t __size_;
27 template <class _Tp>
28 _LIBCPP_HIDE_FROM_ABI void __process(_Tp* __p, false_type) _NOEXCEPT {
29 for (size_t __i = 0; __i < __size_; ++__i, ++__p)
30 __p->~_Tp();
33 template <class _Tp>
34 _LIBCPP_HIDE_FROM_ABI void __process(_Tp*, true_type) _NOEXCEPT {}
36 _LIBCPP_HIDE_FROM_ABI void __incr(false_type) _NOEXCEPT { ++__size_; }
37 _LIBCPP_HIDE_FROM_ABI void __incr(true_type) _NOEXCEPT {}
39 _LIBCPP_HIDE_FROM_ABI void __set(size_t __s, false_type) _NOEXCEPT { __size_ = __s; }
40 _LIBCPP_HIDE_FROM_ABI void __set(size_t, true_type) _NOEXCEPT {}
42 public:
43 _LIBCPP_HIDE_FROM_ABI explicit __destruct_n(size_t __s) _NOEXCEPT : __size_(__s) {}
45 template <class _Tp>
46 _LIBCPP_HIDE_FROM_ABI void __incr() _NOEXCEPT {
47 __incr(integral_constant<bool, is_trivially_destructible<_Tp>::value>());
50 template <class _Tp>
51 _LIBCPP_HIDE_FROM_ABI void __set(size_t __s, _Tp*) _NOEXCEPT {
52 __set(__s, integral_constant<bool, is_trivially_destructible<_Tp>::value>());
55 template <class _Tp>
56 _LIBCPP_HIDE_FROM_ABI void operator()(_Tp* __p) _NOEXCEPT {
57 __process(__p, integral_constant<bool, is_trivially_destructible<_Tp>::value>());
61 _LIBCPP_END_NAMESPACE_STD
63 #endif // _LIBCPP___CXX03___MEMORY_DESTRUCT_N_H