diff --git a/clang/include/clang/AST/JSONNodeDumper.h b/clang/include/clang/AST/JSONNodeDumper.h --- a/clang/include/clang/AST/JSONNodeDumper.h +++ b/clang/include/clang/AST/JSONNodeDumper.h @@ -210,6 +210,7 @@ void VisitAliasAttr(const AliasAttr *AA); void VisitCleanupAttr(const CleanupAttr *CA); + void VisitDeprecatedAttr(const DeprecatedAttr *DA); void VisitTypedefType(const TypedefType *TT); void VisitUsingType(const UsingType *TT); diff --git a/clang/lib/AST/JSONNodeDumper.cpp b/clang/lib/AST/JSONNodeDumper.cpp --- a/clang/lib/AST/JSONNodeDumper.cpp +++ b/clang/lib/AST/JSONNodeDumper.cpp @@ -538,6 +538,11 @@ JOS.attribute("cleanup_function", createBareDeclRef(CA->getFunctionDecl())); } +void JSONNodeDumper::VisitDeprecatedAttr(const DeprecatedAttr *DA) { + JOS.attribute("message", DA->getMessage()); + JOS.attribute("replacement", DA->getReplacement()); +} + void JSONNodeDumper::VisitTypedefType(const TypedefType *TT) { JOS.attribute("decl", createBareDeclRef(TT->getDecl())); if (!TT->typeMatchesDecl()) diff --git a/clang/test/AST/ast-dump-attr-json.cpp b/clang/test/AST/ast-dump-attr-json.cpp --- a/clang/test/AST/ast-dump-attr-json.cpp +++ b/clang/test/AST/ast-dump-attr-json.cpp @@ -8,6 +8,10 @@ __attribute__((cleanup(cleanup_function))) int var; } +__attribute__((deprecated)) int deprecated_var0; +__attribute__((deprecated("reason"))) int deprecated_var1; +__attribute__((deprecated("reason", "replacement"))) int deprecated_var2; + // NOTE: CHECK lines have been autogenerated by gen_ast_dump_json_test.py // using --filters=VarDecl @@ -139,3 +143,147 @@ // CHECK-NEXT: } // CHECK-NEXT: ] // CHECK-NEXT: } + + +// CHECK-NOT: {{^}}Dumping +// CHECK: "kind": "VarDecl", +// CHECK-NEXT: "loc": { +// CHECK-NEXT: "offset": 282, +// CHECK-NEXT: "line": 11, +// CHECK-NEXT: "col": 33, +// CHECK-NEXT: "tokLen": 15 +// CHECK-NEXT: }, +// CHECK-NEXT: "range": { +// CHECK-NEXT: "begin": { +// CHECK-NEXT: "offset": 250, +// CHECK-NEXT: "col": 1, +// CHECK-NEXT: "tokLen": 13 +// CHECK-NEXT: }, +// CHECK-NEXT: "end": { +// CHECK-NEXT: "offset": 282, +// CHECK-NEXT: "col": 33, +// CHECK-NEXT: "tokLen": 15 +// CHECK-NEXT: } +// CHECK-NEXT: }, +// CHECK-NEXT: "name": "deprecated_var0", +// CHECK-NEXT: "mangledName": "deprecated_var0", +// CHECK-NEXT: "type": { +// CHECK-NEXT: "qualType": "int" +// CHECK-NEXT: }, +// CHECK-NEXT: "inner": [ +// CHECK-NEXT: { +// CHECK-NEXT: "id": "0x{{.*}}", +// CHECK-NEXT: "kind": "DeprecatedAttr", +// CHECK-NEXT: "range": { +// CHECK-NEXT: "begin": { +// CHECK-NEXT: "offset": 265, +// CHECK-NEXT: "col": 16, +// CHECK-NEXT: "tokLen": 10 +// CHECK-NEXT: }, +// CHECK-NEXT: "end": { +// CHECK-NEXT: "offset": 265, +// CHECK-NEXT: "col": 16, +// CHECK-NEXT: "tokLen": 10 +// CHECK-NEXT: } +// CHECK-NEXT: }, +// CHECK-NEXT: "message": "", +// CHECK-NEXT: "replacement": "" +// CHECK-NEXT: } +// CHECK-NEXT: ] +// CHECK-NEXT: } + + +// CHECK-NOT: {{^}}Dumping +// CHECK: "kind": "VarDecl", +// CHECK-NEXT: "loc": { +// CHECK-NEXT: "offset": 341, +// CHECK-NEXT: "line": 12, +// CHECK-NEXT: "col": 43, +// CHECK-NEXT: "tokLen": 15 +// CHECK-NEXT: }, +// CHECK-NEXT: "range": { +// CHECK-NEXT: "begin": { +// CHECK-NEXT: "offset": 299, +// CHECK-NEXT: "col": 1, +// CHECK-NEXT: "tokLen": 13 +// CHECK-NEXT: }, +// CHECK-NEXT: "end": { +// CHECK-NEXT: "offset": 341, +// CHECK-NEXT: "col": 43, +// CHECK-NEXT: "tokLen": 15 +// CHECK-NEXT: } +// CHECK-NEXT: }, +// CHECK-NEXT: "name": "deprecated_var1", +// CHECK-NEXT: "mangledName": "deprecated_var1", +// CHECK-NEXT: "type": { +// CHECK-NEXT: "qualType": "int" +// CHECK-NEXT: }, +// CHECK-NEXT: "inner": [ +// CHECK-NEXT: { +// CHECK-NEXT: "id": "0x{{.*}}", +// CHECK-NEXT: "kind": "DeprecatedAttr", +// CHECK-NEXT: "range": { +// CHECK-NEXT: "begin": { +// CHECK-NEXT: "offset": 314, +// CHECK-NEXT: "col": 16, +// CHECK-NEXT: "tokLen": 10 +// CHECK-NEXT: }, +// CHECK-NEXT: "end": { +// CHECK-NEXT: "offset": 333, +// CHECK-NEXT: "col": 35, +// CHECK-NEXT: "tokLen": 1 +// CHECK-NEXT: } +// CHECK-NEXT: }, +// CHECK-NEXT: "message": "reason", +// CHECK-NEXT: "replacement": "" +// CHECK-NEXT: } +// CHECK-NEXT: ] +// CHECK-NEXT: } + + +// CHECK-NOT: {{^}}Dumping +// CHECK: "kind": "VarDecl", +// CHECK-NEXT: "loc": { +// CHECK-NEXT: "offset": 415, +// CHECK-NEXT: "line": 13, +// CHECK-NEXT: "col": 58, +// CHECK-NEXT: "tokLen": 15 +// CHECK-NEXT: }, +// CHECK-NEXT: "range": { +// CHECK-NEXT: "begin": { +// CHECK-NEXT: "offset": 358, +// CHECK-NEXT: "col": 1, +// CHECK-NEXT: "tokLen": 13 +// CHECK-NEXT: }, +// CHECK-NEXT: "end": { +// CHECK-NEXT: "offset": 415, +// CHECK-NEXT: "col": 58, +// CHECK-NEXT: "tokLen": 15 +// CHECK-NEXT: } +// CHECK-NEXT: }, +// CHECK-NEXT: "name": "deprecated_var2", +// CHECK-NEXT: "mangledName": "deprecated_var2", +// CHECK-NEXT: "type": { +// CHECK-NEXT: "qualType": "int" +// CHECK-NEXT: }, +// CHECK-NEXT: "inner": [ +// CHECK-NEXT: { +// CHECK-NEXT: "id": "0x{{.*}}", +// CHECK-NEXT: "kind": "DeprecatedAttr", +// CHECK-NEXT: "range": { +// CHECK-NEXT: "begin": { +// CHECK-NEXT: "offset": 373, +// CHECK-NEXT: "col": 16, +// CHECK-NEXT: "tokLen": 10 +// CHECK-NEXT: }, +// CHECK-NEXT: "end": { +// CHECK-NEXT: "offset": 407, +// CHECK-NEXT: "col": 50, +// CHECK-NEXT: "tokLen": 1 +// CHECK-NEXT: } +// CHECK-NEXT: }, +// CHECK-NEXT: "message": "reason", +// CHECK-NEXT: "replacement": "replacement" +// CHECK-NEXT: } +// CHECK-NEXT: ] +// CHECK-NEXT: }