r364078 - Ensure that top-level QualType objects also have a "kind" field when dumping the AST to JSON.

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 21 10:14:26 PDT 2019


Author: aaronballman
Date: Fri Jun 21 10:14:25 2019
New Revision: 364078

URL: http://llvm.org/viewvc/llvm-project?rev=364078&view=rev
Log:
Ensure that top-level QualType objects also have a "kind" field when dumping the AST to JSON.

Modified:
    cfe/trunk/lib/AST/JSONNodeDumper.cpp
    cfe/trunk/test/AST/ast-dump-types-json.cpp

Modified: cfe/trunk/lib/AST/JSONNodeDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/JSONNodeDumper.cpp?rev=364078&r1=364077&r2=364078&view=diff
==============================================================================
--- cfe/trunk/lib/AST/JSONNodeDumper.cpp (original)
+++ cfe/trunk/lib/AST/JSONNodeDumper.cpp Fri Jun 21 10:14:25 2019
@@ -78,6 +78,7 @@ void JSONNodeDumper::Visit(const Type *T
 
 void JSONNodeDumper::Visit(QualType T) {
   JOS.attribute("id", createPointerRepresentation(T.getAsOpaquePtr()));
+  JOS.attribute("kind", "QualType");
   JOS.attribute("type", createQualType(T));
   JOS.attribute("qualifiers", T.split().Quals.getAsString());
 }

Modified: cfe/trunk/test/AST/ast-dump-types-json.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/ast-dump-types-json.cpp?rev=364078&r1=364077&r2=364078&view=diff
==============================================================================
--- cfe/trunk/test/AST/ast-dump-types-json.cpp (original)
+++ cfe/trunk/test/AST/ast-dump-types-json.cpp Fri Jun 21 10:14:25 2019
@@ -18,6 +18,8 @@ typedef void (CDECL *TestMacroQualifiedT
 typedef void (T::* TestMemberFunctionPointerType)();
 typedef int T::*TestMemberDataPointerType;
 
+typedef int TestQualTypePrinting(const char* c);
+
 // NOTE: CHECK lines have been autogenerated by gen_ast_dump_json_test.py
 
 
@@ -354,5 +356,75 @@ typedef int T::*TestMemberDataPointerTyp
 // CHECK-NEXT:     }
 // CHECK-NEXT:    ]
 // CHECK-NEXT:   }
+// CHECK-NEXT:  ]
+// CHECK-NEXT: }
+
+
+// CHECK:  "kind": "TypedefDecl",
+// CHECK-NEXT:  "loc": {
+// CHECK-NEXT:   "col": 13,
+// CHECK-NEXT:   "file": "{{.*}}",
+// CHECK-NEXT:   "line": 21
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "range": {
+// CHECK-NEXT:   "begin": {
+// CHECK-NEXT:    "col": 1,
+// CHECK-NEXT:    "file": "{{.*}}",
+// CHECK-NEXT:    "line": 21
+// CHECK-NEXT:   },
+// CHECK-NEXT:   "end": {
+// CHECK-NEXT:    "col": 47,
+// CHECK-NEXT:    "file": "{{.*}}",
+// CHECK-NEXT:    "line": 21
+// CHECK-NEXT:   }
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "name": "TestQualTypePrinting",
+// CHECK-NEXT:  "type": {
+// CHECK-NEXT:   "qualType": "int (const char *)"
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "inner": [
+// CHECK-NEXT:   {
+// CHECK-NEXT:    "id": "0x{{.*}}",
+// CHECK-NEXT:    "kind": "FunctionProtoType",
+// CHECK-NEXT:    "type": {
+// CHECK-NEXT:     "qualType": "int (const char *)"
+// CHECK-NEXT:    },
+// CHECK-NEXT:    "cc": "cdecl",
+// CHECK-NEXT:    "inner": [
+// CHECK-NEXT:     {
+// CHECK-NEXT:      "id": "0x{{.*}}",
+// CHECK-NEXT:      "kind": "BuiltinType",
+// CHECK-NEXT:      "type": {
+// CHECK-NEXT:       "qualType": "int"
+// CHECK-NEXT:      }
+// CHECK-NEXT:     },
+// CHECK-NEXT:     {
+// CHECK-NEXT:      "id": "0x{{.*}}",
+// CHECK-NEXT:      "kind": "PointerType",
+// CHECK-NEXT:      "type": {
+// CHECK-NEXT:       "qualType": "const char *"
+// CHECK-NEXT:      },
+// CHECK-NEXT:      "inner": [
+// CHECK-NEXT:       {
+// CHECK-NEXT:        "id": "0x{{.*}}",
+// CHECK-NEXT:        "kind": "QualType",
+// CHECK-NEXT:        "type": {
+// CHECK-NEXT:         "qualType": "const char"
+// CHECK-NEXT:        },
+// CHECK-NEXT:        "qualifiers": "const",
+// CHECK-NEXT:        "inner": [
+// CHECK-NEXT:         {
+// CHECK-NEXT:          "id": "0x{{.*}}",
+// CHECK-NEXT:          "kind": "BuiltinType",
+// CHECK-NEXT:          "type": {
+// CHECK-NEXT:           "qualType": "char"
+// CHECK-NEXT:          }
+// CHECK-NEXT:         }
+// CHECK-NEXT:        ]
+// CHECK-NEXT:       }
+// CHECK-NEXT:      ]
+// CHECK-NEXT:     }
+// CHECK-NEXT:    ]
+// CHECK-NEXT:   }
 // CHECK-NEXT:  ]
 // CHECK-NEXT: }




More information about the cfe-commits mailing list