xref: /freebsd/lib/clang/include/llvm/Config/abi-breaking.h (revision 5897d2f01b9945ebb34757b8d98644f232622fdb)
1 /* $FreeBSD$ */
2 /*===------- llvm/Config/abi-breaking.h - llvm configuration -------*- C -*-===*/
3 /*                                                                            */
4 /*                     The LLVM Compiler Infrastructure                       */
5 /*                                                                            */
6 /* This file is distributed under the University of Illinois Open Source      */
7 /* License. See LICENSE.TXT for details.                                      */
8 /*                                                                            */
9 /*===----------------------------------------------------------------------===*/
10 
11 /* This file controls the C++ ABI break introduced in LLVM public header. */
12 
13 #ifndef LLVM_ABI_BREAKING_CHECKS_H
14 #define LLVM_ABI_BREAKING_CHECKS_H
15 
16 /* Define to enable checks that alter the LLVM C++ ABI */
17 #define LLVM_ENABLE_ABI_BREAKING_CHECKS 1
18 
19 /* Allow selectively disabling link-time mismatch checking so that header-only
20    ADT content from LLVM can be used without linking libSupport. */
21 #if !LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING
22 
23 // ABI_BREAKING_CHECKS protection: provides link-time failure when clients build
24 // mismatch with LLVM
25 #if defined(_MSC_VER)
26 // Use pragma with MSVC
27 #define LLVM_XSTR(s) LLVM_STR(s)
28 #define LLVM_STR(s) #s
29 #pragma detect_mismatch("LLVM_ENABLE_ABI_BREAKING_CHECKS", LLVM_XSTR(LLVM_ENABLE_ABI_BREAKING_CHECKS))
30 #undef LLVM_XSTR
31 #undef LLVM_STR
32 #elif defined(_WIN32) || defined(__CYGWIN__) // Win32 w/o #pragma detect_mismatch
33 // FIXME: Implement checks without weak.
34 #elif defined(__cplusplus)
35 namespace llvm {
36 #if LLVM_ENABLE_ABI_BREAKING_CHECKS
37 extern int EnableABIBreakingChecks;
38 __attribute__((weak, visibility ("hidden"))) int *VerifyEnableABIBreakingChecks = &EnableABIBreakingChecks;
39 #else
40 extern int DisableABIBreakingChecks;
41 __attribute__((weak, visibility ("hidden"))) int *VerifyDisableABIBreakingChecks = &DisableABIBreakingChecks;
42 #endif
43 }
44 #endif // _MSC_VER
45 
46 #endif // LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING
47 
48 #endif
49