[llvm] [LLVM][ADT] Deprecate `make_scope_exit` in favour of CTAD (PR #174109)

Victor Chernyakin via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 31 13:16:34 PST 2025


https://github.com/localspook updated https://github.com/llvm/llvm-project/pull/174109

>From d9d96f6bba5d87bbc3c69c8cb538448317c3b18e Mon Sep 17 00:00:00 2001
From: Victor Chernyakin <chernyakin.victor.j at outlook.com>
Date: Wed, 31 Dec 2025 12:41:51 -0800
Subject: [PATCH 1/2] [LLVM][ADT] Deprecate `make_scope_exit` in favour of CTAD

---
 llvm/include/llvm/ADT/ScopeExit.h | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/llvm/include/llvm/ADT/ScopeExit.h b/llvm/include/llvm/ADT/ScopeExit.h
index 04b602a69f7e3..9888a0f22d192 100644
--- a/llvm/include/llvm/ADT/ScopeExit.h
+++ b/llvm/include/llvm/ADT/ScopeExit.h
@@ -15,6 +15,7 @@
 #ifndef LLVM_ADT_SCOPEEXIT_H
 #define LLVM_ADT_SCOPEEXIT_H
 
+#include "llvm/Support/Compiler.h"
 #include <utility>
 
 namespace llvm {
@@ -50,7 +51,13 @@ template <typename Callable> scope_exit(Callable) -> scope_exit<Callable>;
 // returned object is kept).
 //
 // Interface is specified by p0052r2.
-template <typename Callable> [[nodiscard]] auto make_scope_exit(Callable &&F) {
+template <typename Callable>
+[[nodiscard]]
+LLVM_DEPRECATED(
+    "llvm::make_scope_exit is deprecated and will be removed in LLVM 24. "
+    "Prefer calling the constructor of llvm::scope_exit directly.",
+    "scope_exit") auto make_scope_exit(Callable &&F) {
+  // TODO(LLVM 24): Remove this function.
   return scope_exit(std::forward<Callable>(F));
 }
 

>From 3b822993c20aeb5d68eda3e789f8d6fee795f32c Mon Sep 17 00:00:00 2001
From: Victor Chernyakin <chernyakin.victor.j at outlook.com>
Date: Wed, 31 Dec 2025 13:16:22 -0800
Subject: [PATCH 2/2] Adjust deprecation message

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

diff --git a/llvm/include/llvm/ADT/ScopeExit.h b/llvm/include/llvm/ADT/ScopeExit.h
index 9888a0f22d192..1c0d52eb58aca 100644
--- a/llvm/include/llvm/ADT/ScopeExit.h
+++ b/llvm/include/llvm/ADT/ScopeExit.h
@@ -53,10 +53,8 @@ template <typename Callable> scope_exit(Callable) -> scope_exit<Callable>;
 // Interface is specified by p0052r2.
 template <typename Callable>
 [[nodiscard]]
-LLVM_DEPRECATED(
-    "llvm::make_scope_exit is deprecated and will be removed in LLVM 24. "
-    "Prefer calling the constructor of llvm::scope_exit directly.",
-    "scope_exit") auto make_scope_exit(Callable &&F) {
+LLVM_DEPRECATED("Prefer calling the constructor of llvm::scope_exit directly.",
+                "scope_exit") auto make_scope_exit(Callable &&F) {
   // TODO(LLVM 24): Remove this function.
   return scope_exit(std::forward<Callable>(F));
 }



More information about the llvm-commits mailing list