xref: /freebsd/lib/clang/include/llvm/Config/abi-breaking.h (revision 0d8fe2373503aeac48492f28073049a8bfa4feb5)
1 /* $FreeBSD$ */
2 /*===------- llvm/Config/abi-breaking.h - llvm configuration -------*- C -*-===*/
3 /*                                                                            */
4 /* Part of the LLVM Project, under the Apache License v2.0 with LLVM          */
5 /* Exceptions.                                                                */
6 /* See https://llvm.org/LICENSE.txt for license information.                  */
7 /* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception                    */
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 /* Define to enable reverse iteration of unordered llvm containers */
20 #define LLVM_ENABLE_REVERSE_ITERATION 0
21 
22 /* Allow selectively disabling link-time mismatch checking so that header-only
23    ADT content from LLVM can be used without linking libSupport. */
24 #if !defined(LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING) || !LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING
25 
26 // ABI_BREAKING_CHECKS protection: provides link-time failure when clients build
27 // mismatch with LLVM
28 #if defined(_MSC_VER)
29 // Use pragma with MSVC
30 #define LLVM_XSTR(s) LLVM_STR(s)
31 #define LLVM_STR(s) #s
32 #pragma detect_mismatch("LLVM_ENABLE_ABI_BREAKING_CHECKS", LLVM_XSTR(LLVM_ENABLE_ABI_BREAKING_CHECKS))
33 #undef LLVM_XSTR
34 #undef LLVM_STR
35 #elif defined(_WIN32) || defined(__CYGWIN__) // Win32 w/o #pragma detect_mismatch
36 // FIXME: Implement checks without weak.
37 #elif defined(__cplusplus)
38 #if !(defined(_AIX) && defined(__GNUC__) && !defined(__clang__))
39 #define LLVM_HIDDEN_VISIBILITY __attribute__ ((visibility("hidden")))
40 #else
41 // GCC on AIX does not support visibility attributes. Symbols are not
42 // exported by default on AIX.
43 #define LLVM_HIDDEN_VISIBILITY
44 #endif
45 namespace llvm {
46 #if LLVM_ENABLE_ABI_BREAKING_CHECKS
47 extern int EnableABIBreakingChecks;
48 LLVM_HIDDEN_VISIBILITY
49 __attribute__((weak)) int *VerifyEnableABIBreakingChecks =
50     &EnableABIBreakingChecks;
51 #else
52 extern int DisableABIBreakingChecks;
53 LLVM_HIDDEN_VISIBILITY
54 __attribute__((weak)) int *VerifyDisableABIBreakingChecks =
55     &DisableABIBreakingChecks;
56 #endif
57 }
58 #undef LLVM_HIDDEN_VISIBILITY
59 #endif // _MSC_VER
60 
61 #endif // LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING
62 
63 #endif
64