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 @@ -92,8 +92,8 @@ } constexpr bool has_value() const noexcept { return hasVal; } - [[deprecated("Use has_value instead.")]] constexpr bool - hasValue() const noexcept { + LLVM_DEPRECATED("Use has_value instead.", "has_value") + constexpr bool hasValue() const noexcept { return hasVal; } @@ -101,7 +101,7 @@ assert(hasVal); return val; } - [[deprecated("Use value instead.")]] T &getValue() &noexcept { + LLVM_DEPRECATED("Use value instead.", "value") T &getValue() &noexcept { assert(hasVal); return val; } @@ -109,8 +109,8 @@ assert(hasVal); return val; } - [[deprecated("Use value instead.")]] constexpr T const & - getValue() const &noexcept { + LLVM_DEPRECATED("Use value instead.", "value") + constexpr T const &getValue() const &noexcept { assert(hasVal); return val; } @@ -118,7 +118,7 @@ assert(hasVal); return std::move(val); } - [[deprecated("Use value instead.")]] T &&getValue() &&noexcept { + LLVM_DEPRECATED("Use value instead.", "value") T &&getValue() &&noexcept { assert(hasVal); return std::move(val); } @@ -207,8 +207,8 @@ } constexpr bool has_value() const noexcept { return hasVal; } - [[deprecated("Use has_value instead.")]] constexpr bool - hasValue() const noexcept { + LLVM_DEPRECATED("Use has_value instead.", "has_value") + constexpr bool hasValue() const noexcept { return hasVal; } @@ -216,7 +216,7 @@ assert(hasVal); return val; } - [[deprecated("Use value instead.")]] T &getValue() &noexcept { + LLVM_DEPRECATED("Use value instead.", "value") T &getValue() &noexcept { assert(hasVal); return val; } @@ -224,8 +224,8 @@ assert(hasVal); return val; } - [[deprecated("Use value instead.")]] constexpr T const & - getValue() const &noexcept { + LLVM_DEPRECATED("Use value instead.", "value") + constexpr T const &getValue() const &noexcept { assert(hasVal); return val; } @@ -233,7 +233,7 @@ assert(hasVal); return std::move(val); } - [[deprecated("Use value instead.")]] T &&getValue() &&noexcept { + LLVM_DEPRECATED("Use value instead.", "value") T &&getValue() &&noexcept { assert(hasVal); return std::move(val); } @@ -311,17 +311,19 @@ constexpr const T *getPointer() const { return &Storage.value(); } T *getPointer() { return &Storage.value(); } constexpr const T &value() const & { return Storage.value(); } - [[deprecated("Use value instead.")]] constexpr const T &getValue() const & { + LLVM_DEPRECATED("Use value instead.", "value") + constexpr const T &getValue() const & { return Storage.value(); } T &value() & { return Storage.value(); } - [[deprecated("Use value instead.")]] T &getValue() & { + LLVM_DEPRECATED("Use value instead.", "value") T &getValue() & { return Storage.value(); } constexpr explicit operator bool() const { return has_value(); } constexpr bool has_value() const { return Storage.has_value(); } - [[deprecated("Use has_value instead.")]] constexpr bool hasValue() const { + LLVM_DEPRECATED("Use has_value instead.", "has_value") + constexpr bool hasValue() const { return Storage.has_value(); } constexpr const T *operator->() const { return getPointer(); } @@ -333,8 +335,8 @@ return has_value() ? value() : std::forward(alt); } template - [[deprecated("Use value_or instead.")]] constexpr T - getValueOr(U &&alt) const & { + LLVM_DEPRECATED("Use value_or instead.", "value_or") + constexpr T getValueOr(U &&alt) const & { return has_value() ? value() : std::forward(alt); } @@ -347,7 +349,7 @@ } T &&value() && { return std::move(Storage.value()); } - [[deprecated("Use value instead.")]] T &&getValue() && { + LLVM_DEPRECATED("Use value instead.", "value") T &&getValue() && { return std::move(Storage.value()); } T &&operator*() && { return std::move(Storage.value()); } @@ -356,7 +358,8 @@ return has_value() ? std::move(value()) : std::forward(alt); } template - [[deprecated("Use value_or instead.")]] T getValueOr(U &&alt) && { + LLVM_DEPRECATED("Use value_or instead.", "value_or") + T getValueOr(U &&alt) && { return has_value() ? std::move(value()) : std::forward(alt); } diff --git a/llvm/include/llvm/Support/Compiler.h b/llvm/include/llvm/Support/Compiler.h --- a/llvm/include/llvm/Support/Compiler.h +++ b/llvm/include/llvm/Support/Compiler.h @@ -138,6 +138,12 @@ #define LLVM_ATTRIBUTE_USED #endif +#if defined(__clang__) +#define LLVM_DEPRECATED(MSG, FIX) __attribute__((deprecated(MSG, FIX))) +#else +#define LLVM_DEPRECATED(MSG, FIX) [[deprecated(MSG)]] +#endif + /// LLVM_NODISCARD - Warn if a type or return value is discarded. // Use the 'nodiscard' attribute in C++17 or newer mode.