WPILibC++ 2024.3.2-100-g4ce8f3f
Compiler.h
Go to the documentation of this file.
1//===-- llvm/Support/Compiler.h - Compiler abstraction support --*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file defines several macros, based on the current compiler. This allows
10// use of compiler-specific features in a way that remains portable. This header
11// can be included from either C or C++.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef WPIUTIL_WPI_COMPILER_H
16#define WPIUTIL_WPI_COMPILER_H
17
18
19#include <stddef.h>
20
21#if defined(_MSC_VER)
22#include <sal.h>
23#endif
24
25#ifndef __has_feature
26# define __has_feature(x) 0
27#endif
28
29#ifndef __has_extension
30# define __has_extension(x) 0
31#endif
32
33#ifndef __has_attribute
34# define __has_attribute(x) 0
35#endif
36
37#ifndef __has_builtin
38# define __has_builtin(x) 0
39#endif
40
41#ifndef __has_include
42# define __has_include(x) 0
43#endif
44
45// Only use __has_cpp_attribute in C++ mode. GCC defines __has_cpp_attribute in
46// C mode, but the :: in __has_cpp_attribute(scoped::attribute) is invalid.
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)
50#else
51# define LLVM_HAS_CPP_ATTRIBUTE(x) 0
52#endif
53#endif
54
55/// \macro LLVM_GNUC_PREREQ
56/// Extend the default __GNUC_PREREQ even if glibc's features.h isn't
57/// available.
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))
66# else
67# define LLVM_GNUC_PREREQ(maj, min, patch) 0
68# endif
69#endif
70
71/// \macro LLVM_MSC_PREREQ
72/// Is the compiler MSVC of at least the specified version?
73/// The common \param version values to check for are:
74/// * 1910: VS2017, version 15.1 & 15.2
75/// * 1911: VS2017, version 15.3 & 15.4
76/// * 1912: VS2017, version 15.5
77/// * 1913: VS2017, version 15.6
78/// * 1914: VS2017, version 15.7
79/// * 1915: VS2017, version 15.8
80/// * 1916: VS2017, version 15.9
81/// * 1920: VS2019, version 16.0
82/// * 1921: VS2019, version 16.1
83/// * 1922: VS2019, version 16.2
84/// * 1923: VS2019, version 16.3
85/// * 1924: VS2019, version 16.4
86/// * 1925: VS2019, version 16.5
87/// * 1926: VS2019, version 16.6
88/// * 1927: VS2019, version 16.7
89/// * 1928: VS2019, version 16.8 + 16.9
90/// * 1929: VS2019, version 16.10 + 16.11
91/// * 1930: VS2022, version 17.0
92#ifndef LLVM_MSC_PREREQ
93#ifdef _MSC_VER
94#define LLVM_MSC_PREREQ(version) (_MSC_VER >= (version))
95
96// We require at least VS 2019.
97#if !defined(LLVM_FORCE_USE_OLD_TOOLCHAIN)
98#if !LLVM_MSC_PREREQ(1920)
99#error LLVM requires at least VS 2019.
100#endif
101#endif
102
103#else
104#define LLVM_MSC_PREREQ(version) 0
105#endif
106#endif
107
108/// LLVM_LIBRARY_VISIBILITY - If a class marked with this attribute is linked
109/// into a shared library, then the class should be private to the library and
110/// not accessible from outside it. Can also be used to mark variables and
111/// functions, making them private to any shared library they are linked into.
112/// On PE/COFF targets, library visibility is the default, so this isn't needed.
113///
114/// LLVM_EXTERNAL_VISIBILITY - classes, functions, and variables marked with
115/// this attribute will be made public and visible outside of any shared library
116/// they are linked in to.
117
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")))
124#else
125#define LLVM_ATTRIBUTE_VISIBILITY_HIDDEN
126#define LLVM_ATTRIBUTE_VISIBILITY_DEFAULT
127#endif
128
129
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
135#else
136#define LLVM_EXTERNAL_VISIBILITY
137#endif
138#else
139#define LLVM_LIBRARY_VISIBILITY
140#define LLVM_EXTERNAL_VISIBILITY
141#endif
142
143#ifndef LLVM_PREFETCH
144#if defined(__GNUC__)
145#define LLVM_PREFETCH(addr, rw, locality) __builtin_prefetch(addr, rw, locality)
146#else
147#define LLVM_PREFETCH(addr, rw, locality)
148#endif
149#endif
150
151#ifndef LLVM_ATTRIBUTE_USED
152#if __has_attribute(used)
153#define LLVM_ATTRIBUTE_USED __attribute__((__used__))
154#else
155#define LLVM_ATTRIBUTE_USED
156#endif
157#endif
158
159#if defined(__clang__)
160#define LLVM_DEPRECATED(MSG, FIX) __attribute__((deprecated(MSG, FIX)))
161#else
162#define LLVM_DEPRECATED(MSG, FIX) [[deprecated(MSG)]]
163#endif
164
165// clang-format off
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)")
178#else
179#define LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_PUSH
180#define LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_POP
181#endif
182// clang-format on
183
184// Indicate that a non-static, non-const C++ member function reinitializes
185// the entire object to a known state, independent of the previous state of
186// the object.
187//
188// The clang-tidy check bugprone-use-after-move recognizes this attribute as a
189// marker that a moved-from object has left the indeterminate state and can be
190// reused.
191#if LLVM_HAS_CPP_ATTRIBUTE(clang::reinitializes)
192#define LLVM_ATTRIBUTE_REINITIALIZES [[clang::reinitializes]]
193#else
194#define LLVM_ATTRIBUTE_REINITIALIZES
195#endif
196
197// Some compilers warn about unused functions. When a function is sometimes
198// used or not depending on build settings (e.g. a function only called from
199// within "assert"), this attribute can be used to suppress such warnings.
200//
201// However, it shouldn't be used for unused *variables*, as those have a much
202// more portable solution:
203// (void)unused_var_name;
204// Prefer cast-to-void wherever it is sufficient.
205#ifndef LLVM_ATTRIBUTE_UNUSED
206#if __has_attribute(unused)
207#define LLVM_ATTRIBUTE_UNUSED __attribute__((__unused__))
208#else
209#define LLVM_ATTRIBUTE_UNUSED
210#endif
211#endif
212
213// FIXME: Provide this for PE/COFF targets.
214#if __has_attribute(weak) && !defined(__MINGW32__) && !defined(__CYGWIN__) && \
215 !defined(_WIN32)
216#define LLVM_ATTRIBUTE_WEAK __attribute__((__weak__))
217#else
218#define LLVM_ATTRIBUTE_WEAK
219#endif
220
221#ifndef LLVM_READNONE
222// Prior to clang 3.2, clang did not accept any spelling of
223// __has_attribute(const), so assume it is supported.
224#if defined(__clang__) || defined(__GNUC__)
225// aka 'CONST' but following LLVM Conventions.
226#define LLVM_READNONE __attribute__((__const__))
227#else
228#define LLVM_READNONE
229#endif
230#endif
231
232#ifndef LLVM_READONLY
233#if __has_attribute(pure) || defined(__GNUC__)
234// aka 'PURE' but following LLVM Conventions.
235#define LLVM_READONLY __attribute__((__pure__))
236#else
237#define LLVM_READONLY
238#endif
239#endif
240
241#if __has_attribute(minsize)
242#define LLVM_ATTRIBUTE_MINSIZE __attribute__((minsize))
243#else
244#define LLVM_ATTRIBUTE_MINSIZE
245#endif
246
247#ifndef LLVM_LIKELY
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)
251#else
252#define LLVM_LIKELY(EXPR) (EXPR)
253#define LLVM_UNLIKELY(EXPR) (EXPR)
254#endif
255#endif
256
257/// LLVM_ATTRIBUTE_NOINLINE - On compilers where we have a directive to do so,
258/// mark a method "not for inlining".
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)
264#else
265#define LLVM_ATTRIBUTE_NOINLINE
266#endif
267#endif
268
269/// LLVM_ATTRIBUTE_ALWAYS_INLINE - On compilers where we have a directive to do
270/// so, mark a method "always inline" because it is performance sensitive.
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
276#else
277#define LLVM_ATTRIBUTE_ALWAYS_INLINE inline
278#endif
279#endif
280
281/// LLVM_ATTRIBUTE_NO_DEBUG - On compilers where we have a directive to do
282/// so, mark a method "no debug" because debug info makes the debugger
283/// experience worse.
284#if __has_attribute(nodebug)
285#define LLVM_ATTRIBUTE_NODEBUG __attribute__((nodebug))
286#else
287#define LLVM_ATTRIBUTE_NODEBUG
288#endif
289
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_
295#else
296#define LLVM_ATTRIBUTE_RETURNS_NONNULL
297#endif
298#endif
299
300/// \macro LLVM_ATTRIBUTE_RETURNS_NOALIAS Used to mark a function as returning a
301/// pointer that does not alias any other valid pointer.
302#ifndef LLVM_ATTRIBUTE_RETURNS_NOALIAS
303#ifdef __GNUC__
304#define LLVM_ATTRIBUTE_RETURNS_NOALIAS __attribute__((__malloc__))
305#elif defined(_MSC_VER)
306#define LLVM_ATTRIBUTE_RETURNS_NOALIAS __declspec(restrict)
307#else
308#define LLVM_ATTRIBUTE_RETURNS_NOALIAS
309#endif
310#endif
311
312/// LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
313#ifndef LLVM_FALLTHROUGH
314#if defined(__cplusplus) && __cplusplus > 201402L && LLVM_HAS_CPP_ATTRIBUTE(fallthrough)
315#define LLVM_FALLTHROUGH [[fallthrough]]
316#elif LLVM_HAS_CPP_ATTRIBUTE(gnu::fallthrough)
317#define LLVM_FALLTHROUGH [[gnu::fallthrough]]
318#elif __has_attribute(fallthrough)
319#define LLVM_FALLTHROUGH __attribute__((fallthrough))
320#elif LLVM_HAS_CPP_ATTRIBUTE(clang::fallthrough)
321#define LLVM_FALLTHROUGH [[clang::fallthrough]]
322#else
323#define LLVM_FALLTHROUGH
324#endif
325#endif
326
327/// LLVM_REQUIRE_CONSTANT_INITIALIZATION - Apply this to globals to ensure that
328/// they are constant initialized.
329#if LLVM_HAS_CPP_ATTRIBUTE(clang::require_constant_initialization)
330#define LLVM_REQUIRE_CONSTANT_INITIALIZATION \
331 [[clang::require_constant_initialization]]
332#else
333#define LLVM_REQUIRE_CONSTANT_INITIALIZATION
334#endif
335
336/// LLVM_GSL_OWNER - Apply this to owning classes like SmallVector to enable
337/// lifetime warnings.
338#if LLVM_HAS_CPP_ATTRIBUTE(gsl::Owner)
339#define LLVM_GSL_OWNER [[gsl::Owner]]
340#else
341#define LLVM_GSL_OWNER
342#endif
343
344/// LLVM_GSL_POINTER - Apply this to non-owning classes like
345/// std::string_view to enable lifetime warnings.
346#if LLVM_HAS_CPP_ATTRIBUTE(gsl::Pointer)
347#define LLVM_GSL_POINTER [[gsl::Pointer]]
348#else
349#define LLVM_GSL_POINTER
350#endif
351
352#if LLVM_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L
353#define LLVM_CTOR_NODISCARD [[nodiscard]]
354#else
355#define LLVM_CTOR_NODISCARD
356#endif
357
358/// LLVM_EXTENSION - Support compilers where we have a keyword to suppress
359/// pedantic diagnostics.
360#ifndef LLVM_EXTENSION
361#ifdef __GNUC__
362#define LLVM_EXTENSION __extension__
363#else
364#define LLVM_EXTENSION
365#endif
366#endif
367
368/// LLVM_BUILTIN_UNREACHABLE - On compilers which support it, expands
369/// to an expression which states that it is undefined behavior for the
370/// compiler to reach this point. Otherwise is not defined.
371///
372/// '#else' is intentionally left out so that other macro logic (e.g.,
373/// LLVM_ASSUME_ALIGNED and wpi_unreachable()) can detect whether
374/// LLVM_BUILTIN_UNREACHABLE has a definition.
375#ifndef LLVM_BUILTIN_UNREACHABLE
376#if __has_builtin(__builtin_unreachable) || defined(__GNUC__)
377# define LLVM_BUILTIN_UNREACHABLE __builtin_unreachable()
378#elif defined(_MSC_VER)
379# define LLVM_BUILTIN_UNREACHABLE __assume(false)
380#endif
381#endif
382
383/// LLVM_BUILTIN_TRAP - On compilers which support it, expands to an expression
384/// which causes the program to exit abnormally.
385#ifndef LLVM_BUILTIN_TRAP
386#if __has_builtin(__builtin_trap) || defined(__GNUC__)
387# define LLVM_BUILTIN_TRAP __builtin_trap()
388#elif defined(_MSC_VER)
389// The __debugbreak intrinsic is supported by MSVC, does not require forward
390// declarations involving platform-specific typedefs (unlike RaiseException),
391// results in a call to vectored exception handlers, and encodes to a short
392// instruction that still causes the trapping behavior we want.
393# define LLVM_BUILTIN_TRAP __debugbreak()
394#else
395# define LLVM_BUILTIN_TRAP *(volatile int*)0x11 = 0
396#endif
397#endif
398
399/// LLVM_BUILTIN_DEBUGTRAP - On compilers which support it, expands to
400/// an expression which causes the program to break while running
401/// under a debugger.
402#ifndef LLVM_BUILTIN_DEBUGTRAP
403#if __has_builtin(__builtin_debugtrap)
404# define LLVM_BUILTIN_DEBUGTRAP __builtin_debugtrap()
405#elif defined(_MSC_VER)
406// The __debugbreak intrinsic is supported by MSVC and breaks while
407// running under the debugger, and also supports invoking a debugger
408// when the OS is configured appropriately.
409# define LLVM_BUILTIN_DEBUGTRAP __debugbreak()
410#else
411// Just continue execution when built with compilers that have no
412// support. This is a debugging aid and not intended to force the
413// program to abort if encountered.
414# define LLVM_BUILTIN_DEBUGTRAP
415#endif
416#endif
417
418/// \macro LLVM_ASSUME_ALIGNED
419/// Returns a pointer with an assumed alignment.
420#ifndef LLVM_ASSUME_ALIGNED
421#if __has_builtin(__builtin_assume_aligned) || defined(__GNUC__)
422# define LLVM_ASSUME_ALIGNED(p, a) __builtin_assume_aligned(p, a)
423#elif defined(LLVM_BUILTIN_UNREACHABLE)
424# define LLVM_ASSUME_ALIGNED(p, a) \
425 (((uintptr_t(p) % (a)) == 0) ? (p) : (LLVM_BUILTIN_UNREACHABLE, (p)))
426#else
427# define LLVM_ASSUME_ALIGNED(p, a) (p)
428#endif
429#endif
430
431/// \macro LLVM_PACKED
432/// Used to specify a packed structure.
433/// LLVM_PACKED(
434/// struct A {
435/// int i;
436/// int j;
437/// int k;
438/// long long l;
439/// });
440///
441/// LLVM_PACKED_START
442/// struct B {
443/// int i;
444/// int j;
445/// int k;
446/// long long l;
447/// };
448/// LLVM_PACKED_END
449#ifndef LLVM_PACKED
450#ifdef _MSC_VER
451# define LLVM_PACKED(d) __pragma(pack(push, 1)) d __pragma(pack(pop))
452# define LLVM_PACKED_START __pragma(pack(push, 1))
453# define LLVM_PACKED_END __pragma(pack(pop))
454#else
455# define LLVM_PACKED(d) d __attribute__((packed))
456# define LLVM_PACKED_START _Pragma("pack(push, 1)")
457# define LLVM_PACKED_END _Pragma("pack(pop)")
458#endif
459#endif
460
461/// \macro LLVM_MEMORY_SANITIZER_BUILD
462/// Whether LLVM itself is built with MemorySanitizer instrumentation.
463#if __has_feature(memory_sanitizer)
464# define LLVM_MEMORY_SANITIZER_BUILD 1
465# include <sanitizer/msan_interface.h>
466# define LLVM_NO_SANITIZE_MEMORY_ATTRIBUTE __attribute__((no_sanitize_memory))
467#else
468# define LLVM_MEMORY_SANITIZER_BUILD 0
469# define __msan_allocated_memory(p, size)
470# define __msan_unpoison(p, size)
471# define LLVM_NO_SANITIZE_MEMORY_ATTRIBUTE
472#endif
473
474/// \macro LLVM_ADDRESS_SANITIZER_BUILD
475/// Whether LLVM itself is built with AddressSanitizer instrumentation.
476#if __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
477# define LLVM_ADDRESS_SANITIZER_BUILD 1
478#if __has_include(<sanitizer/asan_interface.h>)
479# include <sanitizer/asan_interface.h>
480#else
481// These declarations exist to support ASan with MSVC. If MSVC eventually ships
482// asan_interface.h in their headers, then we can remove this.
483#ifdef __cplusplus
484extern "C" {
485#endif
486void __asan_poison_memory_region(void const volatile *addr, size_t size);
487void __asan_unpoison_memory_region(void const volatile *addr, size_t size);
488#ifdef __cplusplus
489} // extern "C"
490#endif
491#endif
492#else
493# define LLVM_ADDRESS_SANITIZER_BUILD 0
494# define __asan_poison_memory_region(p, size)
495# define __asan_unpoison_memory_region(p, size)
496#endif
497
498/// \macro LLVM_HWADDRESS_SANITIZER_BUILD
499/// Whether LLVM itself is built with HWAddressSanitizer instrumentation.
500#if __has_feature(hwaddress_sanitizer)
501#define LLVM_HWADDRESS_SANITIZER_BUILD 1
502#else
503#define LLVM_HWADDRESS_SANITIZER_BUILD 0
504#endif
505
506/// \macro LLVM_THREAD_SANITIZER_BUILD
507/// Whether LLVM itself is built with ThreadSanitizer instrumentation.
508#if __has_feature(thread_sanitizer) || defined(__SANITIZE_THREAD__)
509# define LLVM_THREAD_SANITIZER_BUILD 1
510#else
511# define LLVM_THREAD_SANITIZER_BUILD 0
512#endif
513
514#if LLVM_THREAD_SANITIZER_BUILD
515// Thread Sanitizer is a tool that finds races in code.
516// See http://code.google.com/p/data-race-test/wiki/DynamicAnnotations .
517// tsan detects these exact functions by name.
518#ifdef __cplusplus
519extern "C" {
520#endif
521void AnnotateHappensAfter(const char *file, int line, const volatile void *cv);
522void AnnotateHappensBefore(const char *file, int line, const volatile void *cv);
523void AnnotateIgnoreWritesBegin(const char *file, int line);
524void AnnotateIgnoreWritesEnd(const char *file, int line);
525#ifdef __cplusplus
526}
527#endif
528
529// This marker is used to define a happens-before arc. The race detector will
530// infer an arc from the begin to the end when they share the same pointer
531// argument.
532# define TsanHappensBefore(cv) AnnotateHappensBefore(__FILE__, __LINE__, cv)
533
534// This marker defines the destination of a happens-before arc.
535# define TsanHappensAfter(cv) AnnotateHappensAfter(__FILE__, __LINE__, cv)
536
537// Ignore any races on writes between here and the next TsanIgnoreWritesEnd.
538# define TsanIgnoreWritesBegin() AnnotateIgnoreWritesBegin(__FILE__, __LINE__)
539
540// Resume checking for racy writes.
541# define TsanIgnoreWritesEnd() AnnotateIgnoreWritesEnd(__FILE__, __LINE__)
542#else
543# define TsanHappensBefore(cv)
544# define TsanHappensAfter(cv)
545# define TsanIgnoreWritesBegin()
546# define TsanIgnoreWritesEnd()
547#endif
548
549/// \macro LLVM_NO_SANITIZE
550/// Disable a particular sanitizer for a function.
551#ifndef LLVM_NO_SANITIZE
552#if __has_attribute(no_sanitize)
553#define LLVM_NO_SANITIZE(KIND) __attribute__((no_sanitize(KIND)))
554#else
555#define LLVM_NO_SANITIZE(KIND)
556#endif
557#endif
558
559/// Mark debug helper function definitions like dump() that should not be
560/// stripped from debug builds.
561/// Note that you should also surround dump() functions with
562/// `#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)` so they do always
563/// get stripped in release builds.
564// FIXME: Move this to a private config.h as it's not usable in public headers.
565#ifndef LLVM_DUMP_METHOD
566#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
567#define LLVM_DUMP_METHOD LLVM_ATTRIBUTE_NOINLINE LLVM_ATTRIBUTE_USED
568#else
569#define LLVM_DUMP_METHOD LLVM_ATTRIBUTE_NOINLINE
570#endif
571#endif
572
573/// \macro LLVM_PRETTY_FUNCTION
574/// Gets a user-friendly looking function signature for the current scope
575/// using the best available method on each platform. The exact format of the
576/// resulting string is implementation specific and non-portable, so this should
577/// only be used, for example, for logging or diagnostics.
578#ifndef LLVM_PRETTY_FUNCTION
579#if defined(_MSC_VER)
580#define LLVM_PRETTY_FUNCTION __FUNCSIG__
581#elif defined(__GNUC__) || defined(__clang__)
582#define LLVM_PRETTY_FUNCTION __PRETTY_FUNCTION__
583#else
584#define LLVM_PRETTY_FUNCTION __func__
585#endif
586#endif
587
588/// \macro LLVM_THREAD_LOCAL
589/// A thread-local storage specifier which can be used with globals,
590/// extern globals, and static globals.
591///
592/// This is essentially an extremely restricted analog to C++11's thread_local
593/// support. It uses thread_local if available, falling back on gcc __thread
594/// if not. __thread doesn't support many of the C++11 thread_local's
595/// features. You should only use this for PODs that you can statically
596/// initialize to some constant value. In almost all circumstances this is most
597/// appropriate for use with a pointer, integer, or small aggregation of
598/// pointers and integers.
599#if __has_feature(cxx_thread_local) || defined(_MSC_VER)
600#define LLVM_THREAD_LOCAL thread_local
601#else
602// Clang, GCC, and other compatible compilers used __thread prior to C++11 and
603// we only need the restricted functionality that provides.
604#define LLVM_THREAD_LOCAL __thread
605#endif
606
607/// \macro LLVM_ENABLE_EXCEPTIONS
608/// Whether LLVM is built with exception support.
609#if __has_feature(cxx_exceptions)
610#define LLVM_ENABLE_EXCEPTIONS 1
611#elif defined(__GNUC__) && defined(__EXCEPTIONS)
612#define LLVM_ENABLE_EXCEPTIONS 1
613#elif defined(_MSC_VER) && defined(_CPPUNWIND)
614#define LLVM_ENABLE_EXCEPTIONS 1
615#endif
616
617/// \macro LLVM_NO_PROFILE_INSTRUMENT_FUNCTION
618/// Disable the profile instrument for a function.
619#if __has_attribute(no_profile_instrument_function)
620#define LLVM_NO_PROFILE_INSTRUMENT_FUNCTION \
621 __attribute__((no_profile_instrument_function))
622#else
623#define LLVM_NO_PROFILE_INSTRUMENT_FUNCTION
624#endif
625
626/// \macro LLVM_PREFERRED_TYPE
627/// Adjust type of bit-field in debug info.
628#if __has_attribute(preferred_type)
629#define LLVM_PREFERRED_TYPE(T) __attribute__((preferred_type(T)))
630#else
631#define LLVM_PREFERRED_TYPE(T)
632#endif
633
634#endif
#define __asan_poison_memory_region(p, size)
Definition: Compiler.h:494
#define __asan_unpoison_memory_region(p, size)
Definition: Compiler.h:495
then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file
Definition: ThirdPartyNotices.txt:193
Definition: VisionPipeline.h:7