WPILibC++ 2025.2.1
Loading...
Searching...
No Matches
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/// LLVM_ATTRIBUTE_RESTRICT - Annotates a pointer to tell the compiler that
301/// it is not aliased in the current scope.
302#if defined(__clang__) || defined(__GNUC__) || defined(_MSC_VER)
303#define LLVM_ATTRIBUTE_RESTRICT __restrict
304#else
305#define LLVM_ATTRIBUTE_RESTRICT
306#endif
307
308/// \macro LLVM_ATTRIBUTE_RETURNS_NOALIAS Used to mark a function as returning a
309/// pointer that does not alias any other valid pointer.
310#ifndef LLVM_ATTRIBUTE_RETURNS_NOALIAS
311#ifdef __GNUC__
312#define LLVM_ATTRIBUTE_RETURNS_NOALIAS __attribute__((__malloc__))
313#elif defined(_MSC_VER)
314#define LLVM_ATTRIBUTE_RETURNS_NOALIAS __declspec(restrict)
315#else
316#define LLVM_ATTRIBUTE_RETURNS_NOALIAS
317#endif
318#endif
319
320/// LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
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]]
330#else
331#define LLVM_FALLTHROUGH
332#endif
333#endif
334
335/// LLVM_REQUIRE_CONSTANT_INITIALIZATION - Apply this to globals to ensure that
336/// they are constant initialized.
337#if LLVM_HAS_CPP_ATTRIBUTE(clang::require_constant_initialization)
338#define LLVM_REQUIRE_CONSTANT_INITIALIZATION \
339 [[clang::require_constant_initialization]]
340#else
341#define LLVM_REQUIRE_CONSTANT_INITIALIZATION
342#endif
343
344/// LLVM_GSL_OWNER - Apply this to owning classes like SmallVector to enable
345/// lifetime warnings.
346#if LLVM_HAS_CPP_ATTRIBUTE(gsl::Owner)
347#define LLVM_GSL_OWNER [[gsl::Owner]]
348#else
349#define LLVM_GSL_OWNER
350#endif
351
352/// LLVM_GSL_POINTER - Apply this to non-owning classes like
353/// std::string_view to enable lifetime warnings.
354#if LLVM_HAS_CPP_ATTRIBUTE(gsl::Pointer)
355#define LLVM_GSL_POINTER [[gsl::Pointer]]
356#else
357#define LLVM_GSL_POINTER
358#endif
359
360#if LLVM_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L
361#define LLVM_CTOR_NODISCARD [[nodiscard]]
362#else
363#define LLVM_CTOR_NODISCARD
364#endif
365
366/// LLVM_EXTENSION - Support compilers where we have a keyword to suppress
367/// pedantic diagnostics.
368#ifndef LLVM_EXTENSION
369#ifdef __GNUC__
370#define LLVM_EXTENSION __extension__
371#else
372#define LLVM_EXTENSION
373#endif
374#endif
375
376/// LLVM_BUILTIN_UNREACHABLE - On compilers which support it, expands
377/// to an expression which states that it is undefined behavior for the
378/// compiler to reach this point. Otherwise is not defined.
379///
380/// '#else' is intentionally left out so that other macro logic (e.g.,
381/// LLVM_ASSUME_ALIGNED and wpi_unreachable()) can detect whether
382/// LLVM_BUILTIN_UNREACHABLE has a definition.
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)
388#endif
389#endif
390
391/// LLVM_BUILTIN_TRAP - On compilers which support it, expands to an expression
392/// which causes the program to exit abnormally.
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)
397// The __debugbreak intrinsic is supported by MSVC, does not require forward
398// declarations involving platform-specific typedefs (unlike RaiseException),
399// results in a call to vectored exception handlers, and encodes to a short
400// instruction that still causes the trapping behavior we want.
401# define LLVM_BUILTIN_TRAP __debugbreak()
402#else
403# define LLVM_BUILTIN_TRAP *(volatile int*)0x11 = 0
404#endif
405#endif
406
407/// LLVM_BUILTIN_DEBUGTRAP - On compilers which support it, expands to
408/// an expression which causes the program to break while running
409/// under a debugger.
410#ifndef LLVM_BUILTIN_DEBUGTRAP
411#if __has_builtin(__builtin_debugtrap)
412# define LLVM_BUILTIN_DEBUGTRAP __builtin_debugtrap()
413#elif defined(_MSC_VER)
414// The __debugbreak intrinsic is supported by MSVC and breaks while
415// running under the debugger, and also supports invoking a debugger
416// when the OS is configured appropriately.
417# define LLVM_BUILTIN_DEBUGTRAP __debugbreak()
418#else
419// Just continue execution when built with compilers that have no
420// support. This is a debugging aid and not intended to force the
421// program to abort if encountered.
422# define LLVM_BUILTIN_DEBUGTRAP
423#endif
424#endif
425
426/// \macro LLVM_ASSUME_ALIGNED
427/// Returns a pointer with an assumed alignment.
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)))
434#else
435# define LLVM_ASSUME_ALIGNED(p, a) (p)
436#endif
437#endif
438
439/// \macro LLVM_PACKED
440/// Used to specify a packed structure.
441/// LLVM_PACKED(
442/// struct A {
443/// int i;
444/// int j;
445/// int k;
446/// long long l;
447/// });
448///
449/// LLVM_PACKED_START
450/// struct B {
451/// int i;
452/// int j;
453/// int k;
454/// long long l;
455/// };
456/// LLVM_PACKED_END
457#ifndef LLVM_PACKED
458#ifdef _MSC_VER
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))
462#else
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)")
466#endif
467#endif
468
469/// \macro LLVM_MEMORY_SANITIZER_BUILD
470/// Whether LLVM itself is built with MemorySanitizer instrumentation.
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))
475#else
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
480#endif
481
482/// \macro LLVM_ADDRESS_SANITIZER_BUILD
483/// Whether LLVM itself is built with AddressSanitizer instrumentation.
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>
488#else
489// These declarations exist to support ASan with MSVC. If MSVC eventually ships
490// asan_interface.h in their headers, then we can remove this.
491#ifdef __cplusplus
492extern "C" {
493#endif
494void __asan_poison_memory_region(void const volatile *addr, size_t size);
495void __asan_unpoison_memory_region(void const volatile *addr, size_t size);
496#ifdef __cplusplus
497} // extern "C"
498#endif
499#endif
500#else
501# define LLVM_ADDRESS_SANITIZER_BUILD 0
502# define __asan_poison_memory_region(p, size)
503# define __asan_unpoison_memory_region(p, size)
504#endif
505
506/// \macro LLVM_HWADDRESS_SANITIZER_BUILD
507/// Whether LLVM itself is built with HWAddressSanitizer instrumentation.
508#if __has_feature(hwaddress_sanitizer)
509#define LLVM_HWADDRESS_SANITIZER_BUILD 1
510#else
511#define LLVM_HWADDRESS_SANITIZER_BUILD 0
512#endif
513
514/// \macro LLVM_THREAD_SANITIZER_BUILD
515/// Whether LLVM itself is built with ThreadSanitizer instrumentation.
516#if __has_feature(thread_sanitizer) || defined(__SANITIZE_THREAD__)
517# define LLVM_THREAD_SANITIZER_BUILD 1
518#else
519# define LLVM_THREAD_SANITIZER_BUILD 0
520#endif
521
522#if LLVM_THREAD_SANITIZER_BUILD
523// Thread Sanitizer is a tool that finds races in code.
524// See http://code.google.com/p/data-race-test/wiki/DynamicAnnotations .
525// tsan detects these exact functions by name.
526#ifdef __cplusplus
527extern "C" {
528#endif
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);
533#ifdef __cplusplus
534}
535#endif
536
537// This marker is used to define a happens-before arc. The race detector will
538// infer an arc from the begin to the end when they share the same pointer
539// argument.
540# define TsanHappensBefore(cv) AnnotateHappensBefore(__FILE__, __LINE__, cv)
541
542// This marker defines the destination of a happens-before arc.
543# define TsanHappensAfter(cv) AnnotateHappensAfter(__FILE__, __LINE__, cv)
544
545// Ignore any races on writes between here and the next TsanIgnoreWritesEnd.
546# define TsanIgnoreWritesBegin() AnnotateIgnoreWritesBegin(__FILE__, __LINE__)
547
548// Resume checking for racy writes.
549# define TsanIgnoreWritesEnd() AnnotateIgnoreWritesEnd(__FILE__, __LINE__)
550#else
551# define TsanHappensBefore(cv)
552# define TsanHappensAfter(cv)
553# define TsanIgnoreWritesBegin()
554# define TsanIgnoreWritesEnd()
555#endif
556
557/// \macro LLVM_NO_SANITIZE
558/// Disable a particular sanitizer for a function.
559#ifndef LLVM_NO_SANITIZE
560#if __has_attribute(no_sanitize)
561#define LLVM_NO_SANITIZE(KIND) __attribute__((no_sanitize(KIND)))
562#else
563#define LLVM_NO_SANITIZE(KIND)
564#endif
565#endif
566
567/// Mark debug helper function definitions like dump() that should not be
568/// stripped from debug builds.
569/// Note that you should also surround dump() functions with
570/// `#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)` so they do always
571/// get stripped in release builds.
572// FIXME: Move this to a private config.h as it's not usable in public headers.
573#ifndef LLVM_DUMP_METHOD
574#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
575#define LLVM_DUMP_METHOD LLVM_ATTRIBUTE_NOINLINE LLVM_ATTRIBUTE_USED
576#else
577#define LLVM_DUMP_METHOD LLVM_ATTRIBUTE_NOINLINE
578#endif
579#endif
580
581/// \macro LLVM_PRETTY_FUNCTION
582/// Gets a user-friendly looking function signature for the current scope
583/// using the best available method on each platform. The exact format of the
584/// resulting string is implementation specific and non-portable, so this should
585/// only be used, for example, for logging or diagnostics.
586#ifndef LLVM_PRETTY_FUNCTION
587#if defined(_MSC_VER)
588#define LLVM_PRETTY_FUNCTION __FUNCSIG__
589#elif defined(__GNUC__) || defined(__clang__)
590#define LLVM_PRETTY_FUNCTION __PRETTY_FUNCTION__
591#else
592#define LLVM_PRETTY_FUNCTION __func__
593#endif
594#endif
595
596/// \macro LLVM_THREAD_LOCAL
597/// A thread-local storage specifier which can be used with globals,
598/// extern globals, and static globals.
599///
600/// This is essentially an extremely restricted analog to C++11's thread_local
601/// support. It uses thread_local if available, falling back on gcc __thread
602/// if not. __thread doesn't support many of the C++11 thread_local's
603/// features. You should only use this for PODs that you can statically
604/// initialize to some constant value. In almost all circumstances this is most
605/// appropriate for use with a pointer, integer, or small aggregation of
606/// pointers and integers.
607#if __has_feature(cxx_thread_local) || defined(_MSC_VER)
608#define LLVM_THREAD_LOCAL thread_local
609#else
610// Clang, GCC, and other compatible compilers used __thread prior to C++11 and
611// we only need the restricted functionality that provides.
612#define LLVM_THREAD_LOCAL __thread
613#endif
614
615/// \macro LLVM_ENABLE_EXCEPTIONS
616/// Whether LLVM is built with exception support.
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
623#endif
624
625/// \macro LLVM_NO_PROFILE_INSTRUMENT_FUNCTION
626/// Disable the profile instrument for a function.
627#if __has_attribute(no_profile_instrument_function)
628#define LLVM_NO_PROFILE_INSTRUMENT_FUNCTION \
629 __attribute__((no_profile_instrument_function))
630#else
631#define LLVM_NO_PROFILE_INSTRUMENT_FUNCTION
632#endif
633
634/// \macro LLVM_PREFERRED_TYPE
635/// Adjust type of bit-field in debug info.
636#if __has_attribute(preferred_type)
637#define LLVM_PREFERRED_TYPE(T) __attribute__((preferred_type(T)))
638#else
639#define LLVM_PREFERRED_TYPE(T)
640#endif
641
642#endif
#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