1
+ // ===-- clang/Support/Compiler.h - Compiler abstraction support -*- 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-License-Identifier: Apache-2.0 WITH LLVM-exception
6
+ //
7
+ // ===----------------------------------------------------------------------===//
8
+ //
9
+ // This file defines explicit visibility macros used to export symbols from
10
+ // clang-cpp
11
+ //
12
+ // ===----------------------------------------------------------------------===//
13
+
14
+ #ifndef CLANG_SUPPORT_COMPILER_H
15
+ #define CLANG_SUPPORT_COMPILER_H
16
+
17
+ #include " llvm/Support/Compiler.h"
18
+
19
+ // / CLANG_ABI is the main export/visibility macro to mark something as
20
+ // / explicitly exported when clang is built as a shared library with everything
21
+ // / else that is unannotated will have internal visibility.
22
+ // /
23
+ // / CLANG_EXPORT_TEMPLATE is used on explicit template instantiations in source
24
+ // / files that were declared extern in a header. This macro is only set as a
25
+ // / compiler export attribute on windows, on other platforms it does nothing.
26
+ // /
27
+ // / CLANG_TEMPLATE_ABI is for annotating extern template declarations in headers
28
+ // / for both functions and classes. On windows its turned in to dllimport for
29
+ // / library consumers, for other platforms its a default visibility attribute.
30
+ #ifndef CLANG_ABI_GENERATING_ANNOTATIONS
31
+ // Marker to add to classes or functions in public headers that should not have
32
+ // export macros added to them by the clang tool
33
+ #define CLANG_ABI_NOT_EXPORTED
34
+ #if defined(LLVM_BUILD_LLVM_DYLIB) || defined(LLVM_BUILD_SHARED_LIBS)
35
+ // Some libraries like those for tablegen are linked in to tools that used
36
+ // in the build so can't depend on the llvm shared library. If export macros
37
+ // were left enabled when building these we would get duplicate or
38
+ // missing symbol linker errors on windows.
39
+ #if defined(CLANG_BUILD_STATIC)
40
+ #define CLANG_ABI
41
+ #define CLANG_TEMPLATE_ABI
42
+ #define CLANG_EXPORT_TEMPLATE
43
+ #elif defined(_WIN32) && !defined(__MINGW32__)
44
+ #if defined(CLANG_EXPORTS)
45
+ #define CLANG_ABI __declspec (dllexport)
46
+ #define CLANG_TEMPLATE_ABI
47
+ #define CLANG_EXPORT_TEMPLATE __declspec (dllexport)
48
+ #else
49
+ #define CLANG_ABI __declspec (dllimport)
50
+ #define CLANG_TEMPLATE_ABI __declspec (dllimport)
51
+ #define CLANG_EXPORT_TEMPLATE
52
+ #endif
53
+ #elif defined(__ELF__) || defined(__MINGW32__) || defined(_AIX)
54
+ #define CLANG_ABI LLVM_ATTRIBUTE_VISIBILITY_DEFAULT
55
+ #define CLANG_TEMPLATE_ABI LLVM_ATTRIBUTE_VISIBILITY_DEFAULT
56
+ #define CLANG_EXPORT_TEMPLATE
57
+ #elif defined(__MACH__) || defined(__WASM__)
58
+ #define CLANG_ABI LLVM_ATTRIBUTE_VISIBILITY_DEFAULT
59
+ #define CLANG_TEMPLATE_ABI
60
+ #define CLANG_EXPORT_TEMPLATE
61
+ #endif
62
+ #else
63
+ #define CLANG_ABI
64
+ #define CLANG_TEMPLATE_ABI
65
+ #define CLANG_EXPORT_TEMPLATE
66
+ #endif
67
+ #endif
68
+
69
+ #endif
0 commit comments