[llvm] [NFC][LLVM][Support] Misc code cleanup in ScopedPrinter (PR #161462)
Rahul Joshi via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 1 13:06:00 PDT 2025
https://github.com/jurahul updated https://github.com/llvm/llvm-project/pull/161462
>From 46000da42cb939b4525649c2b1b7096ce3bbf837 Mon Sep 17 00:00:00 2001
From: Rahul Joshi <rjoshi at nvidia.com>
Date: Tue, 30 Sep 2025 17:12:28 -0700
Subject: [PATCH 1/3] [NFC][LLVM][Support] Misc code cleanup in ScopedPrinter
- Use character instead of a single character string.
- Add missing header to ScopedPrinter.cpp and adjust the code to
conform to LLVM coding standards.
---
llvm/lib/Support/ScopedPrinter.cpp | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/llvm/lib/Support/ScopedPrinter.cpp b/llvm/lib/Support/ScopedPrinter.cpp
index a17e397c0aa58..9eadb456ab1a4 100644
--- a/llvm/lib/Support/ScopedPrinter.cpp
+++ b/llvm/lib/Support/ScopedPrinter.cpp
@@ -1,12 +1,22 @@
-#include "llvm/Support/ScopedPrinter.h"
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// Implementation of ScopedPrinter.
+//
+//===----------------------------------------------------------------------===//
+#include "llvm/Support/ScopedPrinter.h"
#include "llvm/Support/Format.h"
+using namespace llvm;
using namespace llvm::support;
-namespace llvm {
-
-raw_ostream &operator<<(raw_ostream &OS, const HexNumber &Value) {
+raw_ostream &llvm::operator<<(raw_ostream &OS, const HexNumber &Value) {
OS << "0x" << utohexstr(Value.Value);
return OS;
}
@@ -45,5 +55,3 @@ JSONScopedPrinter::JSONScopedPrinter(
if (this->OuterScope)
this->OuterScope->setPrinter(*this);
}
-
-} // namespace llvm
>From e737d8ca396c8d075c5e29acfeb966e5cb362adf Mon Sep 17 00:00:00 2001
From: Rahul Joshi <rjoshi at nvidia.com>
Date: Wed, 1 Oct 2025 08:58:08 -0700
Subject: [PATCH 2/3] Drop unused using namespace
---
llvm/lib/Support/ScopedPrinter.cpp | 1 -
1 file changed, 1 deletion(-)
diff --git a/llvm/lib/Support/ScopedPrinter.cpp b/llvm/lib/Support/ScopedPrinter.cpp
index 9eadb456ab1a4..0fbf690cfe476 100644
--- a/llvm/lib/Support/ScopedPrinter.cpp
+++ b/llvm/lib/Support/ScopedPrinter.cpp
@@ -14,7 +14,6 @@
#include "llvm/Support/Format.h"
using namespace llvm;
-using namespace llvm::support;
raw_ostream &llvm::operator<<(raw_ostream &OS, const HexNumber &Value) {
OS << "0x" << utohexstr(Value.Value);
>From 60aecb810198aecaf00a2dea35ef21afb5595492 Mon Sep 17 00:00:00 2001
From: Rahul Joshi <rjoshi at nvidia.com>
Date: Wed, 1 Oct 2025 09:25:42 -0700
Subject: [PATCH 3/3] Review feedback
---
llvm/lib/Support/ScopedPrinter.cpp | 4 ----
1 file changed, 4 deletions(-)
diff --git a/llvm/lib/Support/ScopedPrinter.cpp b/llvm/lib/Support/ScopedPrinter.cpp
index 0fbf690cfe476..efb61785d17b0 100644
--- a/llvm/lib/Support/ScopedPrinter.cpp
+++ b/llvm/lib/Support/ScopedPrinter.cpp
@@ -5,10 +5,6 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
-//
-// Implementation of ScopedPrinter.
-//
-//===----------------------------------------------------------------------===//
#include "llvm/Support/ScopedPrinter.h"
#include "llvm/Support/Format.h"
More information about the llvm-commits
mailing list