diff --git a/clang/include/clang/AST/TextNodeDumper.h b/clang/include/clang/AST/TextNodeDumper.h index 0fb4baf0ca4d..4636c8ef65d3 100644 --- a/clang/include/clang/AST/TextNodeDumper.h +++ b/clang/include/clang/AST/TextNodeDumper.h @@ -231,6 +231,7 @@ public: void VisitCaseStmt(const CaseStmt *Node); void VisitConstantExpr(const ConstantExpr *Node); void VisitCallExpr(const CallExpr *Node); + void VisitCXXOperatorCallExpr(const CXXOperatorCallExpr *Node); void VisitCastExpr(const CastExpr *Node); void VisitImplicitCastExpr(const ImplicitCastExpr *Node); void VisitDeclRefExpr(const DeclRefExpr *Node); diff --git a/clang/lib/AST/TextNodeDumper.cpp b/clang/lib/AST/TextNodeDumper.cpp index 72f0ba37e3e7..84f9738ade8d 100644 --- a/clang/lib/AST/TextNodeDumper.cpp +++ b/clang/lib/AST/TextNodeDumper.cpp @@ -715,6 +715,14 @@ void TextNodeDumper::VisitCallExpr(const CallExpr *Node) { OS << " adl"; } +void TextNodeDumper::VisitCXXOperatorCallExpr(const CXXOperatorCallExpr *Node) { + const char *OperatorSpelling = clang::getOperatorSpelling(Node->getOperator()); + if (OperatorSpelling) + OS << " '" << OperatorSpelling << "'"; + + VisitCallExpr(Node); +} + void TextNodeDumper::VisitCastExpr(const CastExpr *Node) { OS << " <"; { diff --git a/clang/test/AST/ast-dump-overloaded-operators.cpp b/clang/test/AST/ast-dump-overloaded-operators.cpp new file mode 100644 index 000000000000..cd4e14be9f1a --- /dev/null +++ b/clang/test/AST/ast-dump-overloaded-operators.cpp @@ -0,0 +1,30 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -ast-dump %s | FileCheck -strict-whitespace %s + +enum E {}; +void operator+(E,E); +void operator,(E,E); + +void test() { + E e; + e + e; + e , e; +} +// CHECK: TranslationUnitDecl {{.*}} <> +// CHECK: `-FunctionDecl {{.*}} line:7:6 test 'void ()' +// CHECK-NEXT: `-CompoundStmt {{.*}} +// CHECK-NEXT: |-DeclStmt {{.*}} +// CHECK-NEXT: | `-VarDecl {{.*}} col:5 used e 'E' +// CHECK-NEXT: |-CXXOperatorCallExpr {{.*}} 'void' '+' +// CHECK-NEXT: | |-ImplicitCastExpr {{.*}} 'void (*)(E, E)' +// CHECK-NEXT: | | `-DeclRefExpr {{.*}} 'void (E, E)' lvalue Function {{.*}} 'operator+' 'void (E, E)' +// CHECK-NEXT: | |-ImplicitCastExpr {{.*}} 'E' +// CHECK-NEXT: | | `-DeclRefExpr {{.*}} 'E' lvalue Var {{.*}} 'e' 'E' +// CHECK-NEXT: | `-ImplicitCastExpr {{.*}} 'E' +// CHECK-NEXT: | `-DeclRefExpr {{.*}} 'E' lvalue Var {{.*}} 'e' 'E' +// CHECK-NEXT: `-CXXOperatorCallExpr {{.*}} 'void' ',' +// CHECK-NEXT: |-ImplicitCastExpr {{.*}} 'void (*)(E, E)' +// CHECK-NEXT: | `-DeclRefExpr {{.*}} 'void (E, E)' lvalue Function {{.*}} 'operator,' 'void (E, E)' +// CHECK-NEXT: |-ImplicitCastExpr {{.*}} 'E' +// CHECK-NEXT: | `-DeclRefExpr {{.*}} 'E' lvalue Var {{.*}} 'e' 'E' +// CHECK-NEXT: `-ImplicitCastExpr {{.*}} 'E' +// CHECK-NEXT: `-DeclRefExpr {{.*}} 'E' lvalue Var {{.*}} 'e' 'E' diff --git a/clang/test/Import/call-expr/test.cpp b/clang/test/Import/call-expr/test.cpp index 86c1b50c47d6..e2836a2bb9de 100644 --- a/clang/test/Import/call-expr/test.cpp +++ b/clang/test/Import/call-expr/test.cpp @@ -5,4 +5,4 @@ void expr() { // CHECK: FunctionDecl 0x{{[^ ]*}} <{{[^>]*}}> line:{{.*}}:{{[^ ]*}} used f 'void ()' // CHECK: -CallExpr 0x{{[^ ]*}} <{{[^>]*}}> 'void' adl -// CHECK: -CXXOperatorCallExpr 0x{{[^ ]*}} <{{[^>]*}}> 'void' adl +// CHECK: -CXXOperatorCallExpr 0x{{[^ ]*}} <{{[^>]*}}> 'void' '+' adl