[TySan] Don't report globals with incomplete types. (#121922)
[llvm-project.git] / libcxx / include / __cxx03 / __memory / addressof.h
blob6c88ec87be1ac23564e76ad0fa6ac4dd0de27e1a
1 // -*- C++ -*-
2 //===----------------------------------------------------------------------===//
3 //
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //
8 //===----------------------------------------------------------------------===//
10 #ifndef _LIBCPP___CXX03___MEMORY_ADDRESSOF_H
11 #define _LIBCPP___CXX03___MEMORY_ADDRESSOF_H
13 #include <__cxx03/__config>
15 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16 # pragma GCC system_header
17 #endif
19 _LIBCPP_BEGIN_NAMESPACE_STD
21 template <class _Tp>
22 inline _LIBCPP_CONSTEXPR_SINCE_CXX17 _LIBCPP_NO_CFI _LIBCPP_HIDE_FROM_ABI _Tp* addressof(_Tp& __x) _NOEXCEPT {
23 return __builtin_addressof(__x);
26 #if defined(_LIBCPP_HAS_OBJC_ARC) && !defined(_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF)
27 // Objective-C++ Automatic Reference Counting uses qualified pointers
28 // that require special addressof() signatures. When
29 // _LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF is defined, the compiler
30 // itself is providing these definitions. Otherwise, we provide them.
31 template <class _Tp>
32 inline _LIBCPP_HIDE_FROM_ABI __strong _Tp* addressof(__strong _Tp& __x) _NOEXCEPT {
33 return &__x;
36 # ifdef _LIBCPP_HAS_OBJC_ARC_WEAK
37 template <class _Tp>
38 inline _LIBCPP_HIDE_FROM_ABI __weak _Tp* addressof(__weak _Tp& __x) _NOEXCEPT {
39 return &__x;
41 # endif
43 template <class _Tp>
44 inline _LIBCPP_HIDE_FROM_ABI __autoreleasing _Tp* addressof(__autoreleasing _Tp& __x) _NOEXCEPT {
45 return &__x;
48 template <class _Tp>
49 inline _LIBCPP_HIDE_FROM_ABI __unsafe_unretained _Tp* addressof(__unsafe_unretained _Tp& __x) _NOEXCEPT {
50 return &__x;
52 #endif
54 #if !defined(_LIBCPP_CXX03_LANG)
55 template <class _Tp>
56 _Tp* addressof(const _Tp&&) noexcept = delete;
57 #endif
59 _LIBCPP_END_NAMESPACE_STD
61 #endif // _LIBCPP___CXX03___MEMORY_ADDRESSOF_H