Rename ToString to mention Operator (#2539)

Naming this ToString within the Carbon namespace encourages incidental overloading of the function, and that doesn't seem to be intentional; this feels questionable [under overloading style](https://google.github.io/styleguide/cppguide.html#Function_Overloading). OperatorToString seems helpful in that it makes it easy to see at a glance where it's being used.
This commit is contained in:
Jon Ross-Perkins
2023-01-20 11:32:37 -08:00
committed by GitHub
parent 09ac000305
commit 421883ec8f
5 changed files with 13 additions and 12 deletions
+4 -4
View File
@@ -111,7 +111,7 @@ auto TupleExpressionFromParenContents(
Expression::~Expression() = default;
auto ToString(Operator op) -> std::string_view {
auto OperatorToString(Operator op) -> std::string_view {
switch (op) {
case Operator::Add:
return "+";
@@ -217,13 +217,13 @@ void Expression::Print(llvm::raw_ostream& out) const {
const auto& op = cast<OperatorExpression>(*this);
switch (op.arguments().size()) {
case 0:
out << ToString(op.op());
out << OperatorToString(op.op());
break;
case 1:
out << ToString(op.op()) << " " << *op.arguments()[0];
out << OperatorToString(op.op()) << " " << *op.arguments()[0];
break;
case 2:
out << *op.arguments()[0] << " " << ToString(op.op()) << " "
out << *op.arguments()[0] << " " << OperatorToString(op.op()) << " "
<< *op.arguments()[1];
break;
default: