serge-sans-paille created this revision. serge-sans-paille added a reviewer: aaron.ballman. Herald added a project: All. serge-sans-paille requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D157781 Files: clang/include/clang/AST/JSONNodeDumper.h clang/lib/AST/JSONNodeDumper.cpp clang/test/AST/ast-dump-attr-json.cpp
Index: clang/test/AST/ast-dump-attr-json.cpp =================================================================== --- clang/test/AST/ast-dump-attr-json.cpp +++ clang/test/AST/ast-dump-attr-json.cpp @@ -3,6 +3,11 @@ int global_decl; extern __attribute__((alias("global_decl"))) int global_alias; +void cleanup_function(int*); +void some() { + __attribute__((cleanup(cleanup_function))) int var; +} + // NOTE: CHECK lines have been autogenerated by gen_ast_dump_json_test.py // using --filters=VarDecl @@ -78,7 +83,59 @@ // CHECK-NEXT: "tokLen": 1 // CHECK-NEXT: } // CHECK-NEXT: }, -// CHECK-NEXT: "decl": "global_decl" +// CHECK-NEXT: "aliasee": "global_decl" +// CHECK-NEXT: } +// CHECK-NEXT: ] +// CHECK-NEXT: } + + +// CHECK-NOT: {{^}}Dumping +// CHECK: "kind": "VarDecl", +// CHECK-NEXT: "loc": { +// CHECK-NEXT: "offset": 242, +// CHECK-NEXT: "col": 50, +// CHECK-NEXT: "tokLen": 3 +// CHECK-NEXT: }, +// CHECK-NEXT: "range": { +// CHECK-NEXT: "begin": { +// CHECK-NEXT: "offset": 195, +// CHECK-NEXT: "col": 3, +// CHECK-NEXT: "tokLen": 13 +// CHECK-NEXT: }, +// CHECK-NEXT: "end": { +// CHECK-NEXT: "offset": 242, +// CHECK-NEXT: "col": 50, +// CHECK-NEXT: "tokLen": 3 +// CHECK-NEXT: } +// CHECK-NEXT: }, +// CHECK-NEXT: "name": "var", +// CHECK-NEXT: "type": { +// CHECK-NEXT: "qualType": "int" +// CHECK-NEXT: }, +// CHECK-NEXT: "inner": [ +// CHECK-NEXT: { +// CHECK-NEXT: "id": "0x{{.*}}", +// CHECK-NEXT: "kind": "CleanupAttr", +// CHECK-NEXT: "range": { +// CHECK-NEXT: "begin": { +// CHECK-NEXT: "offset": 210, +// CHECK-NEXT: "col": 18, +// CHECK-NEXT: "tokLen": 7 +// CHECK-NEXT: }, +// CHECK-NEXT: "end": { +// CHECK-NEXT: "offset": 234, +// CHECK-NEXT: "col": 42, +// CHECK-NEXT: "tokLen": 1 +// CHECK-NEXT: } +// CHECK-NEXT: }, +// CHECK-NEXT: "cleanup_function": { +// CHECK-NEXT: "id": "0x{{.*}}", +// CHECK-NEXT: "kind": "FunctionDecl", +// CHECK-NEXT: "name": "cleanup_function", +// CHECK-NEXT: "type": { +// CHECK-NEXT: "qualType": "void (int *)" +// CHECK-NEXT: } +// CHECK-NEXT: } // CHECK-NEXT: } // CHECK-NEXT: ] // CHECK-NEXT: } Index: clang/lib/AST/JSONNodeDumper.cpp =================================================================== --- clang/lib/AST/JSONNodeDumper.cpp +++ clang/lib/AST/JSONNodeDumper.cpp @@ -534,6 +534,10 @@ JOS.attribute("aliasee", AA->getAliasee()); } +void JSONNodeDumper::VisitCleanupAttr(const CleanupAttr *CA) { + JOS.attribute("cleanup_function", createBareDeclRef(CA->getFunctionDecl())); +} + void JSONNodeDumper::VisitTypedefType(const TypedefType *TT) { JOS.attribute("decl", createBareDeclRef(TT->getDecl())); if (!TT->typeMatchesDecl()) Index: clang/include/clang/AST/JSONNodeDumper.h =================================================================== --- clang/include/clang/AST/JSONNodeDumper.h +++ clang/include/clang/AST/JSONNodeDumper.h @@ -209,6 +209,7 @@ void Visit(const APValue &Value, QualType Ty); void VisitAliasAttr(const AliasAttr *AA); + void VisitCleanupAttr(const CleanupAttr *CA); void VisitTypedefType(const TypedefType *TT); void VisitUsingType(const UsingType *TT);
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits