[llvm] [llvm-lto2] Replace std::atomic_init with brace initiation. NFC (PR #143274)

via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 7 09:15:02 PDT 2025


https://github.com/scuzqy created https://github.com/llvm/llvm-project/pull/143274

In C++ 20, std::atomic_init is deprecated.
This patch replaces call to std::atomic_init with brace initiation.

>From 9ffce95045ee99cf5389b7f1eb1a26ddd7e42995 Mon Sep 17 00:00:00 2001
From: scuzqy <scuzqy at outlook.com>
Date: Sun, 8 Jun 2025 00:14:13 +0800
Subject: [PATCH] [llvm-lto2] Replace std::atomic_init with brace initiation.
 NFC

In C++ 20, std::atomic_init is deprecated.
This patch replaces call to std::atomic_init with brace initiation.
---
 llvm/tools/llvm-lto2/llvm-lto2.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/llvm/tools/llvm-lto2/llvm-lto2.cpp b/llvm/tools/llvm-lto2/llvm-lto2.cpp
index 2bbb65be3b31e..95cd4cf1777e5 100644
--- a/llvm/tools/llvm-lto2/llvm-lto2.cpp
+++ b/llvm/tools/llvm-lto2/llvm-lto2.cpp
@@ -394,8 +394,7 @@ static int run(int argc, char **argv) {
   // behavior. Instead, we don't exit in the multi-threaded case, but we make
   // sure to report the error and then at the end (after joining cleanly)
   // exit(1).
-  std::atomic<bool> HasErrors;
-  std::atomic_init(&HasErrors, false);
+  std::atomic<bool> HasErrors{false};
   Conf.DiagHandler = [&](const DiagnosticInfo &DI) {
     DiagnosticPrinterRawOStream DP(errs());
     DI.print(DP);



More information about the llvm-commits mailing list