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