mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 13:11:05 +01:00
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:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user