[clang] 17db331 - [ASTDump] TextNodeDumper learned to dump builtin name for AtomicExpr (#102748)

via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 12 18:50:38 PDT 2024


Author: Enna1
Date: 2024-08-13T09:50:34+08:00
New Revision: 17db3313c75120fd8415529723eb96cbad399338

URL: https://github.com/llvm/llvm-project/commit/17db3313c75120fd8415529723eb96cbad399338
DIFF: https://github.com/llvm/llvm-project/commit/17db3313c75120fd8415529723eb96cbad399338.diff

LOG: [ASTDump] TextNodeDumper learned to dump builtin name for AtomicExpr (#102748)

In 4198576157bfd0d08c08b784220d6132b709ae2c, we add support for dumping
builtin name for AtomicExpr in JSON dump. This change syncs
`TextNodeDumper` with `JSONNodeDumper`, makes `TextNodeDumper` learned
to dump builtin name for AtomicExpr.

Added: 
    

Modified: 
    clang/include/clang/AST/TextNodeDumper.h
    clang/lib/AST/TextNodeDumper.cpp
    clang/test/AST/atomic-expr.cpp

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/AST/TextNodeDumper.h b/clang/include/clang/AST/TextNodeDumper.h
index 39dd1f515c9eb3..88d5535829910f 100644
--- a/clang/include/clang/AST/TextNodeDumper.h
+++ b/clang/include/clang/AST/TextNodeDumper.h
@@ -410,6 +410,7 @@ class TextNodeDumper
   void VisitOpenACCConstructStmt(const OpenACCConstructStmt *S);
   void VisitOpenACCLoopConstruct(const OpenACCLoopConstruct *S);
   void VisitEmbedExpr(const EmbedExpr *S);
+  void VisitAtomicExpr(const AtomicExpr *AE);
 };
 
 } // namespace clang

diff  --git a/clang/lib/AST/TextNodeDumper.cpp b/clang/lib/AST/TextNodeDumper.cpp
index 388c927c9aa558..d50d4c7028c697 100644
--- a/clang/lib/AST/TextNodeDumper.cpp
+++ b/clang/lib/AST/TextNodeDumper.cpp
@@ -2892,3 +2892,7 @@ void TextNodeDumper::VisitEmbedExpr(const EmbedExpr *S) {
   AddChild("begin", [=] { OS << S->getStartingElementPos(); });
   AddChild("number of elements", [=] { OS << S->getDataElementCount(); });
 }
+
+void TextNodeDumper::VisitAtomicExpr(const AtomicExpr *AE) {
+  OS << ' ' << AE->getOpAsString();
+}

diff  --git a/clang/test/AST/atomic-expr.cpp b/clang/test/AST/atomic-expr.cpp
index bdb7bcb00569a1..d9d632ffc5917b 100644
--- a/clang/test/AST/atomic-expr.cpp
+++ b/clang/test/AST/atomic-expr.cpp
@@ -25,14 +25,14 @@ void useage(){
 }
 
 // CHECK:FunctionTemplateDecl 0x{{[0-9a-f]+}} <{{[^,]+}}, line:{{.*}}:1> line:{{.*}}:6 pr43370
-// CHECK: AtomicExpr
+// CHECK: AtomicExpr 0x{{[0-9a-f]+}} <{{.*}}> 'void' __atomic_store_n
 // CHECK-NEXT: ImplicitCastExpr
 // CHECK-SAME: <ArrayToPointerDecay>
 // CHECK-NEXT: DeclRefExpr 0x{{[0-9a-f]+}} <{{[^:]+}}:20> 'int[2]' lvalue Var 0x{{[0-9a-f]+}} 'arr' 'int[2]'
 // CHECK-NEXT: IntegerLiteral 0x{{[0-9a-f]+}} <{{[^:]+}}:28> 'int' 5
 // CHECK-NEXT: IntegerLiteral 0x{{[0-9a-f]+}} <{{[^:]+}}:25> 'int' 0
 // CHECK:FunctionDecl 0x{{[0-9a-f]+}} <line:{{.*}}:1, line:{{.*}}:1> line:{{.*}}:6 used pr43370
-// CHECK: AtomicExpr
+// CHECK: AtomicExpr 0x{{[0-9a-f]+}} <{{.*}}> 'void' __atomic_store_n
 // CHECK-NEXT: ImplicitCastExpr
 // CHECK-SAME: <ArrayToPointerDecay>
 // CHECK-NEXT: DeclRefExpr 0x{{[0-9a-f]+}} <{{[^:]+}}:20> 'int[2]' lvalue Var 0x{{[0-9a-f]+}} 'arr' 'int[2]'
@@ -40,7 +40,7 @@ void useage(){
 // CHECK-NEXT: IntegerLiteral 0x{{[0-9a-f]+}} <{{[^:]+}}:25> 'int' 0
 
 // CHECK:FunctionTemplateDecl 0x{{[0-9a-f]+}} <line:{{.*}}:1, line:{{.*}}:1> line:{{.*}}:6 foo
-// CHECK: AtomicExpr
+// CHECK: AtomicExpr 0x{{[0-9a-f]+}} <{{.*}}> 'bool' __atomic_compare_exchange_n
 // CHECK-NEXT: ImplicitCastExpr
 // CHECK-SAME: <ArrayToPointerDecay>
 // CHECK-NEXT: DeclRefExpr 0x{{[0-9a-f]+}} <{{[^:]+}}:37> 'int[2]' lvalue Var 0x{{[0-9a-f]+}} 'arr' 'int[2]'
@@ -53,7 +53,7 @@ void useage(){
 // CHECK-NEXT: ImplicitCastExpr
 // CHECK-NEXT: IntegerLiteral 0x{{[0-9a-f]+}} <{{[^:]+}}:50> 'int' 0
 // CHECK:FunctionDecl 0x{{[0-9a-f]+}} <line:{{.*}}:1, line:{{.*}}:1> line:{{.*}}:6 used foo
-// CHECK: AtomicExpr
+// CHECK: AtomicExpr 0x{{[0-9a-f]+}} <{{.*}}> 'bool' __atomic_compare_exchange_n
 // CHECK-NEXT: ImplicitCastExpr
 // CHECK-SAME: <ArrayToPointerDecay>
 // CHECK-NEXT: DeclRefExpr 0x{{[0-9a-f]+}} <{{[^:]+}}:37> 'int[2]' lvalue Var 0x{{[0-9a-f]+}} 'arr' 'int[2]'


        


More information about the cfe-commits mailing list