[clang] 4b15bb9 - [clang][ASTDumper] Remove redundant dump of BlockDecl's ParmVarDecl

via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 24 03:42:36 PDT 2023


Author: dingfei
Date: 2023-07-24T18:42:26+08:00
New Revision: 4b15bb9a317edcf6a3ad95ddaa4a843afe700261

URL: https://github.com/llvm/llvm-project/commit/4b15bb9a317edcf6a3ad95ddaa4a843afe700261
DIFF: https://github.com/llvm/llvm-project/commit/4b15bb9a317edcf6a3ad95ddaa4a843afe700261.diff

LOG: [clang][ASTDumper] Remove redundant dump of BlockDecl's ParmVarDecl

ParmVarDecl of BlockDecl is unnecessarily dumped twice.
Remove this duplication as other FunctionDecls.

Fixes https://github.com/llvm/llvm-project/issues/64005 (#2)

Differential Revision: https://reviews.llvm.org/D155985

Added: 
    

Modified: 
    clang/docs/ReleaseNotes.rst
    clang/include/clang/AST/ASTNodeTraverser.h
    clang/test/AST/ast-dump-decl-json.m
    clang/test/AST/ast-dump-decl.m

Removed: 
    


################################################################################
diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 5d09c454dea290..4e60efa1c025ed 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -674,7 +674,8 @@ Bug Fixes in This Version
   value exprs is invalid. Propagating the error info up by replacing BlockExpr
   with a RecoveryExpr. This fixes:
   (`#63863 <https://github.com/llvm/llvm-project/issues/63863>_`)
-- Invalidate BlockDecl with invalid ParmVarDecl
+- Invalidate BlockDecl with invalid ParmVarDecl. Remove redundant dump of
+  BlockDecl's ParmVarDecl
   (`#64005 <https://github.com/llvm/llvm-project/issues/64005>_`)
 
 Bug Fixes to Compiler Builtins

diff  --git a/clang/include/clang/AST/ASTNodeTraverser.h b/clang/include/clang/AST/ASTNodeTraverser.h
index 35efb81bb522ed..d649ef6816ca42 100644
--- a/clang/include/clang/AST/ASTNodeTraverser.h
+++ b/clang/include/clang/AST/ASTNodeTraverser.h
@@ -104,7 +104,8 @@ class ASTNodeTraverser
         Visit(Comment, Comment);
 
       // Decls within functions are visited by the body.
-      if (!isa<FunctionDecl>(*D) && !isa<ObjCMethodDecl>(*D)) {
+      if (!isa<FunctionDecl>(*D) && !isa<ObjCMethodDecl>(*D) &&
+          !isa<BlockDecl>(*D)) {
         if (Traversal != TK_AsIs) {
           if (const auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(D)) {
             auto SK = CTSD->getSpecializationKind();

diff  --git a/clang/test/AST/ast-dump-decl-json.m b/clang/test/AST/ast-dump-decl-json.m
index 18450c9f82026f..9d82c6696cb524 100644
--- a/clang/test/AST/ast-dump-decl-json.m
+++ b/clang/test/AST/ast-dump-decl-json.m
@@ -1924,31 +1924,6 @@ void f(void) {
 // CHECK-NEXT:              ]
 // CHECK-NEXT:             }
 // CHECK-NEXT:            ]
-// CHECK-NEXT:           },
-// CHECK-NEXT:           {
-// CHECK-NEXT:            "id": "0x{{.*}}",
-// CHECK-NEXT:            "kind": "ParmVarDecl",
-// CHECK-NEXT:            "loc": {
-// CHECK-NEXT:             "offset": {{[0-9]+}},
-// CHECK-NEXT:             "col": 9,
-// CHECK-NEXT:             "tokLen": 1
-// CHECK-NEXT:            },
-// CHECK-NEXT:            "range": {
-// CHECK-NEXT:             "begin": {
-// CHECK-NEXT:              "offset": {{[0-9]+}},
-// CHECK-NEXT:              "col": 5,
-// CHECK-NEXT:              "tokLen": 3
-// CHECK-NEXT:             },
-// CHECK-NEXT:             "end": {
-// CHECK-NEXT:              "offset": {{[0-9]+}},
-// CHECK-NEXT:              "col": 9,
-// CHECK-NEXT:              "tokLen": 1
-// CHECK-NEXT:             }
-// CHECK-NEXT:            },
-// CHECK-NEXT:            "name": "y",
-// CHECK-NEXT:            "type": {
-// CHECK-NEXT:             "qualType": "int"
-// CHECK-NEXT:            }
 // CHECK-NEXT:           }
 // CHECK-NEXT:          ]
 // CHECK-NEXT:         }

diff  --git a/clang/test/AST/ast-dump-decl.m b/clang/test/AST/ast-dump-decl.m
index 1157c99e459749..0b259d522645dc 100644
--- a/clang/test/AST/ast-dump-decl.m
+++ b/clang/test/AST/ast-dump-decl.m
@@ -142,12 +142,17 @@ @implementation TestObjCProperty {
 
 void TestBlockDecl(int x) {
   ^(int y, ...){ x; };
+  int z;
 }
 // CHECK:      FunctionDecl{{.*}}TestBlockDecl
 // CHECK:      BlockDecl {{.+}} <col:3, col:21> col:3 variadic
 // CHECK-NEXT:   ParmVarDecl{{.*}} y 'int'
 // CHECK-NEXT:   capture ParmVar{{.*}} 'x' 'int'
 // CHECK-NEXT:   CompoundStmt
+// CHECK-NEXT:     ImplicitCastExpr
+// CHECK-NEXT:       DeclRefExpr{{.*}} 'x'
+// CHECK-NEXT: DeclStmt
+// CHECK-NEXT:   VarDecl{{.*}} z
 
 @interface B
 + (int) foo;


        


More information about the cfe-commits mailing list