• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*===------- llvm/Config/abi-breaking.h - llvm configuration -------*- C -*-===*/
2 /*                                                                            */
3 /* Part of the LLVM Project, under the Apache License v2.0 with LLVM          */
4 /* Exceptions.                                                                */
5 /* See https://llvm.org/LICENSE.txt for license information.                  */
6 /* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception                    */
7 /*                                                                            */
8 /*===----------------------------------------------------------------------===*/
9 
10 /* This file controls the C++ ABI break introduced in LLVM public header. */
11 
12 #ifndef LLVM_ABI_BREAKING_CHECKS_H
13 #define LLVM_ABI_BREAKING_CHECKS_H
14 
15 /* Define to enable checks that alter the LLVM C++ ABI */
16 #if defined(NDEBUG)
17 #define LLVM_ENABLE_ABI_BREAKING_CHECKS 0
18 #else
19 #define LLVM_ENABLE_ABI_BREAKING_CHECKS 1
20 #endif
21 
22 /* Define to enable reverse iteration of unordered llvm containers */
23 #define LLVM_ENABLE_REVERSE_ITERATION 0
24 
25 /* Allow selectively disabling link-time mismatch checking so that header-only
26    ADT content from LLVM can be used without linking libSupport. */
27 #if !LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING
28 
29 // ABI_BREAKING_CHECKS protection: provides link-time failure when clients build
30 // mismatch with LLVM
31 #if defined(_MSC_VER)
32 // Use pragma with MSVC
33 #define LLVM_XSTR(s) LLVM_STR(s)
34 #define LLVM_STR(s) #s
35 #pragma detect_mismatch("LLVM_ENABLE_ABI_BREAKING_CHECKS", LLVM_XSTR(LLVM_ENABLE_ABI_BREAKING_CHECKS))
36 #undef LLVM_XSTR
37 #undef LLVM_STR
38 #elif defined(_WIN32) || defined(__CYGWIN__) // Win32 w/o #pragma detect_mismatch
39 // FIXME: Implement checks without weak.
40 #elif defined(__cplusplus)
41 #if !(defined(_AIX) && defined(__GNUC__) && !defined(__clang__))
42 #define LLVM_HIDDEN_VISIBILITY __attribute__ ((visibility("hidden")))
43 #else
44 // GCC on AIX does not support visibility attributes. Symbols are not
45 // exported by default on AIX.
46 #define LLVM_HIDDEN_VISIBILITY
47 #endif
48 namespace llvm {
49 #if LLVM_ENABLE_ABI_BREAKING_CHECKS
50 extern int EnableABIBreakingChecks;
51 LLVM_HIDDEN_VISIBILITY
52 __attribute__((weak)) int *VerifyEnableABIBreakingChecks =
53     &EnableABIBreakingChecks;
54 #else
55 extern int DisableABIBreakingChecks;
56 LLVM_HIDDEN_VISIBILITY
57 __attribute__((weak)) int *VerifyDisableABIBreakingChecks =
58     &DisableABIBreakingChecks;
59 #endif
60 }
61 #undef LLVM_HIDDEN_VISIBILITY
62 #endif // _MSC_VER
63 
64 #endif // LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING
65 
66 #endif
67