[lld][WebAssembly] Reinstate mistakenly disabled test. NFC
[llvm-project.git] / libcxx / include / __memory / addressof.h
blobc45dedfaec9bcdf89580dda7b68c9ccf0b5447f1
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___MEMORY_ADDRESSOF_H
11 #define _LIBCPP___MEMORY_ADDRESSOF_H
13 #include <__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_AFTER_CXX14
23 _LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY
24 _Tp*
25 addressof(_Tp& __x) _NOEXCEPT
27 return __builtin_addressof(__x);
30 #if defined(_LIBCPP_HAS_OBJC_ARC) && !defined(_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF)
31 // Objective-C++ Automatic Reference Counting uses qualified pointers
32 // that require special addressof() signatures. When
33 // _LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF is defined, the compiler
34 // itself is providing these definitions. Otherwise, we provide them.
35 template <class _Tp>
36 inline _LIBCPP_INLINE_VISIBILITY
37 __strong _Tp*
38 addressof(__strong _Tp& __x) _NOEXCEPT
40 return &__x;
43 #ifdef _LIBCPP_HAS_OBJC_ARC_WEAK
44 template <class _Tp>
45 inline _LIBCPP_INLINE_VISIBILITY
46 __weak _Tp*
47 addressof(__weak _Tp& __x) _NOEXCEPT
49 return &__x;
51 #endif
53 template <class _Tp>
54 inline _LIBCPP_INLINE_VISIBILITY
55 __autoreleasing _Tp*
56 addressof(__autoreleasing _Tp& __x) _NOEXCEPT
58 return &__x;
61 template <class _Tp>
62 inline _LIBCPP_INLINE_VISIBILITY
63 __unsafe_unretained _Tp*
64 addressof(__unsafe_unretained _Tp& __x) _NOEXCEPT
66 return &__x;
68 #endif
70 #if !defined(_LIBCPP_CXX03_LANG)
71 template <class _Tp> _Tp* addressof(const _Tp&&) noexcept = delete;
72 #endif
74 _LIBCPP_END_NAMESPACE_STD
76 #endif // _LIBCPP___MEMORY_ADDRESSOF_H