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 -3
View File
@@ -49,10 +49,11 @@ auto BinaryOperatorExpressionMatcher::MatchAndExplainImpl(
return false;
}
if (op->op() != op_) {
*out << "whose operator is not " << ToString(op_);
*out << "whose operator is not " << OperatorToString(op_);
return false;
}
*out << "which is a " << ToString(op_) << " expression whose left operand ";
*out << "which is a " << OperatorToString(op_)
<< " expression whose left operand ";
bool matched = lhs_.MatchAndExplain(*op->arguments()[0], out);
*out << " and right operand ";
if (!rhs_.MatchAndExplain(*op->arguments()[1], out)) {
@@ -63,7 +64,7 @@ auto BinaryOperatorExpressionMatcher::MatchAndExplainImpl(
void BinaryOperatorExpressionMatcher::DescribeToImpl(std::ostream* out,
bool negated) const {
*out << "is " << (negated ? "not " : "") << "a " << ToString(op_)
*out << "is " << (negated ? "not " : "") << "a " << OperatorToString(op_)
<< " expression whose ";
*out << "left operand ";
lhs_.DescribeTo(out);