Use getOperatorSpelling to get the spelling of an overloaded operator
rather than duplicating operator name tables in multiple places.
llvm-svn: 363446
diff --git a/clang/lib/AST/StmtPrinter.cpp b/clang/lib/AST/StmtPrinter.cpp
index 563095f..83c017f 100644
--- a/clang/lib/AST/StmtPrinter.cpp
+++ b/clang/lib/AST/StmtPrinter.cpp
@@ -1622,21 +1622,14 @@
// C++
void StmtPrinter::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *Node) {
- const char *OpStrings[NUM_OVERLOADED_OPERATORS] = {
- "",
-#define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \
- Spelling,
-#include "clang/Basic/OperatorKinds.def"
- };
-
OverloadedOperatorKind Kind = Node->getOperator();
if (Kind == OO_PlusPlus || Kind == OO_MinusMinus) {
if (Node->getNumArgs() == 1) {
- OS << OpStrings[Kind] << ' ';
+ OS << getOperatorSpelling(Kind) << ' ';
PrintExpr(Node->getArg(0));
} else {
PrintExpr(Node->getArg(0));
- OS << ' ' << OpStrings[Kind];
+ OS << ' ' << getOperatorSpelling(Kind);
}
} else if (Kind == OO_Arrow) {
PrintExpr(Node->getArg(0));
@@ -1656,11 +1649,11 @@
PrintExpr(Node->getArg(1));
OS << ']';
} else if (Node->getNumArgs() == 1) {
- OS << OpStrings[Kind] << ' ';
+ OS << getOperatorSpelling(Kind) << ' ';
PrintExpr(Node->getArg(0));
} else if (Node->getNumArgs() == 2) {
PrintExpr(Node->getArg(0));
- OS << ' ' << OpStrings[Kind] << ' ';
+ OS << ' ' << getOperatorSpelling(Kind) << ' ';
PrintExpr(Node->getArg(1));
} else {
llvm_unreachable("unknown overloaded operator");