summaryrefslogtreecommitdiff
path: root/externals/demangle/DemangleConfig.h
diff options
context:
space:
mode:
Diffstat (limited to 'externals/demangle/DemangleConfig.h')
-rw-r--r--externals/demangle/DemangleConfig.h93
1 files changed, 93 insertions, 0 deletions
diff --git a/externals/demangle/DemangleConfig.h b/externals/demangle/DemangleConfig.h
new file mode 100644
index 000000000..f155f69fa
--- /dev/null
+++ b/externals/demangle/DemangleConfig.h
@@ -0,0 +1,93 @@
1//===--- DemangleConfig.h ---------------------------------------*- C++ -*-===//
2//
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-FileCopyrightText: Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9//
10// This file contains a variety of feature test macros copied from
11// include/llvm/Support/Compiler.h so that LLVMDemangle does not need to take
12// a dependency on LLVMSupport.
13//
14//===----------------------------------------------------------------------===//
15
16#ifndef LLVM_DEMANGLE_COMPILER_H
17#define LLVM_DEMANGLE_COMPILER_H
18
19#ifndef __has_feature
20#define __has_feature(x) 0
21#endif
22
23#ifndef __has_cpp_attribute
24#define __has_cpp_attribute(x) 0
25#endif
26
27#ifndef __has_attribute
28#define __has_attribute(x) 0
29#endif
30
31#ifndef __has_builtin
32#define __has_builtin(x) 0
33#endif
34
35#ifndef DEMANGLE_GNUC_PREREQ
36#if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__)
37#define DEMANGLE_GNUC_PREREQ(maj, min, patch) \
38 ((__GNUC__ << 20) + (__GNUC_MINOR__ << 10) + __GNUC_PATCHLEVEL__ >= \
39 ((maj) << 20) + ((min) << 10) + (patch))
40#elif defined(__GNUC__) && defined(__GNUC_MINOR__)
41#define DEMANGLE_GNUC_PREREQ(maj, min, patch) \
42 ((__GNUC__ << 20) + (__GNUC_MINOR__ << 10) >= ((maj) << 20) + ((min) << 10))
43#else
44#define DEMANGLE_GNUC_PREREQ(maj, min, patch) 0
45#endif
46#endif
47
48#if __has_attribute(used) || DEMANGLE_GNUC_PREREQ(3, 1, 0)
49#define DEMANGLE_ATTRIBUTE_USED __attribute__((__used__))
50#else
51#define DEMANGLE_ATTRIBUTE_USED
52#endif
53
54#if __has_builtin(__builtin_unreachable) || DEMANGLE_GNUC_PREREQ(4, 5, 0)
55#define DEMANGLE_UNREACHABLE __builtin_unreachable()
56#elif defined(_MSC_VER)
57#define DEMANGLE_UNREACHABLE __assume(false)
58#else
59#define DEMANGLE_UNREACHABLE
60#endif
61
62#if __has_attribute(noinline) || DEMANGLE_GNUC_PREREQ(3, 4, 0)
63#define DEMANGLE_ATTRIBUTE_NOINLINE __attribute__((noinline))
64#elif defined(_MSC_VER)
65#define DEMANGLE_ATTRIBUTE_NOINLINE __declspec(noinline)
66#else
67#define DEMANGLE_ATTRIBUTE_NOINLINE
68#endif
69
70#if !defined(NDEBUG)
71#define DEMANGLE_DUMP_METHOD DEMANGLE_ATTRIBUTE_NOINLINE DEMANGLE_ATTRIBUTE_USED
72#else
73#define DEMANGLE_DUMP_METHOD DEMANGLE_ATTRIBUTE_NOINLINE
74#endif
75
76#if __cplusplus > 201402L && __has_cpp_attribute(fallthrough)
77#define DEMANGLE_FALLTHROUGH [[fallthrough]]
78#elif __has_cpp_attribute(gnu::fallthrough)
79#define DEMANGLE_FALLTHROUGH [[gnu::fallthrough]]
80#elif !__cplusplus
81// Workaround for llvm.org/PR23435, since clang 3.6 and below emit a spurious
82// error when __has_cpp_attribute is given a scoped attribute in C mode.
83#define DEMANGLE_FALLTHROUGH
84#elif __has_cpp_attribute(clang::fallthrough)
85#define DEMANGLE_FALLTHROUGH [[clang::fallthrough]]
86#else
87#define DEMANGLE_FALLTHROUGH
88#endif
89
90#define DEMANGLE_NAMESPACE_BEGIN namespace llvm { namespace itanium_demangle {
91#define DEMANGLE_NAMESPACE_END } }
92
93#endif