| 
 | 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 having hidden 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 | +// Some libraries like those for tablegen are linked in to tools that used  | 
 | 35 | +// in the build so can't depend on the llvm shared library. If export macros  | 
 | 36 | +// were left enabled when building these we would get duplicate or  | 
 | 37 | +// missing symbol linker errors on windows.  | 
 | 38 | +#if defined(CLANG_BUILD_STATIC)  | 
 | 39 | +#define CLANG_ABI  | 
 | 40 | +#define CLANG_TEMPLATE_ABI  | 
 | 41 | +#define CLANG_EXPORT_TEMPLATE  | 
 | 42 | +#elif defined(_WIN32) && !defined(__MINGW32__)  | 
 | 43 | +#if defined(CLANG_EXPORTS)  | 
 | 44 | +#define CLANG_ABI __declspec(dllexport)  | 
 | 45 | +#define CLANG_TEMPLATE_ABI  | 
 | 46 | +#define CLANG_EXPORT_TEMPLATE __declspec(dllexport)  | 
 | 47 | +#else  | 
 | 48 | +#define CLANG_ABI __declspec(dllimport)  | 
 | 49 | +#define CLANG_TEMPLATE_ABI __declspec(dllimport)  | 
 | 50 | +#define CLANG_EXPORT_TEMPLATE  | 
 | 51 | +#endif  | 
 | 52 | +#elif defined(__ELF__) || defined(__MINGW32__) || defined(_AIX)  | 
 | 53 | +#define CLANG_ABI LLVM_ATTRIBUTE_VISIBILITY_DEFAULT  | 
 | 54 | +#define CLANG_TEMPLATE_ABI LLVM_ATTRIBUTE_VISIBILITY_DEFAULT  | 
 | 55 | +#define CLANG_EXPORT_TEMPLATE  | 
 | 56 | +#elif defined(__MACH__) || defined(__WASM__)  | 
 | 57 | +#define CLANG_ABI LLVM_ATTRIBUTE_VISIBILITY_DEFAULT  | 
 | 58 | +#define CLANG_TEMPLATE_ABI  | 
 | 59 | +#define CLANG_EXPORT_TEMPLATE  | 
 | 60 | +#endif  | 
 | 61 | +#endif  | 
 | 62 | + | 
 | 63 | +#endif  | 
0 commit comments