[llvm] [Support][ScopedPrinter] Remove unused printVersion (PR #203166)

Shawn Zhong via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 10 21:11:12 PDT 2026


https://github.com/ShawnZhong created https://github.com/llvm/llvm-project/pull/203166

While I was working on #200069, I found that `ScopedPrinter::printVersion` is also broken for JSON output, as it does not have or use `JSONScopedPrinter` override. 

Luckily, this function has no real caller, so it might as well just be removed. 

A bit of history: 
- `printVersion` was added in  https://github.com/llvm/llvm-project/commit/cdd313ca1980 ("Use ScopedPrinter in llvm-pdbdump") to print PDB header versions. 
- Its only callers were removed in https://github.com/llvm/llvm-project/commit/b560fdf3b84e ([llvm-pdbutil] rewrite the "raw" output style), and it has had no users since except for its own unit test. 

>From 16b07ff29b49736157f6feb36ac120d5f8a44d7c Mon Sep 17 00:00:00 2001
From: ShawnZhong <github at shawnzhong.com>
Date: Thu, 11 Jun 2026 04:04:39 +0000
Subject: [PATCH] [Support][ScopedPrinter] Remove unused printVersion

---
 llvm/include/llvm/Support/ScopedPrinter.h    | 8 --------
 llvm/unittests/Support/ScopedPrinterTest.cpp | 9 ---------
 2 files changed, 17 deletions(-)

diff --git a/llvm/include/llvm/Support/ScopedPrinter.h b/llvm/include/llvm/Support/ScopedPrinter.h
index e9e9903b2482a..c3bf79f71937c 100644
--- a/llvm/include/llvm/Support/ScopedPrinter.h
+++ b/llvm/include/llvm/Support/ScopedPrinter.h
@@ -284,14 +284,6 @@ class LLVM_ABI ScopedPrinter {
     startLine() << Label << ": " << (Value ? "Yes" : "No") << '\n';
   }
 
-  template <typename T, typename... TArgs>
-  void printVersion(StringRef Label, T MajorVersion, TArgs... MinorVersions) {
-    startLine() << Label << ": ";
-    getOStream() << MajorVersion;
-    ((getOStream() << '.' << MinorVersions), ...);
-    getOStream() << "\n";
-  }
-
   template <typename T>
   void printList(StringRef Label, const ArrayRef<T> List) {
     SmallVector<std::string, 10> StringList;
diff --git a/llvm/unittests/Support/ScopedPrinterTest.cpp b/llvm/unittests/Support/ScopedPrinterTest.cpp
index 280b3ee8c29c9..9a0ba5727682a 100644
--- a/llvm/unittests/Support/ScopedPrinterTest.cpp
+++ b/llvm/unittests/Support/ScopedPrinterTest.cpp
@@ -731,15 +731,6 @@ False: No
   verifyAll(ExpectedOut, JSONExpectedOut, PrintFunc);
 }
 
-TEST_F(ScopedPrinterTest, PrintVersion) {
-  auto PrintFunc = [](ScopedPrinter &W) {
-    W.printVersion("Version", "123", "456", "789");
-  };
-  const char *ExpectedOut = R"(Version: 123.456.789
-)";
-  verifyScopedPrinter(ExpectedOut, PrintFunc);
-}
-
 TEST_F(ScopedPrinterTest, PrintList) {
   auto PrintFunc = [](ScopedPrinter &W) {
     const std::vector<uint64_t> EmptyList;



More information about the llvm-commits mailing list