diff --git a/llvm/include/llvm-c/ErrorHandling.h b/llvm/include/llvm-c/ErrorHandling.h --- a/llvm/include/llvm-c/ErrorHandling.h +++ b/llvm/include/llvm-c/ErrorHandling.h @@ -15,6 +15,7 @@ #define LLVM_C_ERRORHANDLING_H #include "llvm-c/ExternC.h" +#include "llvm/Support/LLVMSupportExports.h" LLVM_C_EXTERN_C_BEGIN @@ -40,7 +41,7 @@ * signals and prints which component of LLVM you were in at the time if the * crash. */ -void LLVMEnablePrettyStackTrace(void); +LLVM_SUPPORT_ABI void LLVMEnablePrettyStackTrace(void); LLVM_C_EXTERN_C_END diff --git a/llvm/include/llvm/ADT/APFixedPoint.h b/llvm/include/llvm/ADT/APFixedPoint.h --- a/llvm/include/llvm/ADT/APFixedPoint.h +++ b/llvm/include/llvm/ADT/APFixedPoint.h @@ -18,6 +18,7 @@ #include "llvm/ADT/APSInt.h" #include "llvm/ADT/SmallString.h" +#include "llvm/Support/LLVMSupportExports.h" #include "llvm/Support/raw_ostream.h" namespace llvm { @@ -30,7 +31,7 @@ /// if any). The scale represents the number of fractional bits in this type. /// When HasUnsignedPadding is true and this type is unsigned, the first bit /// in the value this represents is treated as padding. -class FixedPointSemantics { +class LLVM_SUPPORT_ABI FixedPointSemantics { public: FixedPointSemantics(unsigned Width, unsigned Scale, bool IsSigned, bool IsSaturated, bool HasUnsignedPadding) @@ -97,7 +98,7 @@ /// info about the fixed point type's width, sign, scale, and saturation, and /// provides different operations that would normally be performed on fixed point /// types. -class APFixedPoint { +class LLVM_SUPPORT_ABI APFixedPoint { public: APFixedPoint(const APInt &Val, const FixedPointSemantics &Sema) : Val(Val, !Sema.isSigned()), Sema(Sema) { diff --git a/llvm/include/llvm/ADT/APFloat.h b/llvm/include/llvm/ADT/APFloat.h --- a/llvm/include/llvm/ADT/APFloat.h +++ b/llvm/include/llvm/ADT/APFloat.h @@ -20,6 +20,8 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/FloatingPointMode.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/LLVMSupportExports.h" + #include #define APFLOAT_DISPATCH_ON_SEMANTICS(METHOD_CALL) \ @@ -140,7 +142,7 @@ // This is the common type definitions shared by APFloat and its internal // implementation classes. This struct should not define any non-static data // members. -struct APFloatBase { +struct LLVM_SUPPORT_ABI APFloatBase { typedef APInt::WordType integerPart; static constexpr unsigned integerPartWidth = APInt::APINT_BITS_PER_WORD; @@ -244,7 +246,7 @@ namespace detail { -class IEEEFloat final : public APFloatBase { +class LLVM_SUPPORT_ABI IEEEFloat final : public APFloatBase { public: /// \name Constructors /// @{ @@ -404,7 +406,7 @@ /// emphasizes producing different codes for different inputs in order to /// be used in canonicalization and memoization. As such, equality is /// bitwiseIsEqual, and 0 != -0. - friend hash_code hash_value(const IEEEFloat &Arg); + friend LLVM_SUPPORT_ABI hash_code hash_value(const IEEEFloat &Arg); /// Converts this value into a decimal string. /// @@ -448,12 +450,12 @@ /// 0 -> \c IEK_Zero /// Inf -> \c IEK_Inf /// - friend int ilogb(const IEEEFloat &Arg); + friend LLVM_SUPPORT_ABI int ilogb(const IEEEFloat &Arg); /// Returns: X * 2^Exp for integral exponents. - friend IEEEFloat scalbn(IEEEFloat X, int Exp, roundingMode); + friend LLVM_SUPPORT_ABI IEEEFloat scalbn(IEEEFloat X, int Exp, roundingMode); - friend IEEEFloat frexp(const IEEEFloat &X, int &Exp, roundingMode); + friend LLVM_SUPPORT_ABI IEEEFloat frexp(const IEEEFloat &X, int &Exp, roundingMode); /// \name Special value setters. /// @{ @@ -590,10 +592,10 @@ unsigned int sign : 1; }; -hash_code hash_value(const IEEEFloat &Arg); -int ilogb(const IEEEFloat &Arg); -IEEEFloat scalbn(IEEEFloat X, int Exp, IEEEFloat::roundingMode); -IEEEFloat frexp(const IEEEFloat &Val, int &Exp, IEEEFloat::roundingMode RM); +LLVM_SUPPORT_ABI hash_code hash_value(const IEEEFloat &Arg); +LLVM_SUPPORT_ABI int ilogb(const IEEEFloat &Arg); +LLVM_SUPPORT_ABI IEEEFloat scalbn(IEEEFloat X, int Exp, IEEEFloat::roundingMode); +LLVM_SUPPORT_ABI IEEEFloat frexp(const IEEEFloat &Val, int &Exp, IEEEFloat::roundingMode RM); // This mode implements more precise float in terms of two APFloats. // The interface and layout is designed for arbitrary underlying semantics, @@ -687,8 +689,8 @@ bool getExactInverse(APFloat *inv) const; - friend DoubleAPFloat scalbn(const DoubleAPFloat &X, int Exp, roundingMode); - friend DoubleAPFloat frexp(const DoubleAPFloat &X, int &Exp, roundingMode); + friend LLVM_SUPPORT_ABI DoubleAPFloat scalbn(const DoubleAPFloat &X, int Exp, roundingMode); + friend LLVM_SUPPORT_ABI DoubleAPFloat frexp(const DoubleAPFloat &X, int &Exp, roundingMode); friend hash_code hash_value(const DoubleAPFloat &Arg); }; @@ -698,7 +700,7 @@ // This is a interface class that is currently forwarding functionalities from // detail::IEEEFloat. -class APFloat : public APFloatBase { +class LLVM_SUPPORT_ABI APFloat : public APFloatBase { typedef detail::IEEEFloat IEEEFloat; typedef detail::DoubleAPFloat DoubleAPFloat; @@ -1248,7 +1250,7 @@ APFLOAT_DISPATCH_ON_SEMANTICS(getExactInverse(inv)); } - friend hash_code hash_value(const APFloat &Arg); + friend LLVM_SUPPORT_ABI hash_code hash_value(const APFloat &Arg); friend int ilogb(const APFloat &Arg) { return ilogb(Arg.getIEEE()); } friend APFloat scalbn(APFloat X, int Exp, roundingMode RM); friend APFloat frexp(const APFloat &X, int &Exp, roundingMode RM); @@ -1260,7 +1262,8 @@ /// /// These additional declarations are required in order to compile LLVM with IBM /// xlC compiler. -hash_code hash_value(const APFloat &Arg); +LLVM_SUPPORT_ABI hash_code hash_value(const APFloat &Arg); + inline APFloat scalbn(APFloat X, int Exp, APFloat::roundingMode RM) { if (APFloat::usesLayout(X.getSemantics())) return APFloat(scalbn(X.U.IEEE, Exp, RM), X.getSemantics()); 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_NODISCARD LLVM_SUPPORT_ABI APInt { public: typedef uint64_t WordType; @@ -686,7 +688,7 @@ } /// Overload to compute a hash_code for an APInt value. - friend hash_code hash_value(const APInt &Arg); + friend LLVM_SUPPORT_ABI hash_code hash_value(const APInt &Arg); /// This function returns a pointer to the internal storage of the APInt. /// This is useful for writing out the APInt in binary form without any @@ -2190,7 +2192,7 @@ /// using Stein's algorithm. /// /// \returns the greatest common divisor of A and B. -APInt GreatestCommonDivisor(APInt A, APInt B); +LLVM_SUPPORT_ABI APInt GreatestCommonDivisor(APInt A, APInt B); /// Converts the given APInt to a double value. /// @@ -2221,7 +2223,7 @@ /// Converts the given double value into a APInt. /// /// This function convert a double value to an APInt value. -APInt RoundDoubleToAPInt(double Double, unsigned width); +LLVM_SUPPORT_ABI APInt RoundDoubleToAPInt(double Double, unsigned width); /// Converts a float value into a APInt. /// @@ -2231,10 +2233,10 @@ } /// Return A unsign-divided by B, rounded by the given rounding mode. -APInt RoundingUDiv(const APInt &A, const APInt &B, APInt::Rounding RM); +LLVM_SUPPORT_ABI APInt RoundingUDiv(const APInt &A, const APInt &B, APInt::Rounding RM); /// Return A sign-divided by B, rounded by the given rounding mode. -APInt RoundingSDiv(const APInt &A, const APInt &B, APInt::Rounding RM); +LLVM_SUPPORT_ABI APInt RoundingSDiv(const APInt &A, const APInt &B, APInt::Rounding RM); /// Let q(n) = An^2 + Bn + C, and BW = bit width of the value range /// (e.g. 32 for i32). @@ -2269,7 +2271,7 @@ /// /// The returned value may have a different bit width from the input /// coefficients. -Optional SolveQuadraticEquationWrap(APInt A, APInt B, APInt C, +LLVM_SUPPORT_ABI Optional SolveQuadraticEquationWrap(APInt A, APInt B, APInt C, unsigned RangeWidth); /// Compare two values, and if they are different, return the position of the @@ -2281,18 +2283,18 @@ // See friend declaration above. This additional declaration is required in // order to compile LLVM with IBM xlC compiler. -hash_code hash_value(const APInt &Arg); +LLVM_SUPPORT_ABI hash_code hash_value(const APInt &Arg); /// StoreIntToMemory - Fills the StoreBytes bytes of memory starting from Dst /// with the integer held in IntVal. -void StoreIntToMemory(const APInt &IntVal, uint8_t *Dst, unsigned StoreBytes); +LLVM_SUPPORT_ABI void StoreIntToMemory(const APInt &IntVal, uint8_t *Dst, unsigned StoreBytes); /// LoadIntFromMemory - Loads the integer stored in the LoadBytes bytes starting /// from Src into IntVal, which is assumed to be wide enough and to hold zero. -void LoadIntFromMemory(APInt &IntVal, const uint8_t *Src, unsigned LoadBytes); +LLVM_SUPPORT_ABI void LoadIntFromMemory(APInt &IntVal, const uint8_t *Src, unsigned LoadBytes); /// Provide DenseMapInfo for APInt. -template <> struct DenseMapInfo { +template <> struct LLVM_SUPPORT_ABI DenseMapInfo { static inline APInt getEmptyKey() { APInt V(nullptr, 0); V.U.VAL = 0; diff --git a/llvm/include/llvm/ADT/APSInt.h b/llvm/include/llvm/ADT/APSInt.h --- a/llvm/include/llvm/ADT/APSInt.h +++ b/llvm/include/llvm/ADT/APSInt.h @@ -15,11 +15,12 @@ #define LLVM_ADT_APSINT_H #include "llvm/ADT/APInt.h" +#include "llvm/Support/LLVMSupportExports.h" namespace llvm { /// An arbitrary precision integer that knows its signedness. -class LLVM_NODISCARD APSInt : public APInt { +class LLVM_NODISCARD LLVM_SUPPORT_ABI APSInt : public APInt { bool IsUnsigned; public: 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; @@ -282,7 +284,7 @@ /// than using plain FoldingSetNodeIDs, since the 32-element SmallVector /// is often much larger than necessary, and the possibility of heap /// allocation means it requires a non-trivial destructor call. -class FoldingSetNodeIDRef { +class LLVM_SUPPORT_ABI FoldingSetNodeIDRef { const unsigned *Data = nullptr; size_t Size = 0; @@ -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; @@ -662,7 +664,7 @@ //===----------------------------------------------------------------------===// /// FoldingSetIteratorImpl - This is the common iterator support shared by all /// folding sets, which knows how to walk the folding set hash table. -class FoldingSetIteratorImpl { +class LLVM_SUPPORT_ABI FoldingSetIteratorImpl { protected: FoldingSetNode *NodePtr; diff --git a/llvm/include/llvm/ADT/Hashing.h b/llvm/include/llvm/ADT/Hashing.h --- a/llvm/include/llvm/ADT/Hashing.h +++ b/llvm/include/llvm/ADT/Hashing.h @@ -319,7 +319,7 @@ /// This variable can be set using the \see llvm::set_fixed_execution_seed /// function. See that function for details. Do not, under any circumstances, /// set or read this variable. -extern uint64_t fixed_seed_override; +extern LLVM_SUPPORT_ABI uint64_t fixed_seed_override; inline uint64_t get_execution_seed() { // FIXME: This needs to be a per-execution seed. This is just a placeholder 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/IntervalMap.h b/llvm/include/llvm/ADT/IntervalMap.h --- a/llvm/include/llvm/ADT/IntervalMap.h +++ b/llvm/include/llvm/ADT/IntervalMap.h @@ -108,7 +108,9 @@ #include "llvm/ADT/bit.h" #include "llvm/Support/AlignOf.h" #include "llvm/Support/Allocator.h" +#include "llvm/Support/LLVMSupportExports.h" #include "llvm/Support/RecyclingAllocator.h" + #include #include #include @@ -413,6 +415,7 @@ /// @param Position Insert position. /// @param Grow Reserve space for a new element at Position. /// @return (node, offset) for Position. +LLVM_SUPPORT_ABI IdxPair distribute(unsigned Nodes, unsigned Elements, unsigned Capacity, const unsigned *CurSize, unsigned NewSize[], unsigned Position, bool Grow); @@ -492,7 +495,7 @@ // //===----------------------------------------------------------------------===// -class NodeRef { +class LLVM_SUPPORT_ABI NodeRef { struct CacheAlignedPointerTraits { static inline void *getAsVoidPointer(void *P) { return P; } static inline void *getFromVoidPointer(void *P) { return P; } @@ -772,7 +775,7 @@ // //===----------------------------------------------------------------------===// -class Path { +class LLVM_SUPPORT_ABI Path { /// Entry - Each step in the path is a node pointer and an offset into that /// node. struct Entry { diff --git a/llvm/include/llvm/ADT/Optional.h b/llvm/include/llvm/ADT/Optional.h --- a/llvm/include/llvm/ADT/Optional.h +++ b/llvm/include/llvm/ADT/Optional.h @@ -19,7 +19,9 @@ #include "llvm/ADT/None.h" #include "llvm/ADT/STLForwardCompat.h" #include "llvm/Support/Compiler.h" +#include "llvm/Support/LLVMSupportExports.h" #include "llvm/Support/type_traits.h" + #include #include #include @@ -479,7 +481,7 @@ return !(X < Y); } -raw_ostream &operator<<(raw_ostream &OS, NoneType); +LLVM_SUPPORT_ABI raw_ostream &operator<<(raw_ostream &OS, NoneType); template () << std::declval())> 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/SmallVector.h b/llvm/include/llvm/ADT/SmallVector.h --- a/llvm/include/llvm/ADT/SmallVector.h +++ b/llvm/include/llvm/ADT/SmallVector.h @@ -16,8 +16,10 @@ #include "llvm/ADT/iterator_range.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/LLVMSupportExports.h" #include "llvm/Support/MemAlloc.h" #include "llvm/Support/type_traits.h" + #include #include #include @@ -59,12 +61,12 @@ /// This is a helper for \a grow() that's out of line to reduce code /// duplication. This function will report a fatal error if it can't grow at /// least to \p MinSize. - void *mallocForGrow(size_t MinSize, size_t TSize, size_t &NewCapacity); + LLVM_SUPPORT_ABI void *mallocForGrow(size_t MinSize, size_t TSize, size_t &NewCapacity); /// This is an implementation of the grow() method which only works /// on POD-like data types and is out of line to reduce code duplication. /// This function will report a fatal error if it cannot increase capacity. - void grow_pod(void *FirstEl, size_t MinSize, size_t TSize); + LLVM_SUPPORT_ABI void grow_pod(void *FirstEl, size_t MinSize, size_t TSize); public: size_t size() const { return Size; } @@ -87,6 +89,11 @@ } }; +extern template LLVM_SUPPORT_ABI SmallVectorBase; +#if SIZE_MAX > UINT32_MAX +extern template LLVM_SUPPORT_ABI SmallVectorBase; +#endif + template using SmallVectorSizeType = typename std::conditional= 8, uint64_t, diff --git a/llvm/include/llvm/ADT/Statistic.h b/llvm/include/llvm/ADT/Statistic.h --- a/llvm/include/llvm/ADT/Statistic.h +++ b/llvm/include/llvm/ADT/Statistic.h @@ -27,6 +27,8 @@ #include "llvm/Config/llvm-config.h" #include "llvm/Support/Compiler.h" +#include "llvm/Support/LLVMSupportExports.h" + #include #include #include @@ -46,7 +48,7 @@ class raw_fd_ostream; class StringRef; -class TrackingStatistic { +class LLVM_SUPPORT_ABI TrackingStatistic { public: const char *const DebugType; const char *const Name; @@ -172,25 +174,25 @@ static llvm::TrackingStatistic VARNAME = {DEBUG_TYPE, #VARNAME, DESC} /// Enable the collection and printing of statistics. -void EnableStatistics(bool DoPrintOnExit = true); +LLVM_SUPPORT_ABI void EnableStatistics(bool DoPrintOnExit = true); /// Check if statistics are enabled. -bool AreStatisticsEnabled(); +LLVM_SUPPORT_ABI bool AreStatisticsEnabled(); /// Return a file stream to print our output on. -std::unique_ptr CreateInfoOutputFile(); +LLVM_SUPPORT_ABI std::unique_ptr CreateInfoOutputFile(); /// Print statistics to the file returned by CreateInfoOutputFile(). -void PrintStatistics(); +LLVM_SUPPORT_ABI void PrintStatistics(); /// Print statistics to the given output stream. -void PrintStatistics(raw_ostream &OS); +LLVM_SUPPORT_ABI void PrintStatistics(raw_ostream &OS); /// Print statistics in JSON format. This does include all global timers (\see /// Timer, TimerGroup). Note that the timers are cleared after printing and will /// not be printed in human readable form or in a second call of /// PrintStatisticsJSON(). -void PrintStatisticsJSON(raw_ostream &OS); +LLVM_SUPPORT_ABI void PrintStatisticsJSON(raw_ostream &OS); /// Get the statistics. This can be used to look up the value of /// statistics without needing to parse JSON. 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 @@ -311,7 +313,7 @@ /// StrInStrNoCase - Portable version of strcasestr. Locates the first /// occurrence of string 's1' in string 's2', ignoring case. Returns /// the offset of s2 in s1 or npos if s2 cannot be found. -StringRef::size_type StrInStrNoCase(StringRef s1, StringRef s2); +LLVM_SUPPORT_ABI StringRef::size_type StrInStrNoCase(StringRef s1, StringRef s2); /// getToken - This function extracts one token from source, ignoring any /// leading characters that appear in the Delimiters string, and ending the @@ -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"); @@ -349,14 +353,14 @@ /// Print each character of the specified string, escaping it if it is not /// printable or if it is an escape char. -void printEscapedString(StringRef Name, raw_ostream &Out); +LLVM_SUPPORT_ABI void printEscapedString(StringRef Name, raw_ostream &Out); /// Print each character of the specified string, escaping HTML special /// characters. -void printHTMLEscaped(StringRef String, raw_ostream &Out); +LLVM_SUPPORT_ABI void printHTMLEscaped(StringRef String, raw_ostream &Out); /// printLowerCase - Print each character as lowercase if it is uppercase. -void printLowerCase(StringRef String, raw_ostream &Out); +LLVM_SUPPORT_ABI void printLowerCase(StringRef String, raw_ostream &Out); /// Converts a string from camel-case to snake-case by replacing all uppercase /// letters with '_' followed by the letter in lowercase, except if the 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,13 +41,18 @@ class StringRef; /// Helper functions for StringRef::getAsInteger. + LLVM_SUPPORT_ABI bool getAsUnsignedInteger(StringRef Str, unsigned Radix, unsigned long long &Result); + LLVM_SUPPORT_ABI bool getAsSignedInteger(StringRef Str, unsigned Radix, long long &Result); + LLVM_SUPPORT_ABI bool consumeUnsignedInteger(StringRef &Str, unsigned Radix, unsigned long long &Result); + + LLVM_SUPPORT_ABI bool consumeSignedInteger(StringRef &Str, unsigned Radix, long long &Result); /// StringRef - Represent a constant reference to a string, i.e. a character @@ -55,7 +62,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 +952,7 @@ /// @} /// Compute a hash_code for a StringRef. - LLVM_NODISCARD + LLVM_NODISCARD LLVM_SUPPORT_ABI hash_code hash_value(StringRef S); // Provide DenseMapInfo for StringRefs. diff --git a/llvm/include/llvm/ADT/Triple.h b/llvm/include/llvm/ADT/Triple.h --- a/llvm/include/llvm/ADT/Triple.h +++ b/llvm/include/llvm/ADT/Triple.h @@ -10,6 +10,7 @@ #define LLVM_ADT_TRIPLE_H #include "llvm/ADT/Twine.h" +#include "llvm/Support/LLVMSupportExports.h" // Some system headers or GCC predefined macros conflict with identifiers in // this file. Undefine them here. @@ -42,7 +43,7 @@ /// /// See autoconf/config.guess for a glimpse into what configuration names /// look like in practice. -class Triple { +class LLVM_SUPPORT_ABI Triple { public: enum ArchType { UnknownArch, 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/AArch64TargetParser.h b/llvm/include/llvm/Support/AArch64TargetParser.h --- a/llvm/include/llvm/Support/AArch64TargetParser.h +++ b/llvm/include/llvm/Support/AArch64TargetParser.h @@ -17,6 +17,8 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/ARMTargetParser.h" +#include "llvm/Support/LLVMSupportExports.h" + #include // FIXME:This should be made into class design,to avoid dupplication. @@ -111,31 +113,31 @@ }; // FIXME: These should be moved to TargetTuple once it exists -bool getExtensionFeatures(uint64_t Extensions, +LLVM_SUPPORT_ABI bool getExtensionFeatures(uint64_t Extensions, std::vector &Features); -bool getArchFeatures(ArchKind AK, std::vector &Features); +LLVM_SUPPORT_ABI bool getArchFeatures(ArchKind AK, std::vector &Features); StringRef getArchName(ArchKind AK); unsigned getArchAttr(ArchKind AK); StringRef getCPUAttr(ArchKind AK); StringRef getSubArch(ArchKind AK); StringRef getArchExtName(unsigned ArchExtKind); -StringRef getArchExtFeature(StringRef ArchExt); +LLVM_SUPPORT_ABI StringRef getArchExtFeature(StringRef ArchExt); // Information by Name unsigned getDefaultFPU(StringRef CPU, ArchKind AK); -uint64_t getDefaultExtensions(StringRef CPU, ArchKind AK); +LLVM_SUPPORT_ABI uint64_t getDefaultExtensions(StringRef CPU, ArchKind AK); StringRef getDefaultCPU(StringRef Arch); -ArchKind getCPUArchKind(StringRef CPU); +LLVM_SUPPORT_ABI ArchKind getCPUArchKind(StringRef CPU); // Parser -ArchKind parseArch(StringRef Arch); +LLVM_SUPPORT_ABI ArchKind parseArch(StringRef Arch); ArchExtKind parseArchExt(StringRef ArchExt); -ArchKind parseCPUArch(StringRef CPU); +LLVM_SUPPORT_ABI ArchKind parseCPUArch(StringRef CPU); // Used by target parser tests -void fillValidCPUArchList(SmallVectorImpl &Values); +LLVM_SUPPORT_ABI void fillValidCPUArchList(SmallVectorImpl &Values); -bool isX18ReservedByDefault(const Triple &TT); +LLVM_SUPPORT_ABI bool isX18ReservedByDefault(const Triple &TT); struct ParsedBranchProtection { StringRef Scope; @@ -143,7 +145,7 @@ bool BranchTargetEnforcement; }; -bool parseBranchProtection(StringRef Spec, ParsedBranchProtection &PBP, +LLVM_SUPPORT_ABI bool parseBranchProtection(StringRef Spec, ParsedBranchProtection &PBP, StringRef &Err); } // namespace AArch64 diff --git a/llvm/include/llvm/Support/AMDGPUMetadata.h b/llvm/include/llvm/Support/AMDGPUMetadata.h --- a/llvm/include/llvm/Support/AMDGPUMetadata.h +++ b/llvm/include/llvm/Support/AMDGPUMetadata.h @@ -16,6 +16,8 @@ #define LLVM_SUPPORT_AMDGPUMETADATA_H #include "llvm/ADT/StringRef.h" +#include "llvm/Support/LLVMSupportExports.h" + #include #include #include @@ -441,10 +443,10 @@ }; /// Converts \p String to \p HSAMetadata. -std::error_code fromString(StringRef String, Metadata &HSAMetadata); +LLVM_SUPPORT_ABI std::error_code fromString(StringRef String, Metadata &HSAMetadata); /// Converts \p HSAMetadata to \p String. -std::error_code toString(Metadata HSAMetadata, std::string &String); +LLVM_SUPPORT_ABI std::error_code toString(Metadata HSAMetadata, std::string &String); //===----------------------------------------------------------------------===// // HSA metadata for v3 code object. diff --git a/llvm/include/llvm/Support/ARMAttributeParser.h b/llvm/include/llvm/Support/ARMAttributeParser.h --- a/llvm/include/llvm/Support/ARMAttributeParser.h +++ b/llvm/include/llvm/Support/ARMAttributeParser.h @@ -16,11 +16,12 @@ #include "llvm/Support/DataExtractor.h" #include "llvm/Support/Endian.h" #include "llvm/Support/Error.h" +#include "llvm/Support/LLVMSupportExports.h" namespace llvm { class StringRef; -class ARMAttributeParser : public ELFAttributeParser { +class LLVM_SUPPORT_ABI ARMAttributeParser : public ELFAttributeParser { struct DisplayHandler { ARMBuildAttrs::AttrType attribute; Error (ARMAttributeParser::*routine)(ARMBuildAttrs::AttrType); diff --git a/llvm/include/llvm/Support/ARMBuildAttributes.h b/llvm/include/llvm/Support/ARMBuildAttributes.h --- a/llvm/include/llvm/Support/ARMBuildAttributes.h +++ b/llvm/include/llvm/Support/ARMBuildAttributes.h @@ -19,11 +19,12 @@ #define LLVM_SUPPORT_ARMBUILDATTRIBUTES_H #include "llvm/Support/ELFAttributes.h" +#include "llvm/Support/LLVMSupportExports.h" namespace llvm { namespace ARMBuildAttrs { -const TagNameMap &getARMAttributeTags(); +LLVM_SUPPORT_ABI const TagNameMap &getARMAttributeTags(); enum SpecialAttr { // This is for the .cpu asm attr. It translates into one or more diff --git a/llvm/include/llvm/Support/ARMTargetParser.h b/llvm/include/llvm/Support/ARMTargetParser.h --- a/llvm/include/llvm/Support/ARMTargetParser.h +++ b/llvm/include/llvm/Support/ARMTargetParser.h @@ -17,6 +17,8 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/ARMBuildAttributes.h" +#include "llvm/Support/LLVMSupportExports.h" + #include namespace llvm { @@ -232,48 +234,48 @@ }; // Information by ID -StringRef getFPUName(unsigned FPUKind); +LLVM_SUPPORT_ABI StringRef getFPUName(unsigned FPUKind); FPUVersion getFPUVersion(unsigned FPUKind); NeonSupportLevel getFPUNeonSupportLevel(unsigned FPUKind); FPURestriction getFPURestriction(unsigned FPUKind); // FIXME: These should be moved to TargetTuple once it exists -bool getFPUFeatures(unsigned FPUKind, std::vector &Features); -bool getHWDivFeatures(uint64_t HWDivKind, std::vector &Features); -bool getExtensionFeatures(uint64_t Extensions, +LLVM_SUPPORT_ABI bool getFPUFeatures(unsigned FPUKind, std::vector &Features); +LLVM_SUPPORT_ABI bool getHWDivFeatures(uint64_t HWDivKind, std::vector &Features); +LLVM_SUPPORT_ABI bool getExtensionFeatures(uint64_t Extensions, std::vector &Features); -StringRef getArchName(ArchKind AK); -unsigned getArchAttr(ArchKind AK); -StringRef getCPUAttr(ArchKind AK); -StringRef getSubArch(ArchKind AK); -StringRef getArchExtName(uint64_t ArchExtKind); +LLVM_SUPPORT_ABI StringRef getArchName(ArchKind AK); +LLVM_SUPPORT_ABI unsigned getArchAttr(ArchKind AK); +LLVM_SUPPORT_ABI StringRef getCPUAttr(ArchKind AK); +LLVM_SUPPORT_ABI StringRef getSubArch(ArchKind AK); +LLVM_SUPPORT_ABI StringRef getArchExtName(uint64_t ArchExtKind); StringRef getArchExtFeature(StringRef ArchExt); -bool appendArchExtFeatures(StringRef CPU, ARM::ArchKind AK, StringRef ArchExt, +LLVM_SUPPORT_ABI bool appendArchExtFeatures(StringRef CPU, ARM::ArchKind AK, StringRef ArchExt, std::vector &Features, unsigned &ArgFPUKind); // Information by Name -unsigned getDefaultFPU(StringRef CPU, ArchKind AK); -uint64_t getDefaultExtensions(StringRef CPU, ArchKind AK); -StringRef getDefaultCPU(StringRef Arch); +LLVM_SUPPORT_ABI unsigned getDefaultFPU(StringRef CPU, ArchKind AK); +LLVM_SUPPORT_ABI uint64_t getDefaultExtensions(StringRef CPU, ArchKind AK); +LLVM_SUPPORT_ABI StringRef getDefaultCPU(StringRef Arch); StringRef getCanonicalArchName(StringRef Arch); StringRef getFPUSynonym(StringRef FPU); StringRef getArchSynonym(StringRef Arch); // Parser -uint64_t parseHWDiv(StringRef HWDiv); -unsigned parseFPU(StringRef FPU); -ArchKind parseArch(StringRef Arch); -uint64_t parseArchExt(StringRef ArchExt); -ArchKind parseCPUArch(StringRef CPU); -ISAKind parseArchISA(StringRef Arch); +LLVM_SUPPORT_ABI uint64_t parseHWDiv(StringRef HWDiv); +LLVM_SUPPORT_ABI unsigned parseFPU(StringRef FPU); +LLVM_SUPPORT_ABI ArchKind parseArch(StringRef Arch); +LLVM_SUPPORT_ABI uint64_t parseArchExt(StringRef ArchExt); +LLVM_SUPPORT_ABI ArchKind parseCPUArch(StringRef CPU); +LLVM_SUPPORT_ABI ISAKind parseArchISA(StringRef Arch); EndianKind parseArchEndian(StringRef Arch); -ProfileKind parseArchProfile(StringRef Arch); -unsigned parseArchVersion(StringRef Arch); +LLVM_SUPPORT_ABI ProfileKind parseArchProfile(StringRef Arch); +LLVM_SUPPORT_ABI unsigned parseArchVersion(StringRef Arch); -void fillValidCPUArchList(SmallVectorImpl &Values); -StringRef computeDefaultTargetABI(const Triple &TT, StringRef CPU); +LLVM_SUPPORT_ABI void fillValidCPUArchList(SmallVectorImpl &Values); +LLVM_SUPPORT_ABI StringRef computeDefaultTargetABI(const Triple &TT, StringRef CPU); } // namespace ARM } // namespace llvm diff --git a/llvm/include/llvm/Support/ARMWinEH.h b/llvm/include/llvm/Support/ARMWinEH.h --- a/llvm/include/llvm/Support/ARMWinEH.h +++ b/llvm/include/llvm/Support/ARMWinEH.h @@ -11,6 +11,7 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/Support/Endian.h" +#include "llvm/Support/LLVMSupportExports.h" namespace llvm { namespace ARM { @@ -205,7 +206,8 @@ /// SavedRegisterMask - Utility function to calculate the set of saved general /// purpose (r0-r15) and VFP (d0-d31) registers. -std::pair SavedRegisterMask(const RuntimeFunction &RF); +LLVM_SUPPORT_ABI std::pair +SavedRegisterMask(const RuntimeFunction &RF); /// RuntimeFunctionARM64 - An entry in the table of procedure data (.pdata) /// diff --git a/llvm/include/llvm/Support/Allocator.h b/llvm/include/llvm/Support/Allocator.h --- a/llvm/include/llvm/Support/Allocator.h +++ b/llvm/include/llvm/Support/Allocator.h @@ -23,8 +23,10 @@ #include "llvm/Support/AllocatorBase.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/LLVMSupportExports.h" #include "llvm/Support/MathExtras.h" #include "llvm/Support/MemAlloc.h" + #include #include #include @@ -40,7 +42,7 @@ // We call out to an external function to actually print the message as the // printing code uses Allocator.h in its implementation. -void printBumpPtrAllocatorStats(unsigned NumSlabs, size_t BytesAllocated, +LLVM_SUPPORT_ABI void printBumpPtrAllocatorStats(unsigned NumSlabs, size_t BytesAllocated, size_t TotalMemory); } // end namespace detail diff --git a/llvm/include/llvm/Support/BinaryStreamError.h b/llvm/include/llvm/Support/BinaryStreamError.h --- a/llvm/include/llvm/Support/BinaryStreamError.h +++ b/llvm/include/llvm/Support/BinaryStreamError.h @@ -11,6 +11,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/Support/Error.h" +#include "llvm/Support/LLVMSupportExports.h" #include @@ -24,7 +25,7 @@ }; /// Base class for errors originating when parsing raw PDB files -class BinaryStreamError : public ErrorInfo { +class LLVM_SUPPORT_ABI BinaryStreamError : public ErrorInfo { public: static char ID; explicit BinaryStreamError(stream_error_code C); diff --git a/llvm/include/llvm/Support/BinaryStreamReader.h b/llvm/include/llvm/Support/BinaryStreamReader.h --- a/llvm/include/llvm/Support/BinaryStreamReader.h +++ b/llvm/include/llvm/Support/BinaryStreamReader.h @@ -18,7 +18,9 @@ #include "llvm/Support/ConvertUTF.h" #include "llvm/Support/Endian.h" #include "llvm/Support/Error.h" +#include "llvm/Support/LLVMSupportExports.h" #include "llvm/Support/type_traits.h" + #include namespace llvm { @@ -28,7 +30,7 @@ /// null-terminated strings, integers in various flavors of endianness, etc. /// Can be subclassed to provide reading of custom datatypes, although no /// are overridable. -class BinaryStreamReader { +class LLVM_SUPPORT_ABI BinaryStreamReader { public: BinaryStreamReader() = default; explicit BinaryStreamReader(BinaryStreamRef Ref); diff --git a/llvm/include/llvm/Support/BinaryStreamRef.h b/llvm/include/llvm/Support/BinaryStreamRef.h --- a/llvm/include/llvm/Support/BinaryStreamRef.h +++ b/llvm/include/llvm/Support/BinaryStreamRef.h @@ -14,6 +14,8 @@ #include "llvm/Support/BinaryStream.h" #include "llvm/Support/BinaryStreamError.h" #include "llvm/Support/Error.h" +#include "llvm/Support/LLVMSupportExports.h" + #include #include #include @@ -153,7 +155,7 @@ /// general, you should not pass around pointers or references to BinaryStreams /// and use inheritance to achieve polymorphism. Instead, you should pass /// around BinaryStreamRefs by value and achieve polymorphism that way. -class BinaryStreamRef +class LLVM_SUPPORT_ABI BinaryStreamRef : public BinaryStreamRefBase { friend BinaryStreamRefBase; friend class WritableBinaryStreamRef; @@ -219,7 +221,7 @@ bool empty() const { return size() == 0; } }; -class WritableBinaryStreamRef +class LLVM_SUPPORT_ABI WritableBinaryStreamRef : public BinaryStreamRefBase { friend BinaryStreamRefBase; diff --git a/llvm/include/llvm/Support/BinaryStreamWriter.h b/llvm/include/llvm/Support/BinaryStreamWriter.h --- a/llvm/include/llvm/Support/BinaryStreamWriter.h +++ b/llvm/include/llvm/Support/BinaryStreamWriter.h @@ -17,6 +17,8 @@ #include "llvm/Support/BinaryStreamRef.h" #include "llvm/Support/Endian.h" #include "llvm/Support/Error.h" +#include "llvm/Support/LLVMSupportExports.h" + #include #include #include @@ -28,7 +30,7 @@ /// such as null-terminated strings, integers in various flavors of endianness, /// etc. Can be subclassed to provide reading and writing of custom datatypes, /// although no methods are overridable. -class BinaryStreamWriter { +class LLVM_SUPPORT_ABI BinaryStreamWriter { public: BinaryStreamWriter() = default; explicit BinaryStreamWriter(WritableBinaryStreamRef Ref); diff --git a/llvm/include/llvm/Support/BlockFrequency.h b/llvm/include/llvm/Support/BlockFrequency.h --- a/llvm/include/llvm/Support/BlockFrequency.h +++ b/llvm/include/llvm/Support/BlockFrequency.h @@ -15,13 +15,14 @@ #include "llvm/Support/BranchProbability.h" #include "llvm/Support/DataTypes.h" +#include "llvm/Support/LLVMSupportExports.h" namespace llvm { class raw_ostream; // This class represents Block Frequency as a 64-bit value. -class BlockFrequency { +class LLVM_SUPPORT_ABI BlockFrequency { uint64_t Frequency; public: diff --git a/llvm/include/llvm/Support/BranchProbability.h b/llvm/include/llvm/Support/BranchProbability.h --- a/llvm/include/llvm/Support/BranchProbability.h +++ b/llvm/include/llvm/Support/BranchProbability.h @@ -14,6 +14,8 @@ #define LLVM_SUPPORT_BRANCHPROBABILITY_H #include "llvm/Support/DataTypes.h" +#include "llvm/Support/LLVMSupportExports.h" + #include #include #include @@ -27,7 +29,7 @@ // no greater than 1. It uses a fixed-point-like implementation, in which the // denominator is always a constant value (here we use 1<<31 for maximum // precision). -class BranchProbability { +class LLVM_SUPPORT_ABI BranchProbability { // Numerator uint32_t N; diff --git a/llvm/include/llvm/Support/BuryPointer.h b/llvm/include/llvm/Support/BuryPointer.h --- a/llvm/include/llvm/Support/BuryPointer.h +++ b/llvm/include/llvm/Support/BuryPointer.h @@ -9,6 +9,8 @@ #ifndef LLVM_SUPPORT_BURYPOINTER_H #define LLVM_SUPPORT_BURYPOINTER_H +#include "llvm/Support/LLVMSupportExports.h" + #include namespace llvm { @@ -19,7 +21,8 @@ // the memory is not misdiagnosed as an unintentional leak by leak detection // tools (this is achieved by preserving pointers to the object in a globally // visible array). -void BuryPointer(const void *Ptr); +LLVM_SUPPORT_ABI void BuryPointer(const void *Ptr); + template void BuryPointer(std::unique_ptr Ptr) { BuryPointer(Ptr.release()); } diff --git a/llvm/include/llvm/Support/COM.h b/llvm/include/llvm/Support/COM.h --- a/llvm/include/llvm/Support/COM.h +++ b/llvm/include/llvm/Support/COM.h @@ -14,12 +14,14 @@ #ifndef LLVM_SUPPORT_COM_H #define LLVM_SUPPORT_COM_H +#include "llvm/Support/LLVMSupportExports.h" + namespace llvm { namespace sys { enum class COMThreadingMode { SingleThreaded, MultiThreaded }; -class InitializeCOMRAII { +class LLVM_SUPPORT_ABI InitializeCOMRAII { public: explicit InitializeCOMRAII(COMThreadingMode Threading, bool SpeedOverMemory = false); diff --git a/llvm/include/llvm/Support/CRC.h b/llvm/include/llvm/Support/CRC.h --- a/llvm/include/llvm/Support/CRC.h +++ b/llvm/include/llvm/Support/CRC.h @@ -14,16 +14,17 @@ #define LLVM_SUPPORT_CRC_H #include "llvm/Support/DataTypes.h" +#include "llvm/Support/LLVMSupportExports.h" namespace llvm { template class ArrayRef; // Compute the CRC-32 of Data. -uint32_t crc32(ArrayRef Data); +LLVM_SUPPORT_ABI uint32_t crc32(ArrayRef Data); // Compute the running CRC-32 of Data, with CRC being the previous value of the // checksum. -uint32_t crc32(uint32_t CRC, ArrayRef Data); +LLVM_SUPPORT_ABI uint32_t crc32(uint32_t CRC, ArrayRef Data); // Class for computing the JamCRC. // @@ -42,7 +43,7 @@ // // N.B. We permit flexibility of the "Init" value. Some consumers of this need // it to be zero. -class JamCRC { +class LLVM_SUPPORT_ABI JamCRC { public: JamCRC(uint32_t Init = 0xFFFFFFFFU) : CRC(Init) {} diff --git a/llvm/include/llvm/Support/CachePruning.h b/llvm/include/llvm/Support/CachePruning.h --- a/llvm/include/llvm/Support/CachePruning.h +++ b/llvm/include/llvm/Support/CachePruning.h @@ -15,6 +15,8 @@ #define LLVM_SUPPORT_CACHEPRUNING_H #include "llvm/ADT/Optional.h" +#include "llvm/Support/LLVMSupportExports.h" + #include namespace llvm { @@ -73,7 +75,7 @@ /// As a safeguard against data loss if the user specifies the wrong directory /// as their cache directory, this function will ignore files not matching the /// pattern "llvmcache-*". -bool pruneCache(StringRef Path, CachePruningPolicy Policy); +LLVM_SUPPORT_ABI bool pruneCache(StringRef Path, CachePruningPolicy Policy); } // namespace llvm diff --git a/llvm/include/llvm/Support/Chrono.h b/llvm/include/llvm/Support/Chrono.h --- a/llvm/include/llvm/Support/Chrono.h +++ b/llvm/include/llvm/Support/Chrono.h @@ -11,6 +11,7 @@ #include "llvm/Support/Compiler.h" #include "llvm/Support/FormatProviders.h" +#include "llvm/Support/LLVMSupportExports.h" #include #include @@ -56,6 +57,7 @@ } // namespace sys +LLVM_SUPPORT_ABI raw_ostream &operator<<(raw_ostream &OS, sys::TimePoint<> TP); /// Format provider for TimePoint<> @@ -67,7 +69,7 @@ /// /// If no options are given, the default format is "%Y-%m-%d %H:%M:%S.%N". template <> -struct format_provider> { +struct LLVM_SUPPORT_ABI format_provider> { static void format(const sys::TimePoint<> &TP, llvm::raw_ostream &OS, StringRef Style); }; @@ -76,12 +78,12 @@ template struct unit { static const char value[]; }; template const char unit::value[] = ""; -template <> struct unit> { static const char value[]; }; -template <> struct unit> { static const char value[]; }; -template <> struct unit> { static const char value[]; }; -template <> struct unit { static const char value[]; }; -template <> struct unit { static const char value[]; }; -template <> struct unit { static const char value[]; }; +template <> struct LLVM_SUPPORT_ABI unit> { static const char value[]; }; +template <> struct LLVM_SUPPORT_ABI unit> { static const char value[]; }; +template <> struct LLVM_SUPPORT_ABI unit> { static const char value[]; }; +template <> struct LLVM_SUPPORT_ABI unit { static const char value[]; }; +template <> struct LLVM_SUPPORT_ABI unit { static const char value[]; }; +template <> struct LLVM_SUPPORT_ABI unit { static const char value[]; }; } // namespace detail /// Implementation of format_provider for duration types. 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, @@ -82,7 +85,7 @@ /// used to print out the version when --version is given /// on the command line. This allows other systems using the /// CommandLine utilities to print their own version string. -void SetVersionPrinter(VersionPrinterTy func); +LLVM_SUPPORT_ABI void SetVersionPrinter(VersionPrinterTy func); ///===---------------------------------------------------------------------===// /// AddExtraVersionPrinter - Add an extra printer to use in addition to the @@ -91,13 +94,13 @@ /// which will be called after the basic LLVM version /// printing is complete. Each can then add additional /// information specific to the tool. -void AddExtraVersionPrinter(VersionPrinterTy func); +LLVM_SUPPORT_ABI void AddExtraVersionPrinter(VersionPrinterTy func); // PrintOptionValues - Print option values. // With -print-options print the difference between option values and defaults. // With -print-all-options print all option values. // (Currently not perfect, but best-effort.) -void PrintOptionValues(); +LLVM_SUPPORT_ABI void PrintOptionValues(); // Forward declaration - AddLiteralOption needs to be up here to make gcc happy. class Option; @@ -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; @@ -202,12 +206,12 @@ }; // The general Option Category (used as default category). -OptionCategory &getGeneralCategory(); +LLVM_SUPPORT_ABI OptionCategory &getGeneralCategory(); //===----------------------------------------------------------------------===// // SubCommand class // -class SubCommand { +class LLVM_SUPPORT_ABI SubCommand { private: StringRef Name; StringRef Description; @@ -238,15 +242,15 @@ }; // A special subcommand representing no subcommand -extern ManagedStatic TopLevelSubCommand; +extern LLVM_SUPPORT_ABI ManagedStatic TopLevelSubCommand; // A special subcommand that can be used to put an option into all subcommands. -extern ManagedStatic AllSubCommands; +extern LLVM_SUPPORT_ABI ManagedStatic AllSubCommands; //===----------------------------------------------------------------------===// // 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: @@ -638,7 +642,7 @@ } private: - void anchor() override; + LLVM_SUPPORT_ABI void anchor() override; }; template <> @@ -655,7 +659,7 @@ } private: - void anchor() override; + LLVM_SUPPORT_ABI void anchor() override; }; //===----------------------------------------------------------------------===// @@ -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) {} @@ -953,7 +957,7 @@ //-------------------------------------------------- // parser -template <> class parser : public basic_parser { +template <> class LLVM_SUPPORT_ABI parser : public basic_parser { public: parser(Option &O) : basic_parser(O) {} @@ -979,7 +983,7 @@ //-------------------------------------------------- // parser // -template <> class parser : public basic_parser { +template <> class LLVM_SUPPORT_ABI parser : public basic_parser { public: parser(Option &O) : basic_parser(O) {} @@ -1023,7 +1027,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) {} @@ -1091,7 +1095,7 @@ // parser // template <> -class parser : public basic_parser { +class LLVM_SUPPORT_ABI parser : public basic_parser { public: parser(Option &O) : basic_parser(O) {} @@ -1114,7 +1118,7 @@ //-------------------------------------------------- // parser // -template <> class parser : public basic_parser { +template <> class LLVM_SUPPORT_ABI parser : public basic_parser { public: parser(Option &O) : basic_parser(O) {} @@ -1136,7 +1140,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) {} @@ -1183,7 +1187,7 @@ //-------------------------------------------------- // parser // -template <> class parser : public basic_parser { +template <> class LLVM_SUPPORT_ABI parser : public basic_parser { public: parser(Option &O) : basic_parser(O) {} @@ -1859,7 +1863,7 @@ // Aliased command line option (alias this name to a preexisting name) // -class alias : public Option { +class LLVM_SUPPORT_ABI alias : public Option { Option *AliasFor; bool handleOccurrence(unsigned pos, StringRef /*ArgName*/, @@ -1930,20 +1934,20 @@ // output. All occurrences of cl::extrahelp will be accumulated and // printed to stderr at the end of the regular help, just before // exit is called. -struct extrahelp { +struct LLVM_SUPPORT_ABI extrahelp { StringRef morehelp; explicit extrahelp(StringRef help); }; -void PrintVersionMessage(); +LLVM_SUPPORT_ABI void PrintVersionMessage(); /// This function just prints the help message, exactly the same way as if the /// -help or -help-hidden option had been given on the command line. /// /// \param Hidden if true will print hidden options /// \param Categorized if true print options in categories -void PrintHelpMessage(bool Hidden = false, bool Categorized = false); +LLVM_SUPPORT_ABI void PrintHelpMessage(bool Hidden = false, bool Categorized = false); //===----------------------------------------------------------------------===// // Public interface for accessing registered options. @@ -2016,7 +2020,7 @@ /// \param [in] MarkEOLs true if tokenizing a response file and you want end of /// lines and end of the response file to be marked with a nullptr string. /// \param [out] NewArgv All parsed strings are appended to NewArgv. -void TokenizeGNUCommandLine(StringRef Source, StringSaver &Saver, +LLVM_SUPPORT_ABI void TokenizeGNUCommandLine(StringRef Source, StringSaver &Saver, SmallVectorImpl &NewArgv, bool MarkEOLs = false); @@ -2031,7 +2035,7 @@ /// \param [in] MarkEOLs true if tokenizing a response file and you want end of /// lines and end of the response file to be marked with a nullptr string. /// \param [out] NewArgv All parsed strings are appended to NewArgv. -void TokenizeWindowsCommandLine(StringRef Source, StringSaver &Saver, +LLVM_SUPPORT_ABI void TokenizeWindowsCommandLine(StringRef Source, StringSaver &Saver, SmallVectorImpl &NewArgv, bool MarkEOLs = false); @@ -2072,7 +2076,7 @@ /// commands resolving file names in them relative to the directory where /// CfgFilename resides. /// -bool readConfigFile(StringRef CfgFileName, StringSaver &Saver, +LLVM_SUPPORT_ABI bool readConfigFile(StringRef CfgFileName, StringSaver &Saver, SmallVectorImpl &Argv); /// Expand response files on a command line recursively using the given @@ -2094,7 +2098,7 @@ /// \param [in] CurrentDir Path used to resolve relative rsp files. If set to /// None, process' cwd is used instead. /// \return true if all @files were expanded successfully or there were none. -bool ExpandResponseFiles(StringSaver &Saver, TokenizerCallback Tokenizer, +LLVM_SUPPORT_ABI bool ExpandResponseFiles(StringSaver &Saver, TokenizerCallback Tokenizer, SmallVectorImpl &Argv, bool MarkEOLs, bool RelativeNames, llvm::Optional CurrentDir, @@ -2102,7 +2106,7 @@ /// An overload of ExpandResponseFiles() that uses /// llvm::vfs::getRealFileSystem(). -bool ExpandResponseFiles( +LLVM_SUPPORT_ABI bool ExpandResponseFiles( StringSaver &Saver, TokenizerCallback Tokenizer, SmallVectorImpl &Argv, bool MarkEOLs = false, bool RelativeNames = false, @@ -2112,7 +2116,7 @@ /// environment variable EnvVar and command line options, then expands response /// files recursively. The tokenizer is a predefined GNU or Windows one. /// \return true if all @files were expanded successfully or there were none. -bool expandResponseFiles(int Argc, const char *const *Argv, const char *EnvVar, +LLVM_SUPPORT_ABI bool expandResponseFiles(int Argc, const char *const *Argv, const char *EnvVar, StringSaver &Saver, SmallVectorImpl &NewArgv); @@ -2123,6 +2127,7 @@ /// Some tools (like clang-format) like to be able to hide all options that are /// not specific to the tool. This function allows a tool to specify a single /// option category to display in the -help output. +LLVM_SUPPORT_ABI void HideUnrelatedOptions(cl::OptionCategory &Category, SubCommand &Sub = *TopLevelSubCommand); @@ -2133,19 +2138,20 @@ /// Some tools (like clang-format) like to be able to hide all options that are /// not specific to the tool. This function allows a tool to specify a single /// option category to display in the -help output. +LLVM_SUPPORT_ABI void HideUnrelatedOptions(ArrayRef Categories, SubCommand &Sub = *TopLevelSubCommand); /// Reset all command line options to a state that looks as if they have /// never appeared on the command line. This is useful for being able to parse /// a command line multiple times (especially useful for writing tests). -void ResetAllOptionOccurrences(); +LLVM_SUPPORT_ABI void ResetAllOptionOccurrences(); /// Reset the command line parser back to its initial state. This /// removes /// all options, categories, and subcommands and returns the parser to a state /// where no options are supported. -void ResetCommandLineParser(); +LLVM_SUPPORT_ABI void ResetCommandLineParser(); /// Parses `Arg` into the option handler `Handler`. bool ProvidePositionalOption(Option *Handler, StringRef Arg, int i); diff --git a/llvm/include/llvm/Support/Compression.h b/llvm/include/llvm/Support/Compression.h --- a/llvm/include/llvm/Support/Compression.h +++ b/llvm/include/llvm/Support/Compression.h @@ -14,6 +14,7 @@ #define LLVM_SUPPORT_COMPRESSION_H #include "llvm/Support/DataTypes.h" +#include "llvm/Support/LLVMSupportExports.h" namespace llvm { template class SmallVectorImpl; @@ -27,15 +28,15 @@ static constexpr int DefaultCompression = 6; static constexpr int BestSizeCompression = 9; -bool isAvailable(); +LLVM_SUPPORT_ABI bool isAvailable(); -Error compress(StringRef InputBuffer, SmallVectorImpl &CompressedBuffer, +LLVM_SUPPORT_ABI Error compress(StringRef InputBuffer, SmallVectorImpl &CompressedBuffer, int Level = DefaultCompression); -Error uncompress(StringRef InputBuffer, char *UncompressedBuffer, +LLVM_SUPPORT_ABI Error uncompress(StringRef InputBuffer, char *UncompressedBuffer, size_t &UncompressedSize); -Error uncompress(StringRef InputBuffer, +LLVM_SUPPORT_ABI Error uncompress(StringRef InputBuffer, SmallVectorImpl &UncompressedBuffer, size_t UncompressedSize); diff --git a/llvm/include/llvm/Support/ConvertUTF.h b/llvm/include/llvm/Support/ConvertUTF.h --- a/llvm/include/llvm/Support/ConvertUTF.h +++ b/llvm/include/llvm/Support/ConvertUTF.h @@ -89,6 +89,8 @@ #ifndef LLVM_SUPPORT_CONVERTUTF_H #define LLVM_SUPPORT_CONVERTUTF_H +#include "llvm/Support/LLVMSupportExports.h" + #include #include #include @@ -135,7 +137,7 @@ lenientConversion } ConversionFlags; -ConversionResult ConvertUTF8toUTF16 ( +LLVM_SUPPORT_ABI ConversionResult ConvertUTF8toUTF16 ( const UTF8** sourceStart, const UTF8* sourceEnd, UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags); @@ -151,11 +153,11 @@ * Convert a partial UTF8 sequence to UTF32. If the sequence ends in an * incomplete code unit sequence, returns \c sourceIllegal. */ -ConversionResult ConvertUTF8toUTF32( +LLVM_SUPPORT_ABI ConversionResult ConvertUTF8toUTF32( const UTF8** sourceStart, const UTF8* sourceEnd, UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags); -ConversionResult ConvertUTF16toUTF8 ( +LLVM_SUPPORT_ABI ConversionResult ConvertUTF16toUTF8 ( const UTF16** sourceStart, const UTF16* sourceEnd, UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags); @@ -171,11 +173,11 @@ const UTF32** sourceStart, const UTF32* sourceEnd, UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags); -Boolean isLegalUTF8Sequence(const UTF8 *source, const UTF8 *sourceEnd); +LLVM_SUPPORT_ABI Boolean isLegalUTF8Sequence(const UTF8 *source, const UTF8 *sourceEnd); -Boolean isLegalUTF8String(const UTF8 **source, const UTF8 *sourceEnd); +LLVM_SUPPORT_ABI Boolean isLegalUTF8String(const UTF8 **source, const UTF8 *sourceEnd); -unsigned getNumBytesForUTF8(UTF8 firstByte); +LLVM_SUPPORT_ABI unsigned getNumBytesForUTF8(UTF8 firstByte); /*************************************************************************/ /* Below are LLVM-specific wrappers of the functions above. */ @@ -193,6 +195,7 @@ * the first character which could not be converted. * \return true on success. */ +LLVM_SUPPORT_ABI bool ConvertUTF8toWide(unsigned WideCharWidth, llvm::StringRef Source, char *&ResultPtr, const UTF8 *&ErrorPtr); @@ -200,18 +203,21 @@ * Converts a UTF-8 StringRef to a std::wstring. * \return true on success. */ +LLVM_SUPPORT_ABI bool ConvertUTF8toWide(llvm::StringRef Source, std::wstring &Result); /** * Converts a UTF-8 C-string to a std::wstring. * \return true on success. */ +LLVM_SUPPORT_ABI bool ConvertUTF8toWide(const char *Source, std::wstring &Result); /** * Converts a std::wstring to a UTF-8 encoded std::string. * \return true on success. */ +LLVM_SUPPORT_ABI bool convertWideToUTF8(const std::wstring &Source, std::string &Result); @@ -225,7 +231,7 @@ * * \returns true on success. */ -bool ConvertCodePointToUTF8(unsigned Source, char *&ResultPtr); +LLVM_SUPPORT_ABI bool ConvertCodePointToUTF8(unsigned Source, char *&ResultPtr); /** * Convert the first UTF8 sequence in the given source buffer to a UTF32 @@ -267,7 +273,7 @@ * \param [out] Out Converted UTF-8 is stored here on success. * \returns true on success */ -bool convertUTF16ToUTF8String(ArrayRef SrcBytes, std::string &Out); +LLVM_SUPPORT_ABI bool convertUTF16ToUTF8String(ArrayRef SrcBytes, std::string &Out); /** * Converts a UTF16 string into a UTF8 std::string. @@ -276,20 +282,20 @@ * \param [out] Out Converted UTF-8 is stored here on success. * \returns true on success */ -bool convertUTF16ToUTF8String(ArrayRef Src, std::string &Out); +LLVM_SUPPORT_ABI bool convertUTF16ToUTF8String(ArrayRef Src, std::string &Out); /** * Converts a UTF-8 string into a UTF-16 string with native endianness. * * \returns true on success */ -bool convertUTF8ToUTF16String(StringRef SrcUTF8, +LLVM_SUPPORT_ABI bool convertUTF8ToUTF16String(StringRef SrcUTF8, SmallVectorImpl &DstUTF16); #if defined(_WIN32) namespace sys { namespace windows { -std::error_code UTF8ToUTF16(StringRef utf8, SmallVectorImpl &utf16); +LLVM_SUPPORT_ABI std::error_code UTF8ToUTF16(StringRef utf8, SmallVectorImpl &utf16); /// Convert to UTF16 from the current code page used in the system std::error_code CurCPToUTF16(StringRef utf8, SmallVectorImpl &utf16); std::error_code UTF16ToUTF8(const wchar_t *utf16, size_t utf16_len, diff --git a/llvm/include/llvm/Support/CrashRecoveryContext.h b/llvm/include/llvm/Support/CrashRecoveryContext.h --- a/llvm/include/llvm/Support/CrashRecoveryContext.h +++ b/llvm/include/llvm/Support/CrashRecoveryContext.h @@ -10,6 +10,7 @@ #define LLVM_SUPPORT_CRASHRECOVERYCONTEXT_H #include "llvm/ADT/STLExtras.h" +#include "llvm/Support/LLVMSupportExports.h" namespace llvm { class CrashRecoveryContextCleanup; @@ -43,7 +44,7 @@ /// To assist recovery the class allows specifying set of actions that will be /// executed in any case, whether crash occurs or not. These actions may be used /// to reclaim resources in the case of crash. -class CrashRecoveryContext { +class LLVM_SUPPORT_ABI CrashRecoveryContext { void *Impl = nullptr; CrashRecoveryContextCleanup *head = nullptr; @@ -121,7 +122,7 @@ /// /// Cleanup handlers are stored in a double list, which is owned and managed by /// a crash recovery context. -class CrashRecoveryContextCleanup { +class LLVM_SUPPORT_ABI CrashRecoveryContextCleanup { protected: CrashRecoveryContext *context = nullptr; CrashRecoveryContextCleanup(CrashRecoveryContext *context) diff --git a/llvm/include/llvm/Support/DJB.h b/llvm/include/llvm/Support/DJB.h --- a/llvm/include/llvm/Support/DJB.h +++ b/llvm/include/llvm/Support/DJB.h @@ -14,6 +14,7 @@ #define LLVM_SUPPORT_DJB_H #include "llvm/ADT/StringRef.h" +#include "llvm/Support/LLVMSupportExports.h" namespace llvm { @@ -26,7 +27,7 @@ /// Computes the Bernstein hash after folding the input according to the Dwarf 5 /// standard case folding rules. -uint32_t caseFoldingDjbHash(StringRef Buffer, uint32_t H = 5381); +LLVM_SUPPORT_ABI uint32_t caseFoldingDjbHash(StringRef Buffer, uint32_t H = 5381); } // namespace llvm #endif // LLVM_SUPPORT_DJB_H diff --git a/llvm/include/llvm/Support/DataExtractor.h b/llvm/include/llvm/Support/DataExtractor.h --- a/llvm/include/llvm/Support/DataExtractor.h +++ b/llvm/include/llvm/Support/DataExtractor.h @@ -12,6 +12,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/Support/DataTypes.h" #include "llvm/Support/Error.h" +#include "llvm/Support/LLVMSupportExports.h" namespace llvm { @@ -38,7 +39,7 @@ return uint24_t(C.Bytes[2], C.Bytes[1], C.Bytes[0]); } -class DataExtractor { +class LLVM_SUPPORT_ABI DataExtractor { StringRef Data; uint8_t IsLittleEndian; uint8_t AddressSize; 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; @@ -105,12 +107,12 @@ /// to install signal handlers if they are certain there will be no /// conflict. /// -extern bool EnableDebugBuffering; +extern LLVM_SUPPORT_ABI bool EnableDebugBuffering; /// 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/DebugCounter.h b/llvm/include/llvm/Support/DebugCounter.h --- a/llvm/include/llvm/Support/DebugCounter.h +++ b/llvm/include/llvm/Support/DebugCounter.h @@ -47,13 +47,15 @@ #include "llvm/ADT/StringRef.h" #include "llvm/ADT/UniqueVector.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/LLVMSupportExports.h" + #include namespace llvm { class raw_ostream; -class DebugCounter { +class LLVM_SUPPORT_ABI DebugCounter { public: ~DebugCounter(); diff --git a/llvm/include/llvm/Support/DynamicLibrary.h b/llvm/include/llvm/Support/DynamicLibrary.h --- a/llvm/include/llvm/Support/DynamicLibrary.h +++ b/llvm/include/llvm/Support/DynamicLibrary.h @@ -13,6 +13,8 @@ #ifndef LLVM_SUPPORT_DYNAMICLIBRARY_H #define LLVM_SUPPORT_DYNAMICLIBRARY_H +#include "llvm/Support/LLVMSupportExports.h" + #include namespace llvm { @@ -33,7 +35,7 @@ /// /// Note: there is currently no interface for temporarily loading a library, /// or for unloading libraries when the LLVM library is unloaded. - class DynamicLibrary { + class LLVM_SUPPORT_ABI DynamicLibrary { // Placeholder whose address represents an invalid library. // We use this instead of NULL or a pointer-int pair because the OS library // might define 0 or 1 to be "special" handles, such as "search all". diff --git a/llvm/include/llvm/Support/ELFAttributeParser.h b/llvm/include/llvm/Support/ELFAttributeParser.h --- a/llvm/include/llvm/Support/ELFAttributeParser.h +++ b/llvm/include/llvm/Support/ELFAttributeParser.h @@ -14,13 +14,14 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/Support/DataExtractor.h" #include "llvm/Support/Error.h" +#include "llvm/Support/LLVMSupportExports.h" #include namespace llvm { class StringRef; -class ELFAttributeParser { +class LLVM_SUPPORT_ABI ELFAttributeParser { StringRef vendor; std::unordered_map attributes; std::unordered_map attributesStr; diff --git a/llvm/include/llvm/Support/ELFAttributes.h b/llvm/include/llvm/Support/ELFAttributes.h --- a/llvm/include/llvm/Support/ELFAttributes.h +++ b/llvm/include/llvm/Support/ELFAttributes.h @@ -11,6 +11,7 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/StringRef.h" +#include "llvm/Support/LLVMSupportExports.h" namespace llvm { @@ -25,9 +26,9 @@ enum AttrType : unsigned { File = 1, Section = 2, Symbol = 3 }; -StringRef attrTypeAsString(unsigned attr, TagNameMap tagNameMap, +LLVM_SUPPORT_ABI StringRef attrTypeAsString(unsigned attr, TagNameMap tagNameMap, bool hasTagPrefix = true); -Optional attrTypeFromString(StringRef tag, TagNameMap tagNameMap); +LLVM_SUPPORT_ABI Optional attrTypeFromString(StringRef tag, TagNameMap tagNameMap); // Magic numbers for ELF attributes. enum AttrMagic { Format_Version = 0x41 }; 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; @@ -379,10 +381,13 @@ } } + // FIXME(compnerd) is this portable? + LLVM_SUPPORT_ABI std::error_code convertToErrorCode() const override; // Used by ErrorInfo::classID. - static char ID; + // FIXME(compnerd) is this portable? + LLVM_SUPPORT_ABI static char ID; private: ErrorList(std::unique_ptr Payload1, @@ -719,7 +724,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]] LLVM_SUPPORT_ABI void report_fatal_error(Error Err, bool gen_crash_diag = true); /// Report a fatal error if Err is a failure value. /// @@ -1013,7 +1018,7 @@ /// This is useful in the base level of your program to allow clean termination /// (allowing clean deallocation of resources, etc.), while reporting error /// information to the user. -void logAllUnhandledErrors(Error E, raw_ostream &OS, Twine ErrorBanner = {}); +LLVM_SUPPORT_ABI void logAllUnhandledErrors(Error E, raw_ostream &OS, Twine ErrorBanner = {}); /// Write all error messages (if any) in E to a string. The newline character /// is used to separate error messages. @@ -1130,8 +1135,8 @@ /// This is useful if you're writing an interface that returns a Error /// (or Expected) and you want to call code that still returns /// std::error_codes. -class ECError : public ErrorInfo { - friend Error errorCodeToError(std::error_code); +class LLVM_SUPPORT_ABI ECError : public ErrorInfo { + friend LLVM_SUPPORT_ABI Error errorCodeToError(std::error_code); virtual void anchor() override; @@ -1156,16 +1161,16 @@ /// 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); +LLVM_SUPPORT_ABI Error errorCodeToError(std::error_code EC); /// Helper for converting an ECError to a std::error_code. /// /// This method requires that Err be Error() or an ECError, otherwise it /// will trigger a call to abort(). -std::error_code errorToErrorCode(Error Err); +LLVM_SUPPORT_ABI std::error_code errorToErrorCode(Error Err); /// Convert an ErrorOr to an Expected. template Expected errorOrToExpected(ErrorOr &&EO) { @@ -1205,7 +1210,7 @@ /// } /// @endcode /// -class StringError : public ErrorInfo { +class LLVM_SUPPORT_ABI StringError : public ErrorInfo { public: static char ID; @@ -1236,7 +1241,7 @@ return make_error(Stream.str(), EC); } -Error createStringError(std::error_code EC, char const *Msg); +LLVM_SUPPORT_ABI Error createStringError(std::error_code EC, char const *Msg); inline Error createStringError(std::error_code EC, const Twine &S) { return createStringError(EC, S.str().c_str()); @@ -1252,7 +1257,7 @@ /// /// In some cases, an error needs to live along a 'source' name, in order to /// show more detailed information to the user. -class FileError final : public ErrorInfo { +class LLVM_SUPPORT_ABI FileError final : public ErrorInfo { friend Error createFileError(const Twine &, Error); friend Error createFileError(const Twine &, size_t, Error); diff --git a/llvm/include/llvm/Support/ErrorHandling.h b/llvm/include/llvm/Support/ErrorHandling.h --- a/llvm/include/llvm/Support/ErrorHandling.h +++ b/llvm/include/llvm/Support/ErrorHandling.h @@ -15,6 +15,8 @@ #define LLVM_SUPPORT_ERRORHANDLING_H #include "llvm/Support/Compiler.h" +#include "llvm/Support/LLVMSupportExports.h" + #include namespace llvm { @@ -42,11 +44,11 @@ /// /// \param user_data - An argument which will be passed to the install error /// handler. - void install_fatal_error_handler(fatal_error_handler_t handler, + LLVM_SUPPORT_ABI void install_fatal_error_handler(fatal_error_handler_t handler, void *user_data = nullptr); /// Restores default error handling behaviour. - void remove_fatal_error_handler(); + LLVM_SUPPORT_ABI void remove_fatal_error_handler(); /// ScopedFatalErrorHandler - This is a simple helper class which just /// calls install_fatal_error_handler in its constructor and @@ -68,13 +70,13 @@ /// standard error, followed by a newline. /// After the error handler is called this function will call abort(), it /// does not return. -[[noreturn]] void report_fatal_error(const char *reason, +[[noreturn]] LLVM_SUPPORT_ABI void report_fatal_error(const char *reason, bool gen_crash_diag = true); -[[noreturn]] void report_fatal_error(const std::string &reason, +[[noreturn]] LLVM_SUPPORT_ABI void report_fatal_error(const std::string &reason, bool gen_crash_diag = true); -[[noreturn]] void report_fatal_error(StringRef reason, +[[noreturn]] LLVM_SUPPORT_ABI void report_fatal_error(StringRef reason, bool gen_crash_diag = true); -[[noreturn]] void report_fatal_error(const Twine &reason, +[[noreturn]] LLVM_SUPPORT_ABI void report_fatal_error(const Twine &reason, bool gen_crash_diag = true); /// Installs a new bad alloc error handler that should be used whenever a @@ -113,13 +115,13 @@ /// If no error handler is installed (default), throws a bad_alloc exception /// if LLVM is compiled with exception support. Otherwise prints the error /// to standard error and calls abort(). -[[noreturn]] void report_bad_alloc_error(const char *Reason, +[[noreturn]] LLVM_SUPPORT_ABI void report_bad_alloc_error(const char *Reason, bool GenCrashDiag = true); /// This function calls abort(), and prints the optional message to stderr. /// Use the llvm_unreachable macro (that adds location info), instead of /// calling this function directly. -[[noreturn]] void +[[noreturn]] LLVM_SUPPORT_ABI void llvm_unreachable_internal(const char *msg = nullptr, const char *file = nullptr, unsigned line = 0); } diff --git a/llvm/include/llvm/Support/ExtensibleRTTI.h b/llvm/include/llvm/Support/ExtensibleRTTI.h --- a/llvm/include/llvm/Support/ExtensibleRTTI.h +++ b/llvm/include/llvm/Support/ExtensibleRTTI.h @@ -60,6 +60,8 @@ #ifndef LLVM_SUPPORT_EXTENSIBLERTTI_H #define LLVM_SUPPORT_EXTENSIBLERTTI_H +#include "llvm/Support/LLVMSupportExports.h" + namespace llvm { template class RTTIExtends; @@ -68,7 +70,7 @@ /// /// This class defines virtual methods, dynamicClassID and isA, that enable /// type comparisons. -class RTTIRoot { +class LLVM_SUPPORT_ABI RTTIRoot { public: virtual ~RTTIRoot() = default; diff --git a/llvm/include/llvm/Support/FileCollector.h b/llvm/include/llvm/Support/FileCollector.h --- a/llvm/include/llvm/Support/FileCollector.h +++ b/llvm/include/llvm/Support/FileCollector.h @@ -12,7 +12,9 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringSet.h" +#include "llvm/Support/LLVMSupportExports.h" #include "llvm/Support/VirtualFileSystem.h" + #include #include @@ -67,13 +69,13 @@ /// /// In order to preserve the relative topology of files we use their real paths /// as relative paths inside of the Root. -class FileCollector : public FileCollectorBase { +class LLVM_SUPPORT_ABI FileCollector : public FileCollectorBase { public: /// Helper utility that encapsulates the logic for canonicalizing a virtual /// path and a path to copy from. - class PathCanonicalizer { + class LLVM_SUPPORT_ABI PathCanonicalizer { public: - struct PathStorage { + struct LLVM_SUPPORT_ABI PathStorage { SmallString<256> CopyFrom; SmallString<256> VirtualPath; }; diff --git a/llvm/include/llvm/Support/FileOutputBuffer.h b/llvm/include/llvm/Support/FileOutputBuffer.h --- a/llvm/include/llvm/Support/FileOutputBuffer.h +++ b/llvm/include/llvm/Support/FileOutputBuffer.h @@ -16,6 +16,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/Support/DataTypes.h" #include "llvm/Support/Error.h" +#include "llvm/Support/LLVMSupportExports.h" namespace llvm { /// FileOutputBuffer - This interface provides simple way to create an in-memory @@ -25,7 +26,7 @@ /// If the FileOutputBuffer is committed, the target file's content will become /// the buffer content at the time of the commit. If the FileOutputBuffer is /// not committed, the file will be deleted in the FileOutputBuffer destructor. -class FileOutputBuffer { +class LLVM_SUPPORT_ABI FileOutputBuffer { public: enum { /// Set the 'x' bit on the resulting file. diff --git a/llvm/include/llvm/Support/FileSystem.h b/llvm/include/llvm/Support/FileSystem.h --- a/llvm/include/llvm/Support/FileSystem.h +++ b/llvm/include/llvm/Support/FileSystem.h @@ -35,7 +35,9 @@ #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorOr.h" #include "llvm/Support/FileSystem/UniqueID.h" +#include "llvm/Support/LLVMSupportExports.h" #include "llvm/Support/MD5.h" + #include #include #include @@ -134,7 +136,7 @@ /// Represents the result of a call to directory_iterator::status(). This is a /// subset of the information returned by a regular sys::fs::status() call, and /// represents the information provided by Windows FileFirstFile/FindNextFile. -class basic_file_status { +class LLVM_SUPPORT_ABI basic_file_status { protected: #if defined(LLVM_ON_UNIX) time_t fs_st_atime = 0; @@ -224,7 +226,7 @@ /// Represents the result of a call to sys::fs::status(). class file_status : public basic_file_status { - friend bool equivalent(file_status A, file_status B); + friend LLVM_SUPPORT_ABI bool equivalent(file_status A, file_status B); #if defined(LLVM_ON_UNIX) dev_t fs_st_dev = 0; @@ -281,7 +283,7 @@ /// relative/../path => /relative/../path /// /// @param path A path that is modified to be an absolute path. -void make_absolute(const Twine ¤t_directory, SmallVectorImpl &path); +LLVM_SUPPORT_ABI void make_absolute(const Twine ¤t_directory, SmallVectorImpl &path); /// Make \a path an absolute path. /// @@ -294,7 +296,7 @@ /// @param path A path that is modified to be an absolute path. /// @returns errc::success if \a path has been made absolute, otherwise a /// platform-specific error_code. -std::error_code make_absolute(SmallVectorImpl &path); +LLVM_SUPPORT_ABI std::error_code make_absolute(SmallVectorImpl &path); /// Create all the non-existent directories in path. /// @@ -302,7 +304,7 @@ /// @returns errc::success if is_directory(path), otherwise a platform /// specific error_code. If IgnoreExisting is false, also returns /// error if the directory already existed. -std::error_code create_directories(const Twine &path, +LLVM_SUPPORT_ABI std::error_code create_directories(const Twine &path, bool IgnoreExisting = true, perms Perms = owner_all | group_all); @@ -312,7 +314,7 @@ /// @returns errc::success if is_directory(path), otherwise a platform /// specific error_code. If IgnoreExisting is false, also returns /// error if the directory already existed. -std::error_code create_directory(const Twine &path, bool IgnoreExisting = true, +LLVM_SUPPORT_ABI std::error_code create_directory(const Twine &path, bool IgnoreExisting = true, perms Perms = owner_all | group_all); /// Create a link from \a from to \a to. @@ -334,7 +336,7 @@ /// @param from The path to hard link from. This is created. /// @returns errc::success if the link was created, otherwise a platform /// specific error_code. -std::error_code create_hard_link(const Twine &to, const Twine &from); +LLVM_SUPPORT_ABI std::error_code create_hard_link(const Twine &to, const Twine &from); /// Collapse all . and .. patterns, resolve all symlinks, and optionally /// expand ~ expressions to the user's home directory. @@ -343,7 +345,7 @@ /// @param output The location to store the resolved path. /// @param expand_tilde If true, resolves ~ expressions to the user's home /// directory. -std::error_code real_path(const Twine &path, SmallVectorImpl &output, +LLVM_SUPPORT_ABI std::error_code real_path(const Twine &path, SmallVectorImpl &output, bool expand_tilde = false); /// Expands ~ expressions to the user's home directory. On Unix ~user @@ -357,7 +359,7 @@ /// @param result Holds the current path on return. /// @returns errc::success if the current path has been stored in result, /// otherwise a platform-specific error_code. -std::error_code current_path(SmallVectorImpl &result); +LLVM_SUPPORT_ABI std::error_code current_path(SmallVectorImpl &result); /// Set the current path. /// @@ -372,14 +374,14 @@ /// @returns errc::success if path has been removed or didn't exist, otherwise a /// platform-specific error code. If IgnoreNonExisting is false, also /// returns error if the file didn't exist. -std::error_code remove(const Twine &path, bool IgnoreNonExisting = true); +LLVM_SUPPORT_ABI std::error_code remove(const Twine &path, bool IgnoreNonExisting = true); /// Recursively delete a directory. /// /// @param path Input path. /// @returns errc::success if path has been removed or didn't exist, otherwise a /// platform-specific error code. -std::error_code remove_directories(const Twine &path, bool IgnoreErrors = true); +LLVM_SUPPORT_ABI std::error_code remove_directories(const Twine &path, bool IgnoreErrors = true); /// Rename \a from to \a to. /// @@ -389,19 +391,19 @@ /// /// @param from The path to rename from. /// @param to The path to rename to. This is created. -std::error_code rename(const Twine &from, const Twine &to); +LLVM_SUPPORT_ABI std::error_code rename(const Twine &from, const Twine &to); /// Copy the contents of \a From to \a To. /// /// @param From The path to copy from. /// @param To The path to copy to. This is created. -std::error_code copy_file(const Twine &From, const Twine &To); +LLVM_SUPPORT_ABI std::error_code copy_file(const Twine &From, const Twine &To); /// Copy the contents of \a From to \a To. /// /// @param From The path to copy from. /// @param ToFD The open file descriptor of the destination file. -std::error_code copy_file(const Twine &From, int ToFD); +LLVM_SUPPORT_ABI std::error_code copy_file(const Twine &From, int ToFD); /// Resize path to size. File is resized as if by POSIX truncate(). /// @@ -445,7 +447,7 @@ /// @param status A basic_file_status previously returned from stat. /// @returns True if the file represented by status exists, false if it does /// not. -bool exists(const basic_file_status &status); +LLVM_SUPPORT_ABI bool exists(const basic_file_status &status); enum class AccessMode { Exist, Write, Execute }; @@ -454,7 +456,7 @@ /// @param Path Input path. /// @returns errc::success if the path can be accessed, otherwise a /// platform-specific error_code. -std::error_code access(const Twine &Path, AccessMode Mode); +LLVM_SUPPORT_ABI std::error_code access(const Twine &Path, AccessMode Mode); /// Does file exist? /// @@ -468,7 +470,7 @@ /// /// @param Path Input path. /// @returns True if we can execute it, false otherwise. -bool can_execute(const Twine &Path); +LLVM_SUPPORT_ABI bool can_execute(const Twine &Path); /// Can we write this file? /// @@ -487,7 +489,7 @@ /// /// @returns True if A and B both represent the same file system entity, false /// otherwise. -bool equivalent(file_status A, file_status B); +LLVM_SUPPORT_ABI bool equivalent(file_status A, file_status B); /// Do paths represent the same thing? /// @@ -499,7 +501,7 @@ /// inode (or equivalent). /// @returns errc::success if result has been successfully set, otherwise a /// platform-specific error_code. -std::error_code equivalent(const Twine &A, const Twine &B, bool &result); +LLVM_SUPPORT_ABI std::error_code equivalent(const Twine &A, const Twine &B, bool &result); /// Simpler version of equivalent for clients that don't need to /// differentiate between an error and false. @@ -546,7 +548,7 @@ /// /// @param status A basic_file_status previously returned from status. /// @returns status.type() == file_type::directory_file. -bool is_directory(const basic_file_status &status); +LLVM_SUPPORT_ABI bool is_directory(const basic_file_status &status); /// Is path a directory? /// @@ -555,7 +557,7 @@ /// symlinks, false if it is not. Undefined otherwise. /// @returns errc::success if result has been successfully set, otherwise a /// platform-specific error_code. -std::error_code is_directory(const Twine &path, bool &result); +LLVM_SUPPORT_ABI std::error_code is_directory(const Twine &path, bool &result); /// Simpler version of is_directory for clients that don't need to /// differentiate between an error and false. @@ -568,7 +570,7 @@ /// /// @param status A basic_file_status previously returned from status. /// @returns status_known(status) && status.type() == file_type::regular_file. -bool is_regular_file(const basic_file_status &status); +LLVM_SUPPORT_ABI bool is_regular_file(const basic_file_status &status); /// Is path a regular file? /// @@ -577,7 +579,7 @@ /// symlinks), false if it is not. Undefined otherwise. /// @returns errc::success if result has been successfully set, otherwise a /// platform-specific error_code. -std::error_code is_regular_file(const Twine &path, bool &result); +LLVM_SUPPORT_ABI std::error_code is_regular_file(const Twine &path, bool &result); /// Simpler version of is_regular_file for clients that don't need to /// differentiate between an error and false. @@ -637,15 +639,15 @@ /// statted. /// @returns errc::success if result has been successfully set, otherwise a /// platform-specific error_code. -std::error_code status(const Twine &path, file_status &result, +LLVM_SUPPORT_ABI std::error_code status(const Twine &path, file_status &result, bool follow = true); /// A version for when a file descriptor is already available. -std::error_code status(int FD, file_status &Result); +LLVM_SUPPORT_ABI std::error_code status(int FD, file_status &Result); #ifdef _WIN32 /// A version for when a file descriptor is already available. -std::error_code status(file_t FD, file_status &Result); +LLVM_SUPPORT_ABI std::error_code status(file_t FD, file_status &Result); #endif /// Get file creation mode mask of the process. @@ -654,7 +656,7 @@ /// @note There is no umask on Windows. This function returns 0 always /// on Windows. This function does not return an error_code because /// umask(2) never fails. It is not thread safe. -unsigned getUmask(); +LLVM_SUPPORT_ABI unsigned getUmask(); /// Set file permissions. /// @@ -665,12 +667,12 @@ /// @note On Windows, all permissions except *_write are ignored. Using any of /// owner_write, group_write, or all_write will make the file writable. /// Otherwise, the file will be marked as read-only. -std::error_code setPermissions(const Twine &Path, perms Permissions); +LLVM_SUPPORT_ABI std::error_code setPermissions(const Twine &Path, perms Permissions); /// Vesion of setPermissions accepting a file descriptor. /// TODO Delete the path based overload once we implement the FD based overload /// on Windows. -std::error_code setPermissions(int FD, perms Permissions); +LLVM_SUPPORT_ABI std::error_code setPermissions(int FD, perms Permissions); /// Get file permissions. /// @@ -702,7 +704,7 @@ /// @returns errc::success if the file times were successfully set, otherwise a /// platform-specific error_code or errc::function_not_supported on /// platforms where the functionality isn't available. -std::error_code setLastAccessAndModificationTime(int FD, TimePoint<> AccessTime, +LLVM_SUPPORT_ABI std::error_code setLastAccessAndModificationTime(int FD, TimePoint<> AccessTime, TimePoint<> ModificationTime); /// Simpler version that sets both file modification and access time to the same @@ -828,14 +830,14 @@ /// @param Mode Set to the opened file's permissions. /// @returns errc::success if Result{FD,Path} have been successfully set, /// otherwise a platform-specific error_code. -std::error_code createUniqueFile(const Twine &Model, int &ResultFD, +LLVM_SUPPORT_ABI std::error_code createUniqueFile(const Twine &Model, int &ResultFD, SmallVectorImpl &ResultPath, OpenFlags Flags = OF_None, unsigned Mode = all_read | all_write); /// Simpler version for clients that don't want an open file. An empty /// file will still be created. -std::error_code createUniqueFile(const Twine &Model, +LLVM_SUPPORT_ABI std::error_code createUniqueFile(const Twine &Model, SmallVectorImpl &ResultPath, unsigned Mode = all_read | all_write); @@ -846,7 +848,7 @@ /// /// The destructor doesn't implicitly discard because there is no way to /// properly handle errors in a destructor. -class TempFile { +class LLVM_SUPPORT_ABI TempFile { bool Done = false; TempFile(StringRef Name, int FD); @@ -886,18 +888,18 @@ /// /// This should be used for things like a temporary .s that is removed after /// running the assembler. -std::error_code createTemporaryFile(const Twine &Prefix, StringRef Suffix, +LLVM_SUPPORT_ABI std::error_code createTemporaryFile(const Twine &Prefix, StringRef Suffix, int &ResultFD, SmallVectorImpl &ResultPath, OpenFlags Flags = OF_None); /// Simpler version for clients that don't want an open file. An empty /// file will still be created. -std::error_code createTemporaryFile(const Twine &Prefix, StringRef Suffix, +LLVM_SUPPORT_ABI std::error_code createTemporaryFile(const Twine &Prefix, StringRef Suffix, SmallVectorImpl &ResultPath, OpenFlags Flags = OF_None); -std::error_code createUniqueDirectory(const Twine &Prefix, +LLVM_SUPPORT_ABI std::error_code createUniqueDirectory(const Twine &Prefix, SmallVectorImpl &ResultPath); /// Get a unique name, not currently exisiting in the filesystem. Subject @@ -956,7 +958,7 @@ /// @param Mode The access permissions of the file, represented in octal. /// @returns errc::success if \a Name has been opened, otherwise a /// platform-specific error_code. -std::error_code openFile(const Twine &Name, int &ResultFD, +LLVM_SUPPORT_ABI std::error_code openFile(const Twine &Name, int &ResultFD, CreationDisposition Disp, FileAccess Access, OpenFlags Flags, unsigned Mode = 0666); @@ -981,9 +983,9 @@ /// Converts from a Posix file descriptor number to a native file handle. /// On Windows, this retreives the underlying handle. On non-Windows, this is a /// no-op. -file_t convertFDToNativeFile(int FD); - -#ifndef _WIN32 +#if defined(_WIN32) +LLVM_SUPPORT_ABI file_t convertFDToNativeFile(int FD); +#else inline file_t convertFDToNativeFile(int FD) { return FD; } #endif @@ -1135,7 +1137,7 @@ /// location. /// @returns a platform-specific file descriptor if \a Name has been opened, /// otherwise an error object. -Expected +LLVM_SUPPORT_ABI Expected openNativeFileForRead(const Twine &Name, OpenFlags Flags = OF_None, SmallVectorImpl *RealPath = nullptr); @@ -1174,7 +1176,7 @@ /// @param FD The descriptor representing the file to unlock. /// @returns errc::success if lock is successfully released or platform-specific /// error_code otherwise. -std::error_code unlockFile(int FD); +LLVM_SUPPORT_ABI std::error_code unlockFile(int FD); /// @brief Close the file object. This should be used instead of ::close for /// portability. On error, the caller should assume the file is closed, as is @@ -1185,7 +1187,7 @@ /// /// @returns An error code if closing the file failed. Typically, an error here /// means that the filesystem may have failed to perform some buffered writes. -std::error_code closeFile(file_t &F); +LLVM_SUPPORT_ABI std::error_code closeFile(file_t &F); #ifdef LLVM_ON_UNIX /// @brief Change ownership of a file. @@ -1226,7 +1228,7 @@ } }; -std::error_code getUniqueID(const Twine Path, UniqueID &Result); +LLVM_SUPPORT_ABI std::error_code getUniqueID(const Twine Path, UniqueID &Result); /// Get disk space usage information. /// @@ -1241,7 +1243,7 @@ /// This class represents a memory mapped file. It is based on /// boost::iostreams::mapped_file. -class mapped_file_region { +class LLVM_SUPPORT_ABI mapped_file_region { public: enum mapmode { readonly, ///< May only access map via const_data as read only. @@ -1317,14 +1319,14 @@ /// Return the path to the main executable, given the value of argv[0] from /// program startup and the address of main itself. In extremis, this function /// may fail and return an empty path. -std::string getMainExecutable(const char *argv0, void *MainExecAddr); +LLVM_SUPPORT_ABI std::string getMainExecutable(const char *argv0, void *MainExecAddr); /// @} /// @name Iterators /// @{ /// directory_entry - A single entry in a directory. -class directory_entry { +class LLVM_SUPPORT_ABI directory_entry { // FIXME: different platforms make different information available "for free" // when traversing a directory. The design of this class wraps most of the // information in basic_file_status, so on platforms where we can't populate @@ -1374,9 +1376,9 @@ struct DirIterState; - std::error_code directory_iterator_construct(DirIterState &, StringRef, bool); - std::error_code directory_iterator_increment(DirIterState &); - std::error_code directory_iterator_destruct(DirIterState &); + LLVM_SUPPORT_ABI std::error_code directory_iterator_construct(DirIterState &, StringRef, bool); + LLVM_SUPPORT_ABI std::error_code directory_iterator_increment(DirIterState &); + LLVM_SUPPORT_ABI std::error_code directory_iterator_destruct(DirIterState &); /// Keeps state for the directory_iterator. struct DirIterState { diff --git a/llvm/include/llvm/Support/FileUtilities.h b/llvm/include/llvm/Support/FileUtilities.h --- a/llvm/include/llvm/Support/FileUtilities.h +++ b/llvm/include/llvm/Support/FileUtilities.h @@ -18,6 +18,7 @@ #include "llvm/Support/Errc.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FileSystem.h" +#include "llvm/Support/LLVMSupportExports.h" #include "llvm/Support/Path.h" namespace llvm { @@ -29,7 +30,7 @@ /// option, it will set the string to an error message if an error occurs, or /// if the files are different. /// - int DiffFilesWithTolerance(StringRef FileA, + LLVM_SUPPORT_ABI int DiffFilesWithTolerance(StringRef FileA, StringRef FileB, double AbsTol, double RelTol, std::string *Error = nullptr); @@ -82,7 +83,7 @@ failed_to_rename_temp_file }; - class AtomicFileWriteError : public llvm::ErrorInfo { + class LLVM_SUPPORT_ABI AtomicFileWriteError : public llvm::ErrorInfo { public: AtomicFileWriteError(atomic_write_error Error) : Error(Error) {} @@ -104,10 +105,10 @@ /// writes content of \p Buffer to the file and renames it to \p FinalPath. /// /// \returns \c AtomicFileWriteError in case of error. - llvm::Error writeFileAtomically(StringRef TempPathModel, StringRef FinalPath, + LLVM_SUPPORT_ABI llvm::Error writeFileAtomically(StringRef TempPathModel, StringRef FinalPath, StringRef Buffer); - llvm::Error + LLVM_SUPPORT_ABI llvm::Error writeFileAtomically(StringRef TempPathModel, StringRef FinalPath, std::function Writer); } // End llvm namespace 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/FormatProviders.h b/llvm/include/llvm/Support/FormatProviders.h --- a/llvm/include/llvm/Support/FormatProviders.h +++ b/llvm/include/llvm/Support/FormatProviders.h @@ -19,6 +19,7 @@ #include "llvm/ADT/StringSwitch.h" #include "llvm/ADT/Twine.h" #include "llvm/Support/FormatVariadicDetails.h" +#include "llvm/Support/LLVMSupportExports.h" #include "llvm/Support/NativeFormatting.h" #include 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. /// @@ -169,7 +171,7 @@ /// fouts() - This returns a reference to a formatted_raw_ostream for /// standard output. Use it like: fouts() << "foo" << "bar"; -formatted_raw_ostream &fouts(); +LLVM_SUPPORT_ABI formatted_raw_ostream &fouts(); /// ferrs() - This returns a reference to a formatted_raw_ostream for /// standard error. Use it like: ferrs() << "foo" << "bar"; diff --git a/llvm/include/llvm/Support/GlobPattern.h b/llvm/include/llvm/Support/GlobPattern.h --- a/llvm/include/llvm/Support/GlobPattern.h +++ b/llvm/include/llvm/Support/GlobPattern.h @@ -17,6 +17,8 @@ #include "llvm/ADT/BitVector.h" #include "llvm/ADT/Optional.h" #include "llvm/Support/Error.h" +#include "llvm/Support/LLVMSupportExports.h" + #include // This class represents a glob pattern. Supported metacharacters @@ -26,7 +28,7 @@ template class ArrayRef; class StringRef; -class GlobPattern { +class LLVM_SUPPORT_ABI GlobPattern { public: static Expected create(StringRef Pat); bool match(StringRef S) const; diff --git a/llvm/include/llvm/Support/GraphWriter.h b/llvm/include/llvm/Support/GraphWriter.h --- a/llvm/include/llvm/Support/GraphWriter.h +++ b/llvm/include/llvm/Support/GraphWriter.h @@ -27,7 +27,9 @@ #include "llvm/ADT/Twine.h" #include "llvm/Support/DOTGraphTraits.h" #include "llvm/Support/FileSystem.h" +#include "llvm/Support/LLVMSupportExports.h" #include "llvm/Support/raw_ostream.h" + #include #include #include @@ -39,7 +41,7 @@ namespace DOT { // Private functions... -std::string EscapeString(const std::string &Label); +LLVM_SUPPORT_ABI std::string EscapeString(const std::string &Label); /// Get a color string for this node number. Simply round-robin selects /// from a reasonable number of colors. @@ -59,7 +61,7 @@ } // end namespace GraphProgram -bool DisplayGraph(StringRef Filename, bool wait = true, +LLVM_SUPPORT_ABI bool DisplayGraph(StringRef Filename, bool wait = true, GraphProgram::Name program = GraphProgram::DOT); template @@ -316,7 +318,7 @@ return O; } -std::string createGraphFilename(const Twine &Name, int &FD); +LLVM_SUPPORT_ABI std::string createGraphFilename(const Twine &Name, int &FD); /// Writes graph into a provided @c Filename. /// If @c Filename is empty, generates a random one. diff --git a/llvm/include/llvm/Support/Host.h b/llvm/include/llvm/Support/Host.h --- a/llvm/include/llvm/Support/Host.h +++ b/llvm/include/llvm/Support/Host.h @@ -13,6 +13,8 @@ #ifndef LLVM_SUPPORT_HOST_H #define LLVM_SUPPORT_HOST_H +#include "llvm/Support/LLVMSupportExports.h" + #include namespace llvm { @@ -29,18 +31,18 @@ /// CPU_TYPE-VENDOR-OPERATING_SYSTEM /// or /// CPU_TYPE-VENDOR-KERNEL-OPERATING_SYSTEM - std::string getDefaultTargetTriple(); + LLVM_SUPPORT_ABI std::string getDefaultTargetTriple(); /// getProcessTriple() - Return an appropriate target triple for generating /// code to be loaded into the current process, e.g. when using the JIT. - std::string getProcessTriple(); + LLVM_SUPPORT_ABI std::string getProcessTriple(); /// getHostCPUName - Get the LLVM name for the host CPU. The particular format /// of the name is target dependent, and suitable for passing as -mcpu to the /// target which matches the host. /// /// \return - The host CPU name, or empty if the CPU could not be determined. - StringRef getHostCPUName(); + LLVM_SUPPORT_ABI StringRef getHostCPUName(); /// getHostCPUFeatures - Get the LLVM names for the host CPU features. /// The particular format of the names are target dependent, and suitable for @@ -52,7 +54,7 @@ /// all valid LLVM feature names. /// /// \return - True on success. - bool getHostCPUFeatures(StringMap &Features); + LLVM_SUPPORT_ABI bool getHostCPUFeatures(StringMap &Features); /// Get the number of physical cores (as opposed to logical cores returned /// from thread::hardware_concurrency(), which includes hyperthreads). @@ -64,7 +66,7 @@ StringRef getHostCPUNameForPowerPC(StringRef ProcCpuinfoContent); StringRef getHostCPUNameForARM(StringRef ProcCpuinfoContent); StringRef getHostCPUNameForS390x(StringRef ProcCpuinfoContent); - StringRef getHostCPUNameForBPF(); + LLVM_SUPPORT_ABI StringRef getHostCPUNameForBPF(); /// Helper functions to extract CPU details from CPUID on x86. namespace x86 { 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/InstructionCost.h b/llvm/include/llvm/Support/InstructionCost.h --- a/llvm/include/llvm/Support/InstructionCost.h +++ b/llvm/include/llvm/Support/InstructionCost.h @@ -19,14 +19,16 @@ #define LLVM_SUPPORT_INSTRUCTIONCOST_H #include "llvm/ADT/Optional.h" +#include "llvm/Support/LLVMSupportExports.h" #include "llvm/Support/MathExtras.h" + #include namespace llvm { class raw_ostream; -class InstructionCost { +class LLVM_SUPPORT_ABI InstructionCost { public: using CostType = int64_t; diff --git a/llvm/include/llvm/Support/ItaniumManglingCanonicalizer.h b/llvm/include/llvm/Support/ItaniumManglingCanonicalizer.h --- a/llvm/include/llvm/Support/ItaniumManglingCanonicalizer.h +++ b/llvm/include/llvm/Support/ItaniumManglingCanonicalizer.h @@ -14,6 +14,8 @@ #ifndef LLVM_SUPPORT_ITANIUMMANGLINGCANONICALIZER_H #define LLVM_SUPPORT_ITANIUMMANGLINGCANONICALIZER_H +#include "llvm/Support/LLVMSupportExports.h" + #include #include @@ -33,7 +35,7 @@ /// This can be used when data (eg, profiling data) is available for a version /// of a program built in a different configuration, with correspondingly /// different manglings. -class ItaniumManglingCanonicalizer { +class LLVM_SUPPORT_ABI ItaniumManglingCanonicalizer { public: ItaniumManglingCanonicalizer(); ItaniumManglingCanonicalizer(const ItaniumManglingCanonicalizer &) = delete; 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; @@ -153,7 +155,7 @@ /// An Array is a JSON array, which contains heterogeneous JSON values. /// It simulates std::vector. -class Array { +class LLVM_SUPPORT_ABI Array { std::vector V; public: @@ -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, @@ -567,7 +569,7 @@ /// A "cursor" marking a position within a Value. /// The Value is a tree, and this is the path from the root to the current node. /// This is used to associate errors with particular subobjects. -class Path { +class LLVM_SUPPORT_ABI Path { public: class Root; @@ -797,7 +799,7 @@ /// Parses the provided JSON source, or returns a ParseError. /// The returned Value is self-contained and owns its strings (they do not refer /// to the original source). -llvm::Expected parse(llvm::StringRef JSON); +LLVM_SUPPORT_ABI llvm::Expected parse(llvm::StringRef JSON); class ParseError : public llvm::ErrorInfo { const char *Msg; @@ -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. @@ -1002,7 +1004,7 @@ /// Allow printing json::Value with formatv(). /// The default style is basic/compact formatting, like operator<<. /// A format string like formatv("{0:2}", Value) pretty-prints with indent 2. -template <> struct format_provider { +template <> struct LLVM_SUPPORT_ABI format_provider { static void format(const llvm::json::Value &, raw_ostream &, StringRef); }; } // namespace llvm diff --git a/llvm/include/llvm/Support/KnownBits.h b/llvm/include/llvm/Support/KnownBits.h --- a/llvm/include/llvm/Support/KnownBits.h +++ b/llvm/include/llvm/Support/KnownBits.h @@ -16,11 +16,12 @@ #include "llvm/ADT/APInt.h" #include "llvm/ADT/Optional.h" +#include "llvm/Support/LLVMSupportExports.h" namespace llvm { // Struct for tracking the known zeros and ones of a value. -struct KnownBits { +struct LLVM_SUPPORT_ABI KnownBits { APInt Zero; APInt One; diff --git a/llvm/include/llvm/Support/LEB128.h b/llvm/include/llvm/Support/LEB128.h --- a/llvm/include/llvm/Support/LEB128.h +++ b/llvm/include/llvm/Support/LEB128.h @@ -14,6 +14,7 @@ #ifndef LLVM_SUPPORT_LEB128_H #define LLVM_SUPPORT_LEB128_H +#include "llvm/Support/LLVMSupportExports.h" #include "llvm/Support/raw_ostream.h" namespace llvm { @@ -198,10 +199,10 @@ } /// Utility function to get the size of the ULEB128-encoded value. -extern unsigned getULEB128Size(uint64_t Value); +LLVM_SUPPORT_ABI unsigned getULEB128Size(uint64_t Value); /// Utility function to get the size of the SLEB128-encoded value. -extern unsigned getSLEB128Size(int64_t Value); +LLVM_SUPPORT_ABI unsigned getSLEB128Size(int64_t Value); } // namespace llvm 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/LineIterator.h b/llvm/include/llvm/Support/LineIterator.h --- a/llvm/include/llvm/Support/LineIterator.h +++ b/llvm/include/llvm/Support/LineIterator.h @@ -12,7 +12,9 @@ #include "llvm/ADT/Optional.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/DataTypes.h" +#include "llvm/Support/LLVMSupportExports.h" #include "llvm/Support/MemoryBufferRef.h" + #include namespace llvm { @@ -30,7 +32,7 @@ /// character. /// /// Note that this iterator requires the buffer to be nul terminated. -class line_iterator { +class LLVM_SUPPORT_ABI line_iterator { Optional Buffer; char CommentMarker = '\0'; bool SkipBlanks = true; diff --git a/llvm/include/llvm/Support/Locale.h b/llvm/include/llvm/Support/Locale.h --- a/llvm/include/llvm/Support/Locale.h +++ b/llvm/include/llvm/Support/Locale.h @@ -1,14 +1,24 @@ +//===--- Locale.h - Locale helpers -----------------------------*- 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_LOCALE_H #define LLVM_SUPPORT_LOCALE_H +#include "llvm/Support/LLVMSupportExports.h" + namespace llvm { class StringRef; namespace sys { namespace locale { -int columnWidth(StringRef s); -bool isPrint(int c); +LLVM_SUPPORT_ABI int columnWidth(StringRef s); +LLVM_SUPPORT_ABI bool isPrint(int c); } } diff --git a/llvm/include/llvm/Support/LockFileManager.h b/llvm/include/llvm/Support/LockFileManager.h --- a/llvm/include/llvm/Support/LockFileManager.h +++ b/llvm/include/llvm/Support/LockFileManager.h @@ -10,6 +10,8 @@ #include "llvm/ADT/Optional.h" #include "llvm/ADT/SmallString.h" +#include "llvm/Support/LLVMSupportExports.h" + #include #include // for std::pair @@ -24,7 +26,7 @@ /// system to ensure that only a single process can create that ".lock" file. /// When the lock file is removed, the owning process has finished the /// operation. -class LockFileManager { +class LLVM_SUPPORT_ABI LockFileManager { public: /// Describes the state of a lock file. enum LockFileState { diff --git a/llvm/include/llvm/Support/LowLevelTypeImpl.h b/llvm/include/llvm/Support/LowLevelTypeImpl.h --- a/llvm/include/llvm/Support/LowLevelTypeImpl.h +++ b/llvm/include/llvm/Support/LowLevelTypeImpl.h @@ -28,7 +28,9 @@ #include "llvm/ADT/DenseMapInfo.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/LLVMSupportExports.h" #include "llvm/Support/MachineValueType.h" + #include namespace llvm { @@ -37,7 +39,7 @@ class Type; class raw_ostream; -class LLT { +class LLVM_SUPPORT_ABI LLT { public: /// Get a low-level scalar or aggregate "bag of bits". static LLT scalar(unsigned SizeInBits) { diff --git a/llvm/include/llvm/Support/MD5.h b/llvm/include/llvm/Support/MD5.h --- a/llvm/include/llvm/Support/MD5.h +++ b/llvm/include/llvm/Support/MD5.h @@ -30,6 +30,8 @@ #include "llvm/ADT/StringRef.h" #include "llvm/Support/Endian.h" +#include "llvm/SUpport/LLVMSupportExports.h" + #include #include @@ -38,9 +40,9 @@ template class SmallString; template class ArrayRef; -class MD5 { +class LLVM_SUPPORT_ABI MD5 { public: - struct MD5Result { + struct LLVM_SUPPORT_ABI MD5Result { std::array Bytes; operator std::array() const { return Bytes; } diff --git a/llvm/include/llvm/Support/ManagedStatic.h b/llvm/include/llvm/Support/ManagedStatic.h --- a/llvm/include/llvm/Support/ManagedStatic.h +++ b/llvm/include/llvm/Support/ManagedStatic.h @@ -13,6 +13,8 @@ #ifndef LLVM_SUPPORT_MANAGEDSTATIC_H #define LLVM_SUPPORT_MANAGEDSTATIC_H +#include "llvm/Support/LLVMSupportExports.h" + #include #include @@ -46,7 +48,7 @@ #endif /// ManagedStaticBase - Common base class for ManagedStatic instances. -class ManagedStaticBase { +class LLVM_SUPPORT_ABI ManagedStaticBase { protected: #ifdef LLVM_USE_CONSTEXPR_CTOR mutable std::atomic Ptr{}; @@ -111,7 +113,7 @@ }; /// llvm_shutdown - Deallocate and destroy all ManagedStatic variables. -void llvm_shutdown(); +LLVM_SUPPORT_ABI void llvm_shutdown(); /// llvm_shutdown_obj - This is a simple helper class that calls /// llvm_shutdown() when it is destroyed. diff --git a/llvm/include/llvm/Support/MathExtras.h b/llvm/include/llvm/Support/MathExtras.h --- a/llvm/include/llvm/Support/MathExtras.h +++ b/llvm/include/llvm/Support/MathExtras.h @@ -14,6 +14,8 @@ #define LLVM_SUPPORT_MATHEXTRAS_H #include "llvm/Support/Compiler.h" +#include "llvm/Support/LLVMSupportExports.h" + #include #include #include @@ -875,7 +877,7 @@ } /// Use this rather than HUGE_VALF; the latter causes warnings on MSVC. -extern const float huge_valf; +extern LLVM_SUPPORT_ABI const float huge_valf; /// Add two signed integers, computing the two's complement truncated result, 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/Memory.h b/llvm/include/llvm/Support/Memory.h --- a/llvm/include/llvm/Support/Memory.h +++ b/llvm/include/llvm/Support/Memory.h @@ -14,6 +14,8 @@ #define LLVM_SUPPORT_MEMORY_H #include "llvm/Support/DataTypes.h" +#include "llvm/Support/LLVMSupportExports.h" + #include namespace llvm { @@ -49,7 +51,7 @@ /// MemoryBlock instances. /// @since 1.4 /// An abstraction for memory operations. - class Memory { + class LLVM_SUPPORT_ABI Memory { public: enum ProtectionFlags { MF_READ = 0x1000000, 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. @@ -159,7 +161,7 @@ /// access to the underlying contents. It only supports creation methods that /// are guaranteed to produce a writable buffer. For example, mapping a file /// read-only is not supported. -class WritableMemoryBuffer : public MemoryBuffer { +class LLVM_SUPPORT_ABI WritableMemoryBuffer : public MemoryBuffer { protected: WritableMemoryBuffer() = default; diff --git a/llvm/include/llvm/Support/MemoryBufferRef.h b/llvm/include/llvm/Support/MemoryBufferRef.h --- a/llvm/include/llvm/Support/MemoryBufferRef.h +++ b/llvm/include/llvm/Support/MemoryBufferRef.h @@ -14,12 +14,13 @@ #define LLVM_SUPPORT_MEMORYBUFFERREF_H #include "llvm/ADT/StringRef.h" +#include "llvm/Support/LLVMSupportExports.h" namespace llvm { class MemoryBuffer; -class MemoryBufferRef { +class LLVM_SUPPORT_ABI MemoryBufferRef { StringRef Buffer; StringRef Identifier; 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 { @@ -21,24 +23,38 @@ }; enum class HexPrintStyle { Upper, Lower, PrefixUpper, PrefixLower }; -size_t getDefaultPrecision(FloatStyle Style); +LLVM_SUPPORT_ABI 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); + +LLVM_SUPPORT_ABI void write_double(raw_ostream &S, double D, FloatStyle Style, Optional Precision = None); } diff --git a/llvm/include/llvm/Support/OptimizedStructLayout.h b/llvm/include/llvm/Support/OptimizedStructLayout.h --- a/llvm/include/llvm/Support/OptimizedStructLayout.h +++ b/llvm/include/llvm/Support/OptimizedStructLayout.h @@ -35,8 +35,10 @@ #ifndef LLVM_SUPPORT_OPTIMIZEDSTRUCTLAYOUT_H #define LLVM_SUPPORT_OPTIMIZEDSTRUCTLAYOUT_H -#include "llvm/Support/Alignment.h" #include "llvm/ADT/ArrayRef.h" +#include "llvm/Support/Alignment.h" +#include "llvm/Support/LLVMSupportExports.h" + #include namespace llvm { @@ -135,7 +137,7 @@ /// The return value is the total size of the struct and its required /// alignment. Note that the total size is not rounded up to a multiple /// of the required alignment; clients which require this can do so easily. -std::pair performOptimizedStructLayout( +LLVM_SUPPORT_ABI std::pair performOptimizedStructLayout( MutableArrayRef Fields); } // namespace llvm diff --git a/llvm/include/llvm/Support/Parallel.h b/llvm/include/llvm/Support/Parallel.h --- a/llvm/include/llvm/Support/Parallel.h +++ b/llvm/include/llvm/Support/Parallel.h @@ -12,6 +12,7 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/Config/llvm-config.h" #include "llvm/Support/Error.h" +#include "llvm/Support/LLVMSupportExports.h" #include "llvm/Support/MathExtras.h" #include "llvm/Support/Threading.h" @@ -27,7 +28,7 @@ // Strategy for the default executor used by the parallel routines provided by // this file. It defaults to using all hardware threads and should be // initialized before the first use of parallel routines. -extern ThreadPoolStrategy strategy; +extern LLVM_SUPPORT_ABI ThreadPoolStrategy strategy; namespace detail { @@ -59,7 +60,7 @@ } }; -class TaskGroup { +class LLVM_SUPPORT_ABI TaskGroup { Latch L; bool Parallel; diff --git a/llvm/include/llvm/Support/Path.h b/llvm/include/llvm/Support/Path.h --- a/llvm/include/llvm/Support/Path.h +++ b/llvm/include/llvm/Support/Path.h @@ -18,6 +18,8 @@ #include "llvm/ADT/Twine.h" #include "llvm/ADT/iterator.h" #include "llvm/Support/DataTypes.h" +#include "llvm/Support/LLVMSupportExports.h" + #include #include @@ -58,16 +60,16 @@ Style S = Style::native; ///< The path style to use. // An end iterator has Position = Path.size() + 1. - friend const_iterator begin(StringRef path, Style style); - friend const_iterator end(StringRef path); + friend LLVM_SUPPORT_ABI const_iterator begin(StringRef path, Style style); + friend LLVM_SUPPORT_ABI const_iterator end(StringRef path); public: reference operator*() const { return Component; } - const_iterator &operator++(); // preincrement - bool operator==(const const_iterator &RHS) const; + LLVM_SUPPORT_ABI const_iterator &operator++(); // preincrement + LLVM_SUPPORT_ABI bool operator==(const const_iterator &RHS) const; /// Difference in bytes between this and RHS. - ptrdiff_t operator-(const const_iterator &RHS) const; + LLVM_SUPPORT_ABI ptrdiff_t operator-(const const_iterator &RHS) const; }; /// Reverse path iterator. @@ -83,37 +85,37 @@ size_t Position = 0; ///< The iterators current position within Path. Style S = Style::native; ///< The path style to use. - friend reverse_iterator rbegin(StringRef path, Style style); - friend reverse_iterator rend(StringRef path); + friend LLVM_SUPPORT_ABI reverse_iterator rbegin(StringRef path, Style style); + friend LLVM_SUPPORT_ABI reverse_iterator rend(StringRef path); public: reference operator*() const { return Component; } - reverse_iterator &operator++(); // preincrement - bool operator==(const reverse_iterator &RHS) const; + LLVM_SUPPORT_ABI reverse_iterator &operator++(); // preincrement + LLVM_SUPPORT_ABI bool operator==(const reverse_iterator &RHS) const; /// Difference in bytes between this and RHS. - ptrdiff_t operator-(const reverse_iterator &RHS) const; + LLVM_SUPPORT_ABI ptrdiff_t operator-(const reverse_iterator &RHS) const; }; /// Get begin iterator over \a path. /// @param path Input path. /// @returns Iterator initialized with the first component of \a path. -const_iterator begin(StringRef path, Style style = Style::native); +LLVM_SUPPORT_ABI const_iterator begin(StringRef path, Style style = Style::native); /// Get end iterator over \a path. /// @param path Input path. /// @returns Iterator initialized to the end of \a path. -const_iterator end(StringRef path); +LLVM_SUPPORT_ABI const_iterator end(StringRef path); /// Get reverse begin iterator over \a path. /// @param path Input path. /// @returns Iterator initialized with the first reverse component of \a path. -reverse_iterator rbegin(StringRef path, Style style = Style::native); +LLVM_SUPPORT_ABI reverse_iterator rbegin(StringRef path, Style style = Style::native); /// Get reverse end iterator over \a path. /// @param path Input path. /// @returns Iterator initialized to the reverse end of \a path. -reverse_iterator rend(StringRef path); +LLVM_SUPPORT_ABI reverse_iterator rend(StringRef path); /// @} /// @name Lexical Modifiers @@ -131,7 +133,7 @@ /// @endcode /// /// @param path A path that is modified to not have a file component. -void remove_filename(SmallVectorImpl &path, Style style = Style::native); +LLVM_SUPPORT_ABI void remove_filename(SmallVectorImpl &path, Style style = Style::native); /// Replace the file extension of \a path with \a extension. /// @@ -145,7 +147,7 @@ /// @param extension The extension to be added. It may be empty. It may also /// optionally start with a '.', if it does not, one will be /// prepended. -void replace_extension(SmallVectorImpl &path, const Twine &extension, +LLVM_SUPPORT_ABI void replace_extension(SmallVectorImpl &path, const Twine &extension, Style style = Style::native); /// Replace matching path prefix with another path. @@ -170,7 +172,7 @@ /// @param style The style used to match the prefix. Exact match using /// Posix style, case/separator insensitive match for Windows style. /// @result true if \a Path begins with OldPrefix -bool replace_path_prefix(SmallVectorImpl &Path, StringRef OldPrefix, +LLVM_SUPPORT_ABI bool replace_path_prefix(SmallVectorImpl &Path, StringRef OldPrefix, StringRef NewPrefix, Style style = Style::native); @@ -184,12 +186,12 @@ /// /// @param path Set to \a path + \a component. /// @param a The component to be appended to \a path. -void append(SmallVectorImpl &path, const Twine &a, +LLVM_SUPPORT_ABI void append(SmallVectorImpl &path, const Twine &a, const Twine &b = "", const Twine &c = "", const Twine &d = ""); -void append(SmallVectorImpl &path, Style style, const Twine &a, +LLVM_SUPPORT_ABI void append(SmallVectorImpl &path, Style style, const Twine &a, const Twine &b = "", const Twine &c = "", const Twine &d = ""); /// Append to path. @@ -203,7 +205,7 @@ /// @param path Set to \a path + [\a begin, \a end). /// @param begin Start of components to append. /// @param end One past the end of components to append. -void append(SmallVectorImpl &path, const_iterator begin, +LLVM_SUPPORT_ABI void append(SmallVectorImpl &path, const_iterator begin, const_iterator end, Style style = Style::native); /// @} @@ -216,7 +218,7 @@ /// /// @param path A path that is transformed to native format. /// @param result Holds the result of the transformation. -void native(const Twine &path, SmallVectorImpl &result, +LLVM_SUPPORT_ABI void native(const Twine &path, SmallVectorImpl &result, Style style = Style::native); /// Convert path to the native form in place. This is used to give paths to @@ -224,7 +226,7 @@ /// on Windows all '/' are converted to '\'. /// /// @param path A path that is transformed to native format. -void native(SmallVectorImpl &path, Style style = Style::native); +LLVM_SUPPORT_ABI void native(SmallVectorImpl &path, Style style = Style::native); /// Replaces backslashes with slashes if Windows. /// @@ -232,7 +234,7 @@ /// @result The result of replacing backslashes with forward slashes if Windows. /// On Unix, this function is a no-op because backslashes are valid path /// chracters. -std::string convert_to_slash(StringRef path, Style style = Style::native); +LLVM_SUPPORT_ABI std::string convert_to_slash(StringRef path, Style style = Style::native); /// @} /// @name Lexical Observers @@ -248,7 +250,7 @@ /// /// @param path Input path. /// @result The root name of \a path if it has one, otherwise "". -StringRef root_name(StringRef path, Style style = Style::native); +LLVM_SUPPORT_ABI StringRef root_name(StringRef path, Style style = Style::native); /// Get root directory. /// @@ -261,7 +263,7 @@ /// @param path Input path. /// @result The root directory of \a path if it has one, otherwise /// "". -StringRef root_directory(StringRef path, Style style = Style::native); +LLVM_SUPPORT_ABI StringRef root_directory(StringRef path, Style style = Style::native); /// Get root path. /// @@ -269,7 +271,7 @@ /// /// @param path Input path. /// @result The root path of \a path if it has one, otherwise "". -StringRef root_path(StringRef path, Style style = Style::native); +LLVM_SUPPORT_ABI StringRef root_path(StringRef path, Style style = Style::native); /// Get relative path. /// @@ -281,7 +283,7 @@ /// /// @param path Input path. /// @result The path starting after root_path if one exists, otherwise "". -StringRef relative_path(StringRef path, Style style = Style::native); +LLVM_SUPPORT_ABI StringRef relative_path(StringRef path, Style style = Style::native); /// Get parent path. /// @@ -293,7 +295,7 @@ /// /// @param path Input path. /// @result The parent path of \a path if one exists, otherwise "". -StringRef parent_path(StringRef path, Style style = Style::native); +LLVM_SUPPORT_ABI StringRef parent_path(StringRef path, Style style = Style::native); /// Get filename. /// @@ -307,7 +309,7 @@ /// @param path Input path. /// @result The filename part of \a path. This is defined as the last component /// of \a path. Similar to the POSIX "basename" utility. -StringRef filename(StringRef path, Style style = Style::native); +LLVM_SUPPORT_ABI StringRef filename(StringRef path, Style style = Style::native); /// Get stem. /// @@ -325,7 +327,7 @@ /// /// @param path Input path. /// @result The stem of \a path. -StringRef stem(StringRef path, Style style = Style::native); +LLVM_SUPPORT_ABI StringRef stem(StringRef path, Style style = Style::native); /// Get extension. /// @@ -341,18 +343,18 @@ /// /// @param path Input path. /// @result The extension of \a path. -StringRef extension(StringRef path, Style style = Style::native); +LLVM_SUPPORT_ABI StringRef extension(StringRef path, Style style = Style::native); /// Check whether the given char is a path separator on the host OS. /// /// @param value a character /// @result true if \a value is a path separator character on the host OS -bool is_separator(char value, Style style = Style::native); +LLVM_SUPPORT_ABI bool is_separator(char value, Style style = Style::native); /// Return the preferred separator for this platform. /// /// @result StringRef of the preferred separator, null-terminated. -StringRef get_separator(Style style = Style::native); +LLVM_SUPPORT_ABI StringRef get_separator(Style style = Style::native); /// Get the typical temporary directory for the system, e.g., /// "/var/tmp" or "C:/TEMP" @@ -363,27 +365,27 @@ /// (e.g., TEMP on Windows, TMPDIR on *nix) to specify a temporary directory. /// /// @param result Holds the resulting path name. -void system_temp_directory(bool erasedOnReboot, SmallVectorImpl &result); +LLVM_SUPPORT_ABI void system_temp_directory(bool erasedOnReboot, SmallVectorImpl &result); /// Get the user's home directory. /// /// @param result Holds the resulting path name. /// @result True if a home directory is set, false otherwise. -bool home_directory(SmallVectorImpl &result); +LLVM_SUPPORT_ABI bool home_directory(SmallVectorImpl &result); /// Get the directory where packages should read user-specific configurations. /// e.g. $XDG_CONFIG_HOME. /// /// @param result Holds the resulting path name. /// @result True if the appropriate path was determined, it need not exist. -bool user_config_directory(SmallVectorImpl &result); +LLVM_SUPPORT_ABI bool user_config_directory(SmallVectorImpl &result); /// Get the directory where installed packages should put their /// machine-local cache, e.g. $XDG_CACHE_HOME. /// /// @param result Holds the resulting path name. /// @result True if the appropriate path was determined, it need not exist. -bool cache_directory(SmallVectorImpl &result); +LLVM_SUPPORT_ABI bool cache_directory(SmallVectorImpl &result); /// Has root name? /// @@ -399,7 +401,7 @@ /// /// @param path Input path. /// @result True if the path has a root directory, false otherwise. -bool has_root_directory(const Twine &path, Style style = Style::native); +LLVM_SUPPORT_ABI bool has_root_directory(const Twine &path, Style style = Style::native); /// Has root path? /// @@ -423,7 +425,7 @@ /// /// @param path Input path. /// @result True if the path has a parent path, false otherwise. -bool has_parent_path(const Twine &path, Style style = Style::native); +LLVM_SUPPORT_ABI bool has_parent_path(const Twine &path, Style style = Style::native); /// Has filename? /// @@ -447,7 +449,7 @@ /// /// @param path Input path. /// @result True if the path has a extension, false otherwise. -bool has_extension(const Twine &path, Style style = Style::native); +LLVM_SUPPORT_ABI bool has_extension(const Twine &path, Style style = Style::native); /// Is path absolute? /// @@ -466,7 +468,7 @@ /// /// @param path Input path. /// @result True if the path is absolute, false if it is not. -bool is_absolute(const Twine &path, Style style = Style::native); +LLVM_SUPPORT_ABI bool is_absolute(const Twine &path, Style style = Style::native); /// Is path absolute using GNU rules? /// @@ -491,19 +493,19 @@ /// means to derive the style from the host. /// @result True if the path is absolute following GNU rules, false if it is /// not. -bool is_absolute_gnu(const Twine &path, Style style = Style::native); +LLVM_SUPPORT_ABI bool is_absolute_gnu(const Twine &path, Style style = Style::native); /// Is path relative? /// /// @param path Input path. /// @result True if the path is relative, false if it is not. -bool is_relative(const Twine &path, Style style = Style::native); +LLVM_SUPPORT_ABI bool is_relative(const Twine &path, Style style = Style::native); /// Remove redundant leading "./" pieces and consecutive separators. /// /// @param path Input path. /// @result The cleaned-up \a path. -StringRef remove_leading_dotslash(StringRef path, Style style = Style::native); +LLVM_SUPPORT_ABI StringRef remove_leading_dotslash(StringRef path, Style style = Style::native); /// In-place remove any './' and optionally '../' components from a path. /// @@ -511,7 +513,7 @@ /// @param remove_dot_dot specify if '../' (except for leading "../") should be /// removed /// @result True if path was changed -bool remove_dots(SmallVectorImpl &path, bool remove_dot_dot = false, +LLVM_SUPPORT_ABI bool remove_dots(SmallVectorImpl &path, bool remove_dot_dot = false, Style style = Style::native); } // end namespace path diff --git a/llvm/include/llvm/Support/PluginLoader.h b/llvm/include/llvm/Support/PluginLoader.h --- a/llvm/include/llvm/Support/PluginLoader.h +++ b/llvm/include/llvm/Support/PluginLoader.h @@ -16,6 +16,7 @@ #ifndef LLVM_SUPPORT_PLUGINLOADER_H #define LLVM_SUPPORT_PLUGINLOADER_H +#include "llvm/Support/LLVMSupportExports.h" #ifndef DONT_GET_PLUGIN_LOADER_OPTION #include "llvm/Support/CommandLine.h" #endif @@ -23,7 +24,7 @@ #include namespace llvm { - struct PluginLoader { + struct LLVM_SUPPORT_ABI PluginLoader { void operator=(const std::string &Filename); static unsigned getNumPlugins(); static std::string& getPlugin(unsigned num); diff --git a/llvm/include/llvm/Support/PrettyStackTrace.h b/llvm/include/llvm/Support/PrettyStackTrace.h --- a/llvm/include/llvm/Support/PrettyStackTrace.h +++ b/llvm/include/llvm/Support/PrettyStackTrace.h @@ -17,6 +17,7 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/Support/Compiler.h" +#include "llvm/Support/LLVMSupportExports.h" namespace llvm { class raw_ostream; @@ -24,7 +25,7 @@ /// Enables dumping a "pretty" stack trace when the program crashes. /// /// \see PrettyStackTraceEntry - void EnablePrettyStackTrace(); + LLVM_SUPPORT_ABI void EnablePrettyStackTrace(); /// Enables (or disables) dumping a "pretty" stack trace when the user sends /// SIGINFO or SIGUSR1 to the current process. @@ -35,21 +36,21 @@ /// /// \see EnablePrettyStackTrace /// \see PrettyStackTraceEntry - void EnablePrettyStackTraceOnSigInfoForThisThread(bool ShouldEnable = true); + LLVM_SUPPORT_ABI void EnablePrettyStackTraceOnSigInfoForThisThread(bool ShouldEnable = true); /// Replaces the generic bug report message that is output upon /// a crash. - void setBugReportMsg(const char *Msg); + LLVM_SUPPORT_ABI void setBugReportMsg(const char *Msg); /// Get the bug report message that will be output upon a crash. - const char *getBugReportMsg(); + LLVM_SUPPORT_ABI const char *getBugReportMsg(); /// PrettyStackTraceEntry - This class is used to represent a frame of the /// "pretty" stack trace that is dumped when a program crashes. You can define /// subclasses of this and declare them on the program stack: when they are /// constructed and destructed, they will add their symbolic frames to a /// virtual stack trace. This gets dumped out if the program crashes. - class PrettyStackTraceEntry { + class LLVM_SUPPORT_ABI PrettyStackTraceEntry { friend PrettyStackTraceEntry *ReverseStackTrace(PrettyStackTraceEntry *); PrettyStackTraceEntry *NextEntry; @@ -69,7 +70,7 @@ /// PrettyStackTraceString - This object prints a specified string (which /// should not contain newlines) to the stream as the stack trace when a crash /// occurs. - class PrettyStackTraceString : public PrettyStackTraceEntry { + class LLVM_SUPPORT_ABI PrettyStackTraceString : public PrettyStackTraceEntry { const char *Str; public: PrettyStackTraceString(const char *str) : Str(str) {} @@ -88,7 +89,7 @@ /// PrettyStackTraceProgram - This object prints a specified program arguments /// to the stream as the stack trace when a crash occurs. - class PrettyStackTraceProgram : public PrettyStackTraceEntry { + class LLVM_SUPPORT_ABI PrettyStackTraceProgram : public PrettyStackTraceEntry { int ArgC; const char *const *ArgV; public: @@ -100,7 +101,7 @@ }; /// Returns the topmost element of the "pretty" stack state. - const void *SavePrettyStackState(); + LLVM_SUPPORT_ABI const void *SavePrettyStackState(); /// Restores the topmost element of the "pretty" stack state to State, which /// should come from a previous call to SavePrettyStackState(). This is @@ -109,7 +110,7 @@ /// happens after a crash that's been recovered by CrashRecoveryContext /// doesn't have frames on it that were added in code unwound by the /// CrashRecoveryContext. - void RestorePrettyStackState(const void *State); + LLVM_SUPPORT_ABI void RestorePrettyStackState(const void *State); } // end namespace llvm diff --git a/llvm/include/llvm/Support/Process.h b/llvm/include/llvm/Support/Process.h --- a/llvm/include/llvm/Support/Process.h +++ b/llvm/include/llvm/Support/Process.h @@ -29,7 +29,9 @@ #include "llvm/Support/Chrono.h" #include "llvm/Support/DataTypes.h" #include "llvm/Support/Error.h" +#include "llvm/Support/LLVMSupportExports.h" #include "llvm/Support/Program.h" + #include namespace llvm { @@ -41,7 +43,7 @@ /// A collection of legacy interfaces for querying information about the /// current executing process. -class Process { +class LLVM_SUPPORT_ABI Process { public: using Pid = int32_t; @@ -219,7 +221,6 @@ private: [[noreturn]] static void ExitNoCleanup(int RetCode); }; - } } diff --git a/llvm/include/llvm/Support/Program.h b/llvm/include/llvm/Support/Program.h --- a/llvm/include/llvm/Support/Program.h +++ b/llvm/include/llvm/Support/Program.h @@ -20,6 +20,8 @@ #include "llvm/Config/llvm-config.h" #include "llvm/Support/ErrorOr.h" #include "llvm/Support/FileSystem.h" +#include "llvm/Support/LLVMSupportExports.h" + #include #include @@ -75,7 +77,7 @@ /// /// \returns The fully qualified path to the first \p Name in \p Paths if it /// exists. \p Name if \p Name has slashes in it. Otherwise an error. - ErrorOr + LLVM_SUPPORT_ABI ErrorOr findProgramByName(StringRef Name, ArrayRef Paths = {}); // These functions change the specified standard stream (stdin or stdout) mode @@ -87,7 +89,7 @@ // These functions change the specified standard stream (stdin or stdout) to // binary mode. They return errc::success if the specified stream // was changed. Otherwise a platform dependent error is returned. - std::error_code ChangeStdinToBinary(); + LLVM_SUPPORT_ABI std::error_code ChangeStdinToBinary(); std::error_code ChangeStdoutToBinary(); /// This function executes the program using the arguments provided. The @@ -101,6 +103,7 @@ /// A zero or positive value indicates the result code of the program. /// -1 indicates failure to execute /// -2 indicates a crash during execution or timeout + LLVM_SUPPORT_ABI int ExecuteAndWait( StringRef Program, ///< Path of the program to be executed. It is ///< presumed this is the result of the findProgramByName method. @@ -155,12 +158,12 @@ /// Return true if the given arguments fit within system-specific /// argument length limits. - bool commandLineFitsWithinSystemLimits(StringRef Program, + LLVM_SUPPORT_ABI bool commandLineFitsWithinSystemLimits(StringRef Program, ArrayRef Args); /// Return true if the given arguments fit within system-specific /// argument length limits. - bool commandLineFitsWithinSystemLimits(StringRef Program, + LLVM_SUPPORT_ABI bool commandLineFitsWithinSystemLimits(StringRef Program, ArrayRef Args); /// File encoding options when writing contents that a non-UTF8 tool will @@ -193,7 +196,7 @@ /// should be changed as soon as binutils fix this to support UTF16 on mingw. /// /// \returns non-zero error_code if failed - std::error_code + LLVM_SUPPORT_ABI std::error_code writeFileWithEncoding(StringRef FileName, StringRef Contents, WindowsEncodingMethod Encoding = WEM_UTF8); @@ -222,7 +225,7 @@ ); /// Print a command argument, and optionally quote it. - void printArg(llvm::raw_ostream &OS, StringRef Arg, bool Quote); + LLVM_SUPPORT_ABI void printArg(llvm::raw_ostream &OS, StringRef Arg, bool Quote); #if defined(_WIN32) /// Given a list of command line arguments, quote and escape them as necessary diff --git a/llvm/include/llvm/Support/RISCVAttributeParser.h b/llvm/include/llvm/Support/RISCVAttributeParser.h --- a/llvm/include/llvm/Support/RISCVAttributeParser.h +++ b/llvm/include/llvm/Support/RISCVAttributeParser.h @@ -10,10 +10,11 @@ #define LLVM_SUPPORT_RISCVATTRIBUTEPARSER_H #include "llvm/Support/ELFAttributeParser.h" +#include "llvm/Support/LLVMSupportExports.h" #include "llvm/Support/RISCVAttributes.h" namespace llvm { -class RISCVAttributeParser : public ELFAttributeParser { +class LLVM_SUPPORT_ABI RISCVAttributeParser : public ELFAttributeParser { struct DisplayHandler { RISCVAttrs::AttrType attribute; Error (RISCVAttributeParser::*routine)(unsigned); diff --git a/llvm/include/llvm/Support/RISCVAttributes.h b/llvm/include/llvm/Support/RISCVAttributes.h --- a/llvm/include/llvm/Support/RISCVAttributes.h +++ b/llvm/include/llvm/Support/RISCVAttributes.h @@ -18,11 +18,12 @@ #define LLVM_SUPPORT_RISCVATTRIBUTES_H #include "llvm/Support/ELFAttributes.h" +#include "llvm/Support/LLVMSupportExports.h" namespace llvm { namespace RISCVAttrs { -const TagNameMap &getRISCVAttributeTags(); +LLVM_SUPPORT_ABI const TagNameMap &getRISCVAttributeTags(); enum AttrType : unsigned { // Attribute types in ELF/.riscv.attributes. diff --git a/llvm/include/llvm/Support/RandomNumberGenerator.h b/llvm/include/llvm/Support/RandomNumberGenerator.h --- a/llvm/include/llvm/Support/RandomNumberGenerator.h +++ b/llvm/include/llvm/Support/RandomNumberGenerator.h @@ -17,6 +17,8 @@ #include "llvm/Support/Compiler.h" #include "llvm/Support/DataTypes.h" // Needed for uint64_t on Windows. +#include "llvm/Support/LLVMSupportExports.h" + #include #include @@ -29,7 +31,7 @@ /// seed should be set by passing the -rng-seed= option. Use /// Module::createRNG to create a new RNG instance for use with that /// module. -class RandomNumberGenerator { +class LLVM_SUPPORT_ABI RandomNumberGenerator { // 64-bit Mersenne Twister by Matsumoto and Nishimura, 2000 // http://en.cppreference.com/w/cpp/numeric/random/mersenne_twister_engine 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/SHA1.h b/llvm/include/llvm/Support/SHA1.h --- a/llvm/include/llvm/Support/SHA1.h +++ b/llvm/include/llvm/Support/SHA1.h @@ -15,6 +15,8 @@ #ifndef LLVM_SUPPORT_SHA1_H #define LLVM_SUPPORT_SHA1_H +#include "llvm/Support/LLVMSupportExports.h" + #include #include @@ -23,7 +25,7 @@ class StringRef; /// A class that wrap the SHA1 algorithm. -class SHA1 { +class LLVM_SUPPORT_ABI SHA1 { public: SHA1() { init(); } diff --git a/llvm/include/llvm/Support/SMTAPI.h b/llvm/include/llvm/Support/SMTAPI.h --- a/llvm/include/llvm/Support/SMTAPI.h +++ b/llvm/include/llvm/Support/SMTAPI.h @@ -17,7 +17,9 @@ #include "llvm/ADT/APFloat.h" #include "llvm/ADT/APSInt.h" #include "llvm/ADT/FoldingSet.h" +#include "llvm/Support/LLVMSupportExports.h" #include "llvm/Support/raw_ostream.h" + #include namespace llvm { @@ -440,7 +442,7 @@ using SMTSolverRef = std::shared_ptr; /// Convenience method to create and Z3Solver object -SMTSolverRef CreateZ3Solver(); +LLVM_SUPPORT_ABI SMTSolverRef CreateZ3Solver(); } // namespace llvm diff --git a/llvm/include/llvm/Support/ScaledNumber.h b/llvm/include/llvm/Support/ScaledNumber.h --- a/llvm/include/llvm/Support/ScaledNumber.h +++ b/llvm/include/llvm/Support/ScaledNumber.h @@ -21,7 +21,9 @@ #ifndef LLVM_SUPPORT_SCALEDNUMBER_H #define LLVM_SUPPORT_SCALEDNUMBER_H +#include "llvm/Support/LLVMSupportExports.h" #include "llvm/Support/MathExtras.h" + #include #include #include @@ -105,7 +107,7 @@ /// Multiply two 64-bit integers to create a 64-bit scaled number. /// /// Implemented with four 64-bit integer multiplies. -std::pair multiply64(uint64_t LHS, uint64_t RHS); +LLVM_SUPPORT_ABI std::pair multiply64(uint64_t LHS, uint64_t RHS); /// Multiply two 32-bit integers to create a 32-bit scaled number. /// @@ -135,7 +137,7 @@ /// Implemented with long division. /// /// \pre \c Dividend and \c Divisor are non-zero. -std::pair divide64(uint64_t Dividend, uint64_t Divisor); +LLVM_SUPPORT_ABI std::pair divide64(uint64_t Dividend, uint64_t Divisor); /// Divide two 32-bit integers to create a 32-bit scaled number. /// @@ -241,7 +243,7 @@ /// 1, and 0 for less than, greater than, and equal, respectively. /// /// \pre 0 <= ScaleDiff < 64. -int compareImpl(uint64_t L, uint64_t R, int ScaleDiff); +LLVM_SUPPORT_ABI int compareImpl(uint64_t L, uint64_t R, int ScaleDiff); /// Compare two scaled numbers. /// @@ -416,7 +418,7 @@ namespace llvm { class raw_ostream; -class ScaledNumberBase { +class LLVM_SUPPORT_ABI ScaledNumberBase { public: static constexpr int DefaultPrecision = 10; diff --git a/llvm/include/llvm/Support/ScopedPrinter.h b/llvm/include/llvm/Support/ScopedPrinter.h --- a/llvm/include/llvm/Support/ScopedPrinter.h +++ b/llvm/include/llvm/Support/ScopedPrinter.h @@ -16,7 +16,9 @@ #include "llvm/ADT/StringRef.h" #include "llvm/Support/DataTypes.h" #include "llvm/Support/Endian.h" +#include "llvm/Support/LLVMSupportExports.h" #include "llvm/Support/raw_ostream.h" + #include namespace llvm { @@ -57,8 +59,9 @@ uint64_t Value; }; -raw_ostream &operator<<(raw_ostream &OS, const HexNumber &Value); -std::string to_hexString(uint64_t Value, bool UpperCase = true); +LLVM_SUPPORT_ABI raw_ostream &operator<<(raw_ostream &OS, const HexNumber &Value); + +LLVM_SUPPORT_ABI std::string to_hexString(uint64_t Value, bool UpperCase = true); template std::string to_string(const T &Value) { std::string number; @@ -67,7 +70,7 @@ return stream.str(); } -class ScopedPrinter { +class LLVM_SUPPORT_ABI ScopedPrinter { public: ScopedPrinter(raw_ostream &OS) : OS(OS), IndentLevel(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,12 +26,12 @@ /// 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. /// Remove a file if a fatal signal occurs. - bool RemoveFileOnSignal(StringRef Filename, std::string* ErrMsg = nullptr); + LLVM_SUPPORT_ABI bool RemoveFileOnSignal(StringRef Filename, std::string* ErrMsg = nullptr); /// This function removes a file from the list of files to be removed on /// signal delivery. @@ -43,16 +45,16 @@ /// StringRef(), in which case we will only search $PATH. /// \param DisableCrashReporting if \c true, disable the normal crash /// reporting mechanisms on the underlying operating system. - void PrintStackTraceOnErrorSignal(StringRef Argv0, + LLVM_SUPPORT_ABI void PrintStackTraceOnErrorSignal(StringRef Argv0, bool DisableCrashReporting = false); /// Disable all system dialog boxes that appear when the process crashes. - void DisableSystemDialogsOnCrash(); + LLVM_SUPPORT_ABI void DisableSystemDialogsOnCrash(); /// Print the stack trace using the given \c raw_ostream object. /// \param Depth refers to the number of stackframes to print. If not /// specified, the entire frame is printed. - void PrintStackTrace(raw_ostream &OS, int Depth = 0); + LLVM_SUPPORT_ABI void PrintStackTrace(raw_ostream &OS, int Depth = 0); // Run all registered signal handlers. void RunSignalHandlers(); @@ -73,7 +75,7 @@ /// functions. An null interrupt function pointer disables the current /// installed function. Note also that the handler may be executed on a /// different thread on some platforms. - void SetInterruptFunction(void (*IF)()); + LLVM_SUPPORT_ABI void SetInterruptFunction(void (*IF)()); /// Registers a function to be called when an "info" signal is delivered to /// the process. diff --git a/llvm/include/llvm/Support/SmallVectorMemoryBuffer.h b/llvm/include/llvm/Support/SmallVectorMemoryBuffer.h --- a/llvm/include/llvm/Support/SmallVectorMemoryBuffer.h +++ b/llvm/include/llvm/Support/SmallVectorMemoryBuffer.h @@ -15,6 +15,7 @@ #define LLVM_SUPPORT_SMALLVECTORMEMORYBUFFER_H #include "llvm/ADT/SmallVector.h" +#include "llvm/Support/LLVMSupportExports.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/raw_ostream.h" @@ -26,7 +27,7 @@ /// instances. This is useful for MCJIT and Orc, where object files are streamed /// into SmallVectors, then inspected using ObjectFile (which takes a /// MemoryBuffer). -class SmallVectorMemoryBuffer : public MemoryBuffer { +class LLVM_SUPPORT_ABI SmallVectorMemoryBuffer : public MemoryBuffer { public: /// Construct an SmallVectorMemoryBuffer from the given SmallVector /// r-value. 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, @@ -223,7 +225,7 @@ }; /// Represents a single fixit, a replacement of one range of text with another. -class SMFixIt { +class LLVM_SUPPORT_ABI SMFixIt { SMRange Range; std::string Text; @@ -248,7 +250,7 @@ /// Instances of this class encapsulate one diagnostic report, allowing /// printing to a raw_ostream as a caret diagnostic. -class SMDiagnostic { +class LLVM_SUPPORT_ABI SMDiagnostic { const SourceMgr *SM = nullptr; SMLoc Loc; std::string Filename; diff --git a/llvm/include/llvm/Support/SpecialCaseList.h b/llvm/include/llvm/Support/SpecialCaseList.h --- a/llvm/include/llvm/Support/SpecialCaseList.h +++ b/llvm/include/llvm/Support/SpecialCaseList.h @@ -52,8 +52,10 @@ #define LLVM_SUPPORT_SPECIALCASELIST_H #include "llvm/ADT/StringMap.h" +#include "llvm/Support/LLVMSupportExports.h" #include "llvm/Support/Regex.h" #include "llvm/Support/TrigramIndex.h" + #include #include #include @@ -66,7 +68,7 @@ class FileSystem; } -class SpecialCaseList { +class LLVM_SUPPORT_ABI SpecialCaseList { public: /// Parses the special case list entries from files. On failure, returns /// 0 and writes an error message to string. @@ -120,10 +122,10 @@ /// literal strings than Regex. class Matcher { public: - bool insert(std::string Regexp, unsigned LineNumber, std::string &REError); + LLVM_SUPPORT_ABI bool insert(std::string Regexp, unsigned LineNumber, std::string &REError); // Returns the line number in the source file that this query matches to. // Returns zero if no match is found. - unsigned match(StringRef Query) const; + LLVM_SUPPORT_ABI unsigned match(StringRef Query) const; private: StringMap Strings; diff --git a/llvm/include/llvm/Support/StringSaver.h b/llvm/include/llvm/Support/StringSaver.h --- a/llvm/include/llvm/Support/StringSaver.h +++ b/llvm/include/llvm/Support/StringSaver.h @@ -13,12 +13,13 @@ #include "llvm/ADT/StringRef.h" #include "llvm/ADT/Twine.h" #include "llvm/Support/Allocator.h" +#include "llvm/Support/LLVMSupportExports.h" namespace llvm { /// Saves strings in the provided stable storage and returns a /// StringRef with a stable character pointer. -class StringSaver final { +class LLVM_SUPPORT_ABI StringSaver final { BumpPtrAllocator &Alloc; public: @@ -39,7 +40,7 @@ /// /// Compared to StringPool, it performs fewer allocations but doesn't support /// refcounting/deletion. -class UniqueStringSaver final { +class LLVM_SUPPORT_ABI UniqueStringSaver final { StringSaver Strings; llvm::DenseSet Unique; diff --git a/llvm/include/llvm/Support/SuffixTree.h b/llvm/include/llvm/Support/SuffixTree.h --- a/llvm/include/llvm/Support/SuffixTree.h +++ b/llvm/include/llvm/Support/SuffixTree.h @@ -15,6 +15,8 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" #include "llvm/Support/Allocator.h" +#include "llvm/Support/LLVMSupportExports.h" + #include namespace llvm { @@ -134,7 +136,7 @@ /// paper is available at /// /// https://www.cs.helsinki.fi/u/ukkonen/SuffixT1withFigs.pdf -class SuffixTree { +class LLVM_SUPPORT_ABI SuffixTree { public: /// Each element is an integer representing an instruction in the module. llvm::ArrayRef Str; diff --git a/llvm/include/llvm/Support/SymbolRemappingReader.h b/llvm/include/llvm/Support/SymbolRemappingReader.h --- a/llvm/include/llvm/Support/SymbolRemappingReader.h +++ b/llvm/include/llvm/Support/SymbolRemappingReader.h @@ -62,11 +62,12 @@ #include "llvm/ADT/StringRef.h" #include "llvm/Support/Error.h" #include "llvm/Support/ItaniumManglingCanonicalizer.h" +#include "llvm/Support/LLVMSupportExports.h" #include "llvm/Support/MemoryBuffer.h" namespace llvm { -class SymbolRemappingParseError : public ErrorInfo { +class LLVM_SUPPORT_ABI SymbolRemappingParseError : public ErrorInfo { public: SymbolRemappingParseError(StringRef File, int64_t Line, const Twine &Message) : File(File), Line(Line), Message(Message.str()) {} @@ -94,7 +95,7 @@ /// /// Remaps the symbol names in profile data to match those in the program /// according to a set of rules specified in a given file. -class SymbolRemappingReader { +class LLVM_SUPPORT_ABI SymbolRemappingReader { public: /// Read remappings from the given buffer, which must live as long as /// the remapper. diff --git a/llvm/include/llvm/Support/SystemUtils.h b/llvm/include/llvm/Support/SystemUtils.h --- a/llvm/include/llvm/Support/SystemUtils.h +++ b/llvm/include/llvm/Support/SystemUtils.h @@ -14,6 +14,8 @@ #ifndef LLVM_SUPPORT_SYSTEMUTILS_H #define LLVM_SUPPORT_SYSTEMUTILS_H +#include "llvm/Support/LLVMSupportExports.h" + namespace llvm { class raw_ostream; @@ -21,6 +23,7 @@ /// generate a warning message to errs() advising against display of bitcode /// and return true. Otherwise just return false. /// Check for output written to a console +LLVM_SUPPORT_ABI bool CheckBitcodeOutputToConsole( raw_ostream &stream_to_check ///< The stream to be checked ); diff --git a/llvm/include/llvm/Support/TargetParser.h b/llvm/include/llvm/Support/TargetParser.h --- a/llvm/include/llvm/Support/TargetParser.h +++ b/llvm/include/llvm/Support/TargetParser.h @@ -19,6 +19,8 @@ #include "llvm/ADT/Triple.h" #include "llvm/Support/ARMTargetParser.h" #include "llvm/Support/AArch64TargetParser.h" +#include "llvm/Support/LLVMSupportExports.h" + #include namespace llvm { @@ -132,18 +134,18 @@ FEATURE_SRAMECC = 1 << 8, }; -StringRef getArchNameAMDGCN(GPUKind AK); -StringRef getArchNameR600(GPUKind AK); -StringRef getCanonicalArchName(const Triple &T, StringRef Arch); -GPUKind parseArchAMDGCN(StringRef CPU); -GPUKind parseArchR600(StringRef CPU); -unsigned getArchAttrAMDGCN(GPUKind AK); -unsigned getArchAttrR600(GPUKind AK); +LLVM_SUPPORT_ABI StringRef getArchNameAMDGCN(GPUKind AK); +LLVM_SUPPORT_ABI StringRef getArchNameR600(GPUKind AK); +LLVM_SUPPORT_ABI StringRef getCanonicalArchName(const Triple &T, StringRef Arch); +LLVM_SUPPORT_ABI GPUKind parseArchAMDGCN(StringRef CPU); +LLVM_SUPPORT_ABI GPUKind parseArchR600(StringRef CPU); +LLVM_SUPPORT_ABI unsigned getArchAttrAMDGCN(GPUKind AK); +LLVM_SUPPORT_ABI unsigned getArchAttrR600(GPUKind AK); -void fillValidArchListAMDGCN(SmallVectorImpl &Values); -void fillValidArchListR600(SmallVectorImpl &Values); +LLVM_SUPPORT_ABI void fillValidArchListAMDGCN(SmallVectorImpl &Values); +LLVM_SUPPORT_ABI void fillValidArchListR600(SmallVectorImpl &Values); -IsaVersion getIsaVersion(StringRef GPU); +LLVM_SUPPORT_ABI IsaVersion getIsaVersion(StringRef GPU); } // namespace AMDGPU @@ -165,15 +167,15 @@ FK_64BIT = 1 << 7, }; -bool checkCPUKind(CPUKind Kind, bool IsRV64); -bool checkTuneCPUKind(CPUKind Kind, bool IsRV64); -CPUKind parseCPUKind(StringRef CPU); -CPUKind parseTuneCPUKind(StringRef CPU, bool IsRV64); -StringRef getMArchFromMcpu(StringRef CPU); -void fillValidCPUArchList(SmallVectorImpl &Values, bool IsRV64); -void fillValidTuneCPUArchList(SmallVectorImpl &Values, bool IsRV64); -bool getCPUFeaturesExceptStdExt(CPUKind Kind, std::vector &Features); -StringRef resolveTuneCPUAlias(StringRef TuneCPU, bool IsRV64); +LLVM_SUPPORT_ABI bool checkCPUKind(CPUKind Kind, bool IsRV64); +LLVM_SUPPORT_ABI bool checkTuneCPUKind(CPUKind Kind, bool IsRV64); +LLVM_SUPPORT_ABI CPUKind parseCPUKind(StringRef CPU); +LLVM_SUPPORT_ABI CPUKind parseTuneCPUKind(StringRef CPU, bool IsRV64); +LLVM_SUPPORT_ABI StringRef getMArchFromMcpu(StringRef CPU); +LLVM_SUPPORT_ABI void fillValidCPUArchList(SmallVectorImpl &Values, bool IsRV64); +LLVM_SUPPORT_ABI void fillValidTuneCPUArchList(SmallVectorImpl &Values, bool IsRV64); +LLVM_SUPPORT_ABI bool getCPUFeaturesExceptStdExt(CPUKind Kind, std::vector &Features); +LLVM_SUPPORT_ABI StringRef resolveTuneCPUAlias(StringRef TuneCPU, bool IsRV64); } // namespace RISCV diff --git a/llvm/include/llvm/Support/TargetRegistry.h b/llvm/include/llvm/Support/TargetRegistry.h --- a/llvm/include/llvm/Support/TargetRegistry.h +++ b/llvm/include/llvm/Support/TargetRegistry.h @@ -27,6 +27,8 @@ #include "llvm/Support/CodeGen.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FormattedStream.h" +#include "llvm/Support/LLVMSupportExports.h" + #include #include #include @@ -675,7 +677,7 @@ }; /// TargetRegistry - Generic interface to target specific features. -struct TargetRegistry { +struct LLVM_SUPPORT_ABI TargetRegistry { // FIXME: Make this a namespace, probably just move all the Register* // functions into Target (currently they all just set members on the Target // anyway, and Target friends this class so those functions can... diff --git a/llvm/include/llvm/Support/ThreadPool.h b/llvm/include/llvm/Support/ThreadPool.h --- a/llvm/include/llvm/Support/ThreadPool.h +++ b/llvm/include/llvm/Support/ThreadPool.h @@ -14,6 +14,7 @@ #define LLVM_SUPPORT_THREADPOOL_H #include "llvm/Config/llvm-config.h" +#include "llvm/Support/LLVMSupportExports.h" #include "llvm/Support/Threading.h" #include "llvm/Support/thread.h" @@ -34,7 +35,7 @@ /// /// The pool keeps a vector of threads alive, waiting on a condition variable /// for some work to become available. -class ThreadPool { +class LLVM_SUPPORT_ABI ThreadPool { public: using TaskTy = std::function; using PackagedTaskTy = std::packaged_task; diff --git a/llvm/include/llvm/Support/Threading.h b/llvm/include/llvm/Support/Threading.h --- a/llvm/include/llvm/Support/Threading.h +++ b/llvm/include/llvm/Support/Threading.h @@ -20,6 +20,8 @@ #include "llvm/ADT/StringRef.h" #include "llvm/Config/llvm-config.h" // for LLVM_ON_UNIX #include "llvm/Support/Compiler.h" +#include "llvm/Support/LLVMSupportExports.h" + #include // So we can check the C++ standard lib macros. #include @@ -53,7 +55,7 @@ /// Returns true if LLVM is compiled with support for multi-threading, and /// false otherwise. -bool llvm_is_multithreaded(); +LLVM_SUPPORT_ABI bool llvm_is_multithreaded(); #if LLVM_THREADING_USE_STD_CALL_ONCE @@ -116,7 +118,7 @@ } /// This tells how a thread pool will be used - class ThreadPoolStrategy { + class LLVM_SUPPORT_ABI ThreadPoolStrategy { public: // The default value (0) means all available threads should be used, // taking the affinity mask into account. If set, this value only represents @@ -152,7 +154,7 @@ /// strategy, we attempt to equally allocate the threads on all CPU sockets. /// "0" or an empty string will return the \p Default strategy. /// "all" for using all hardware threads. - Optional + LLVM_SUPPORT_ABI Optional get_threadpool_strategy(StringRef Num, ThreadPoolStrategy Default = {}); /// Returns a thread strategy for tasks requiring significant memory or other @@ -205,7 +207,7 @@ /// Note that not all platforms guarantee that the value returned will be /// unique across the entire system, so portable code should not assume /// this. - uint64_t get_threadid(); + LLVM_SUPPORT_ABI uint64_t get_threadid(); /// Get the maximum length of a thread name on this platform. /// A value of 0 means there is no limit. @@ -217,7 +219,7 @@ /// wildly across operating systems, and we only make a best effort to /// perform the operation on supported platforms. No indication of success /// or failure is returned. - void set_thread_name(const Twine &Name); + LLVM_SUPPORT_ABI void set_thread_name(const Twine &Name); /// Get the name of the current thread. The level of support for /// getting a thread's name varies wildly across operating systems, and it @@ -225,7 +227,7 @@ /// that you can later get it back. This function is intended for diagnostic /// purposes, and as with setting a thread's name no indication of whether /// the operation succeeded or failed is returned. - void get_thread_name(SmallVectorImpl &Name); + LLVM_SUPPORT_ABI void get_thread_name(SmallVectorImpl &Name); /// Returns a mask that represents on which hardware thread, core, CPU, NUMA /// group, the calling thread can be executed. On Windows, threads cannot @@ -246,7 +248,8 @@ /// If the priority is default tries to restore current threads priority to /// default scheduling priority. enum class SetThreadPriorityResult { FAILURE, SUCCESS }; - SetThreadPriorityResult set_thread_priority(ThreadPriority Priority); + + LLVM_SUPPORT_ABI SetThreadPriorityResult set_thread_priority(ThreadPriority Priority); } #endif diff --git a/llvm/include/llvm/Support/TimeProfiler.h b/llvm/include/llvm/Support/TimeProfiler.h --- a/llvm/include/llvm/Support/TimeProfiler.h +++ b/llvm/include/llvm/Support/TimeProfiler.h @@ -10,24 +10,25 @@ #define LLVM_SUPPORT_TIMEPROFILER_H #include "llvm/Support/Error.h" +#include "llvm/Support/LLVMSupportExports.h" #include "llvm/Support/raw_ostream.h" namespace llvm { struct TimeTraceProfiler; -TimeTraceProfiler *getTimeTraceProfilerInstance(); +LLVM_SUPPORT_ABI TimeTraceProfiler *getTimeTraceProfilerInstance(); /// Initialize the time trace profiler. /// This sets up the global \p TimeTraceProfilerInstance /// variable to be the profiler instance. -void timeTraceProfilerInitialize(unsigned TimeTraceGranularity, +LLVM_SUPPORT_ABI void timeTraceProfilerInitialize(unsigned TimeTraceGranularity, StringRef ProcName); /// Cleanup the time trace profiler, if it was initialized. -void timeTraceProfilerCleanup(); +LLVM_SUPPORT_ABI void timeTraceProfilerCleanup(); /// Finish a time trace profiler running on a worker thread. -void timeTraceProfilerFinishThread(); +LLVM_SUPPORT_ABI void timeTraceProfilerFinishThread(); /// Is the time trace profiler enabled, i.e. initialized? inline bool timeTraceProfilerEnabled() { @@ -37,7 +38,7 @@ /// Write profiling data to output stream. /// Data produced is JSON, in Chrome "Trace Event" format, see /// https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview -void timeTraceProfilerWrite(raw_pwrite_stream &OS); +LLVM_SUPPORT_ABI void timeTraceProfilerWrite(raw_pwrite_stream &OS); /// Write profiling data to a file. /// The function will write to \p PreferredFileName if provided, if not @@ -51,12 +52,12 @@ /// Profiler copies the string data, so the pointers can be given into /// temporaries. Time sections can be hierarchical; every Begin must have a /// matching End pair but they can nest. -void timeTraceProfilerBegin(StringRef Name, StringRef Detail); -void timeTraceProfilerBegin(StringRef Name, +LLVM_SUPPORT_ABI void timeTraceProfilerBegin(StringRef Name, StringRef Detail); +LLVM_SUPPORT_ABI void timeTraceProfilerBegin(StringRef Name, llvm::function_ref Detail); /// Manually end the last time section. -void timeTraceProfilerEnd(); +LLVM_SUPPORT_ABI void timeTraceProfilerEnd(); /// The TimeTraceScope is a helper class to call the begin and end functions /// of the time trace profiler. When the object is constructed, it begins 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 @@ -23,7 +25,7 @@ class TimerGroup; class raw_ostream; -class TimeRecord { +class LLVM_SUPPORT_ABI TimeRecord { double WallTime; ///< Wall clock time elapsed in seconds. double UserTime; ///< User time elapsed. double SystemTime; ///< System time elapsed. @@ -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. @@ -143,7 +145,7 @@ /// stopTimer() methods of the Timer class. When the object is constructed, it /// starts the timer specified as its argument. When it is destroyed, it stops /// the relevant timer. This makes it easy to time a region of code. -class TimeRegion { +class LLVM_SUPPORT_ABI TimeRegion { Timer *T; TimeRegion(const TimeRegion &) = delete; @@ -163,7 +165,7 @@ /// you to declare a new timer, AND specify the region to time, all in one /// statement. All timers with the same name are merged. This is primarily /// used for debugging and for hunting performance problems. -struct NamedRegionTimer : public TimeRegion { +struct LLVM_SUPPORT_ABI NamedRegionTimer : public TimeRegion { explicit NamedRegionTimer(StringRef Name, StringRef Description, StringRef GroupName, StringRef GroupDescription, bool Enabled = true); @@ -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; @@ -243,7 +245,7 @@ private: friend class Timer; - friend void PrintStatisticsJSON(raw_ostream &OS); + friend LLVM_SUPPORT_ABI void PrintStatisticsJSON(raw_ostream &OS); void addTimer(Timer &T); void removeTimer(Timer &T); void prepareToPrintList(bool reset_time = false); 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 { @@ -28,7 +29,7 @@ /// before the raw_fd_ostream is constructed and destructed after the /// raw_fd_ostream is destructed. It installs cleanups in its constructor and /// uninstalls them in its destructor. - class CleanupInstaller { + class LLVM_SUPPORT_ABI CleanupInstaller { /// The name of the file. std::string Filename; public: @@ -50,9 +51,11 @@ public: /// This constructor's arguments are passed to raw_fd_ostream's /// constructor. + LLVM_SUPPORT_ABI ToolOutputFile(StringRef Filename, std::error_code &EC, sys::fs::OpenFlags Flags); + LLVM_SUPPORT_ABI ToolOutputFile(StringRef Filename, int FD); /// Return the contained raw_fd_ostream. 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" @@ -29,7 +30,7 @@ /// Reports a diagnostic message to indicate an invalid size request has been /// done on a scalable vector. This function may not return. -void reportInvalidSizeRequest(const char *Msg); +LLVM_SUPPORT_ABI void reportInvalidSizeRequest(const char *Msg); template struct LinearPolyBaseTypeTraits {}; @@ -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/Unicode.h b/llvm/include/llvm/Support/Unicode.h --- a/llvm/include/llvm/Support/Unicode.h +++ b/llvm/include/llvm/Support/Unicode.h @@ -14,6 +14,8 @@ #ifndef LLVM_SUPPORT_UNICODE_H #define LLVM_SUPPORT_UNICODE_H +#include "llvm/Support/LLVMSupportExports.h" + namespace llvm { class StringRef; @@ -57,7 +59,7 @@ /// * 0 for each non-spacing and enclosing combining mark; /// * 2 for each CJK character excluding halfwidth forms; /// * 1 for each of the remaining characters. -int columnWidthUTF8(StringRef Text); +LLVM_SUPPORT_ABI int columnWidthUTF8(StringRef Text); /// Fold input unicode character according the Simple unicode case folding /// rules. diff --git a/llvm/include/llvm/Support/Valgrind.h b/llvm/include/llvm/Support/Valgrind.h --- a/llvm/include/llvm/Support/Valgrind.h +++ b/llvm/include/llvm/Support/Valgrind.h @@ -15,12 +15,14 @@ #ifndef LLVM_SUPPORT_VALGRIND_H #define LLVM_SUPPORT_VALGRIND_H +#include "llvm/Support/LLVMSupportExports.h" + #include namespace llvm { namespace sys { // True if Valgrind is controlling this process. - bool RunningOnValgrind(); + LLVM_SUPPORT_ABI bool RunningOnValgrind(); // Discard valgrind's translation of code in the range [Addr .. Addr + Len). // Otherwise valgrind may continue to execute the old version of the code. diff --git a/llvm/include/llvm/Support/VersionTuple.h b/llvm/include/llvm/Support/VersionTuple.h --- a/llvm/include/llvm/Support/VersionTuple.h +++ b/llvm/include/llvm/Support/VersionTuple.h @@ -17,6 +17,8 @@ #include "llvm/ADT/DenseMapInfo.h" #include "llvm/ADT/Hashing.h" #include "llvm/ADT/Optional.h" +#include "llvm/Support/LLVMSupportExports.h" + #include #include @@ -25,7 +27,7 @@ class StringRef; /// Represents a version number in the form major[.minor[.subminor[.build]]]. -class VersionTuple { +class LLVM_SUPPORT_ABI VersionTuple { unsigned Major : 32; unsigned Minor : 31; @@ -174,6 +176,7 @@ }; /// Print a version number. +LLVM_SUPPORT_ABI raw_ostream &operator<<(raw_ostream &Out, const VersionTuple &V); // Provide DenseMapInfo for version tuples. diff --git a/llvm/include/llvm/Support/VirtualFileSystem.h b/llvm/include/llvm/Support/VirtualFileSystem.h --- a/llvm/include/llvm/Support/VirtualFileSystem.h +++ b/llvm/include/llvm/Support/VirtualFileSystem.h @@ -22,8 +22,10 @@ #include "llvm/Support/Chrono.h" #include "llvm/Support/ErrorOr.h" #include "llvm/Support/FileSystem.h" +#include "llvm/Support/LLVMSupportExports.h" #include "llvm/Support/Path.h" #include "llvm/Support/SourceMgr.h" + #include #include #include @@ -43,7 +45,7 @@ namespace vfs { /// The result of a \p status operation. -class Status { +class LLVM_SUPPORT_ABI Status { std::string Name; llvm::sys::fs::UniqueID UID; llvm::sys::TimePoint<> MTime; @@ -96,7 +98,7 @@ }; /// Represents an open file. -class File { +class LLVM_SUPPORT_ABI File { public: /// Destroy the file after closing it (if open). /// Sub-classes should generally call close() inside their destructors. We @@ -206,7 +208,7 @@ /// An input iterator over the recursive contents of a virtual path, /// similar to llvm::sys::fs::recursive_directory_iterator. -class recursive_directory_iterator { +class LLVM_SUPPORT_ABI recursive_directory_iterator { FileSystem *FS; std::shared_ptr State; // Input iterator semantics on copy. @@ -242,7 +244,7 @@ }; /// The virtual file system interface. -class FileSystem : public llvm::ThreadSafeRefCountedBase { +class LLVM_SUPPORT_ABI FileSystem : public llvm::ThreadSafeRefCountedBase { public: virtual ~FileSystem(); @@ -301,13 +303,13 @@ /// the operating system. /// The working directory is linked to the process's working directory. /// (This is usually thread-hostile). -IntrusiveRefCntPtr getRealFileSystem(); +LLVM_SUPPORT_ABI IntrusiveRefCntPtr getRealFileSystem(); /// Create an \p vfs::FileSystem for the 'real' file system, as seen by /// the operating system. /// It has its own working directory, independent of (but initially equal to) /// that of the process. -std::unique_ptr createPhysicalFileSystem(); +LLVM_SUPPORT_ABI std::unique_ptr createPhysicalFileSystem(); /// A file system that allows overlaying one \p AbstractFileSystem on top /// of another. @@ -319,7 +321,7 @@ /// top-most (most recently added) directory are used. When there is a file /// that exists in more than one file system, the file in the top-most file /// system overrides the other(s). -class OverlayFileSystem : public FileSystem { +class LLVM_SUPPORT_ABI OverlayFileSystem : public FileSystem { using FileSystemList = SmallVector, 1>; /// The stack of file systems, implemented as a list in order of @@ -367,7 +369,7 @@ /// By default, this delegates all calls to the underlying file system. This /// is useful when derived file systems want to override some calls and still /// proxy other calls. -class ProxyFileSystem : public FileSystem { +class LLVM_SUPPORT_ABI ProxyFileSystem : public FileSystem { public: explicit ProxyFileSystem(IntrusiveRefCntPtr FS) : FS(std::move(FS)) {} @@ -413,7 +415,7 @@ } // namespace detail /// An in-memory file system. -class InMemoryFileSystem : public FileSystem { +class LLVM_SUPPORT_ABI InMemoryFileSystem : public FileSystem { std::unique_ptr Root; std::string WorkingDirectory; bool UseNormalizedPaths = true; @@ -500,7 +502,7 @@ /// Gets a \p FileSystem for a virtual file system described in YAML /// format. -std::unique_ptr +LLVM_SUPPORT_ABI std::unique_ptr getVFSFromYAML(std::unique_ptr Buffer, llvm::SourceMgr::DiagHandlerTy DiagHandler, StringRef YAMLFilePath, void *DiagContext = nullptr, @@ -873,14 +875,14 @@ /// Collect all pairs of entries from the /// \p YAMLFilePath. This is used by the module dependency collector to forward /// the entries into the reproducer output VFS YAML file. -void collectVFSFromYAML( +LLVM_SUPPORT_ABI void collectVFSFromYAML( std::unique_ptr Buffer, llvm::SourceMgr::DiagHandlerTy DiagHandler, StringRef YAMLFilePath, SmallVectorImpl &CollectedEntries, void *DiagContext = nullptr, IntrusiveRefCntPtr ExternalFS = getRealFileSystem()); -class YAMLVFSWriter { +class LLVM_SUPPORT_ABI YAMLVFSWriter { std::vector Mappings; Optional IsCaseSensitive; Optional IsOverlayRelative; diff --git a/llvm/include/llvm/Support/WindowsError.h b/llvm/include/llvm/Support/WindowsError.h --- a/llvm/include/llvm/Support/WindowsError.h +++ b/llvm/include/llvm/Support/WindowsError.h @@ -9,10 +9,12 @@ #ifndef LLVM_SUPPORT_WINDOWSERROR_H #define LLVM_SUPPORT_WINDOWSERROR_H +#include "llvm/Support/LLVMSupportExports.h" + #include namespace llvm { -std::error_code mapWindowsError(unsigned EV); +LLVM_SUPPORT_ABI std::error_code mapWindowsError(unsigned EV); } #endif 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 { @@ -20,7 +21,7 @@ class OptionCategory; } -extern cl::OptionCategory &getColorCategory(); +LLVM_SUPPORT_ABI cl::OptionCategory &getColorCategory(); // Symbolic names for various syntax elements. enum class HighlightColor { @@ -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/X86TargetParser.h b/llvm/include/llvm/Support/X86TargetParser.h --- a/llvm/include/llvm/Support/X86TargetParser.h +++ b/llvm/include/llvm/Support/X86TargetParser.h @@ -16,6 +16,7 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringMap.h" +#include "llvm/Support/LLVMSupportExports.h" namespace llvm { class StringRef; @@ -133,30 +134,30 @@ /// Parse \p CPU string into a CPUKind. Will only accept 64-bit capable CPUs if /// \p Only64Bit is true. -CPUKind parseArchX86(StringRef CPU, bool Only64Bit = false); -CPUKind parseTuneCPU(StringRef CPU, bool Only64Bit = false); +LLVM_SUPPORT_ABI CPUKind parseArchX86(StringRef CPU, bool Only64Bit = false); +LLVM_SUPPORT_ABI CPUKind parseTuneCPU(StringRef CPU, bool Only64Bit = false); /// Provide a list of valid CPU names. If \p Only64Bit is true, the list will /// only contain 64-bit capable CPUs. -void fillValidCPUArchList(SmallVectorImpl &Values, +LLVM_SUPPORT_ABI void fillValidCPUArchList(SmallVectorImpl &Values, bool Only64Bit = false); /// Provide a list of valid -mtune names. -void fillValidTuneCPUList(SmallVectorImpl &Values, +LLVM_SUPPORT_ABI void fillValidTuneCPUList(SmallVectorImpl &Values, bool Only64Bit = false); /// Get the key feature prioritizing target multiversioning. -ProcessorFeatures getKeyFeature(CPUKind Kind); +LLVM_SUPPORT_ABI ProcessorFeatures getKeyFeature(CPUKind Kind); /// Fill in the features that \p CPU supports into \p Features. -void getFeaturesForCPU(StringRef CPU, SmallVectorImpl &Features); +LLVM_SUPPORT_ABI void getFeaturesForCPU(StringRef CPU, SmallVectorImpl &Features); /// Set or clear entries in \p Features that are implied to be enabled/disabled /// by the provided \p Feature. -void updateImpliedFeatures(StringRef Feature, bool Enabled, +LLVM_SUPPORT_ABI void updateImpliedFeatures(StringRef Feature, bool Enabled, StringMap &Features); -uint64_t getCpuSupportsMask(ArrayRef FeatureStrs); -unsigned getFeaturePriority(ProcessorFeatures Feat); +LLVM_SUPPORT_ABI uint64_t getCpuSupportsMask(ArrayRef FeatureStrs); +LLVM_SUPPORT_ABI unsigned getFeaturePriority(ProcessorFeatures Feat); } // namespace X86 } // namespace llvm diff --git a/llvm/include/llvm/Support/YAMLParser.h b/llvm/include/llvm/Support/YAMLParser.h --- a/llvm/include/llvm/Support/YAMLParser.h +++ b/llvm/include/llvm/Support/YAMLParser.h @@ -39,8 +39,10 @@ #include "llvm/ADT/StringRef.h" #include "llvm/Support/Allocator.h" +#include "llvm/Support/LLVMSupportExports.h" #include "llvm/Support/SMLoc.h" #include "llvm/Support/SourceMgr.h" + #include #include #include @@ -65,25 +67,25 @@ /// Dump all the tokens in this stream to OS. /// \returns true if there was an error, false otherwise. -bool dumpTokens(StringRef Input, raw_ostream &); +LLVM_SUPPORT_ABI bool dumpTokens(StringRef Input, raw_ostream &); /// Scans all tokens in input without outputting anything. This is used /// for benchmarking the tokenizer. /// \returns true if there was an error, false otherwise. -bool scanTokens(StringRef Input); +LLVM_SUPPORT_ABI bool scanTokens(StringRef Input); /// Escape \a Input for a double quoted scalar; if \p EscapePrintable /// is true, all UTF8 sequences will be escaped, if \p EscapePrintable is /// false, those UTF8 sequences encoding printable unicode scalars will not be /// escaped, but emitted verbatim. -std::string escape(StringRef Input, bool EscapePrintable = true); +LLVM_SUPPORT_ABI std::string escape(StringRef Input, bool EscapePrintable = true); /// Parse \p S as a bool according to https://yaml.org/type/bool.html. -llvm::Optional parseBool(StringRef S); +LLVM_SUPPORT_ABI llvm::Optional parseBool(StringRef S); /// This class represents a YAML stream potentially containing multiple /// documents. -class Stream { +class LLVM_SUPPORT_ABI Stream { public: /// This keeps a reference to the string referenced by \p Input. Stream(StringRef Input, SourceMgr &, bool ShowColors = true, @@ -116,7 +118,7 @@ }; /// Abstract base class for all Nodes. -class Node { +class LLVM_SUPPORT_ABI Node { virtual void anchor(); public: @@ -209,7 +211,7 @@ /// /// Example: /// Adena -class ScalarNode final : public Node { +class LLVM_SUPPORT_ABI ScalarNode final : public Node { void anchor() override; public: @@ -282,7 +284,7 @@ /// /// Example: /// Section: .text -class KeyValueNode final : public Node { +class LLVM_SUPPORT_ABI KeyValueNode final : public Node { void anchor() override; public: @@ -411,7 +413,7 @@ /// Example: /// Name: _main /// Scope: Global -class MappingNode final : public Node { +class LLVM_SUPPORT_ABI MappingNode final : public Node { void anchor() override; public: @@ -459,7 +461,7 @@ /// Example: /// - Hello /// - World -class SequenceNode final : public Node { +class LLVM_SUPPORT_ABI SequenceNode final : public Node { void anchor() override; public: @@ -528,7 +530,7 @@ /// A YAML Stream is a sequence of Documents. A document contains a root /// node. -class Document { +class LLVM_SUPPORT_ABI Document { public: Document(Stream &ParentStream); diff --git a/llvm/include/llvm/Support/YAMLTraits.h b/llvm/include/llvm/Support/YAMLTraits.h --- a/llvm/include/llvm/Support/YAMLTraits.h +++ b/llvm/include/llvm/Support/YAMLTraits.h @@ -18,12 +18,14 @@ #include "llvm/Support/AlignOf.h" #include "llvm/Support/Allocator.h" #include "llvm/Support/Endian.h" +#include "llvm/SUpport/LLVMSupportExports.h" #include "llvm/Support/Regex.h" #include "llvm/Support/SMLoc.h" #include "llvm/Support/SourceMgr.h" #include "llvm/Support/VersionTuple.h" #include "llvm/Support/YAMLParser.h" #include "llvm/Support/raw_ostream.h" + #include #include #include @@ -748,7 +750,7 @@ !has_MappingValidateTraits::value> {}; // Base class for Input and Output. -class IO { +class LLVM_SUPPORT_ABI IO { public: IO(void *Ctxt = nullptr); virtual ~IO(); @@ -1141,49 +1143,49 @@ } template<> -struct ScalarTraits { +struct LLVM_SUPPORT_ABI ScalarTraits { static void output(const bool &, void* , raw_ostream &); static StringRef input(StringRef, void *, bool &); static QuotingType mustQuote(StringRef) { return QuotingType::None; } }; template<> -struct ScalarTraits { +struct LLVM_SUPPORT_ABI ScalarTraits { static void output(const StringRef &, void *, raw_ostream &); static StringRef input(StringRef, void *, StringRef &); static QuotingType mustQuote(StringRef S) { return needsQuotes(S); } }; template<> -struct ScalarTraits { +struct LLVM_SUPPORT_ABI ScalarTraits { static void output(const std::string &, void *, raw_ostream &); static StringRef input(StringRef, void *, std::string &); static QuotingType mustQuote(StringRef S) { return needsQuotes(S); } }; template<> -struct ScalarTraits { +struct LLVM_SUPPORT_ABI ScalarTraits { static void output(const uint8_t &, void *, raw_ostream &); static StringRef input(StringRef, void *, uint8_t &); static QuotingType mustQuote(StringRef) { return QuotingType::None; } }; template<> -struct ScalarTraits { +struct LLVM_SUPPORT_ABI ScalarTraits { static void output(const uint16_t &, void *, raw_ostream &); static StringRef input(StringRef, void *, uint16_t &); static QuotingType mustQuote(StringRef) { return QuotingType::None; } }; template<> -struct ScalarTraits { +struct LLVM_SUPPORT_ABI ScalarTraits { static void output(const uint32_t &, void *, raw_ostream &); static StringRef input(StringRef, void *, uint32_t &); static QuotingType mustQuote(StringRef) { return QuotingType::None; } }; template<> -struct ScalarTraits { +struct LLVM_SUPPORT_ABI ScalarTraits { static void output(const uint64_t &, void *, raw_ostream &); static StringRef input(StringRef, void *, uint64_t &); static QuotingType mustQuote(StringRef) { return QuotingType::None; } @@ -1204,14 +1206,14 @@ }; template<> -struct ScalarTraits { +struct LLVM_SUPPORT_ABI ScalarTraits { static void output(const int32_t &, void *, raw_ostream &); static StringRef input(StringRef, void *, int32_t &); static QuotingType mustQuote(StringRef) { return QuotingType::None; } }; template<> -struct ScalarTraits { +struct LLVM_SUPPORT_ABI ScalarTraits { static void output(const int64_t &, void *, raw_ostream &); static StringRef input(StringRef, void *, int64_t &); static QuotingType mustQuote(StringRef) { return QuotingType::None; } @@ -1225,7 +1227,7 @@ }; template<> -struct ScalarTraits { +struct LLVM_SUPPORT_ABI ScalarTraits { static void output(const double &, void *, raw_ostream &); static StringRef input(StringRef, void *, double &); static QuotingType mustQuote(StringRef) { return QuotingType::None; } @@ -1370,7 +1372,7 @@ /// the mapRequired() method calls may not be in the same order /// as the keys in the document. /// -class Input : public IO { +class LLVM_SUPPORT_ABI Input : public IO { public: // Construct a yaml Input object from a StringRef and optional // user-data. The DiagHandler can be specified to provide @@ -1533,7 +1535,7 @@ /// The Output class is used to generate a yaml document from in-memory structs /// and vectors. /// -class Output : public IO { +class LLVM_SUPPORT_ABI Output : public IO { public: Output(raw_ostream &, void *Ctxt = nullptr, int WrapColumn = 70); ~Output() override; @@ -1690,34 +1692,34 @@ LLVM_YAML_STRONG_TYPEDEF(uint64_t, Hex64) template<> -struct ScalarTraits { +struct LLVM_SUPPORT_ABI ScalarTraits { static void output(const Hex8 &, void *, raw_ostream &); static StringRef input(StringRef, void *, Hex8 &); static QuotingType mustQuote(StringRef) { return QuotingType::None; } }; template<> -struct ScalarTraits { +struct LLVM_SUPPORT_ABI ScalarTraits { static void output(const Hex16 &, void *, raw_ostream &); static StringRef input(StringRef, void *, Hex16 &); static QuotingType mustQuote(StringRef) { return QuotingType::None; } }; template<> -struct ScalarTraits { +struct LLVM_SUPPORT_ABI ScalarTraits { static void output(const Hex32 &, void *, raw_ostream &); static StringRef input(StringRef, void *, Hex32 &); static QuotingType mustQuote(StringRef) { return QuotingType::None; } }; template<> -struct ScalarTraits { +struct LLVM_SUPPORT_ABI ScalarTraits { static void output(const Hex64 &, void *, raw_ostream &); static StringRef input(StringRef, void *, Hex64 &); static QuotingType mustQuote(StringRef) { return QuotingType::None; } }; -template <> struct ScalarTraits { +template <> struct LLVM_SUPPORT_ABI ScalarTraits { static void output(const VersionTuple &Value, void *, llvm::raw_ostream &Out); static StringRef input(StringRef, void *, VersionTuple &); static QuotingType mustQuote(StringRef) { return QuotingType::None; } 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 @@ -592,7 +594,7 @@ /// A raw_ostream of a file for reading/writing/seeking. /// -class raw_fd_stream : public raw_fd_ostream { +class LLVM_SUPPORT_ABI raw_fd_stream : public raw_fd_ostream { public: /// Open the specified file for reading/writing/seeking. If an error occurs, /// information about the error is put into EC, and the stream should be @@ -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; @@ -700,7 +702,7 @@ ~raw_null_ostream() override; }; -class buffer_ostream : public raw_svector_ostream { +class LLVM_SUPPORT_ABI buffer_ostream : public raw_svector_ostream { raw_ostream &OS; SmallVector Buffer; @@ -711,7 +713,7 @@ ~buffer_ostream() override { OS << str(); } }; -class buffer_unique_ostream : public raw_svector_ostream { +class LLVM_SUPPORT_ABI buffer_unique_ostream : public raw_svector_ostream { std::unique_ptr OS; SmallVector Buffer; @@ -731,7 +733,7 @@ /// for other names. For raw_fd_ostream instances, the stream writes to /// a temporary file. The final output file is atomically replaced with the /// temporary file after the \p Write function is finished. -Error writeToOutput(StringRef OutputFileName, +LLVM_SUPPORT_ABI Error writeToOutput(StringRef OutputFileName, std::function Write); } // end namespace llvm diff --git a/llvm/include/llvm/Support/thread.h b/llvm/include/llvm/Support/thread.h --- a/llvm/include/llvm/Support/thread.h +++ b/llvm/include/llvm/Support/thread.h @@ -18,6 +18,7 @@ #include "llvm/ADT/Optional.h" #include "llvm/Config/llvm-config.h" +#include "llvm/Support/LLVMSupportExports.h" #ifdef _WIN32 typedef unsigned long DWORD; @@ -118,11 +119,14 @@ native_handle_type Thread; }; -thread::native_handle_type +LLVM_SUPPORT_ABI thread::native_handle_type llvm_execute_on_thread_impl(thread::start_routine_type ThreadFunc, void *Arg, llvm::Optional StackSizeInBytes); -void llvm_thread_join_impl(thread::native_handle_type Thread); -void llvm_thread_detach_impl(thread::native_handle_type Thread); + +LLVM_SUPPORT_ABI void llvm_thread_join_impl(thread::native_handle_type Thread); + +LLVM_SUPPORT_ABI void llvm_thread_detach_impl(thread::native_handle_type Thread); + thread::id llvm_thread_get_id_impl(thread::native_handle_type Thread); thread::id llvm_thread_get_current_id_impl(); diff --git a/llvm/include/llvm/Support/xxhash.h b/llvm/include/llvm/Support/xxhash.h --- a/llvm/include/llvm/Support/xxhash.h +++ b/llvm/include/llvm/Support/xxhash.h @@ -40,10 +40,11 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/StringRef.h" +#include "llvm/Support/LLVMSupportExports.h" namespace llvm { -uint64_t xxHash64(llvm::StringRef Data); -uint64_t xxHash64(llvm::ArrayRef Data); +LLVM_SUPPORT_ABI uint64_t xxHash64(llvm::StringRef Data); +LLVM_SUPPORT_ABI uint64_t xxHash64(llvm::ArrayRef Data); } #endif 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) diff --git a/llvm/lib/Support/Windows/Threading.inc b/llvm/lib/Support/Windows/Threading.inc --- a/llvm/lib/Support/Windows/Threading.inc +++ b/llvm/lib/Support/Windows/Threading.inc @@ -24,7 +24,7 @@ #endif namespace llvm { -HANDLE +LLVM_SUPPORT_ABI HANDLE llvm_execute_on_thread_impl(unsigned(__stdcall *ThreadFunc)(void *), void *Arg, llvm::Optional StackSizeInBytes) { HANDLE hThread = (HANDLE)::_beginthreadex( @@ -37,12 +37,14 @@ return hThread; } +LLVM_SUPPORT_ABI void llvm_thread_join_impl(HANDLE hThread) { if (::WaitForSingleObject(hThread, INFINITE) == WAIT_FAILED) { ReportLastErrorFatal("WaitForSingleObject failed"); } } +LLVM_SUPPORT_ABI void llvm_thread_detach_impl(HANDLE hThread) { if (::CloseHandle(hThread) == FALSE) { ReportLastErrorFatal("CloseHandle failed");