[llvm] [Support] Use a C++17 fold expression in ScopedPrinter.h (NFC) (PR #161778)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 2 21:50:40 PDT 2025


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

None

>From ef1403ccd97fda282758526ca19493c6b56f073e Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Tue, 30 Sep 2025 23:02:10 -0700
Subject: [PATCH] [Support] Use a C++17 fold expression in ScopedPrinter.h
 (NFC)

---
 llvm/include/llvm/Support/ScopedPrinter.h | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/llvm/include/llvm/Support/ScopedPrinter.h b/llvm/include/llvm/Support/ScopedPrinter.h
index a08cc8fd31fd2..ce125f60fd44c 100644
--- a/llvm/include/llvm/Support/ScopedPrinter.h
+++ b/llvm/include/llvm/Support/ScopedPrinter.h
@@ -454,14 +454,10 @@ class LLVM_ABI ScopedPrinter {
   virtual raw_ostream &getOStream() { return OS; }
 
 private:
-  template <typename T> void printVersionInternal(T Value) {
+  template <typename T, typename... TArgs>
+  void printVersionInternal(T Value, TArgs... Args) {
     getOStream() << Value;
-  }
-
-  template <typename S, typename T, typename... TArgs>
-  void printVersionInternal(S Value, T Value2, TArgs... Args) {
-    getOStream() << Value << ".";
-    printVersionInternal(Value2, Args...);
+    ((getOStream() << '.' << Args), ...);
   }
 
   static bool flagName(const FlagEntry &LHS, const FlagEntry &RHS) {



More information about the llvm-commits mailing list