Index: clang/include/clang/AST/JSONNodeDumper.h =================================================================== --- clang/include/clang/AST/JSONNodeDumper.h +++ clang/include/clang/AST/JSONNodeDumper.h @@ -210,6 +210,8 @@ void VisitAliasAttr(const AliasAttr *AA); void VisitCleanupAttr(const CleanupAttr *CA); + void VisitDeprecatedAttr(const DeprecatedAttr *DA); + void VisitUnavailableAttr(const UnavailableAttr *UA); void VisitTypedefType(const TypedefType *TT); void VisitUsingType(const UsingType *TT); Index: clang/lib/AST/JSONNodeDumper.cpp =================================================================== --- clang/lib/AST/JSONNodeDumper.cpp +++ clang/lib/AST/JSONNodeDumper.cpp @@ -538,6 +538,15 @@ 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::VisitUnavailableAttr(const UnavailableAttr *UA) { + JOS.attribute("message", UA->getMessage()); +} + void JSONNodeDumper::VisitTypedefType(const TypedefType *TT) { JOS.attribute("decl", createBareDeclRef(TT->getDecl())); if (!TT->typeMatchesDecl()) 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 @@ -8,6 +8,13 @@ __attribute__((cleanup(cleanup_function))) int var; } +__attribute__((deprecated)) int deprecated_var0; +__attribute__((deprecated("reason"))) int deprecated_var1; +__attribute__((deprecated("reason", "replacement"))) int deprecated_var2; + +__attribute__((unavailable)) int unavailable_var0; +__attribute__((unavailable("reason"))) int unavailable_var1; + // NOTE: CHECK lines have been autogenerated by gen_ast_dump_json_test.py // using --filters=VarDecl @@ -139,3 +146,241 @@ // 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: } + + +// CHECK-NOT: {{^}}Dumping +// CHECK: "kind": "VarDecl", +// CHECK-NEXT: "loc": { +// CHECK-NEXT: "offset": 466, +// CHECK-NEXT: "line": 15, +// CHECK-NEXT: "col": 34, +// CHECK-NEXT: "tokLen": 16 +// CHECK-NEXT: }, +// CHECK-NEXT: "range": { +// CHECK-NEXT: "begin": { +// CHECK-NEXT: "offset": 433, +// CHECK-NEXT: "col": 1, +// CHECK-NEXT: "tokLen": 13 +// CHECK-NEXT: }, +// CHECK-NEXT: "end": { +// CHECK-NEXT: "offset": 466, +// CHECK-NEXT: "col": 34, +// CHECK-NEXT: "tokLen": 16 +// CHECK-NEXT: } +// CHECK-NEXT: }, +// CHECK-NEXT: "name": "unavailable_var0", +// CHECK-NEXT: "mangledName": "unavailable_var0", +// CHECK-NEXT: "type": { +// CHECK-NEXT: "qualType": "int" +// CHECK-NEXT: }, +// CHECK-NEXT: "inner": [ +// CHECK-NEXT: { +// CHECK-NEXT: "id": "0x{{.*}}", +// CHECK-NEXT: "kind": "UnavailableAttr", +// CHECK-NEXT: "range": { +// CHECK-NEXT: "begin": { +// CHECK-NEXT: "offset": 448, +// CHECK-NEXT: "col": 16, +// CHECK-NEXT: "tokLen": 11 +// CHECK-NEXT: }, +// CHECK-NEXT: "end": { +// CHECK-NEXT: "offset": 448, +// CHECK-NEXT: "col": 16, +// CHECK-NEXT: "tokLen": 11 +// CHECK-NEXT: } +// CHECK-NEXT: }, +// CHECK-NEXT: "message": "" +// CHECK-NEXT: } +// CHECK-NEXT: ] +// CHECK-NEXT: } + + +// CHECK-NOT: {{^}}Dumping +// CHECK: "kind": "VarDecl", +// CHECK-NEXT: "loc": { +// CHECK-NEXT: "offset": 527, +// CHECK-NEXT: "line": 16, +// CHECK-NEXT: "col": 44, +// CHECK-NEXT: "tokLen": 16 +// CHECK-NEXT: }, +// CHECK-NEXT: "range": { +// CHECK-NEXT: "begin": { +// CHECK-NEXT: "offset": 484, +// CHECK-NEXT: "col": 1, +// CHECK-NEXT: "tokLen": 13 +// CHECK-NEXT: }, +// CHECK-NEXT: "end": { +// CHECK-NEXT: "offset": 527, +// CHECK-NEXT: "col": 44, +// CHECK-NEXT: "tokLen": 16 +// CHECK-NEXT: } +// CHECK-NEXT: }, +// CHECK-NEXT: "name": "unavailable_var1", +// CHECK-NEXT: "mangledName": "unavailable_var1", +// CHECK-NEXT: "type": { +// CHECK-NEXT: "qualType": "int" +// CHECK-NEXT: }, +// CHECK-NEXT: "inner": [ +// CHECK-NEXT: { +// CHECK-NEXT: "id": "0x{{.*}}", +// CHECK-NEXT: "kind": "UnavailableAttr", +// CHECK-NEXT: "range": { +// CHECK-NEXT: "begin": { +// CHECK-NEXT: "offset": 499, +// CHECK-NEXT: "col": 16, +// CHECK-NEXT: "tokLen": 11 +// CHECK-NEXT: }, +// CHECK-NEXT: "end": { +// CHECK-NEXT: "offset": 519, +// CHECK-NEXT: "col": 36, +// CHECK-NEXT: "tokLen": 1 +// CHECK-NEXT: } +// CHECK-NEXT: }, +// CHECK-NEXT: "message": "reason" +// CHECK-NEXT: } +// CHECK-NEXT: ] +// CHECK-NEXT: }