9#ifndef mozilla_Attributes_h
10#define mozilla_Attributes_h
25# define MOZ_ALWAYS_INLINE_EVEN_DEBUG __forceinline
26#elif defined(__GNUC__)
27# define MOZ_ALWAYS_INLINE_EVEN_DEBUG __attribute__((always_inline)) inline
29# define MOZ_ALWAYS_INLINE_EVEN_DEBUG inline
33# define MOZ_ALWAYS_INLINE MOZ_ALWAYS_INLINE_EVEN_DEBUG
34#elif defined(_MSC_VER) && !defined(__cplusplus)
35# define MOZ_ALWAYS_INLINE __inline
37# define MOZ_ALWAYS_INLINE inline
53# define MOZ_HAVE_NEVER_INLINE __declspec(noinline)
54# define MOZ_HAVE_NORETURN __declspec(noreturn)
57# if __has_extension(cxx_constexpr)
58# define MOZ_HAVE_CXX11_CONSTEXPR
60# if __has_extension(cxx_explicit_conversions)
61# define MOZ_HAVE_EXPLICIT_CONVERSION
64#elif defined(__clang__)
70# ifndef __has_extension
71# define __has_extension __has_feature
73# if __has_extension(cxx_constexpr)
74# define MOZ_HAVE_CXX11_CONSTEXPR
76# if __has_extension(cxx_explicit_conversions)
77# define MOZ_HAVE_EXPLICIT_CONVERSION
79# if __has_attribute(noinline)
80# define MOZ_HAVE_NEVER_INLINE __attribute__((noinline))
82# if __has_attribute(noreturn)
83# define MOZ_HAVE_NORETURN __attribute__((noreturn))
85#elif defined(__GNUC__)
86# if defined(__GXX_EXPERIMENTAL_CXX0X__) || (defined(__cplusplus) && __cplusplus >= 201103L)
87# define MOZ_HAVE_CXX11_CONSTEXPR
88# if MOZ_GCC_VERSION_AT_LEAST(4, 8, 0)
89# define MOZ_HAVE_CXX11_CONSTEXPR_IN_TEMPLATES
91# define MOZ_HAVE_EXPLICIT_CONVERSION
93# define MOZ_HAVE_NEVER_INLINE __attribute__((noinline))
94# define MOZ_HAVE_NORETURN __attribute__((noreturn))
101#ifdef __clang_analyzer__
102# if __has_extension(attribute_analyzer_noreturn)
103# define MOZ_HAVE_ANALYZER_NORETURN __attribute__((analyzer_noreturn))
117#ifdef MOZ_HAVE_CXX11_CONSTEXPR
118# define MOZ_CONSTEXPR constexpr
119# define MOZ_CONSTEXPR_VAR constexpr
120# ifdef MOZ_HAVE_CXX11_CONSTEXPR_IN_TEMPLATES
121# define MOZ_CONSTEXPR_TMPL constexpr
123# define MOZ_CONSTEXPR_TMPL
126# define MOZ_CONSTEXPR
127# define MOZ_CONSTEXPR_VAR const
128# define MOZ_CONSTEXPR_TMPL
150#ifdef MOZ_HAVE_EXPLICIT_CONVERSION
151# define MOZ_EXPLICIT_CONVERSION explicit
153# define MOZ_EXPLICIT_CONVERSION
162#if defined(MOZ_HAVE_NEVER_INLINE)
163# define MOZ_NEVER_INLINE MOZ_HAVE_NEVER_INLINE
165# define MOZ_NEVER_INLINE
182#if defined(MOZ_HAVE_NORETURN)
183# define MOZ_NORETURN MOZ_HAVE_NORETURN
203#if defined(__GNUC__) || defined(__clang__)
204# define MOZ_COLD __attribute__ ((cold))
219#if defined(__GNUC__) || defined(__clang__)
220# define MOZ_NONNULL(...) __attribute__ ((nonnull(__VA_ARGS__)))
222# define MOZ_NONNULL(...)
241#if defined(MOZ_HAVE_ANALYZER_NORETURN)
242# define MOZ_PRETEND_NORETURN_FOR_STATIC_ANALYSIS MOZ_HAVE_ANALYZER_NORETURN
244# define MOZ_PRETEND_NORETURN_FOR_STATIC_ANALYSIS
254#if defined(__has_feature)
255# if __has_feature(address_sanitizer)
256# define MOZ_HAVE_ASAN_DENYLIST
258#elif defined(__GNUC__)
259# if defined(__SANITIZE_ADDRESS__)
260# define MOZ_HAVE_ASAN_DENYLIST
264#if defined(MOZ_HAVE_ASAN_DENYLIST)
265# define MOZ_ASAN_DENYLIST MOZ_NEVER_INLINE __attribute__((no_sanitize_address))
267# define MOZ_ASAN_DENYLIST
276#if defined(__has_feature)
277# if __has_feature(thread_sanitizer)
278# define MOZ_TSAN_DENYLIST MOZ_NEVER_INLINE __attribute__((no_sanitize_thread))
280# define MOZ_TSAN_DENYLIST
283# define MOZ_TSAN_DENYLIST
309#if defined(__GNUC__) || defined(__clang__)
310# define MOZ_ALLOCATOR __attribute__ ((malloc, warn_unused_result))
312# define MOZ_ALLOCATOR
328#if defined(__GNUC__) || defined(__clang__)
329# define MOZ_WARN_UNUSED_RESULT __attribute__ ((warn_unused_result))
331# define MOZ_WARN_UNUSED_RESULT
436#ifdef MOZ_CLANG_PLUGIN
437# define MOZ_MUST_OVERRIDE __attribute__((annotate("moz_must_override")))
438# define MOZ_STACK_CLASS __attribute__((annotate("moz_stack_class")))
439# define MOZ_NONHEAP_CLASS __attribute__((annotate("moz_nonheap_class")))
440# define MOZ_TRIVIAL_CTOR_DTOR __attribute__((annotate("moz_trivial_ctor_dtor")))
443# define MOZ_ONLY_USED_TO_AVOID_STATIC_CONSTRUCTORS __attribute__((annotate("moz_global_class")))
445# define MOZ_ONLY_USED_TO_AVOID_STATIC_CONSTRUCTORS __attribute__((annotate("moz_global_class"))) \
446 MOZ_TRIVIAL_CTOR_DTOR
448# define MOZ_IMPLICIT __attribute__((annotate("moz_implicit")))
449# define MOZ_NO_ARITHMETIC_EXPR_IN_ARGUMENT __attribute__((annotate("moz_no_arith_expr_in_arg")))
450# define MOZ_OWNING_REF __attribute__((annotate("moz_strong_ref")))
451# define MOZ_NON_OWNING_REF __attribute__((annotate("moz_weak_ref")))
452# define MOZ_UNSAFE_REF(reason) __attribute__((annotate("moz_strong_ref")))
453# define MOZ_NO_ADDREF_RELEASE_ON_RETURN __attribute__((annotate("moz_no_addref_release_on_return")))
459# define MOZ_HEAP_ALLOCATOR \
460 _Pragma("clang diagnostic push") \
461 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
462 __attribute__((annotate("moz_heap_allocator"))) \
463 _Pragma("clang diagnostic pop")
465# define MOZ_MUST_OVERRIDE
466# define MOZ_STACK_CLASS
467# define MOZ_NONHEAP_CLASS
468# define MOZ_TRIVIAL_CTOR_DTOR
469# define MOZ_ONLY_USED_TO_AVOID_STATIC_CONSTRUCTORS
471# define MOZ_NO_ARITHMETIC_EXPR_IN_ARGUMENT
472# define MOZ_HEAP_ALLOCATOR
473# define MOZ_OWNING_REF
474# define MOZ_NON_OWNING_REF
475# define MOZ_UNSAFE_REF(reason)
476# define MOZ_NO_ADDREF_RELEASE_ON_RETURN