From d563b1380313e6669fc72c470b3ae4a7ba1497f0 Mon Sep 17 00:00:00 2001 From: Justin Bogner Date: Sun, 16 Oct 2016 20:56:20 +0000 Subject: [PATCH] Support: Prefer the LLVM_NODISCARD spelling Update functions annotated with LLVM_ATTRIBUTE_UNUSED_RESULT to use LLVM_NODISCARD instead. llvm-svn: 284344 --- llvm/include/llvm/Support/Casting.h | 48 +++++++++++++++-------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/llvm/include/llvm/Support/Casting.h b/llvm/include/llvm/Support/Casting.h index 6ba5efa47554..a73047b2b557 100644 --- a/llvm/include/llvm/Support/Casting.h +++ b/llvm/include/llvm/Support/Casting.h @@ -128,8 +128,7 @@ struct isa_impl_wrap { // // if (isa(myVal)) { ... } // -template -LLVM_ATTRIBUTE_UNUSED_RESULT inline bool isa(const Y &Val) { +template LLVM_NODISCARD inline bool isa(const Y &Val) { return isa_impl_wrap::SimpleType>::doit(Val); } @@ -243,9 +242,10 @@ inline typename cast_retty::ret_type cast(Y *Val) { // accepted. // template -LLVM_ATTRIBUTE_UNUSED_RESULT inline typename std::enable_if< - !is_simple_type::value, typename cast_retty::ret_type>::type -cast_or_null(const Y &Val) { +LLVM_NODISCARD inline + typename std::enable_if::value, + typename cast_retty::ret_type>::type + cast_or_null(const Y &Val) { if (!Val) return nullptr; assert(isa(Val) && "cast_or_null() argument of incompatible type!"); @@ -253,9 +253,10 @@ cast_or_null(const Y &Val) { } template -LLVM_ATTRIBUTE_UNUSED_RESULT inline typename std::enable_if< - !is_simple_type::value, typename cast_retty::ret_type>::type -cast_or_null(Y &Val) { +LLVM_NODISCARD inline + typename std::enable_if::value, + typename cast_retty::ret_type>::type + cast_or_null(Y &Val) { if (!Val) return nullptr; assert(isa(Val) && "cast_or_null() argument of incompatible type!"); @@ -263,7 +264,7 @@ cast_or_null(Y &Val) { } template -LLVM_ATTRIBUTE_UNUSED_RESULT inline typename cast_retty::ret_type +LLVM_NODISCARD inline typename cast_retty::ret_type cast_or_null(Y *Val) { if (!Val) return nullptr; assert(isa(Val) && "cast_or_null() argument of incompatible type!"); @@ -280,21 +281,20 @@ cast_or_null(Y *Val) { // template -LLVM_ATTRIBUTE_UNUSED_RESULT inline typename std::enable_if< - !is_simple_type::value, typename cast_retty::ret_type>::type -dyn_cast(const Y &Val) { +LLVM_NODISCARD inline + typename std::enable_if::value, + typename cast_retty::ret_type>::type + dyn_cast(const Y &Val) { return isa(Val) ? cast(Val) : nullptr; } template -LLVM_ATTRIBUTE_UNUSED_RESULT inline typename cast_retty::ret_type -dyn_cast(Y &Val) { +LLVM_NODISCARD inline typename cast_retty::ret_type dyn_cast(Y &Val) { return isa(Val) ? cast(Val) : nullptr; } template -LLVM_ATTRIBUTE_UNUSED_RESULT inline typename cast_retty::ret_type -dyn_cast(Y *Val) { +LLVM_NODISCARD inline typename cast_retty::ret_type dyn_cast(Y *Val) { return isa(Val) ? cast(Val) : nullptr; } @@ -302,21 +302,23 @@ dyn_cast(Y *Val) { // value is accepted. // template -LLVM_ATTRIBUTE_UNUSED_RESULT inline typename std::enable_if< - !is_simple_type::value, typename cast_retty::ret_type>::type -dyn_cast_or_null(const Y &Val) { +LLVM_NODISCARD inline + typename std::enable_if::value, + typename cast_retty::ret_type>::type + dyn_cast_or_null(const Y &Val) { return (Val && isa(Val)) ? cast(Val) : nullptr; } template -LLVM_ATTRIBUTE_UNUSED_RESULT inline typename std::enable_if< - !is_simple_type::value, typename cast_retty::ret_type>::type -dyn_cast_or_null(Y &Val) { +LLVM_NODISCARD inline + typename std::enable_if::value, + typename cast_retty::ret_type>::type + dyn_cast_or_null(Y &Val) { return (Val && isa(Val)) ? cast(Val) : nullptr; } template -LLVM_ATTRIBUTE_UNUSED_RESULT inline typename cast_retty::ret_type +LLVM_NODISCARD inline typename cast_retty::ret_type dyn_cast_or_null(Y *Val) { return (Val && isa(Val)) ? cast(Val) : nullptr; }