forked from OSchip/llvm-project
[clang][AST] TextNodeDumper: dump the operator spelling for overloaded operators.
This mirrors what is done for built-in operators.
This commit is contained in:
parent
21d747184a
commit
6d0f8345ac
|
@ -231,6 +231,7 @@ public:
|
||||||
void VisitCaseStmt(const CaseStmt *Node);
|
void VisitCaseStmt(const CaseStmt *Node);
|
||||||
void VisitConstantExpr(const ConstantExpr *Node);
|
void VisitConstantExpr(const ConstantExpr *Node);
|
||||||
void VisitCallExpr(const CallExpr *Node);
|
void VisitCallExpr(const CallExpr *Node);
|
||||||
|
void VisitCXXOperatorCallExpr(const CXXOperatorCallExpr *Node);
|
||||||
void VisitCastExpr(const CastExpr *Node);
|
void VisitCastExpr(const CastExpr *Node);
|
||||||
void VisitImplicitCastExpr(const ImplicitCastExpr *Node);
|
void VisitImplicitCastExpr(const ImplicitCastExpr *Node);
|
||||||
void VisitDeclRefExpr(const DeclRefExpr *Node);
|
void VisitDeclRefExpr(const DeclRefExpr *Node);
|
||||||
|
|
|
@ -715,6 +715,14 @@ void TextNodeDumper::VisitCallExpr(const CallExpr *Node) {
|
||||||
OS << " adl";
|
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) {
|
void TextNodeDumper::VisitCastExpr(const CastExpr *Node) {
|
||||||
OS << " <";
|
OS << " <";
|
||||||
{
|
{
|
||||||
|
|
|
@ -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 {{.*}} <<invalid sloc>> <invalid sloc>
|
||||||
|
// CHECK: `-FunctionDecl {{.*}} <line:7:1, line:11:1> line:7:6 test 'void ()'
|
||||||
|
// CHECK-NEXT: `-CompoundStmt {{.*}} <col:13, line:11:1>
|
||||||
|
// CHECK-NEXT: |-DeclStmt {{.*}} <line:8:3, col:6>
|
||||||
|
// CHECK-NEXT: | `-VarDecl {{.*}} <col:3, col:5> col:5 used e 'E'
|
||||||
|
// CHECK-NEXT: |-CXXOperatorCallExpr {{.*}} <line:9:3, col:7> 'void' '+'
|
||||||
|
// CHECK-NEXT: | |-ImplicitCastExpr {{.*}} <col:5> 'void (*)(E, E)' <FunctionToPointerDecay>
|
||||||
|
// CHECK-NEXT: | | `-DeclRefExpr {{.*}} <col:5> 'void (E, E)' lvalue Function {{.*}} 'operator+' 'void (E, E)'
|
||||||
|
// CHECK-NEXT: | |-ImplicitCastExpr {{.*}} <col:3> 'E' <LValueToRValue>
|
||||||
|
// CHECK-NEXT: | | `-DeclRefExpr {{.*}} <col:3> 'E' lvalue Var {{.*}} 'e' 'E'
|
||||||
|
// CHECK-NEXT: | `-ImplicitCastExpr {{.*}} <col:7> 'E' <LValueToRValue>
|
||||||
|
// CHECK-NEXT: | `-DeclRefExpr {{.*}} <col:7> 'E' lvalue Var {{.*}} 'e' 'E'
|
||||||
|
// CHECK-NEXT: `-CXXOperatorCallExpr {{.*}} <line:10:3, col:7> 'void' ','
|
||||||
|
// CHECK-NEXT: |-ImplicitCastExpr {{.*}} <col:5> 'void (*)(E, E)' <FunctionToPointerDecay>
|
||||||
|
// CHECK-NEXT: | `-DeclRefExpr {{.*}} <col:5> 'void (E, E)' lvalue Function {{.*}} 'operator,' 'void (E, E)'
|
||||||
|
// CHECK-NEXT: |-ImplicitCastExpr {{.*}} <col:3> 'E' <LValueToRValue>
|
||||||
|
// CHECK-NEXT: | `-DeclRefExpr {{.*}} <col:3> 'E' lvalue Var {{.*}} 'e' 'E'
|
||||||
|
// CHECK-NEXT: `-ImplicitCastExpr {{.*}} <col:7> 'E' <LValueToRValue>
|
||||||
|
// CHECK-NEXT: `-DeclRefExpr {{.*}} <col:7> 'E' lvalue Var {{.*}} 'e' 'E'
|
|
@ -5,4 +5,4 @@ void expr() {
|
||||||
|
|
||||||
// CHECK: FunctionDecl 0x{{[^ ]*}} <{{[^>]*}}> line:{{.*}}:{{[^ ]*}} used f 'void ()'
|
// CHECK: FunctionDecl 0x{{[^ ]*}} <{{[^>]*}}> line:{{.*}}:{{[^ ]*}} used f 'void ()'
|
||||||
// CHECK: -CallExpr 0x{{[^ ]*}} <{{[^>]*}}> 'void' adl
|
// CHECK: -CallExpr 0x{{[^ ]*}} <{{[^>]*}}> 'void' adl
|
||||||
// CHECK: -CXXOperatorCallExpr 0x{{[^ ]*}} <{{[^>]*}}> 'void' adl
|
// CHECK: -CXXOperatorCallExpr 0x{{[^ ]*}} <{{[^>]*}}> 'void' '+' adl
|
||||||
|
|
Loading…
Reference in New Issue