[llvm] [Support] Use std::move in AllocatorHolder's move constructor (NFC) (PR #160444)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 23 22:58:10 PDT 2025


https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/160444

std::move is more idiomatic and readable than the equivalent
static_cast.


>From 5cd599e4909b42919f2d28d8cc70cc29c5bf3359 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Tue, 23 Sep 2025 08:41:47 -0700
Subject: [PATCH] [Support] Use std::move in AllocatorHolder's move constructor
 (NFC)

std::move is more idiomatic and readable than the equivalent
static_cast.
---
 llvm/include/llvm/Support/AllocatorBase.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/include/llvm/Support/AllocatorBase.h b/llvm/include/llvm/Support/AllocatorBase.h
index 0442432250069..3cfc4425bd406 100644
--- a/llvm/include/llvm/Support/AllocatorBase.h
+++ b/llvm/include/llvm/Support/AllocatorBase.h
@@ -111,7 +111,7 @@ template <typename Alloc> class AllocatorHolder : Alloc {
 public:
   AllocatorHolder() = default;
   AllocatorHolder(const Alloc &A) : Alloc(A) {}
-  AllocatorHolder(Alloc &&A) : Alloc(static_cast<Alloc &&>(A)) {}
+  AllocatorHolder(Alloc &&A) : Alloc(std::move(A)) {}
   Alloc &getAllocator() { return *this; }
   const Alloc &getAllocator() const { return *this; }
 };



More information about the llvm-commits mailing list