abi-breaking.h 2.6 KB

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