[llvm] 238ccd0 - [llvm][ADT] Mark scope_exit contructors [[nodiscard]] (#179720)

via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 5 04:54:53 PST 2026


Author: Balázs Benics
Date: 2026-02-05T12:54:48Z
New Revision: 238ccd0223bfdd0749fe91e303523b476f5436a1

URL: https://github.com/llvm/llvm-project/commit/238ccd0223bfdd0749fe91e303523b476f5436a1
DIFF: https://github.com/llvm/llvm-project/commit/238ccd0223bfdd0749fe91e303523b476f5436a1.diff

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

Added: 
    

Modified: 
    llvm/include/llvm/ADT/ScopeExit.h

Removed: 
    


################################################################################
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