danix800 created this revision. danix800 added reviewers: hokein, aaron.ballman. danix800 added a project: clang. Herald added a subscriber: kristof.beyls. Herald added a project: All. danix800 requested review of this revision. Herald added a subscriber: cfe-commits.
`ParmVarDecl` of `BlockDecl` is unnecessary dumped twice. Remove this duplication as other `FunctionDecl`s. Fixes #2 of https://github.com/llvm/llvm-project/issues/64005 Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D155985 Files: clang/include/clang/AST/ASTNodeTraverser.h clang/test/AST/ast-dump-decl-json.m clang/test/AST/ast-dump-decl.m Index: clang/test/AST/ast-dump-decl.m =================================================================== --- clang/test/AST/ast-dump-decl.m +++ clang/test/AST/ast-dump-decl.m @@ -142,12 +142,17 @@ 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; Index: clang/test/AST/ast-dump-decl-json.m =================================================================== --- clang/test/AST/ast-dump-decl-json.m +++ clang/test/AST/ast-dump-decl-json.m @@ -1924,31 +1924,6 @@ // 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: } Index: clang/include/clang/AST/ASTNodeTraverser.h =================================================================== --- clang/include/clang/AST/ASTNodeTraverser.h +++ clang/include/clang/AST/ASTNodeTraverser.h @@ -104,7 +104,8 @@ 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();
Index: clang/test/AST/ast-dump-decl.m =================================================================== --- clang/test/AST/ast-dump-decl.m +++ clang/test/AST/ast-dump-decl.m @@ -142,12 +142,17 @@ 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; Index: clang/test/AST/ast-dump-decl-json.m =================================================================== --- clang/test/AST/ast-dump-decl-json.m +++ clang/test/AST/ast-dump-decl-json.m @@ -1924,31 +1924,6 @@ // 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: } Index: clang/include/clang/AST/ASTNodeTraverser.h =================================================================== --- clang/include/clang/AST/ASTNodeTraverser.h +++ clang/include/clang/AST/ASTNodeTraverser.h @@ -104,7 +104,8 @@ 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();
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits