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)]]
166#if defined(__clang__) || defined(__GNUC__)
167#define LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_PUSH \
168 _Pragma("GCC diagnostic push") \
169 _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
170#define LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_POP \
171 _Pragma("GCC diagnostic pop")
172#elif defined(_MSC_VER)
173#define LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_PUSH \
174 _Pragma("warning(push)") \
175 _Pragma("warning(disable : 4996)")
176#define LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_POP \
177 _Pragma("warning(pop)")
179#define LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_PUSH
180#define LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_POP
191#if LLVM_HAS_CPP_ATTRIBUTE(clang::reinitializes)
192#define LLVM_ATTRIBUTE_REINITIALIZES [[clang::reinitializes]]
194#define LLVM_ATTRIBUTE_REINITIALIZES
205#ifndef LLVM_ATTRIBUTE_UNUSED
206#if __has_attribute(unused)
207#define LLVM_ATTRIBUTE_UNUSED __attribute__((__unused__))
209#define LLVM_ATTRIBUTE_UNUSED
214#if __has_attribute(weak) && !defined(__MINGW32__) && !defined(__CYGWIN__) && \
216#define LLVM_ATTRIBUTE_WEAK __attribute__((__weak__))
218#define LLVM_ATTRIBUTE_WEAK
224#if defined(__clang__) || defined(__GNUC__)
226#define LLVM_READNONE __attribute__((__const__))
233#if __has_attribute(pure) || defined(__GNUC__)
235#define LLVM_READONLY __attribute__((__pure__))
241#if __has_attribute(minsize)
242#define LLVM_ATTRIBUTE_MINSIZE __attribute__((minsize))
244#define LLVM_ATTRIBUTE_MINSIZE
248#if __has_builtin(__builtin_expect) || defined(__GNUC__)
249#define LLVM_LIKELY(EXPR) __builtin_expect((bool)(EXPR), true)
250#define LLVM_UNLIKELY(EXPR) __builtin_expect((bool)(EXPR), false)
252#define LLVM_LIKELY(EXPR) (EXPR)
253#define LLVM_UNLIKELY(EXPR) (EXPR)
259#ifndef LLVM_ATTRIBUTE_NOINLINE
260#if __has_attribute(noinline)
261#define LLVM_ATTRIBUTE_NOINLINE __attribute__((noinline))
262#elif defined(_MSC_VER)
263#define LLVM_ATTRIBUTE_NOINLINE __declspec(noinline)
265#define LLVM_ATTRIBUTE_NOINLINE
271#ifndef LLVM_ATTRIBUTE_ALWAYS_INLINE
272#if __has_attribute(always_inline)
273#define LLVM_ATTRIBUTE_ALWAYS_INLINE inline __attribute__((always_inline))
274#elif defined(_MSC_VER)
275#define LLVM_ATTRIBUTE_ALWAYS_INLINE __forceinline
277#define LLVM_ATTRIBUTE_ALWAYS_INLINE inline
284#if __has_attribute(nodebug)
285#define LLVM_ATTRIBUTE_NODEBUG __attribute__((nodebug))
287#define LLVM_ATTRIBUTE_NODEBUG
290#ifndef LLVM_ATTRIBUTE_RETURNS_NONNULL
291#if __has_attribute(returns_nonnull)
292#define LLVM_ATTRIBUTE_RETURNS_NONNULL __attribute__((returns_nonnull))
293#elif defined(_MSC_VER)
294#define LLVM_ATTRIBUTE_RETURNS_NONNULL _Ret_notnull_
296#define LLVM_ATTRIBUTE_RETURNS_NONNULL
302#if defined(__clang__) || defined(__GNUC__) || defined(_MSC_VER)
303#define LLVM_ATTRIBUTE_RESTRICT __restrict
305#define LLVM_ATTRIBUTE_RESTRICT
310#ifndef LLVM_ATTRIBUTE_RETURNS_NOALIAS
312#define LLVM_ATTRIBUTE_RETURNS_NOALIAS __attribute__((__malloc__))
313#elif defined(_MSC_VER)
314#define LLVM_ATTRIBUTE_RETURNS_NOALIAS __declspec(restrict)
316#define LLVM_ATTRIBUTE_RETURNS_NOALIAS
321#ifndef LLVM_FALLTHROUGH
322#if defined(__cplusplus) && __cplusplus > 201402L && LLVM_HAS_CPP_ATTRIBUTE(fallthrough)
323#define LLVM_FALLTHROUGH [[fallthrough]]
324#elif LLVM_HAS_CPP_ATTRIBUTE(gnu::fallthrough)
325#define LLVM_FALLTHROUGH [[gnu::fallthrough]]
326#elif __has_attribute(fallthrough)
327#define LLVM_FALLTHROUGH __attribute__((fallthrough))
328#elif LLVM_HAS_CPP_ATTRIBUTE(clang::fallthrough)
329#define LLVM_FALLTHROUGH [[clang::fallthrough]]
331#define LLVM_FALLTHROUGH
337#if LLVM_HAS_CPP_ATTRIBUTE(clang::require_constant_initialization)
338#define LLVM_REQUIRE_CONSTANT_INITIALIZATION \
339 [[clang::require_constant_initialization]]
341#define LLVM_REQUIRE_CONSTANT_INITIALIZATION
346#if LLVM_HAS_CPP_ATTRIBUTE(gsl::Owner)
347#define LLVM_GSL_OWNER [[gsl::Owner]]
349#define LLVM_GSL_OWNER
354#if LLVM_HAS_CPP_ATTRIBUTE(gsl::Pointer)
355#define LLVM_GSL_POINTER [[gsl::Pointer]]
357#define LLVM_GSL_POINTER
360#if LLVM_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L
361#define LLVM_CTOR_NODISCARD [[nodiscard]]
363#define LLVM_CTOR_NODISCARD
368#ifndef LLVM_EXTENSION
370#define LLVM_EXTENSION __extension__
372#define LLVM_EXTENSION
383#ifndef LLVM_BUILTIN_UNREACHABLE
384#if __has_builtin(__builtin_unreachable) || defined(__GNUC__)
385# define LLVM_BUILTIN_UNREACHABLE __builtin_unreachable()
386#elif defined(_MSC_VER)
387# define LLVM_BUILTIN_UNREACHABLE __assume(false)
393#ifndef LLVM_BUILTIN_TRAP
394#if __has_builtin(__builtin_trap) || defined(__GNUC__)
395# define LLVM_BUILTIN_TRAP __builtin_trap()
396#elif defined(_MSC_VER)
401# define LLVM_BUILTIN_TRAP __debugbreak()
403# define LLVM_BUILTIN_TRAP *(volatile int*)0x11 = 0
410#ifndef LLVM_BUILTIN_DEBUGTRAP
411#if __has_builtin(__builtin_debugtrap)
412# define LLVM_BUILTIN_DEBUGTRAP __builtin_debugtrap()
413#elif defined(_MSC_VER)
417# define LLVM_BUILTIN_DEBUGTRAP __debugbreak()
422# define LLVM_BUILTIN_DEBUGTRAP
428#ifndef LLVM_ASSUME_ALIGNED
429#if __has_builtin(__builtin_assume_aligned) || defined(__GNUC__)
430# define LLVM_ASSUME_ALIGNED(p, a) __builtin_assume_aligned(p, a)
431#elif defined(LLVM_BUILTIN_UNREACHABLE)
432# define LLVM_ASSUME_ALIGNED(p, a) \
433 (((uintptr_t(p) % (a)) == 0) ? (p) : (LLVM_BUILTIN_UNREACHABLE, (p)))
435# define LLVM_ASSUME_ALIGNED(p, a) (p)
459# define LLVM_PACKED(d) __pragma(pack(push, 1)) d __pragma(pack(pop))
460# define LLVM_PACKED_START __pragma(pack(push, 1))
461# define LLVM_PACKED_END __pragma(pack(pop))
463# define LLVM_PACKED(d) d __attribute__((packed))
464# define LLVM_PACKED_START _Pragma("pack(push, 1)")
465# define LLVM_PACKED_END _Pragma("pack(pop)")
471#if __has_feature(memory_sanitizer)
472# define LLVM_MEMORY_SANITIZER_BUILD 1
473# include <sanitizer/msan_interface.h>
474# define LLVM_NO_SANITIZE_MEMORY_ATTRIBUTE __attribute__((no_sanitize_memory))
476# define LLVM_MEMORY_SANITIZER_BUILD 0
477# define __msan_allocated_memory(p, size)
478# define __msan_unpoison(p, size)
479# define LLVM_NO_SANITIZE_MEMORY_ATTRIBUTE
484#if __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
485# define LLVM_ADDRESS_SANITIZER_BUILD 1
486#if __has_include(<sanitizer/asan_interface.h>)
487# include <sanitizer/asan_interface.h>
501# define LLVM_ADDRESS_SANITIZER_BUILD 0
502# define __asan_poison_memory_region(p, size)
503# define __asan_unpoison_memory_region(p, size)
508#if __has_feature(hwaddress_sanitizer)
509#define LLVM_HWADDRESS_SANITIZER_BUILD 1
511#define LLVM_HWADDRESS_SANITIZER_BUILD 0
516#if __has_feature(thread_sanitizer) || defined(__SANITIZE_THREAD__)
517# define LLVM_THREAD_SANITIZER_BUILD 1
519# define LLVM_THREAD_SANITIZER_BUILD 0
522#if LLVM_THREAD_SANITIZER_BUILD
529void AnnotateHappensAfter(
const char *file,
int line,
const volatile void *
cv);
530void AnnotateHappensBefore(
const char *file,
int line,
const volatile void *
cv);
531void AnnotateIgnoreWritesBegin(
const char *file,
int line);
532void AnnotateIgnoreWritesEnd(
const char *file,
int line);
540# define TsanHappensBefore(cv) AnnotateHappensBefore(__FILE__, __LINE__, cv)
543# define TsanHappensAfter(cv) AnnotateHappensAfter(__FILE__, __LINE__, cv)
546# define TsanIgnoreWritesBegin() AnnotateIgnoreWritesBegin(__FILE__, __LINE__)
549# define TsanIgnoreWritesEnd() AnnotateIgnoreWritesEnd(__FILE__, __LINE__)
551# define TsanHappensBefore(cv)
552# define TsanHappensAfter(cv)
553# define TsanIgnoreWritesBegin()
554# define TsanIgnoreWritesEnd()
559#ifndef LLVM_NO_SANITIZE
560#if __has_attribute(no_sanitize)
561#define LLVM_NO_SANITIZE(KIND) __attribute__((no_sanitize(KIND)))
563#define LLVM_NO_SANITIZE(KIND)
573#ifndef LLVM_DUMP_METHOD
574#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
575#define LLVM_DUMP_METHOD LLVM_ATTRIBUTE_NOINLINE LLVM_ATTRIBUTE_USED
577#define LLVM_DUMP_METHOD LLVM_ATTRIBUTE_NOINLINE
586#ifndef LLVM_PRETTY_FUNCTION
588#define LLVM_PRETTY_FUNCTION __FUNCSIG__
589#elif defined(__GNUC__) || defined(__clang__)
590#define LLVM_PRETTY_FUNCTION __PRETTY_FUNCTION__
592#define LLVM_PRETTY_FUNCTION __func__
607#if __has_feature(cxx_thread_local) || defined(_MSC_VER)
608#define LLVM_THREAD_LOCAL thread_local
612#define LLVM_THREAD_LOCAL __thread
617#if __has_feature(cxx_exceptions)
618#define LLVM_ENABLE_EXCEPTIONS 1
619#elif defined(__GNUC__) && defined(__EXCEPTIONS)
620#define LLVM_ENABLE_EXCEPTIONS 1
621#elif defined(_MSC_VER) && defined(_CPPUNWIND)
622#define LLVM_ENABLE_EXCEPTIONS 1
627#if __has_attribute(no_profile_instrument_function)
628#define LLVM_NO_PROFILE_INSTRUMENT_FUNCTION \
629 __attribute__((no_profile_instrument_function))
631#define LLVM_NO_PROFILE_INSTRUMENT_FUNCTION
636#if __has_attribute(preferred_type)
637#define LLVM_PREFERRED_TYPE(T) __attribute__((preferred_type(T)))
639#define LLVM_PREFERRED_TYPE(T)
#define __asan_poison_memory_region(p, size)
Definition Compiler.h:502
#define __asan_unpoison_memory_region(p, size)
Definition Compiler.h:503
Definition VisionPipeline.h:7