Escape backslashes when formatting

This commit is contained in:
Mathias Baumann
2020-05-13 17:08:37 +02:00
committed by chriseth
parent e9446475bb
commit 820fdd9bf7
7 changed files with 77 additions and 28 deletions
+1 -27
View File
@@ -55,33 +55,7 @@ string AsmPrinter::operator()(Literal const& _literal) const
break;
}
string out;
for (char c: _literal.value.str())
if (c == '\\')
out += "\\\\";
else if (c == '"')
out += "\\\"";
else if (c == '\b')
out += "\\b";
else if (c == '\f')
out += "\\f";
else if (c == '\n')
out += "\\n";
else if (c == '\r')
out += "\\r";
else if (c == '\t')
out += "\\t";
else if (c == '\v')
out += "\\v";
else if (!isprint(c, locale::classic()))
{
ostringstream o;
o << std::hex << setfill('0') << setw(2) << (unsigned)(unsigned char)(c);
out += "\\x" + o.str();
}
else
out += c;
return "\"" + out + "\"" + appendTypeName(_literal.type);
return escapeAndQuoteString(_literal.value.str()) + appendTypeName(_literal.type);
}
string AsmPrinter::operator()(Identifier const& _identifier) const