-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[NFC][LLVM][Support] Misc code cleanup in ScopedPrinter #161462
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-llvm-support Author: Rahul Joshi (jurahul) Changes
Full diff: https://github.com/llvm/llvm-project/pull/161462.diff 2 Files Affected:
diff --git a/llvm/include/llvm/Support/ScopedPrinter.h b/llvm/include/llvm/Support/ScopedPrinter.h
index a08cc8fd31fd2..49b09f9a453ea 100644
--- a/llvm/include/llvm/Support/ScopedPrinter.h
+++ b/llvm/include/llvm/Support/ScopedPrinter.h
@@ -220,59 +220,59 @@ class LLVM_ABI ScopedPrinter {
}
virtual void printNumber(StringRef Label, char Value) {
- startLine() << Label << ": " << static_cast<int>(Value) << "\n";
+ startLine() << Label << ": " << static_cast<int>(Value) << '\n';
}
virtual void printNumber(StringRef Label, signed char Value) {
- startLine() << Label << ": " << static_cast<int>(Value) << "\n";
+ startLine() << Label << ": " << static_cast<int>(Value) << '\n';
}
virtual void printNumber(StringRef Label, unsigned char Value) {
- startLine() << Label << ": " << static_cast<unsigned>(Value) << "\n";
+ startLine() << Label << ": " << static_cast<unsigned>(Value) << '\n';
}
virtual void printNumber(StringRef Label, short Value) {
- startLine() << Label << ": " << Value << "\n";
+ startLine() << Label << ": " << Value << '\n';
}
virtual void printNumber(StringRef Label, unsigned short Value) {
- startLine() << Label << ": " << Value << "\n";
+ startLine() << Label << ": " << Value << '\n';
}
virtual void printNumber(StringRef Label, int Value) {
- startLine() << Label << ": " << Value << "\n";
+ startLine() << Label << ": " << Value << '\n';
}
virtual void printNumber(StringRef Label, unsigned int Value) {
- startLine() << Label << ": " << Value << "\n";
+ startLine() << Label << ": " << Value << '\n';
}
virtual void printNumber(StringRef Label, long Value) {
- startLine() << Label << ": " << Value << "\n";
+ startLine() << Label << ": " << Value << '\n';
}
virtual void printNumber(StringRef Label, unsigned long Value) {
- startLine() << Label << ": " << Value << "\n";
+ startLine() << Label << ": " << Value << '\n';
}
virtual void printNumber(StringRef Label, long long Value) {
- startLine() << Label << ": " << Value << "\n";
+ startLine() << Label << ": " << Value << '\n';
}
virtual void printNumber(StringRef Label, unsigned long long Value) {
- startLine() << Label << ": " << Value << "\n";
+ startLine() << Label << ": " << Value << '\n';
}
virtual void printNumber(StringRef Label, const APSInt &Value) {
- startLine() << Label << ": " << Value << "\n";
+ startLine() << Label << ": " << Value << '\n';
}
virtual void printNumber(StringRef Label, float Value) {
- startLine() << Label << ": " << format("%5.1f", Value) << "\n";
+ startLine() << Label << ": " << format("%5.1f", Value) << '\n';
}
virtual void printNumber(StringRef Label, double Value) {
- startLine() << Label << ": " << format("%5.1f", Value) << "\n";
+ startLine() << Label << ": " << format("%5.1f", Value) << '\n';
}
template <typename T>
@@ -287,7 +287,7 @@ class LLVM_ABI ScopedPrinter {
template <typename... T> void printVersion(StringRef Label, T... Version) {
startLine() << Label << ": ";
printVersionInternal(Version...);
- getOStream() << "\n";
+ getOStream() << '\n';
}
template <typename T>
@@ -379,10 +379,10 @@ class LLVM_ABI ScopedPrinter {
printSymbolOffsetImpl(Label, Symbol, hex(Value));
}
- virtual void printString(StringRef Value) { startLine() << Value << "\n"; }
+ virtual void printString(StringRef Value) { startLine() << Value << '\n'; }
virtual void printString(StringRef Label, StringRef Value) {
- startLine() << Label << ": " << Value << "\n";
+ startLine() << Label << ": " << Value << '\n';
}
void printStringEscaped(StringRef Label, StringRef Value) {
@@ -460,7 +460,7 @@ class LLVM_ABI ScopedPrinter {
template <typename S, typename T, typename... TArgs>
void printVersionInternal(S Value, T Value2, TArgs... Args) {
- getOStream() << Value << ".";
+ getOStream() << Value << '.';
printVersionInternal(Value2, Args...);
}
@@ -506,7 +506,7 @@ class LLVM_ABI ScopedPrinter {
}
virtual void printHexImpl(StringRef Label, HexNumber Value) {
- startLine() << Label << ": " << Value << "\n";
+ startLine() << Label << ": " << Value << '\n';
}
virtual void printHexImpl(StringRef Label, StringRef Str, HexNumber Value) {
@@ -557,7 +557,7 @@ template <>
inline void
ScopedPrinter::printHex<support::ulittle16_t>(StringRef Label,
support::ulittle16_t Value) {
- startLine() << Label << ": " << hex(Value) << "\n";
+ startLine() << Label << ": " << hex(Value) << '\n';
}
struct DelimitedScope {
diff --git a/llvm/lib/Support/ScopedPrinter.cpp b/llvm/lib/Support/ScopedPrinter.cpp
index a17e397c0aa58..8d077ee421b40 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;
}
@@ -28,9 +38,9 @@ void ScopedPrinter::printBinaryImpl(StringRef Label, StringRef Str,
<< "\n";
startLine() << ")\n";
} else {
- startLine() << Label << ":";
+ startLine() << Label << ':';
if (!Str.empty())
- OS << " " << Str;
+ OS << ' ' << Str;
OS << " (" << format_bytes(Data, std::nullopt, Data.size(), 1, 0, true)
<< ")\n";
}
@@ -45,5 +55,3 @@ JSONScopedPrinter::JSONScopedPrinter(
if (this->OuterScope)
this->OuterScope->setPrinter(*this);
}
-
-} // namespace llvm
|
- Use character instead of a single character string. - Add missing header to ScopedPrinter.cpp and adjust the code to conform to LLVM coding standards.
67d94aa
to
46000da
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Add missing file header to ScopedPrinter.cpp and adjust the code to conform to LLVM coding standards.
Add missing file header to ScopedPrinter.cpp and adjust the code to conform to LLVM coding standards.