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

via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 2 21:51:16 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-support

Author: Kazu Hirata (kazutakahirata)

<details>
<summary>Changes</summary>



---
Full diff: https://github.com/llvm/llvm-project/pull/161778.diff


1 Files Affected:

- (modified) llvm/include/llvm/Support/ScopedPrinter.h (+3-7) 


``````````diff
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) {

``````````

</details>


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


More information about the llvm-commits mailing list