1//===-- llvm/Support/Compiler.h - Compiler abstraction support --*- C++ -*-===// 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 7//===----------------------------------------------------------------------===// 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++. 13//===----------------------------------------------------------------------===// 15#ifndef LLVM_SUPPORT_COMPILER_H 16#define LLVM_SUPPORT_COMPILER_H 18#include "llvm/Config/llvm-config.h" 27# define __has_feature(x) 0 30#ifndef __has_extension 31# define __has_extension(x) 0 34#ifndef __has_attribute 35# define __has_attribute(x) 0 39# define __has_builtin(x) 0 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) 48# define LLVM_HAS_CPP_ATTRIBUTE(x) 0 52/// \macro LLVM_GNUC_PREREQ 53/// Extend the default __GNUC_PREREQ even if glibc's features.h isn't 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)) 64# define LLVM_GNUC_PREREQ(maj, min, patch) 0 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 90#define LLVM_MSC_PREREQ(version) (_MSC_VER >= (version)) 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. 100#define LLVM_MSC_PREREQ(version) 0 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. 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. 113#if LLVM_HAS_CPP_ATTRIBUTE(gnu::visibility) && defined(__GNUC__) && \ 115#define LLVM_ATTRIBUTE_VISIBILITY_HIDDEN [[gnu::visibility("hidden")]]
116#define LLVM_ATTRIBUTE_VISIBILITY_DEFAULT [[gnu::visibility("default")]]
117#elif __has_attribute(visibility) 118#define LLVM_ATTRIBUTE_VISIBILITY_HIDDEN __attribute__((visibility("hidden")))
119#define LLVM_ATTRIBUTE_VISIBILITY_DEFAULT __attribute__((visibility("default")))
121#define LLVM_ATTRIBUTE_VISIBILITY_HIDDEN 122#define LLVM_ATTRIBUTE_VISIBILITY_DEFAULT 125#if defined(LLVM_BUILD_LLVM_DYLIB) || defined(LLVM_BUILD_SHARED_LIBS) 126#define LLVM_EXTERNAL_VISIBILITY LLVM_ATTRIBUTE_VISIBILITY_DEFAULT 128#define LLVM_EXTERNAL_VISIBILITY 131#if (!(defined(_WIN32) || defined(__CYGWIN__)) || \ 132 (defined(__MINGW32__) && defined(__clang__))) 133#define LLVM_LIBRARY_VISIBILITY LLVM_ATTRIBUTE_VISIBILITY_HIDDEN 134// Clang compilers older then 15 do not support gnu style attributes on 136#if defined(__clang__) && __clang_major__ < 15 137#define LLVM_LIBRARY_VISIBILITY_NAMESPACE [[gnu::visibility("hidden")]]
139#define LLVM_LIBRARY_VISIBILITY_NAMESPACE LLVM_ATTRIBUTE_VISIBILITY_HIDDEN 141#define LLVM_ALWAYS_EXPORT LLVM_ATTRIBUTE_VISIBILITY_DEFAULT 143#define LLVM_ALWAYS_EXPORT __declspec(dllexport) 144#define LLVM_LIBRARY_VISIBILITY 145#define LLVM_LIBRARY_VISIBILITY_NAMESPACE 147#define LLVM_LIBRARY_VISIBILITY 148#define LLVM_ALWAYS_EXPORT 149#define LLVM_LIBRARY_VISIBILITY_NAMESPACE 152/// LLVM_ABI is the main export/visibility macro to mark something as explicitly 153/// exported when llvm is built as a shared library with everything else that is 154/// unannotated will have internal visibility. 156/// LLVM_ABI_EXPORT is for the special case for things like plugin symbol 157/// declarations or definitions where we don't want the macro to be switching 158/// between dllexport and dllimport on windows based on what codebase is being 159/// built, it will only be dllexport. For non windows platforms this macro 160/// behaves the same as LLVM_ABI. 162/// LLVM_EXPORT_TEMPLATE is used on explicit template instantiations in source 163/// files that were declared extern in a header. This macro is only set as a 164/// compiler export attribute on windows, on other platforms it does nothing. 166/// LLVM_TEMPLATE_ABI is for annotating extern template declarations in headers 167/// for both functions and classes. On windows its turned in to dllimport for 168/// library consumers, for other platforms its a default visibility attribute. 170/// LLVM_C_ABI is used to annotated functions and data that need to be exported 171/// for the libllvm-c API. This used both for the llvm-c headers and for the 172/// functions declared in the different Target's c++ source files that don't 173/// include the header forward declaring them. 174#ifndef LLVM_ABI_GENERATING_ANNOTATIONS 175// Marker to add to classes or functions in public headers that should not have 176// export macros added to them by the clang tool 177#define LLVM_ABI_NOT_EXPORTED 178#if defined(LLVM_BUILD_LLVM_DYLIB) || defined(LLVM_BUILD_SHARED_LIBS) || \ 179 defined(LLVM_ENABLE_PLUGINS) 180// Some libraries like those for tablegen are linked in to tools that used 181// in the build so can't depend on the llvm shared library. If export macros 182// were left enabled when building these we would get duplicate or 183// missing symbol linker errors on windows. 184#if defined(LLVM_BUILD_STATIC) 186#define LLVM_TEMPLATE_ABI 187#define LLVM_EXPORT_TEMPLATE 188#define LLVM_ABI_EXPORT 189#elif defined(_WIN32) && !defined(__MINGW32__) 190#if defined(LLVM_EXPORTS) 191#define LLVM_ABI __declspec(dllexport) 192#define LLVM_TEMPLATE_ABI 193#define LLVM_EXPORT_TEMPLATE __declspec(dllexport) 195#define LLVM_ABI __declspec(dllimport) 196#define LLVM_TEMPLATE_ABI __declspec(dllimport) 197#define LLVM_EXPORT_TEMPLATE 199#define LLVM_ABI_EXPORT __declspec(dllexport) 200#elif defined(__ELF__) || defined(__MINGW32__) || defined(_AIX) || \ 202#define LLVM_ABI LLVM_ATTRIBUTE_VISIBILITY_DEFAULT 203#define LLVM_TEMPLATE_ABI LLVM_ATTRIBUTE_VISIBILITY_DEFAULT 204#define LLVM_EXPORT_TEMPLATE 205#define LLVM_ABI_EXPORT LLVM_ATTRIBUTE_VISIBILITY_DEFAULT 206#elif defined(__MACH__) || defined(__WASM__) 207#define LLVM_ABI LLVM_ATTRIBUTE_VISIBILITY_DEFAULT 208#define LLVM_TEMPLATE_ABI 209#define LLVM_EXPORT_TEMPLATE 210#define LLVM_ABI_EXPORT LLVM_ATTRIBUTE_VISIBILITY_DEFAULT 214#define LLVM_TEMPLATE_ABI 215#define LLVM_EXPORT_TEMPLATE 216#define LLVM_ABI_EXPORT 218#define LLVM_C_ABI LLVM_ABI 222#define LLVM_PREFETCH(addr, rw, locality) __builtin_prefetch(addr, rw, locality) 224#define LLVM_PREFETCH(addr, rw, locality) 227#if __has_attribute(used) 228#define LLVM_ATTRIBUTE_USED __attribute__((__used__)) 230#define LLVM_ATTRIBUTE_USED 233#if defined(__clang__) 234#define LLVM_DEPRECATED(MSG, FIX) __attribute__((deprecated(MSG, FIX))) 236#define LLVM_DEPRECATED(MSG, FIX) [[deprecated(MSG)]] 240#if defined(__clang__) || defined(__GNUC__) 241#define LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_PUSH \ 242 _Pragma("GCC diagnostic push") \
243 _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
244#define LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_POP \ 245 _Pragma("GCC diagnostic pop")
246#elif defined(_MSC_VER) 247#define LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_PUSH \ 248 _Pragma("warning(push)") \
249 _Pragma("warning(disable : 4996)")
250#define LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_POP \ 251 _Pragma("warning(pop)")
253#define LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_PUSH 254#define LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_POP 258// Indicate that a non-static, non-const C++ member function reinitializes 259// the entire object to a known state, independent of the previous state of 262// The clang-tidy check bugprone-use-after-move recognizes this attribute as a 263// marker that a moved-from object has left the indeterminate state and can be 265#if LLVM_HAS_CPP_ATTRIBUTE(clang::reinitializes) 266#define LLVM_ATTRIBUTE_REINITIALIZES [[clang::reinitializes]] 268#define LLVM_ATTRIBUTE_REINITIALIZES 271// Some compilers warn about unused functions. When a function is sometimes 272// used or not depending on build settings (e.g. a function only called from 273// within "assert"), this attribute can be used to suppress such warnings. 275// However, it shouldn't be used for unused *variables*, as those have a much 276// more portable solution: 277// (void)unused_var_name; 278// Prefer cast-to-void wherever it is sufficient. 279#if __has_attribute(unused) 280#define LLVM_ATTRIBUTE_UNUSED __attribute__((__unused__)) 282#define LLVM_ATTRIBUTE_UNUSED 285// FIXME: Provide this for PE/COFF targets. 286#if __has_attribute(weak) && !defined(__MINGW32__) && !defined(__CYGWIN__) && \ 288#define LLVM_ATTRIBUTE_WEAK __attribute__((__weak__)) 290#define LLVM_ATTRIBUTE_WEAK 293// Prior to clang 3.2, clang did not accept any spelling of 294// __has_attribute(const), so assume it is supported. 295#if defined(__clang__) || defined(__GNUC__) 296// aka 'CONST' but following LLVM Conventions. 297#define LLVM_READNONE __attribute__((__const__)) 302#if __has_attribute(pure) || defined(__GNUC__) 303// aka 'PURE' but following LLVM Conventions. 304#define LLVM_READONLY __attribute__((__pure__)) 309#if __has_attribute(minsize) 310#define LLVM_ATTRIBUTE_MINSIZE __attribute__((minsize)) 312#define LLVM_ATTRIBUTE_MINSIZE 315#if __has_builtin(__builtin_expect) || defined(__GNUC__) 316#define LLVM_LIKELY(EXPR) __builtin_expect((bool)(EXPR), true) 317#define LLVM_UNLIKELY(EXPR) __builtin_expect((bool)(EXPR), false) 319#define LLVM_LIKELY(EXPR) (EXPR) 320#define LLVM_UNLIKELY(EXPR) (EXPR) 323/// LLVM_ATTRIBUTE_NOINLINE - On compilers where we have a directive to do so, 324/// mark a method "not for inlining". 325#if __has_attribute(noinline) 326#define LLVM_ATTRIBUTE_NOINLINE __attribute__((noinline)) 327#elif defined(_MSC_VER) 328#define LLVM_ATTRIBUTE_NOINLINE __declspec(noinline) 330#define LLVM_ATTRIBUTE_NOINLINE 333/// LLVM_ATTRIBUTE_ALWAYS_INLINE - On compilers where we have a directive to do 334/// so, mark a method "always inline" because it is performance sensitive. 335#if __has_attribute(always_inline) 336#define LLVM_ATTRIBUTE_ALWAYS_INLINE inline __attribute__((always_inline)) 337#elif defined(_MSC_VER) 338#define LLVM_ATTRIBUTE_ALWAYS_INLINE __forceinline 340#define LLVM_ATTRIBUTE_ALWAYS_INLINE inline 343/// LLVM_ATTRIBUTE_NO_DEBUG - On compilers where we have a directive to do 344/// so, mark a method "no debug" because debug info makes the debugger 346#if __has_attribute(nodebug) 347#define LLVM_ATTRIBUTE_NODEBUG __attribute__((nodebug)) 349#define LLVM_ATTRIBUTE_NODEBUG 352#if __has_attribute(returns_nonnull) 353#define LLVM_ATTRIBUTE_RETURNS_NONNULL __attribute__((returns_nonnull)) 354#elif defined(_MSC_VER) 355#define LLVM_ATTRIBUTE_RETURNS_NONNULL _Ret_notnull_ 357#define LLVM_ATTRIBUTE_RETURNS_NONNULL 360/// LLVM_ATTRIBUTE_RESTRICT - Annotates a pointer to tell the compiler that 361/// it is not aliased in the current scope. 362#if defined(__clang__) || defined(__GNUC__) || defined(_MSC_VER) 363#define LLVM_ATTRIBUTE_RESTRICT __restrict 365#define LLVM_ATTRIBUTE_RESTRICT 368/// \macro LLVM_ATTRIBUTE_RETURNS_NOALIAS Used to mark a function as returning a 369/// pointer that does not alias any other valid pointer. 371#define LLVM_ATTRIBUTE_RETURNS_NOALIAS __attribute__((__malloc__)) 372#elif defined(_MSC_VER) 373#define LLVM_ATTRIBUTE_RETURNS_NOALIAS __declspec(restrict) 375#define LLVM_ATTRIBUTE_RETURNS_NOALIAS 378/// LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements. 379#if defined(__cplusplus) && __cplusplus > 201402L && LLVM_HAS_CPP_ATTRIBUTE(fallthrough) 380#define LLVM_FALLTHROUGH [[fallthrough]] 381#elif LLVM_HAS_CPP_ATTRIBUTE(gnu::fallthrough) 382#define LLVM_FALLTHROUGH [[gnu::fallthrough]] 383#elif __has_attribute(fallthrough) 384#define LLVM_FALLTHROUGH __attribute__((fallthrough)) 385#elif LLVM_HAS_CPP_ATTRIBUTE(clang::fallthrough) 386#define LLVM_FALLTHROUGH [[clang::fallthrough]] 388#define LLVM_FALLTHROUGH 391/// LLVM_REQUIRE_CONSTANT_INITIALIZATION - Apply this to globals to ensure that 392/// they are constant initialized. 393#if LLVM_HAS_CPP_ATTRIBUTE(clang::require_constant_initialization) 394#define LLVM_REQUIRE_CONSTANT_INITIALIZATION \ 395 [[clang::require_constant_initialization]] 397#define LLVM_REQUIRE_CONSTANT_INITIALIZATION 400/// LLVM_GSL_OWNER - Apply this to owning classes like SmallVector to enable 401/// lifetime warnings. 402#if LLVM_HAS_CPP_ATTRIBUTE(gsl::Owner) 403#define LLVM_GSL_OWNER [[gsl::Owner]] 405#define LLVM_GSL_OWNER 408/// LLVM_GSL_POINTER - Apply this to non-owning classes like 409/// StringRef to enable lifetime warnings. 410#if LLVM_HAS_CPP_ATTRIBUTE(gsl::Pointer) 411#define LLVM_GSL_POINTER [[gsl::Pointer]] 413#define LLVM_GSL_POINTER 416#if LLVM_HAS_CPP_ATTRIBUTE(clang::lifetimebound) 417#define LLVM_LIFETIME_BOUND [[clang::lifetimebound]] 419#define LLVM_LIFETIME_BOUND 422#if LLVM_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L 423#define LLVM_CTOR_NODISCARD [[nodiscard]] 425#define LLVM_CTOR_NODISCARD 428/// LLVM_EXTENSION - Support compilers where we have a keyword to suppress 429/// pedantic diagnostics. 431#define LLVM_EXTENSION __extension__ 433#define LLVM_EXTENSION 436/// LLVM_BUILTIN_UNREACHABLE - On compilers which support it, expands 437/// to an expression which states that it is undefined behavior for the 438/// compiler to reach this point. Otherwise is not defined. 440/// '#else' is intentionally left out so that other macro logic (e.g., 441/// LLVM_ASSUME_ALIGNED and llvm_unreachable()) can detect whether 442/// LLVM_BUILTIN_UNREACHABLE has a definition. 443#if __has_builtin(__builtin_unreachable) || defined(__GNUC__) 444# define LLVM_BUILTIN_UNREACHABLE __builtin_unreachable() 445#elif defined(_MSC_VER) 446# define LLVM_BUILTIN_UNREACHABLE __assume(false) 449/// LLVM_BUILTIN_TRAP - On compilers which support it, expands to an expression 450/// which causes the program to exit abnormally. 451#if __has_builtin(__builtin_trap) || defined(__GNUC__) 452# define LLVM_BUILTIN_TRAP __builtin_trap() 453#elif defined(_MSC_VER) 454// The __debugbreak intrinsic is supported by MSVC, does not require forward 455// declarations involving platform-specific typedefs (unlike RaiseException), 456// results in a call to vectored exception handlers, and encodes to a short 457// instruction that still causes the trapping behavior we want. 458# define LLVM_BUILTIN_TRAP __debugbreak() 460# define LLVM_BUILTIN_TRAP *(volatile int*)0x11 = 0 463/// LLVM_BUILTIN_DEBUGTRAP - On compilers which support it, expands to 464/// an expression which causes the program to break while running 466#if __has_builtin(__builtin_debugtrap) 467# define LLVM_BUILTIN_DEBUGTRAP __builtin_debugtrap() 468#elif defined(_MSC_VER) 469// The __debugbreak intrinsic is supported by MSVC and breaks while 470// running under the debugger, and also supports invoking a debugger 471// when the OS is configured appropriately. 472# define LLVM_BUILTIN_DEBUGTRAP __debugbreak() 474// Just continue execution when built with compilers that have no 475// support. This is a debugging aid and not intended to force the 476// program to abort if encountered. 477# define LLVM_BUILTIN_DEBUGTRAP 480/// \macro LLVM_ASSUME_ALIGNED 481/// Returns a pointer with an assumed alignment. 482#if __has_builtin(__builtin_assume_aligned) || defined(__GNUC__) 483# define LLVM_ASSUME_ALIGNED(p, a) __builtin_assume_aligned(p, a) 484#elif defined(LLVM_BUILTIN_UNREACHABLE) 485# define LLVM_ASSUME_ALIGNED(p, a) \ 486 (((uintptr_t(p) % (a)) == 0) ? (p) : (LLVM_BUILTIN_UNREACHABLE, (p))) 488# define LLVM_ASSUME_ALIGNED(p, a) (p) 491/// \macro LLVM_PACKED 492/// Used to specify a packed structure. 510# define LLVM_PACKED(d) __pragma(pack(push, 1)) d __pragma(pack(pop)) 511# define LLVM_PACKED_START __pragma(pack(push, 1)) 512# define LLVM_PACKED_END __pragma(pack(pop)) 514# define LLVM_PACKED(d) d __attribute__((packed)) 515# define LLVM_PACKED_START _Pragma("pack(push, 1)")
516# define LLVM_PACKED_END _Pragma("pack(pop)")
519/// \macro LLVM_MEMORY_SANITIZER_BUILD 520/// Whether LLVM itself is built with MemorySanitizer instrumentation. 521#if __has_feature(memory_sanitizer) 522# define LLVM_MEMORY_SANITIZER_BUILD 1 523# include <sanitizer/msan_interface.h> 524# define LLVM_NO_SANITIZE_MEMORY_ATTRIBUTE __attribute__((no_sanitize_memory)) 526# define LLVM_MEMORY_SANITIZER_BUILD 0 527# define __msan_allocated_memory(p, size) 528# define __msan_unpoison(p, size) 529# define LLVM_NO_SANITIZE_MEMORY_ATTRIBUTE 532/// \macro LLVM_ADDRESS_SANITIZER_BUILD 533/// Whether LLVM itself is built with AddressSanitizer instrumentation. 534#if __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__) 535# define LLVM_ADDRESS_SANITIZER_BUILD 1 536#if __has_include(<sanitizer/asan_interface.h>) 537# include <sanitizer/asan_interface.h> 539// These declarations exist to support ASan with MSVC. If MSVC eventually ships 540// asan_interface.h in their headers, then we can remove this. 551# define LLVM_ADDRESS_SANITIZER_BUILD 0 552# define __asan_poison_memory_region(p, size) 553# define __asan_unpoison_memory_region(p, size) 556/// \macro LLVM_HWADDRESS_SANITIZER_BUILD 557/// Whether LLVM itself is built with HWAddressSanitizer instrumentation. 558#if __has_feature(hwaddress_sanitizer) 559#define LLVM_HWADDRESS_SANITIZER_BUILD 1 561#define LLVM_HWADDRESS_SANITIZER_BUILD 0 564/// \macro LLVM_THREAD_SANITIZER_BUILD 565/// Whether LLVM itself is built with ThreadSanitizer instrumentation. 566#if __has_feature(thread_sanitizer) || defined(__SANITIZE_THREAD__) 567# define LLVM_THREAD_SANITIZER_BUILD 1 569# define LLVM_THREAD_SANITIZER_BUILD 0 572#if LLVM_THREAD_SANITIZER_BUILD 573// Thread Sanitizer is a tool that finds races in code. 574// See http://code.google.com/p/data-race-test/wiki/DynamicAnnotations . 575// tsan detects these exact functions by name. 579void AnnotateHappensAfter(
constchar *
file,
int line,
constvolatilevoid *cv);
580void AnnotateHappensBefore(
constchar *
file,
int line,
constvolatilevoid *cv);
581void AnnotateIgnoreWritesBegin(
constchar *
file,
int line);
582void AnnotateIgnoreWritesEnd(
constchar *
file,
int line);
587// This marker is used to define a happens-before arc. The race detector will 588// infer an arc from the begin to the end when they share the same pointer 590# define TsanHappensBefore(cv) AnnotateHappensBefore(__FILE__, __LINE__, cv) 592// This marker defines the destination of a happens-before arc. 593# define TsanHappensAfter(cv) AnnotateHappensAfter(__FILE__, __LINE__, cv) 595// Ignore any races on writes between here and the next TsanIgnoreWritesEnd. 596# define TsanIgnoreWritesBegin() AnnotateIgnoreWritesBegin(__FILE__, __LINE__) 598// Resume checking for racy writes. 599# define TsanIgnoreWritesEnd() AnnotateIgnoreWritesEnd(__FILE__, __LINE__) 601# define TsanHappensBefore(cv) 602# define TsanHappensAfter(cv) 603# define TsanIgnoreWritesBegin() 604# define TsanIgnoreWritesEnd() 607/// \macro LLVM_NO_SANITIZE 608/// Disable a particular sanitizer for a function. 609#if __has_attribute(no_sanitize) 610#define LLVM_NO_SANITIZE(KIND) __attribute__((no_sanitize(KIND))) 612#define LLVM_NO_SANITIZE(KIND) 615/// Mark debug helper function definitions like dump() that should not be 616/// stripped from debug builds. 617/// Note that you should also surround dump() functions with 618/// `#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)` so they do always 619/// get stripped in release builds. 620// FIXME: Move this to a private config.h as it's not usable in public headers. 621#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 622#define LLVM_DUMP_METHOD LLVM_ATTRIBUTE_NOINLINE LLVM_ATTRIBUTE_USED 624#define LLVM_DUMP_METHOD LLVM_ATTRIBUTE_NOINLINE 627/// \macro LLVM_PRETTY_FUNCTION 628/// Gets a user-friendly looking function signature for the current scope 629/// using the best available method on each platform. The exact format of the 630/// resulting string is implementation specific and non-portable, so this should 631/// only be used, for example, for logging or diagnostics. 633#define LLVM_PRETTY_FUNCTION __FUNCSIG__ 634#elif defined(__GNUC__) || defined(__clang__) 635#define LLVM_PRETTY_FUNCTION __PRETTY_FUNCTION__ 637#define LLVM_PRETTY_FUNCTION __func__ 640/// \macro LLVM_THREAD_LOCAL 641/// A thread-local storage specifier which can be used with globals, 642/// extern globals, and static globals. 644/// This is essentially an extremely restricted analog to C++11's thread_local 645/// support. It uses thread_local if available, falling back on gcc __thread 646/// if not. __thread doesn't support many of the C++11 thread_local's 647/// features. You should only use this for PODs that you can statically 648/// initialize to some constant value. In almost all circumstances this is most 649/// appropriate for use with a pointer, integer, or small aggregation of 650/// pointers and integers. 651#if LLVM_ENABLE_THREADS 652#if __has_feature(cxx_thread_local) || defined(_MSC_VER) 653#define LLVM_THREAD_LOCAL thread_local 655// Clang, GCC, and other compatible compilers used __thread prior to C++11 and 656// we only need the restricted functionality that provides. 657#define LLVM_THREAD_LOCAL __thread 659#else// !LLVM_ENABLE_THREADS 660// If threading is disabled entirely, this compiles to nothing and you get 661// a normal global variable. 662#define LLVM_THREAD_LOCAL 665/// \macro LLVM_ENABLE_EXCEPTIONS 666/// Whether LLVM is built with exception support. 667#if __has_feature(cxx_exceptions) 668#define LLVM_ENABLE_EXCEPTIONS 1 669#elif defined(__GNUC__) && defined(__EXCEPTIONS) 670#define LLVM_ENABLE_EXCEPTIONS 1 671#elif defined(_MSC_VER) && defined(_CPPUNWIND) 672#define LLVM_ENABLE_EXCEPTIONS 1 675/// \macro LLVM_NO_PROFILE_INSTRUMENT_FUNCTION 676/// Disable the profile instrument for a function. 677#if __has_attribute(no_profile_instrument_function) 678#define LLVM_NO_PROFILE_INSTRUMENT_FUNCTION \ 679 __attribute__((no_profile_instrument_function)) 681#define LLVM_NO_PROFILE_INSTRUMENT_FUNCTION 684/// \macro LLVM_PREFERRED_TYPE 685/// Adjust type of bit-field in debug info. 686#if __has_attribute(preferred_type) 687#define LLVM_PREFERRED_TYPE(T) __attribute__((preferred_type(T))) 689#define LLVM_PREFERRED_TYPE(T) #define __asan_poison_memory_region(p, size)
#define __asan_unpoison_memory_region(p, size)
dot regions Print regions of function to dot file(with no function bodies)"