[llvm] [Support] Insertion operator should be forwarded, not moved (PR #152326)

via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 6 09:00:23 PDT 2025


https://github.com/AZero13 updated https://github.com/llvm/llvm-project/pull/152326

>From 7f0f3b0350f62974644359fc1342f93ae81ff2ae Mon Sep 17 00:00:00 2001
From: AZero13 <gfunni234 at gmail.com>
Date: Wed, 6 Aug 2025 11:35:17 -0400
Subject: [PATCH 1/2] [Support] Insertion operator should be forwarded, not
 moved

It is a forwarding reference, after all.
---
 llvm/include/llvm/Support/raw_ostream.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/include/llvm/Support/raw_ostream.h b/llvm/include/llvm/Support/raw_ostream.h
index f87344e860518..01e4a1de86495 100644
--- a/llvm/include/llvm/Support/raw_ostream.h
+++ b/llvm/include/llvm/Support/raw_ostream.h
@@ -426,7 +426,7 @@ std::enable_if_t<!std::is_reference_v<OStream> &&
                  OStream &&>
 operator<<(OStream &&OS, const T &Value) {
   OS << Value;
-  return std::move(OS);
+  return std::forward<OStream>(OS);
 }
 
 /// An abstract base class for streams implementations that also support a

>From ad2e7a43be7ab0fded6ef5361cfd25d0d42a1b10 Mon Sep 17 00:00:00 2001
From: AZero13 <gfunni234 at gmail.com>
Date: Wed, 6 Aug 2025 12:00:13 -0400
Subject: [PATCH 2/2] use std::forward

---
 llvm/lib/TextAPI/TextStubV5.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/TextAPI/TextStubV5.cpp b/llvm/lib/TextAPI/TextStubV5.cpp
index f2687513bb854..b0ddd579facfb 100644
--- a/llvm/lib/TextAPI/TextStubV5.cpp
+++ b/llvm/lib/TextAPI/TextStubV5.cpp
@@ -768,7 +768,7 @@ template <typename ContainerT = Array>
 bool insertNonEmptyValues(Object &Obj, TBDKey Key, ContainerT &&Contents) {
   if (Contents.empty())
     return false;
-  Obj[Keys[Key]] = std::move(Contents);
+  Obj[Keys[Key]] = std::forward<ContainerT>(Contents);
   return true;
 }
 



More information about the llvm-commits mailing list