diff --git a/llvm/include/llvm/ADT/APInt.h b/llvm/include/llvm/ADT/APInt.h --- a/llvm/include/llvm/ADT/APInt.h +++ b/llvm/include/llvm/ADT/APInt.h @@ -16,7 +16,9 @@ #define LLVM_ADT_APINT_H #include "llvm/Support/Compiler.h" +#include "llvm/Support/LLVMSupportExports.h" #include "llvm/Support/MathExtras.h" + #include #include #include @@ -67,7 +69,7 @@ /// * In general, the class tries to follow the style of computation that LLVM /// uses in its IR. This simplifies its use for LLVM. /// -class LLVM_NODISCARD APInt { +class LLVM_SUPPORT_ABI LLVM_NODISCARD APInt { public: typedef uint64_t WordType; diff --git a/llvm/include/llvm/ADT/EpochTracker.h b/llvm/include/llvm/ADT/EpochTracker.h --- a/llvm/include/llvm/ADT/EpochTracker.h +++ b/llvm/include/llvm/ADT/EpochTracker.h @@ -16,6 +16,7 @@ #define LLVM_ADT_EPOCHTRACKER_H #include "llvm/Config/abi-breaking.h" +#include "llvm/Support/LLVMSupportExports.h" #include @@ -32,7 +33,7 @@ /// isHandleInSync at appropriate points to assert that the handle they're using /// is still valid. /// -class DebugEpochBase { +class LLVM_SUPPORT_ABI DebugEpochBase { uint64_t Epoch; public: @@ -78,7 +79,7 @@ #else -class DebugEpochBase { +class LLVM_SUPPORT_ABI DebugEpochBase { public: void incrementEpoch() {} diff --git a/llvm/include/llvm/ADT/FoldingSet.h b/llvm/include/llvm/ADT/FoldingSet.h --- a/llvm/include/llvm/ADT/FoldingSet.h +++ b/llvm/include/llvm/ADT/FoldingSet.h @@ -18,6 +18,8 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/iterator.h" #include "llvm/Support/Allocator.h" +#include "llvm/Support/LLVMSupportExports.h" + #include #include #include @@ -109,7 +111,7 @@ /// in the bucket via a singly linked list. The last node in the list points /// back to the bucket to facilitate node removal. /// -class FoldingSetBase { +class LLVM_SUPPORT_ABI FoldingSetBase { protected: /// Buckets - Array of bucket chains. void **Buckets; @@ -310,7 +312,7 @@ /// FoldingSetNodeID - This class is used to gather all the unique data bits of /// a node. When all the bits are gathered this class is used to produce a /// hash value for the node. -class FoldingSetNodeID { +class LLVM_SUPPORT_ABI FoldingSetNodeID { /// Bits - Vector of all the data bits that make the node unique. /// Use a SmallVector to avoid a heap allocation in the common case. SmallVector Bits; diff --git a/llvm/include/llvm/ADT/IntEqClasses.h b/llvm/include/llvm/ADT/IntEqClasses.h --- a/llvm/include/llvm/ADT/IntEqClasses.h +++ b/llvm/include/llvm/ADT/IntEqClasses.h @@ -21,10 +21,11 @@ #define LLVM_ADT_INTEQCLASSES_H #include "llvm/ADT/SmallVector.h" +#include "llvm/Support/LLVMSupportExports.h" namespace llvm { -class IntEqClasses { +class LLVM_SUPPORT_ABI IntEqClasses { /// EC - When uncompressed, map each integer to a smaller member of its /// equivalence class. The class leader is the smallest member and maps to /// itself. diff --git a/llvm/include/llvm/ADT/SmallPtrSet.h b/llvm/include/llvm/ADT/SmallPtrSet.h --- a/llvm/include/llvm/ADT/SmallPtrSet.h +++ b/llvm/include/llvm/ADT/SmallPtrSet.h @@ -16,8 +16,10 @@ #include "llvm/ADT/EpochTracker.h" #include "llvm/Support/Compiler.h" +#include "llvm/Support/LLVMSupportExports.h" #include "llvm/Support/ReverseIteration.h" #include "llvm/Support/type_traits.h" + #include #include #include @@ -46,7 +48,7 @@ /// (-2), to allow deletion. The hash table is resized when the table is 3/4 or /// more. When this happens, the table is doubled in size. /// -class SmallPtrSetImplBase : public DebugEpochBase { +class LLVM_SUPPORT_ABI SmallPtrSetImplBase : public DebugEpochBase { friend class SmallPtrSetIteratorImpl; protected: diff --git a/llvm/include/llvm/ADT/StringExtras.h b/llvm/include/llvm/ADT/StringExtras.h --- a/llvm/include/llvm/ADT/StringExtras.h +++ b/llvm/include/llvm/ADT/StringExtras.h @@ -18,6 +18,8 @@ #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/Twine.h" +#include "llvm/Support/LLVMSupportExports.h" + #include #include #include @@ -319,11 +321,13 @@ /// there are no tokens in the source string, an empty string is returned. /// The function returns a pair containing the extracted token and the /// remaining tail string. +LLVM_SUPPORT_ABI std::pair getToken(StringRef Source, StringRef Delimiters = " \t\n\v\f\r"); /// SplitString - Split up the specified string according to the specified /// delimiters, appending the result fragments to the output list. +LLVM_SUPPORT_ABI void SplitString(StringRef Source, SmallVectorImpl &OutFragments, StringRef Delimiters = " \t\n\v\f\r"); diff --git a/llvm/include/llvm/ADT/StringMap.h b/llvm/include/llvm/ADT/StringMap.h --- a/llvm/include/llvm/ADT/StringMap.h +++ b/llvm/include/llvm/ADT/StringMap.h @@ -15,6 +15,7 @@ #include "llvm/ADT/StringMapEntry.h" #include "llvm/Support/AllocatorBase.h" +#include "llvm/Support/LLVMSupportExports.h" #include "llvm/Support/PointerLikeTypeTraits.h" #include #include @@ -27,7 +28,7 @@ /// StringMapImpl - This is the base class of StringMap that is shared among /// all of its instantiations. -class StringMapImpl { +class LLVM_SUPPORT_ABI StringMapImpl { protected: // Array of NumBuckets pointers to entries, null pointers are holes. // TheTable[NumBuckets] contains a sentinel value for easy iteration. Followed diff --git a/llvm/include/llvm/ADT/StringRef.h b/llvm/include/llvm/ADT/StringRef.h --- a/llvm/include/llvm/ADT/StringRef.h +++ b/llvm/include/llvm/ADT/StringRef.h @@ -12,6 +12,8 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/iterator_range.h" #include "llvm/Support/Compiler.h" +#include "llvm/Support/LLVMSupportExports.h" + #include #include #include @@ -39,11 +41,13 @@ class StringRef; /// Helper functions for StringRef::getAsInteger. + LLVM_SUPPORT_ABI bool getAsUnsignedInteger(StringRef Str, unsigned Radix, unsigned long long &Result); bool getAsSignedInteger(StringRef Str, unsigned Radix, long long &Result); + LLVM_SUPPORT_ABI bool consumeUnsignedInteger(StringRef &Str, unsigned Radix, unsigned long long &Result); bool consumeSignedInteger(StringRef &Str, unsigned Radix, long long &Result); @@ -55,7 +59,7 @@ /// situations where the character data resides in some other buffer, whose /// lifetime extends past that of the StringRef. For this reason, it is not in /// general safe to store a StringRef. - class LLVM_GSL_POINTER StringRef { + class LLVM_SUPPORT_ABI LLVM_GSL_POINTER StringRef { public: static constexpr size_t npos = ~size_t(0); @@ -945,7 +949,7 @@ /// @} /// Compute a hash_code for a StringRef. - LLVM_NODISCARD + LLVM_SUPPORT_ABI LLVM_NODISCARD hash_code hash_value(StringRef S); // Provide DenseMapInfo for StringRefs. diff --git a/llvm/include/llvm/ADT/Twine.h b/llvm/include/llvm/ADT/Twine.h --- a/llvm/include/llvm/ADT/Twine.h +++ b/llvm/include/llvm/ADT/Twine.h @@ -12,6 +12,8 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/LLVMSupportExports.h" + #include #include #include @@ -80,7 +82,7 @@ /// so we provide two additional methods (and accompanying operator+ /// overloads) to guarantee that particularly important cases (cstring plus /// StringRef) codegen as desired. - class Twine { + class LLVM_SUPPORT_ABI Twine { /// NodeKind - Represent the type of an argument. enum NodeKind : unsigned char { /// An empty string; the result of concatenating anything with it is also diff --git a/llvm/include/llvm/Support/CodeGenCoverage.h b/llvm/include/llvm/Support/CodeGenCoverage.h --- a/llvm/include/llvm/Support/CodeGenCoverage.h +++ b/llvm/include/llvm/Support/CodeGenCoverage.h @@ -12,12 +12,13 @@ #define LLVM_SUPPORT_CODEGENCOVERAGE_H #include "llvm/ADT/BitVector.h" +#include "llvm/Support/LLVMSupportExports.h" namespace llvm { class LLVMContext; class MemoryBuffer; -class CodeGenCoverage { +class LLVM_SUPPORT_ABI CodeGenCoverage { protected: BitVector RuleCoverage; diff --git a/llvm/include/llvm/Support/CommandLine.h b/llvm/include/llvm/Support/CommandLine.h --- a/llvm/include/llvm/Support/CommandLine.h +++ b/llvm/include/llvm/Support/CommandLine.h @@ -30,8 +30,10 @@ #include "llvm/ADT/Twine.h" #include "llvm/ADT/iterator_range.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/LLVMSupportExports.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/raw_ostream.h" + #include #include #include @@ -68,6 +70,7 @@ // that give precedence to later occurrences. If your program supports options // that give precedence to earlier occurrences, you will need to extend this // function to support it correctly. +LLVM_SUPPORT_ABI bool ParseCommandLineOptions(int argc, const char *const *argv, StringRef Overview = "", raw_ostream *Errs = nullptr, @@ -109,6 +112,7 @@ /// /// Literal options are used by some parsers to register special option values. /// This is how the PassNameParser registers pass names for opt. +LLVM_SUPPORT_ABI void AddLiteralOption(Option &O, StringRef Name); //===----------------------------------------------------------------------===// @@ -183,7 +187,7 @@ //===----------------------------------------------------------------------===// // Option Category class // -class OptionCategory { +class LLVM_SUPPORT_ABI OptionCategory { private: StringRef const Name; StringRef const Description; @@ -246,7 +250,7 @@ //===----------------------------------------------------------------------===// // Option Base class // -class Option { +class LLVM_SUPPORT_ABI Option { friend class alias; // handleOccurrences - Overriden by subclasses to handle the value passed into @@ -519,7 +523,7 @@ // OptionValue class // Support value comparison outside the template. -struct GenericOptionValue { +struct LLVM_SUPPORT_ABI GenericOptionValue { virtual bool compare(const GenericOptionValue &V) const = 0; protected: @@ -642,7 +646,7 @@ }; template <> -struct OptionValue final : OptionValueCopy { +struct LLVM_SUPPORT_ABI OptionValue final : OptionValueCopy { using WrapperType = StringRef; OptionValue() = default; @@ -712,7 +716,7 @@ // not need replicated for every instance of the generic parser. This also // allows us to put stuff into CommandLine.cpp // -class generic_parser_base { +class LLVM_SUPPORT_ABI generic_parser_base { protected: class GenericOptionInfo { public: @@ -875,7 +879,7 @@ //-------------------------------------------------- // basic_parser - Super class of parsers to provide boilerplate code // -class basic_parser_impl { // non-template implementation of basic_parser +class LLVM_SUPPORT_ABI basic_parser_impl { // non-template implementation of basic_parser public: basic_parser_impl(Option &) {} @@ -926,7 +930,7 @@ //-------------------------------------------------- // parser // -template <> class parser : public basic_parser { +template <> class LLVM_SUPPORT_ABI parser : public basic_parser { public: parser(Option &O) : basic_parser(O) {} @@ -1045,7 +1049,7 @@ //-------------------------------------------------- // parser // -template <> class parser : public basic_parser { +template <> class LLVM_SUPPORT_ABI parser : public basic_parser { public: parser(Option &O) : basic_parser(O) {} @@ -1158,7 +1162,7 @@ //-------------------------------------------------- // parser // -template <> class parser : public basic_parser { +template <> class LLVM_SUPPORT_ABI parser : public basic_parser { public: parser(Option &O) : basic_parser(O) {} diff --git a/llvm/include/llvm/Support/Debug.h b/llvm/include/llvm/Support/Debug.h --- a/llvm/include/llvm/Support/Debug.h +++ b/llvm/include/llvm/Support/Debug.h @@ -28,6 +28,8 @@ #ifndef LLVM_SUPPORT_DEBUG_H #define LLVM_SUPPORT_DEBUG_H +#include "llvm/Support/LLVMSupportExports.h" + namespace llvm { class raw_ostream; @@ -110,7 +112,7 @@ /// dbgs() - This returns a reference to a raw_ostream for debugging /// messages. If debugging is disabled it returns errs(). Use it /// like: dbgs() << "foo" << "bar"; -raw_ostream &dbgs(); +LLVM_SUPPORT_ABI raw_ostream &dbgs(); // DEBUG macro - This macro should be used by passes to emit debug information. // In the '-debug' option is specified on the commandline, and if this is a diff --git a/llvm/include/llvm/Support/Error.h b/llvm/include/llvm/Support/Error.h --- a/llvm/include/llvm/Support/Error.h +++ b/llvm/include/llvm/Support/Error.h @@ -25,7 +25,9 @@ #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorOr.h" #include "llvm/Support/Format.h" +#include "llvm/Support/LLVMSupportExports.h" #include "llvm/Support/raw_ostream.h" + #include #include #include @@ -45,7 +47,7 @@ /// Base class for error info classes. Do not extend this directly: Extend /// the ErrorInfo template subclass instead. -class ErrorInfoBase { +class LLVM_SUPPORT_ABI ErrorInfoBase { public: virtual ~ErrorInfoBase() = default; @@ -719,7 +721,7 @@ /// Report a serious error, calling any installed error handler. See /// ErrorHandling.h. -[[noreturn]] void report_fatal_error(Error Err, bool gen_crash_diag = true); +[[noreturn]] void LLVM_SUPPORT_ABI report_fatal_error(Error Err, bool gen_crash_diag = true); /// Report a fatal error if Err is a failure value. /// @@ -1156,7 +1158,7 @@ /// sensible conversion to std::error_code is available, as attempts to convert /// to/from this error will result in a fatal error. (i.e. it is a programmatic ///error to try to convert such a value). -std::error_code inconvertibleErrorCode(); +LLVM_SUPPORT_ABI std::error_code inconvertibleErrorCode(); /// Helper for converting an std::error_code to a Error. Error errorCodeToError(std::error_code EC); @@ -1205,7 +1207,7 @@ /// } /// @endcode /// -class StringError : public ErrorInfo { +class LLVM_SUPPORT_ABI StringError : public ErrorInfo { public: static char ID; diff --git a/llvm/include/llvm/Support/Format.h b/llvm/include/llvm/Support/Format.h --- a/llvm/include/llvm/Support/Format.h +++ b/llvm/include/llvm/Support/Format.h @@ -26,6 +26,8 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/DataTypes.h" +#include "llvm/Support/LLVMSupportExports.h" + #include #include #include @@ -35,7 +37,7 @@ /// This is a helper class used for handling formatted output. It is the /// abstract base class of a templated derived class. -class format_object_base { +class LLVM_SUPPORT_ABI format_object_base { protected: const char *Fmt; ~format_object_base() = default; // Disallow polymorphic deletion. diff --git a/llvm/include/llvm/Support/FormatVariadicDetails.h b/llvm/include/llvm/Support/FormatVariadicDetails.h --- a/llvm/include/llvm/Support/FormatVariadicDetails.h +++ b/llvm/include/llvm/Support/FormatVariadicDetails.h @@ -10,6 +10,7 @@ #define LLVM_SUPPORT_FORMATVARIADICDETAILS_H #include "llvm/ADT/StringRef.h" +#include "llvm/Support/LLVMSupportExports.h" #include "llvm/Support/raw_ostream.h" #include @@ -19,7 +20,7 @@ class Error; namespace detail { -class format_adapter { +class LLVM_SUPPORT_ABI format_adapter { virtual void anchor(); protected: diff --git a/llvm/include/llvm/Support/FormattedStream.h b/llvm/include/llvm/Support/FormattedStream.h --- a/llvm/include/llvm/Support/FormattedStream.h +++ b/llvm/include/llvm/Support/FormattedStream.h @@ -15,7 +15,9 @@ #define LLVM_SUPPORT_FORMATTEDSTREAM_H #include "llvm/ADT/SmallString.h" +#include "llvm/Support/LLVMSupportExports.h" #include "llvm/Support/raw_ostream.h" + #include namespace llvm { @@ -27,7 +29,7 @@ /// doesn't attempt to handle everything Unicode can do (combining characters, /// right-to-left markers, etc), but should cover the cases likely to appear in /// source code or diagnostic messages. -class formatted_raw_ostream : public raw_ostream { +class LLVM_SUPPORT_ABI formatted_raw_ostream : public raw_ostream { /// TheStream - The real stream we output to. We set it to be /// unbuffered, since we're already doing our own buffering. /// diff --git a/llvm/include/llvm/Support/InitLLVM.h b/llvm/include/llvm/Support/InitLLVM.h --- a/llvm/include/llvm/Support/InitLLVM.h +++ b/llvm/include/llvm/Support/InitLLVM.h @@ -12,6 +12,7 @@ #include "llvm/ADT/Optional.h" #include "llvm/ADT/SmallVector.h" #include "llvm/Support/Allocator.h" +#include "llvm/Support/LLVMSupportExports.h" #include "llvm/Support/PrettyStackTrace.h" // The main() functions in typical LLVM tools start with InitLLVM which does @@ -32,7 +33,7 @@ // InitLLVM calls llvm_shutdown() on destruction, which cleans up // ManagedStatic objects. namespace llvm { -class InitLLVM { +class LLVM_SUPPORT_ABI InitLLVM { public: InitLLVM(int &Argc, const char **&Argv, bool InstallPipeSignalExitHandler = true); diff --git a/llvm/include/llvm/Support/JSON.h b/llvm/include/llvm/Support/JSON.h --- a/llvm/include/llvm/Support/JSON.h +++ b/llvm/include/llvm/Support/JSON.h @@ -51,7 +51,9 @@ #include "llvm/ADT/StringRef.h" #include "llvm/Support/Error.h" #include "llvm/Support/FormatVariadic.h" +#include "llvm/Support/LLVMSupportExports.h" #include "llvm/Support/raw_ostream.h" + #include namespace llvm { @@ -74,11 +76,11 @@ /// Returns true if \p S is valid UTF-8, which is required for use as JSON. /// If it returns false, \p Offset is set to a byte offset near the first error. -bool isUTF8(llvm::StringRef S, size_t *ErrOffset = nullptr); +LLVM_SUPPORT_ABI bool isUTF8(llvm::StringRef S, size_t *ErrOffset = nullptr); /// Replaces invalid UTF-8 sequences in \p S with the replacement character /// (U+FFFD). The returned string is valid UTF-8. /// This is much slower than isUTF8, so test that first. -std::string fixUTF8(llvm::StringRef S); +LLVM_SUPPORT_ABI std::string fixUTF8(llvm::StringRef S); class Array; class ObjectKey; @@ -87,7 +89,7 @@ /// An Object is a JSON object, which maps strings to heterogenous JSON values. /// It simulates DenseMap. ObjectKey is a maybe-owned string. -class Object { +class LLVM_SUPPORT_ABI Object { using Storage = DenseMap>; Storage M; @@ -286,7 +288,7 @@ /// And parsed: /// Expected E = json::parse("[1, 2, null]"); /// assert(E && E->kind() == Value::Array); -class Value { +class LLVM_SUPPORT_ABI Value { public: enum Kind { Null, @@ -883,7 +885,7 @@ /// This can be mismatched begin()/end() pairs, trying to emit attributes inside /// an array, and so on. /// With asserts disabled, this is undefined behavior. -class OStream { +class LLVM_SUPPORT_ABI OStream { public: using Block = llvm::function_ref; // If IndentSize is nonzero, output is pretty-printed. diff --git a/llvm/include/llvm/Support/LLVMSupportExports.h b/llvm/include/llvm/Support/LLVMSupportExports.h new file mode 100644 --- /dev/null +++ b/llvm/include/llvm/Support/LLVMSupportExports.h @@ -0,0 +1,40 @@ +//===--- SupportMacros.h - ABI Macro Definitions ----------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_SUPPORT_LLVMSUPPORT_EXPORTS_H +#define LLVM_SUPPORT_LLVMSUPPORT_EXPORTS_H + +#if defined(__ELF__) +# if defined(LLVM_SUPPORT_STATIC) +# define LLVM_SUPPORT_ABI +# else +# if defined(LLVMSupport_EXPORTS) +# define LLVM_SUPPORT_ABI __attribute__((__visibility__("protected"))) +# else +# define LLVM_SUPPORT_ABI __attribute__((__visibility__("default"))) +# endif +# endif +#elif defined(__MACH__) || defined(__WASM__) +# if defined(LLVM_SUPPORT_STATIC) +# define LLVM_SUPPORT_ABI +# else +# define LLVM_SUPPORT_ABI __attribute__((__visibility__("default"))) +# endif +#else +# if defined(LLVM_SUPPORT_STATIC) +# define LLVM_SUPPORT_abi +# else +# if defined(LLVMSupport_EXPORTS) +# define LLVM_SUPPORT_ABI __declspec(dllexport) +# else +# define LLVM_SUPPORT_ABI __declspec(dllimport) +# endif +# endif +#endif + +#endif diff --git a/llvm/include/llvm/Support/MemAlloc.h b/llvm/include/llvm/Support/MemAlloc.h --- a/llvm/include/llvm/Support/MemAlloc.h +++ b/llvm/include/llvm/Support/MemAlloc.h @@ -18,6 +18,7 @@ #include "llvm/Support/Compiler.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/LLVMSupportExports.h" #include namespace llvm { @@ -71,7 +72,7 @@ /// like posix_memalign due to portability. It is mostly intended to allow /// compatibility with platforms that, after aligned allocation was added, use /// reduced default alignment. -LLVM_ATTRIBUTE_RETURNS_NONNULL LLVM_ATTRIBUTE_RETURNS_NOALIAS void * +LLVM_SUPPORT_ABI LLVM_ATTRIBUTE_RETURNS_NONNULL LLVM_ATTRIBUTE_RETURNS_NOALIAS void * allocate_buffer(size_t Size, size_t Alignment); /// Deallocate a buffer of memory with the given size and alignment. @@ -81,7 +82,7 @@ /// /// The pointer must have been allocated with the corresponding new operator, /// most likely using the above helper. -void deallocate_buffer(void *Ptr, size_t Size, size_t Alignment); +LLVM_SUPPORT_ABI void deallocate_buffer(void *Ptr, size_t Size, size_t Alignment); } // namespace llvm #endif diff --git a/llvm/include/llvm/Support/MemoryBuffer.h b/llvm/include/llvm/Support/MemoryBuffer.h --- a/llvm/include/llvm/Support/MemoryBuffer.h +++ b/llvm/include/llvm/Support/MemoryBuffer.h @@ -19,7 +19,9 @@ #include "llvm/ADT/Twine.h" #include "llvm/Support/CBindingWrapping.h" #include "llvm/Support/ErrorOr.h" +#include "llvm/Support/LLVMSupportExports.h" #include "llvm/Support/MemoryBufferRef.h" + #include #include #include @@ -47,7 +49,7 @@ /// be more efficient for clients which are reading all the data to stop /// reading when they encounter a '\0' than to continually check the file /// position to see if it has reached the end of the file. -class MemoryBuffer { +class LLVM_SUPPORT_ABI MemoryBuffer { const char *BufferStart; // Start of the buffer. const char *BufferEnd; // End of the buffer. diff --git a/llvm/include/llvm/Support/NativeFormatting.h b/llvm/include/llvm/Support/NativeFormatting.h --- a/llvm/include/llvm/Support/NativeFormatting.h +++ b/llvm/include/llvm/Support/NativeFormatting.h @@ -10,6 +10,8 @@ #define LLVM_SUPPORT_NATIVEFORMATTING_H #include "llvm/ADT/Optional.h" +#include "llvm/Support/LLVMSupportExports.h" + #include namespace llvm { @@ -23,22 +25,35 @@ size_t getDefaultPrecision(FloatStyle Style); -bool isPrefixedHexStyle(HexPrintStyle S); +LLVM_SUPPORT_ABI bool isPrefixedHexStyle(HexPrintStyle S); +LLVM_SUPPORT_ABI void write_integer(raw_ostream &S, unsigned int N, size_t MinDigits, IntegerStyle Style); + +LLVM_SUPPORT_ABI void write_integer(raw_ostream &S, int N, size_t MinDigits, IntegerStyle Style); + +LLVM_SUPPORT_ABI void write_integer(raw_ostream &S, unsigned long N, size_t MinDigits, IntegerStyle Style); + +LLVM_SUPPORT_ABI void write_integer(raw_ostream &S, long N, size_t MinDigits, IntegerStyle Style); + +LLVM_SUPPORT_ABI void write_integer(raw_ostream &S, unsigned long long N, size_t MinDigits, IntegerStyle Style); + +LLVM_SUPPORT_ABI void write_integer(raw_ostream &S, long long N, size_t MinDigits, IntegerStyle Style); +LLVM_SUPPORT_ABI void write_hex(raw_ostream &S, uint64_t N, HexPrintStyle Style, Optional Width = None); + void write_double(raw_ostream &S, double D, FloatStyle Style, Optional Precision = None); } diff --git a/llvm/include/llvm/Support/Regex.h b/llvm/include/llvm/Support/Regex.h --- a/llvm/include/llvm/Support/Regex.h +++ b/llvm/include/llvm/Support/Regex.h @@ -17,6 +17,8 @@ #define LLVM_SUPPORT_REGEX_H #include "llvm/ADT/BitmaskEnum.h" +#include "llvm/Support/LLVMSupportExports.h" + #include struct llvm_regex; @@ -25,7 +27,7 @@ class StringRef; template class SmallVectorImpl; - class Regex { + class LLVM_SUPPORT_ABI Regex { public: enum RegexFlags : unsigned { NoFlags = 0, diff --git a/llvm/include/llvm/Support/Signals.h b/llvm/include/llvm/Support/Signals.h --- a/llvm/include/llvm/Support/Signals.h +++ b/llvm/include/llvm/Support/Signals.h @@ -14,6 +14,8 @@ #ifndef LLVM_SUPPORT_SIGNALS_H #define LLVM_SUPPORT_SIGNALS_H +#include "llvm/Support/LLVMSupportExports.h" + #include namespace llvm { @@ -24,7 +26,7 @@ /// This function runs all the registered interrupt handlers, including the /// removal of files registered by RemoveFileOnSignal. - void RunInterruptHandlers(); + LLVM_SUPPORT_ABI void RunInterruptHandlers(); /// This function registers signal handlers to ensure that if a signal gets /// delivered that the named file is removed. diff --git a/llvm/include/llvm/Support/SourceMgr.h b/llvm/include/llvm/Support/SourceMgr.h --- a/llvm/include/llvm/Support/SourceMgr.h +++ b/llvm/include/llvm/Support/SourceMgr.h @@ -16,8 +16,10 @@ #define LLVM_SUPPORT_SOURCEMGR_H #include "llvm/ADT/SmallVector.h" +#include "llvm/Support/LLVMSupportExports.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/SMLoc.h" + #include namespace llvm { @@ -28,7 +30,7 @@ /// This owns the files read by a parser, handles include stacks, /// and handles diagnostic wrangling. -class SourceMgr { +class LLVM_SUPPORT_ABI SourceMgr { public: enum DiagKind { DK_Error, diff --git a/llvm/include/llvm/Support/Timer.h b/llvm/include/llvm/Support/Timer.h --- a/llvm/include/llvm/Support/Timer.h +++ b/llvm/include/llvm/Support/Timer.h @@ -12,6 +12,8 @@ #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/DataTypes.h" +#include "llvm/Support/LLVMSupportExports.h" + #include #include #include @@ -79,7 +81,7 @@ /// when the last timer is destroyed, otherwise it is printed when its /// TimerGroup is destroyed. Timers do not print their information if they are /// never started. -class Timer { +class LLVM_SUPPORT_ABI Timer { TimeRecord Time; ///< The total time captured. TimeRecord StartTime; ///< The time startTimer() was last called. std::string Name; ///< The name of this time variable. @@ -173,7 +175,7 @@ /// report that is printed when the TimerGroup is destroyed. It is illegal to /// destroy a TimerGroup object before all of the Timers in it are gone. A /// TimerGroup can be specified for a newly created timer in its constructor. -class TimerGroup { +class LLVM_SUPPORT_ABI TimerGroup { struct PrintRecord { TimeRecord Time; std::string Name; diff --git a/llvm/include/llvm/Support/ToolOutputFile.h b/llvm/include/llvm/Support/ToolOutputFile.h --- a/llvm/include/llvm/Support/ToolOutputFile.h +++ b/llvm/include/llvm/Support/ToolOutputFile.h @@ -14,6 +14,7 @@ #define LLVM_SUPPORT_TOOLOUTPUTFILE_H #include "llvm/ADT/Optional.h" +#include "llvm/Support/LLVMSupportExports.h" #include "llvm/Support/raw_ostream.h" namespace llvm { diff --git a/llvm/include/llvm/Support/TypeSize.h b/llvm/include/llvm/Support/TypeSize.h --- a/llvm/include/llvm/Support/TypeSize.h +++ b/llvm/include/llvm/Support/TypeSize.h @@ -16,6 +16,7 @@ #define LLVM_SUPPORT_TYPESIZE_H #include "llvm/ADT/ArrayRef.h" +#include "llvm/Support/LLVMSupportExports.h" #include "llvm/Support/MathExtras.h" #include "llvm/Support/WithColor.h" @@ -414,7 +415,7 @@ // TypeSize is used to represent the size of types. If the type is of fixed // size, it will represent the exact size. If the type is a scalable vector, // it will represent the known minimum size. -class TypeSize : public LinearPolySize { +class LLVM_SUPPORT_ABI TypeSize : public LinearPolySize { public: TypeSize(const LinearPolySize &V) : LinearPolySize(V) {} TypeSize(ScalarTy MinVal, bool IsScalable) diff --git a/llvm/include/llvm/Support/WithColor.h b/llvm/include/llvm/Support/WithColor.h --- a/llvm/include/llvm/Support/WithColor.h +++ b/llvm/include/llvm/Support/WithColor.h @@ -9,6 +9,7 @@ #ifndef LLVM_SUPPORT_WITHCOLOR_H #define LLVM_SUPPORT_WITHCOLOR_H +#include "llvm/Support/LLVMSupportExports.h" #include "llvm/Support/raw_ostream.h" namespace llvm { @@ -50,7 +51,7 @@ /// An RAII object that temporarily switches an output stream to a specific /// color. -class WithColor { +class LLVM_SUPPORT_ABI WithColor { raw_ostream &OS; ColorMode Mode; diff --git a/llvm/include/llvm/Support/raw_ostream.h b/llvm/include/llvm/Support/raw_ostream.h --- a/llvm/include/llvm/Support/raw_ostream.h +++ b/llvm/include/llvm/Support/raw_ostream.h @@ -16,6 +16,8 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/DataTypes.h" +#include "llvm/Support/LLVMSupportExports.h" + #include #include #include @@ -50,7 +52,7 @@ /// output to a stream. It does not support seeking, reopening, rewinding, line /// buffered disciplines etc. It is a simple buffer that outputs /// a chunk at a time. -class raw_ostream { +class LLVM_SUPPORT_ABI raw_ostream { public: // Class kinds to support LLVM-style RTTI. enum class OStreamKind { @@ -412,7 +414,7 @@ /// An abstract base class for streams implementations that also support a /// pwrite operation. This is useful for code that can mostly stream out data, /// but needs to patch in a header that needs to know the output size. -class raw_pwrite_stream : public raw_ostream { +class LLVM_SUPPORT_ABI raw_pwrite_stream : public raw_ostream { virtual void pwrite_impl(const char *Ptr, size_t Size, uint64_t Offset) = 0; void anchor() override; @@ -438,7 +440,7 @@ /// A raw_ostream that writes to a file descriptor. /// -class raw_fd_ostream : public raw_pwrite_stream { +class LLVM_SUPPORT_ABI raw_fd_ostream : public raw_pwrite_stream { int FD; bool ShouldClose; bool SupportsSeeking = false; @@ -574,17 +576,17 @@ /// This returns a reference to a raw_fd_ostream for standard output. Use it /// like: outs() << "foo" << "bar"; -raw_fd_ostream &outs(); +LLVM_SUPPORT_ABI raw_fd_ostream &outs(); /// This returns a reference to a raw_ostream for standard error. /// Use it like: errs() << "foo" << "bar"; /// By default, the stream is tied to stdout to ensure stdout is flushed before /// stderr is written, to ensure the error messages are written in their /// expected place. -raw_fd_ostream &errs(); +LLVM_SUPPORT_ABI raw_fd_ostream &errs(); /// This returns a reference to a raw_ostream which simply discards output. -raw_ostream &nulls(); +LLVM_SUPPORT_ABI raw_ostream &nulls(); //===----------------------------------------------------------------------===// // File Streams @@ -620,7 +622,7 @@ /// A raw_ostream that writes to an std::string. This is a simple adaptor /// class. This class does not encounter output errors. -class raw_string_ostream : public raw_ostream { +class LLVM_SUPPORT_ABI raw_string_ostream : public raw_ostream { std::string &OS; /// See raw_ostream::write_impl. @@ -653,7 +655,7 @@ /// raw_svector_ostream operates without a buffer, delegating all memory /// management to the SmallString. Thus the SmallString is always up-to-date, /// may be used directly and there is no need to call flush(). -class raw_svector_ostream : public raw_pwrite_stream { +class LLVM_SUPPORT_ABI raw_svector_ostream : public raw_pwrite_stream { SmallVectorImpl &OS; /// See raw_ostream::write_impl. @@ -686,7 +688,7 @@ }; /// A raw_ostream that discards all output. -class raw_null_ostream : public raw_pwrite_stream { +class LLVM_SUPPORT_ABI raw_null_ostream : public raw_pwrite_stream { /// See raw_ostream::write_impl. void write_impl(const char *Ptr, size_t size) override; void pwrite_impl(const char *Ptr, size_t Size, uint64_t Offset) override; diff --git a/llvm/lib/Support/CMakeLists.txt b/llvm/lib/Support/CMakeLists.txt --- a/llvm/lib/Support/CMakeLists.txt +++ b/llvm/lib/Support/CMakeLists.txt @@ -101,7 +101,7 @@ endif() endif() -add_llvm_component_library(LLVMSupport +add_llvm_component_library(LLVMSupport SHARED AArch64TargetParser.cpp ABIBreak.cpp ARMTargetParser.cpp @@ -281,7 +281,12 @@ set(llvm_system_libs ${llvm_system_libs} "${terminfo_library}") endif() -set_property(TARGET LLVMSupport PROPERTY LLVM_SYSTEM_LIBS "${llvm_system_libs}") +set_target_properties(LLVMSupport PROPERTIES + LLVM_SYSTEM_LIBS "${llvm_system_libs}" + DEFINE_SYMBOL "LLVMSupport_EXPORTS" + C_VISIBILITY_PRESET hidden + CXX_VISIBILITY_PRESET hidden + VISIBILITY_INLINES_HIDDEN YES) if(LLVM_INTEGRATED_CRT_ALLOC)