1 //===--- DemangleConfig.h --------------------------------------*- 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 // This file is contains a subset of macros copied from
8 // llvm/include/llvm/Demangle/DemangleConfig.h
9 //===----------------------------------------------------------------------===//
11 #ifndef LIBCXXABI_DEMANGLE_DEMANGLE_CONFIG_H
12 #define LIBCXXABI_DEMANGLE_DEMANGLE_CONFIG_H
14 // Must be defined before pulling in headers from libc++. Allow downstream
15 // build systems to override this value.
16 // https://libcxx.llvm.org/UsingLibcxx.html#enabling-the-safe-libc-mode
17 #ifndef _LIBCPP_VERBOSE_ABORT
18 #define _LIBCPP_VERBOSE_ABORT(...) abort_message(__VA_ARGS__)
19 #include "../abort_message.h"
25 // snprintf is implemented in VS 2015
27 #define snprintf _snprintf_s
32 #define __has_feature(x) 0
35 #ifndef __has_cpp_attribute
36 #define __has_cpp_attribute(x) 0
39 #ifndef __has_attribute
40 #define __has_attribute(x) 0
44 #define __has_builtin(x) 0
47 #ifndef DEMANGLE_GNUC_PREREQ
48 #if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__)
49 #define DEMANGLE_GNUC_PREREQ(maj, min, patch) \
50 ((__GNUC__ << 20) + (__GNUC_MINOR__ << 10) + __GNUC_PATCHLEVEL__ >= \
51 ((maj) << 20) + ((min) << 10) + (patch))
52 #elif defined(__GNUC__) && defined(__GNUC_MINOR__)
53 #define DEMANGLE_GNUC_PREREQ(maj, min, patch) \
54 ((__GNUC__ << 20) + (__GNUC_MINOR__ << 10) >= ((maj) << 20) + ((min) << 10))
56 #define DEMANGLE_GNUC_PREREQ(maj, min, patch) 0
60 #if __has_attribute(used) || DEMANGLE_GNUC_PREREQ(3, 1, 0)
61 #define DEMANGLE_ATTRIBUTE_USED __attribute__((__used__))
63 #define DEMANGLE_ATTRIBUTE_USED
66 #if __has_builtin(__builtin_unreachable) || DEMANGLE_GNUC_PREREQ(4, 5, 0)
67 #define DEMANGLE_UNREACHABLE __builtin_unreachable()
68 #elif defined(_MSC_VER)
69 #define DEMANGLE_UNREACHABLE __assume(false)
71 #define DEMANGLE_UNREACHABLE
74 #if __has_attribute(noinline) || DEMANGLE_GNUC_PREREQ(3, 4, 0)
75 #define DEMANGLE_ATTRIBUTE_NOINLINE __attribute__((noinline))
76 #elif defined(_MSC_VER)
77 #define DEMANGLE_ATTRIBUTE_NOINLINE __declspec(noinline)
79 #define DEMANGLE_ATTRIBUTE_NOINLINE
83 #define DEMANGLE_DUMP_METHOD DEMANGLE_ATTRIBUTE_NOINLINE DEMANGLE_ATTRIBUTE_USED
85 #define DEMANGLE_DUMP_METHOD DEMANGLE_ATTRIBUTE_NOINLINE
88 #if __cplusplus > 201402L && __has_cpp_attribute(fallthrough)
89 #define DEMANGLE_FALLTHROUGH [[fallthrough]]
90 #elif __has_cpp_attribute(gnu::fallthrough)
91 #define DEMANGLE_FALLTHROUGH [[gnu::fallthrough]]
93 // Workaround for llvm.org/PR23435, since clang 3.6 and below emit a spurious
94 // error when __has_cpp_attribute is given a scoped attribute in C mode.
95 #define DEMANGLE_FALLTHROUGH
96 #elif __has_cpp_attribute(clang::fallthrough)
97 #define DEMANGLE_FALLTHROUGH [[clang::fallthrough]]
99 #define DEMANGLE_FALLTHROUGH
102 #define DEMANGLE_NAMESPACE_BEGIN namespace { namespace itanium_demangle {
103 #define DEMANGLE_NAMESPACE_END } }
105 #endif // LIBCXXABI_DEMANGLE_DEMANGLE_CONFIG_H