15#ifndef WPIUTIL_WPI_COMPILER_H
16#define WPIUTIL_WPI_COMPILER_H
26# define __has_feature(x) 0
29#ifndef __has_extension
30# define __has_extension(x) 0
33#ifndef __has_attribute
34# define __has_attribute(x) 0
38# define __has_builtin(x) 0
42# define __has_include(x) 0
47#ifndef LLVM_HAS_CPP_ATTRIBUTE
48#if defined(__cplusplus) && defined(__has_cpp_attribute)
49# define LLVM_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x)
51# define LLVM_HAS_CPP_ATTRIBUTE(x) 0
58#ifndef LLVM_GNUC_PREREQ
59# if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__)
60# define LLVM_GNUC_PREREQ(maj, min, patch) \
61 ((__GNUC__ << 20) + (__GNUC_MINOR__ << 10) + __GNUC_PATCHLEVEL__ >= \
62 ((maj) << 20) + ((min) << 10) + (patch))
63# elif defined(__GNUC__) && defined(__GNUC_MINOR__)
64# define LLVM_GNUC_PREREQ(maj, min, patch) \
65 ((__GNUC__ << 20) + (__GNUC_MINOR__ << 10) >= ((maj) << 20) + ((min) << 10))
67# define LLVM_GNUC_PREREQ(maj, min, patch) 0
92#ifndef LLVM_MSC_PREREQ
94#define LLVM_MSC_PREREQ(version) (_MSC_VER >= (version))
97#if !defined(LLVM_FORCE_USE_OLD_TOOLCHAIN)
98#if !LLVM_MSC_PREREQ(1920)
99#error LLVM requires at least VS 2019.
104#define LLVM_MSC_PREREQ(version) 0
118#if LLVM_HAS_CPP_ATTRIBUTE(gnu::visibility)
119#define LLVM_ATTRIBUTE_VISIBILITY_HIDDEN [[gnu::visibility("hidden")]]
120#define LLVM_ATTRIBUTE_VISIBILITY_DEFAULT [[gnu::visibility("default")]]
121#elif __has_attribute(visibility)
122#define LLVM_ATTRIBUTE_VISIBILITY_HIDDEN __attribute__((visibility("hidden")))
123#define LLVM_ATTRIBUTE_VISIBILITY_DEFAULT __attribute__((visibility("default")))
125#define LLVM_ATTRIBUTE_VISIBILITY_HIDDEN
126#define LLVM_ATTRIBUTE_VISIBILITY_DEFAULT
130#if (!(defined(_WIN32) || defined(__CYGWIN__)) || \
131 (defined(__MINGW32__) && defined(__clang__)))
132#define LLVM_LIBRARY_VISIBILITY LLVM_ATTRIBUTE_VISIBILITY_HIDDEN
133#if defined(LLVM_BUILD_LLVM_DYLIB) || defined(LLVM_BUILD_SHARED_LIBS)
134#define LLVM_EXTERNAL_VISIBILITY LLVM_ATTRIBUTE_VISIBILITY_DEFAULT
136#define LLVM_EXTERNAL_VISIBILITY
139#define LLVM_LIBRARY_VISIBILITY
140#define LLVM_EXTERNAL_VISIBILITY
145#define LLVM_PREFETCH(addr, rw, locality) __builtin_prefetch(addr, rw, locality)
147#define LLVM_PREFETCH(addr, rw, locality)
151#ifndef LLVM_ATTRIBUTE_USED
152#if __has_attribute(used)
153#define LLVM_ATTRIBUTE_USED __attribute__((__used__))
155#define LLVM_ATTRIBUTE_USED
159#if defined(__clang__)
160#define LLVM_DEPRECATED(MSG, FIX) __attribute__((deprecated(MSG, FIX)))
162#define LLVM_DEPRECATED(MSG, FIX) [[deprecated(MSG)]]
172#if LLVM_HAS_CPP_ATTRIBUTE(clang::reinitializes)
173#define LLVM_ATTRIBUTE_REINITIALIZES [[clang::reinitializes]]
175#define LLVM_ATTRIBUTE_REINITIALIZES
186#ifndef LLVM_ATTRIBUTE_UNUSED
187#if __has_attribute(unused)
188#define LLVM_ATTRIBUTE_UNUSED __attribute__((__unused__))
190#define LLVM_ATTRIBUTE_UNUSED
195#if __has_attribute(weak) && !defined(__MINGW32__) && !defined(__CYGWIN__) && \
197#define LLVM_ATTRIBUTE_WEAK __attribute__((__weak__))
199#define LLVM_ATTRIBUTE_WEAK
205#if defined(__clang__) || defined(__GNUC__)
207#define LLVM_READNONE __attribute__((__const__))
214#if __has_attribute(pure) || defined(__GNUC__)
216#define LLVM_READONLY __attribute__((__pure__))
222#if __has_attribute(minsize)
223#define LLVM_ATTRIBUTE_MINSIZE __attribute__((minsize))
225#define LLVM_ATTRIBUTE_MINSIZE
229#if __has_builtin(__builtin_expect) || defined(__GNUC__)
230#define LLVM_LIKELY(EXPR) __builtin_expect((bool)(EXPR), true)
231#define LLVM_UNLIKELY(EXPR) __builtin_expect((bool)(EXPR), false)
233#define LLVM_LIKELY(EXPR) (EXPR)
234#define LLVM_UNLIKELY(EXPR) (EXPR)
240#ifndef LLVM_ATTRIBUTE_NOINLINE
241#if __has_attribute(noinline)
242#define LLVM_ATTRIBUTE_NOINLINE __attribute__((noinline))
243#elif defined(_MSC_VER)
244#define LLVM_ATTRIBUTE_NOINLINE __declspec(noinline)
246#define LLVM_ATTRIBUTE_NOINLINE
252#ifndef LLVM_ATTRIBUTE_ALWAYS_INLINE
253#if __has_attribute(always_inline)
254#define LLVM_ATTRIBUTE_ALWAYS_INLINE inline __attribute__((always_inline))
255#elif defined(_MSC_VER)
256#define LLVM_ATTRIBUTE_ALWAYS_INLINE __forceinline
258#define LLVM_ATTRIBUTE_ALWAYS_INLINE inline
265#if __has_attribute(nodebug)
266#define LLVM_ATTRIBUTE_NODEBUG __attribute__((nodebug))
268#define LLVM_ATTRIBUTE_NODEBUG
271#ifndef LLVM_ATTRIBUTE_RETURNS_NONNULL
272#if __has_attribute(returns_nonnull)
273#define LLVM_ATTRIBUTE_RETURNS_NONNULL __attribute__((returns_nonnull))
274#elif defined(_MSC_VER)
275#define LLVM_ATTRIBUTE_RETURNS_NONNULL _Ret_notnull_
277#define LLVM_ATTRIBUTE_RETURNS_NONNULL
283#ifndef LLVM_ATTRIBUTE_RETURNS_NOALIAS
285#define LLVM_ATTRIBUTE_RETURNS_NOALIAS __attribute__((__malloc__))
286#elif defined(_MSC_VER)
287#define LLVM_ATTRIBUTE_RETURNS_NOALIAS __declspec(restrict)
289#define LLVM_ATTRIBUTE_RETURNS_NOALIAS
294#ifndef LLVM_FALLTHROUGH
295#if defined(__cplusplus) && __cplusplus > 201402L && LLVM_HAS_CPP_ATTRIBUTE(fallthrough)
296#define LLVM_FALLTHROUGH [[fallthrough]]
297#elif LLVM_HAS_CPP_ATTRIBUTE(gnu::fallthrough)
298#define LLVM_FALLTHROUGH [[gnu::fallthrough]]
299#elif __has_attribute(fallthrough)
300#define LLVM_FALLTHROUGH __attribute__((fallthrough))
301#elif LLVM_HAS_CPP_ATTRIBUTE(clang::fallthrough)
302#define LLVM_FALLTHROUGH [[clang::fallthrough]]
304#define LLVM_FALLTHROUGH
310#if LLVM_HAS_CPP_ATTRIBUTE(clang::require_constant_initialization)
311#define LLVM_REQUIRE_CONSTANT_INITIALIZATION \
312 [[clang::require_constant_initialization]]
314#define LLVM_REQUIRE_CONSTANT_INITIALIZATION
319#if LLVM_HAS_CPP_ATTRIBUTE(gsl::Owner)
320#define LLVM_GSL_OWNER [[gsl::Owner]]
322#define LLVM_GSL_OWNER
327#if LLVM_HAS_CPP_ATTRIBUTE(gsl::Pointer)
328#define LLVM_GSL_POINTER [[gsl::Pointer]]
330#define LLVM_GSL_POINTER
335#ifndef LLVM_EXTENSION
337#define LLVM_EXTENSION __extension__
339#define LLVM_EXTENSION
350#ifndef LLVM_BUILTIN_UNREACHABLE
351#if __has_builtin(__builtin_unreachable) || defined(__GNUC__)
352# define LLVM_BUILTIN_UNREACHABLE __builtin_unreachable()
353#elif defined(_MSC_VER)
354# define LLVM_BUILTIN_UNREACHABLE __assume(false)
360#ifndef LLVM_BUILTIN_TRAP
361#if __has_builtin(__builtin_trap) || defined(__GNUC__)
362# define LLVM_BUILTIN_TRAP __builtin_trap()
363#elif defined(_MSC_VER)
368# define LLVM_BUILTIN_TRAP __debugbreak()
370# define LLVM_BUILTIN_TRAP *(volatile int*)0x11 = 0
377#ifndef LLVM_BUILTIN_DEBUGTRAP
378#if __has_builtin(__builtin_debugtrap)
379# define LLVM_BUILTIN_DEBUGTRAP __builtin_debugtrap()
380#elif defined(_MSC_VER)
384# define LLVM_BUILTIN_DEBUGTRAP __debugbreak()
389# define LLVM_BUILTIN_DEBUGTRAP
395#ifndef LLVM_ASSUME_ALIGNED
396#if __has_builtin(__builtin_assume_aligned) || defined(__GNUC__)
397# define LLVM_ASSUME_ALIGNED(p, a) __builtin_assume_aligned(p, a)
398#elif defined(LLVM_BUILTIN_UNREACHABLE)
399# define LLVM_ASSUME_ALIGNED(p, a) \
400 (((uintptr_t(p) % (a)) == 0) ? (p) : (LLVM_BUILTIN_UNREACHABLE, (p)))
402# define LLVM_ASSUME_ALIGNED(p, a) (p)
426# define LLVM_PACKED(d) __pragma(pack(push, 1)) d __pragma(pack(pop))
427# define LLVM_PACKED_START __pragma(pack(push, 1))
428# define LLVM_PACKED_END __pragma(pack(pop))
430# define LLVM_PACKED(d) d __attribute__((packed))
431# define LLVM_PACKED_START _Pragma("pack(push, 1)")
432# define LLVM_PACKED_END _Pragma("pack(pop)")
438#if __has_feature(memory_sanitizer)
439# define LLVM_MEMORY_SANITIZER_BUILD 1
440# include <sanitizer/msan_interface.h>
441# define LLVM_NO_SANITIZE_MEMORY_ATTRIBUTE __attribute__((no_sanitize_memory))
443# define LLVM_MEMORY_SANITIZER_BUILD 0
444# define __msan_allocated_memory(p, size)
445# define __msan_unpoison(p, size)
446# define LLVM_NO_SANITIZE_MEMORY_ATTRIBUTE
451#if __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
452# define LLVM_ADDRESS_SANITIZER_BUILD 1
453#if __has_include(<sanitizer/asan_interface.h>)
454# include <sanitizer/asan_interface.h>
468# define LLVM_ADDRESS_SANITIZER_BUILD 0
469# define __asan_poison_memory_region(p, size)
470# define __asan_unpoison_memory_region(p, size)
475#if __has_feature(hwaddress_sanitizer)
476#define LLVM_HWADDRESS_SANITIZER_BUILD 1
478#define LLVM_HWADDRESS_SANITIZER_BUILD 0
483#if __has_feature(thread_sanitizer) || defined(__SANITIZE_THREAD__)
484# define LLVM_THREAD_SANITIZER_BUILD 1
486# define LLVM_THREAD_SANITIZER_BUILD 0
489#if LLVM_THREAD_SANITIZER_BUILD
496void AnnotateHappensAfter(
const char *
file,
int line,
const volatile void *
cv);
497void AnnotateHappensBefore(
const char *
file,
int line,
const volatile void *
cv);
498void AnnotateIgnoreWritesBegin(
const char *
file,
int line);
499void AnnotateIgnoreWritesEnd(
const char *
file,
int line);
507# define TsanHappensBefore(cv) AnnotateHappensBefore(__FILE__, __LINE__, cv)
510# define TsanHappensAfter(cv) AnnotateHappensAfter(__FILE__, __LINE__, cv)
513# define TsanIgnoreWritesBegin() AnnotateIgnoreWritesBegin(__FILE__, __LINE__)
516# define TsanIgnoreWritesEnd() AnnotateIgnoreWritesEnd(__FILE__, __LINE__)
518# define TsanHappensBefore(cv)
519# define TsanHappensAfter(cv)
520# define TsanIgnoreWritesBegin()
521# define TsanIgnoreWritesEnd()
526#ifndef LLVM_NO_SANITIZE
527#if __has_attribute(no_sanitize)
528#define LLVM_NO_SANITIZE(KIND) __attribute__((no_sanitize(KIND)))
530#define LLVM_NO_SANITIZE(KIND)
540#ifndef LLVM_DUMP_METHOD
541#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
542#define LLVM_DUMP_METHOD LLVM_ATTRIBUTE_NOINLINE LLVM_ATTRIBUTE_USED
544#define LLVM_DUMP_METHOD LLVM_ATTRIBUTE_NOINLINE
553#ifndef LLVM_PRETTY_FUNCTION
555#define LLVM_PRETTY_FUNCTION __FUNCSIG__
556#elif defined(__GNUC__) || defined(__clang__)
557#define LLVM_PRETTY_FUNCTION __PRETTY_FUNCTION__
559#define LLVM_PRETTY_FUNCTION __func__
574#if __has_feature(cxx_thread_local) || defined(_MSC_VER)
575#define LLVM_THREAD_LOCAL thread_local
579#define LLVM_THREAD_LOCAL __thread
584#if __has_feature(cxx_exceptions)
585#define LLVM_ENABLE_EXCEPTIONS 1
586#elif defined(__GNUC__) && defined(__EXCEPTIONS)
587#define LLVM_ENABLE_EXCEPTIONS 1
588#elif defined(_MSC_VER) && defined(_CPPUNWIND)
589#define LLVM_ENABLE_EXCEPTIONS 1
594#if __has_attribute(no_profile_instrument_function)
595#define LLVM_NO_PROFILE_INSTRUMENT_FUNCTION \
596 __attribute__((no_profile_instrument_function))
598#define LLVM_NO_PROFILE_INSTRUMENT_FUNCTION
#define __asan_poison_memory_region(p, size)
Definition: Compiler.h:469
#define __asan_unpoison_memory_region(p, size)
Definition: Compiler.h:470
then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file
Definition: ThirdPartyNotices.txt:192
Definition: VisionPipeline.h:7