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