[llvm] [orc-rt] Replace ORC_RT_NODISCARD with [[nodiscard]]. NFCI. (PR #209169)
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 13 05:52:06 PDT 2026
https://github.com/lhames created https://github.com/llvm/llvm-project/pull/209169
The ORC runtime requires C++17, so we can use the C++17 [[nodiscard]] attribute directly, rather than going through a macro.
>From a532ac8b24df8606975144676b86f39fab9e34d0 Mon Sep 17 00:00:00 2001
From: Lang Hames <lhames at gmail.com>
Date: Mon, 13 Jul 2026 22:43:00 +1000
Subject: [PATCH] [orc-rt] Replace ORC_RT_NODISCARD with [[nodiscard]]. NFCI.
The ORC runtime requires C++17, so we can use the C++17 [[nodiscard]]
attribute directly, rather than going through a macro.
---
orc-rt/include/orc-rt/Compiler.h | 16 ----------------
orc-rt/include/orc-rt/Error.h | 4 ++--
2 files changed, 2 insertions(+), 18 deletions(-)
diff --git a/orc-rt/include/orc-rt/Compiler.h b/orc-rt/include/orc-rt/Compiler.h
index e0c0c0989a1c7..8c65ddfab4bbd 100644
--- a/orc-rt/include/orc-rt/Compiler.h
+++ b/orc-rt/include/orc-rt/Compiler.h
@@ -39,22 +39,6 @@
#endif
#endif
-// Use the 'nodiscard' attribute in C++17 or newer mode.
-#if defined(__cplusplus) && __cplusplus > 201402L && \
- ORC_RT_HAS_CPP_ATTRIBUTE(nodiscard)
-#define ORC_RT_NODISCARD [[nodiscard]]
-#elif ORC_RT_HAS_CPP_ATTRIBUTE(clang::warn_unused_result)
-#define ORC_RT_NODISCARD [[clang::warn_unused_result]]
-// Clang in C++14 mode claims that it has the 'nodiscard' attribute, but also
-// warns in the pedantic mode that 'nodiscard' is a C++17 extension (PR33518).
-// Use the 'nodiscard' attribute in C++14 mode only with GCC.
-// TODO: remove this workaround when PR33518 is resolved.
-#elif defined(__GNUC__) && ORC_RT_HAS_CPP_ATTRIBUTE(nodiscard)
-#define ORC_RT_NODISCARD [[nodiscard]]
-#else
-#define ORC_RT_NODISCARD
-#endif
-
#if __has_builtin(__builtin_expect)
#define ORC_RT_LIKELY(EXPR) __builtin_expect((bool)(EXPR), true)
#define ORC_RT_UNLIKELY(EXPR) __builtin_expect((bool)(EXPR), false)
diff --git a/orc-rt/include/orc-rt/Error.h b/orc-rt/include/orc-rt/Error.h
index e1978d91c7034..57c7754656f19 100644
--- a/orc-rt/include/orc-rt/Error.h
+++ b/orc-rt/include/orc-rt/Error.h
@@ -82,7 +82,7 @@ template <typename ThisT, typename ParentT>
char ErrorExtends<ThisT, ParentT>::ID = 0;
/// Represents an environmental error.
-class ORC_RT_NODISCARD Error {
+class [[nodiscard]] Error {
template <typename T> friend class Expected;
@@ -356,7 +356,7 @@ class ErrorAsOutParameter {
/// Expected constructor for details.
struct ForceExpectedSuccessValue {};
-template <typename T> class ORC_RT_NODISCARD Expected {
+template <typename T> class [[nodiscard]] Expected {
template <class OtherT> friend class Expected;
More information about the llvm-commits
mailing list