[llvm] r333669 - [ADT] Make escaping fn conform to coding guidelines
Jonas Devlieghere via llvm-commits
llvm-commits at lists.llvm.org
Thu May 31 10:01:43 PDT 2018
Author: jdevlieghere
Date: Thu May 31 10:01:42 2018
New Revision: 333669
URL: http://llvm.org/viewvc/llvm-project?rev=333669&view=rev
Log:
[ADT] Make escaping fn conform to coding guidelines
As noted by Adrian on llvm-commits, PrintHTMLEscaped and PrintEscaped in
StringExtras did not conform to the LLVM coding guidelines. This commit
rectifies that.
Modified:
llvm/trunk/include/llvm/ADT/StringExtras.h
llvm/trunk/lib/CodeGen/MachineOperand.cpp
llvm/trunk/lib/IR/AsmWriter.cpp
llvm/trunk/lib/IR/Attributes.cpp
llvm/trunk/lib/Support/StringExtras.cpp
llvm/trunk/tools/dsymutil/dsymutil.cpp
llvm/trunk/tools/llvm-cov/SourceCoverageViewHTML.cpp
llvm/trunk/unittests/ADT/StringExtrasTest.cpp
Modified: llvm/trunk/include/llvm/ADT/StringExtras.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/StringExtras.h?rev=333669&r1=333668&r2=333669&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/StringExtras.h (original)
+++ llvm/trunk/include/llvm/ADT/StringExtras.h Thu May 31 10:01:42 2018
@@ -251,13 +251,13 @@ inline StringRef getOrdinalSuffix(unsign
}
}
-/// PrintEscapedString - Print each character of the specified string, escaping
-/// it if it is not printable or if it is an escape char.
-void PrintEscapedString(StringRef Name, raw_ostream &Out);
+/// Print each character of the specified string, escaping it if it is not
+/// printable or if it is an escape char.
+void printEscapedString(StringRef Name, raw_ostream &Out);
/// Print each character of the specified string, escaping HTML special
/// characters.
-void PrintHTMLEscaped(StringRef String, raw_ostream &Out);
+void printHTMLEscaped(StringRef String, raw_ostream &Out);
/// printLowerCase - Print each character as lowercase if it is uppercase.
void printLowerCase(StringRef String, raw_ostream &Out);
Modified: llvm/trunk/lib/CodeGen/MachineOperand.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineOperand.cpp?rev=333669&r1=333668&r2=333669&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineOperand.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineOperand.cpp Thu May 31 10:01:42 2018
@@ -474,7 +474,7 @@ static void printSyncScope(raw_ostream &
Context.getSyncScopeNames(SSNs);
OS << "syncscope(\"";
- PrintEscapedString(SSNs[SSID], OS);
+ printEscapedString(SSNs[SSID], OS);
OS << "\") ";
break;
}
Modified: llvm/trunk/lib/IR/AsmWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/AsmWriter.cpp?rev=333669&r1=333668&r2=333669&view=diff
==============================================================================
--- llvm/trunk/lib/IR/AsmWriter.cpp (original)
+++ llvm/trunk/lib/IR/AsmWriter.cpp Thu May 31 10:01:42 2018
@@ -424,7 +424,7 @@ void llvm::printLLVMNameWithoutPrefix(ra
// Okay, we need quotes. Output the quotes and escape any scary characters as
// needed.
OS << '"';
- PrintEscapedString(Name, OS);
+ printEscapedString(Name, OS);
OS << '"';
}
@@ -1377,7 +1377,7 @@ static void WriteConstantInternal(raw_os
// i8 with ConstantInt values.
if (CA->isString()) {
Out << "c\"";
- PrintEscapedString(CA->getAsString(), Out);
+ printEscapedString(CA->getAsString(), Out);
Out << '"';
return;
}
@@ -1610,7 +1610,7 @@ void MDFieldPrinter::printString(StringR
return;
Out << FS << Name << ": \"";
- PrintEscapedString(Value, Out);
+ printEscapedString(Value, Out);
Out << "\"";
}
@@ -2154,9 +2154,9 @@ static void WriteAsOperandInternal(raw_o
if (IA->getDialect() == InlineAsm::AD_Intel)
Out << "inteldialect ";
Out << '"';
- PrintEscapedString(IA->getAsmString(), Out);
+ printEscapedString(IA->getAsmString(), Out);
Out << "\", \"";
- PrintEscapedString(IA->getConstraintString(), Out);
+ printEscapedString(IA->getConstraintString(), Out);
Out << '"';
return;
}
@@ -2235,7 +2235,7 @@ static void WriteAsOperandInternal(raw_o
if (const MDString *MDS = dyn_cast<MDString>(MD)) {
Out << "!\"";
- PrintEscapedString(MDS->getString(), Out);
+ printEscapedString(MDS->getString(), Out);
Out << '"';
return;
}
@@ -2390,7 +2390,7 @@ void AssemblyWriter::writeSyncScope(cons
Context.getSyncScopeNames(SSNs);
Out << " syncscope(\"";
- PrintEscapedString(SSNs[SSID], Out);
+ printEscapedString(SSNs[SSID], Out);
Out << "\")";
break;
}
@@ -2451,7 +2451,7 @@ void AssemblyWriter::writeOperandBundles
FirstBundle = false;
Out << '"';
- PrintEscapedString(BU.getTagName(), Out);
+ printEscapedString(BU.getTagName(), Out);
Out << '"';
Out << '(';
@@ -2487,7 +2487,7 @@ void AssemblyWriter::printModule(const M
if (!M->getSourceFileName().empty()) {
Out << "source_filename = \"";
- PrintEscapedString(M->getSourceFileName(), Out);
+ printEscapedString(M->getSourceFileName(), Out);
Out << "\"\n";
}
@@ -2509,7 +2509,7 @@ void AssemblyWriter::printModule(const M
// We found a newline, print the portion of the asm string from the
// last newline up to this newline.
Out << "module asm \"";
- PrintEscapedString(Front, Out);
+ printEscapedString(Front, Out);
Out << "\"\n";
} while (!Asm.empty());
}
@@ -3143,7 +3143,7 @@ void AssemblyWriter::printGlobal(const G
if (GV->hasSection()) {
Out << ", section \"";
- PrintEscapedString(GV->getSection(), Out);
+ printEscapedString(GV->getSection(), Out);
Out << '"';
}
maybePrintComdat(Out, *GV);
@@ -3327,7 +3327,7 @@ void AssemblyWriter::printFunction(const
Out << " #" << Machine.getAttributeGroupSlot(Attrs.getFnAttributes());
if (F->hasSection()) {
Out << " section \"";
- PrintEscapedString(F->getSection(), Out);
+ printEscapedString(F->getSection(), Out);
Out << '"';
}
maybePrintComdat(Out, *F);
Modified: llvm/trunk/lib/IR/Attributes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Attributes.cpp?rev=333669&r1=333668&r2=333669&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Attributes.cpp (original)
+++ llvm/trunk/lib/IR/Attributes.cpp Thu May 31 10:01:42 2018
@@ -419,7 +419,7 @@ std::string Attribute::getAsString(bool
{
raw_string_ostream OS(Result);
OS << "=\"";
- PrintEscapedString(AttrVal, OS);
+ printEscapedString(AttrVal, OS);
OS << "\"";
}
return Result;
Modified: llvm/trunk/lib/Support/StringExtras.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/StringExtras.cpp?rev=333669&r1=333668&r2=333669&view=diff
==============================================================================
--- llvm/trunk/lib/Support/StringExtras.cpp (original)
+++ llvm/trunk/lib/Support/StringExtras.cpp Thu May 31 10:01:42 2018
@@ -58,7 +58,7 @@ void llvm::SplitString(StringRef Source,
}
}
-void llvm::PrintEscapedString(StringRef Name, raw_ostream &Out) {
+void llvm::printEscapedString(StringRef Name, raw_ostream &Out) {
for (unsigned i = 0, e = Name.size(); i != e; ++i) {
unsigned char C = Name[i];
if (isprint(C) && C != '\\' && C != '"')
@@ -68,7 +68,7 @@ void llvm::PrintEscapedString(StringRef
}
}
-void llvm::PrintHTMLEscaped(StringRef String, raw_ostream &Out) {
+void llvm::printHTMLEscaped(StringRef String, raw_ostream &Out) {
for (char C : String) {
if (C == '&')
Out << "&";
Modified: llvm/trunk/tools/dsymutil/dsymutil.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/dsymutil/dsymutil.cpp?rev=333669&r1=333668&r2=333669&view=diff
==============================================================================
--- llvm/trunk/tools/dsymutil/dsymutil.cpp (original)
+++ llvm/trunk/tools/dsymutil/dsymutil.cpp Thu May 31 10:01:42 2018
@@ -197,19 +197,19 @@ static bool createPlistFile(llvm::String
if (!BI.OmitShortVersion()) {
PL << "\t\t<key>CFBundleShortVersionString</key>\n";
PL << "\t\t<string>";
- PrintHTMLEscaped(BI.ShortVersionStr, PL);
+ printHTMLEscaped(BI.ShortVersionStr, PL);
PL << "</string>\n";
}
PL << "\t\t<key>CFBundleVersion</key>\n";
PL << "\t\t<string>";
- PrintHTMLEscaped(BI.VersionStr, PL);
+ printHTMLEscaped(BI.VersionStr, PL);
PL << "</string>\n";
if (!Toolchain.empty()) {
PL << "\t\t<key>Toolchain</key>\n";
PL << "\t\t<string>";
- PrintHTMLEscaped(Toolchain, PL);
+ printHTMLEscaped(Toolchain, PL);
PL << "</string>\n";
}
Modified: llvm/trunk/tools/llvm-cov/SourceCoverageViewHTML.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/SourceCoverageViewHTML.cpp?rev=333669&r1=333668&r2=333669&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/SourceCoverageViewHTML.cpp (original)
+++ llvm/trunk/tools/llvm-cov/SourceCoverageViewHTML.cpp Thu May 31 10:01:42 2018
@@ -45,7 +45,7 @@ std::string escape(StringRef Str, const
std::string EscapedHTML;
{
raw_string_ostream OS{EscapedHTML};
- PrintHTMLEscaped(TabExpandedResult, OS);
+ printHTMLEscaped(TabExpandedResult, OS);
}
return EscapedHTML;
}
Modified: llvm/trunk/unittests/ADT/StringExtrasTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/StringExtrasTest.cpp?rev=333669&r1=333668&r2=333669&view=diff
==============================================================================
--- llvm/trunk/unittests/ADT/StringExtrasTest.cpp (original)
+++ llvm/trunk/unittests/ADT/StringExtrasTest.cpp Thu May 31 10:01:42 2018
@@ -93,9 +93,9 @@ TEST(StringExtrasTest, printLowerCase) {
EXPECT_EQ("abcdefg01234.,&!~`'}\"", OS.str());
}
-TEST(StringExtrasTest, PrintHTMLEscaped) {
+TEST(StringExtrasTest, printHTMLEscaped) {
std::string str;
raw_string_ostream OS(str);
- PrintHTMLEscaped("ABCdef123&<>\"'", OS);
+ printHTMLEscaped("ABCdef123&<>\"'", OS);
EXPECT_EQ("ABCdef123&<>"'", OS.str());
}
More information about the llvm-commits
mailing list