From 64bebe980a3af1a25ad18c2b2971317d97185bbf Mon Sep 17 00:00:00 2001 From: Bruno Ricci Date: Sun, 3 Feb 2019 18:20:27 +0000 Subject: [PATCH] [ASTDump] Add a flag indicating whether a CXXThisExpr is implicit There is currently no way to distinguish implicit from explicit CXXThisExpr in the AST dump output. Differential Revision: https://reviews.llvm.org/D57649 Reviewed By: steveire llvm-svn: 353003 --- clang/lib/AST/TextNodeDumper.cpp | 2 ++ clang/test/AST/ast-dump-expr.cpp | 4 ++-- clang/test/AST/dump.cpp | 2 +- clang/test/AST/float16.cpp | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/clang/lib/AST/TextNodeDumper.cpp b/clang/lib/AST/TextNodeDumper.cpp index 6e6700c7470f..9e6f7216e5f7 100644 --- a/clang/lib/AST/TextNodeDumper.cpp +++ b/clang/lib/AST/TextNodeDumper.cpp @@ -854,6 +854,8 @@ void TextNodeDumper::VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *Node) { } void TextNodeDumper::VisitCXXThisExpr(const CXXThisExpr *Node) { + if (Node->isImplicit()) + OS << " implicit"; OS << " this"; } diff --git a/clang/test/AST/ast-dump-expr.cpp b/clang/test/AST/ast-dump-expr.cpp index 0c85e2eea2df..96d3df34cb47 100644 --- a/clang/test/AST/ast-dump-expr.cpp +++ b/clang/test/AST/ast-dump-expr.cpp @@ -255,7 +255,7 @@ void PrimaryExpressions(Ts... a) { // CHECK-NEXT: FieldDecl 0x{{[^ ]*}} col:8 implicit 'V *' // CHECK-NEXT: CXXMethodDecl // CHECK-NEXT: CompoundStmt - // CHECK-NEXT: CXXThisExpr 0x{{[^ ]*}} 'V *' this + // CHECK-NEXT: CXXThisExpr 0x{{[^ ]*}} 'V *' implicit this [*this]{}; // CHECK: LambdaExpr 0x{{[^ ]*}} @@ -272,7 +272,7 @@ void PrimaryExpressions(Ts... a) { // CHECK-NEXT: CompoundStmt // CHECK-NEXT: ParenListExpr 0x{{[^ ]*}} 'NULL TYPE' // CHECK-NEXT: UnaryOperator 0x{{[^ ]*}} '' prefix '*' cannot overflow - // CHECK-NEXT: CXXThisExpr 0x{{[^ ]*}} 'V *' this + // CHECK-NEXT: CXXThisExpr 0x{{[^ ]*}} 'V *' implicit this } }; diff --git a/clang/test/AST/dump.cpp b/clang/test/AST/dump.cpp index d9ddca667220..f92c3e84dfd5 100644 --- a/clang/test/AST/dump.cpp +++ b/clang/test/AST/dump.cpp @@ -56,7 +56,7 @@ struct S { // CHECK-NEXT: | | `-DeclRefExpr {{.+}} 'int' lvalue OMPCapturedExpr {{.+}} 'a' 'int &' // CHECK-NEXT: | |-OMPSharedClause {{.+}} // CHECK-NEXT: | | `-MemberExpr {{.+}} 'int' lvalue ->b -// CHECK-NEXT: | | `-CXXThisExpr {{.+}} 'S *' this +// CHECK-NEXT: | | `-CXXThisExpr {{.+}} 'S *' implicit this // CHECK-NEXT: | |-OMPScheduleClause {{.+}} // CHECK-NEXT: | | `-ImplicitCastExpr {{.+}} 'int' // CHECK-NEXT: | | `-DeclRefExpr {{.+}} 'int' lvalue OMPCapturedExpr {{.+}} '.capture_expr.' 'int' diff --git a/clang/test/AST/float16.cpp b/clang/test/AST/float16.cpp index 2f428e7085ff..1704d35a7718 100644 --- a/clang/test/AST/float16.cpp +++ b/clang/test/AST/float16.cpp @@ -132,7 +132,7 @@ public: //CHECK-NEXT: | | `-BinaryOperator {{.*}} '_Float16' '+' //CHECK-NEXT: | | |-ImplicitCastExpr {{.*}} '_Float16' //CHECK-NEXT: | | | `-MemberExpr {{.*}} '_Float16' lvalue ->f1c 0x{{.*}} -//CHECK-NEXT: | | | `-CXXThisExpr {{.*}} 'C1 *' this +//CHECK-NEXT: | | | `-CXXThisExpr {{.*}} 'C1 *' implicit this //CHECK-NEXT: | | `-ImplicitCastExpr {{.*}} '_Float16' //CHECK-NEXT: | | `-DeclRefExpr {{.*}} '_Float16' lvalue ParmVar 0x{{.*}} 'arg' '_Float16' //CHECK-NEXT: | |-CXXMethodDecl {{.*}} used func2c '_Float16 (_Float16)' static