[llvm] [llvm][ADT] Mark scope_exit contructors [[nodiscard]] (PR #179720)

Balázs Benics via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 4 10:02:13 PST 2026


https://github.com/steakhal created https://github.com/llvm/llvm-project/pull/179720

None

>From 54476fd40039c6fd0bd06e281005fca68b1a8fd7 Mon Sep 17 00:00:00 2001
From: Balazs Benics <benicsbalazs at gmail.com>
Date: Wed, 4 Feb 2026 18:16:01 +0100
Subject: [PATCH] [llvm][ADT] Mark scope_exit contructors [[nodiscard]]

---
 llvm/include/llvm/ADT/ScopeExit.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/llvm/include/llvm/ADT/ScopeExit.h b/llvm/include/llvm/ADT/ScopeExit.h
index 1c0d52eb58aca..6bf1a62846294 100644
--- a/llvm/include/llvm/ADT/ScopeExit.h
+++ b/llvm/include/llvm/ADT/ScopeExit.h
@@ -26,9 +26,10 @@ template <typename Callable> class scope_exit {
 
 public:
   template <typename Fp>
-  explicit scope_exit(Fp &&F) : ExitFunction(std::forward<Fp>(F)) {}
+  [[nodiscard]] explicit scope_exit(Fp &&F)
+      : ExitFunction(std::forward<Fp>(F)) {}
 
-  scope_exit(scope_exit &&Rhs)
+  [[nodiscard]] scope_exit(scope_exit &&Rhs)
       : ExitFunction(std::move(Rhs.ExitFunction)), Engaged(Rhs.Engaged) {
     Rhs.release();
   }



More information about the llvm-commits mailing list