]> granicus.if.org Git - clang/commitdiff
Print additional information about @encode expressions when dumping the AST to JSON.
authorAaron Ballman <aaron@aaronballman.com>
Thu, 20 Jun 2019 19:11:35 +0000 (19:11 +0000)
committerAaron Ballman <aaron@aaronballman.com>
Thu, 20 Jun 2019 19:11:35 +0000 (19:11 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@363966 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/JSONNodeDumper.h
lib/AST/JSONNodeDumper.cpp
test/AST/ast-dump-stmt-json.m

index 18d051b88a024adffafe34fb3dc475e59057400d..e8db14ad818c1720c78a1ff1d7df91bcc80c4ba0 100644 (file)
@@ -232,6 +232,7 @@ public:
   void VisitObjCPropertyDecl(const ObjCPropertyDecl *D);
   void VisitObjCPropertyImplDecl(const ObjCPropertyImplDecl *D);
   void VisitBlockDecl(const BlockDecl *D);
+  void VisitObjCEncodeExpr(const ObjCEncodeExpr *OEE);
 
   void VisitDeclRefExpr(const DeclRefExpr *DRE);
   void VisitPredefinedExpr(const PredefinedExpr *PE);
index f15bd780ba5510bea80ed7df5e1e97f25baeceed..77ba91a1f0c92ef3dcca886bbbe2ed75cf7110ba 100644 (file)
@@ -834,6 +834,10 @@ void JSONNodeDumper::VisitBlockDecl(const BlockDecl *D) {
   attributeOnlyIfTrue("capturesThis", D->capturesCXXThis());
 }
 
+void JSONNodeDumper::VisitObjCEncodeExpr(const ObjCEncodeExpr *OEE) {
+  JOS.attribute("encodedType", createQualType(OEE->getEncodedType()));
+}
+
 void JSONNodeDumper::VisitDeclRefExpr(const DeclRefExpr *DRE) {
   JOS.attribute("referencedDecl", createBareDeclRef(DRE->getDecl()));
   if (DRE->getDecl() != DRE->getFoundDecl())
index 9647f4a78c1cfe2979dce573471bb6bc0277de69..3764bd1d224ee46ecbe91a24da98b47e39f97adc 100644 (file)
@@ -19,6 +19,11 @@ void TestObjCAtCatchStmt() {
   }
 }
 
+void TestObjCEncode() {
+  @encode(int);
+  @encode(typeof(^{;}));
+}
+
 
 // CHECK:  "kind": "FunctionDecl", 
 // CHECK-NEXT:  "loc": {
@@ -730,3 +735,141 @@ void TestObjCAtCatchStmt() {
 // CHECK-NEXT:   }
 // CHECK-NEXT:  ]
 // CHECK-NEXT: }
+
+
+// CHECK:  "kind": "FunctionDecl", 
+// CHECK-NEXT:  "loc": {
+// CHECK-NEXT:   "col": 6, 
+// CHECK-NEXT:   "file": "{{.*}}", 
+// CHECK-NEXT:   "line": 22
+// CHECK-NEXT:  }, 
+// CHECK-NEXT:  "range": {
+// CHECK-NEXT:   "begin": {
+// CHECK-NEXT:    "col": 1, 
+// CHECK-NEXT:    "file": "{{.*}}", 
+// CHECK-NEXT:    "line": 22
+// CHECK-NEXT:   }, 
+// CHECK-NEXT:   "end": {
+// CHECK-NEXT:    "col": 1, 
+// CHECK-NEXT:    "file": "{{.*}}", 
+// CHECK-NEXT:    "line": 25
+// CHECK-NEXT:   }
+// CHECK-NEXT:  }, 
+// CHECK-NEXT:  "name": "TestObjCEncode", 
+// CHECK-NEXT:  "type": {
+// CHECK-NEXT:   "qualType": "void ()"
+// CHECK-NEXT:  }, 
+// CHECK-NEXT:  "inner": [
+// CHECK-NEXT:   {
+// CHECK-NEXT:    "id": "0x{{.*}}", 
+// CHECK-NEXT:    "kind": "CompoundStmt", 
+// CHECK-NEXT:    "range": {
+// CHECK-NEXT:     "begin": {
+// CHECK-NEXT:      "col": 23, 
+// CHECK-NEXT:      "file": "{{.*}}", 
+// CHECK-NEXT:      "line": 22
+// CHECK-NEXT:     }, 
+// CHECK-NEXT:     "end": {
+// CHECK-NEXT:      "col": 1, 
+// CHECK-NEXT:      "file": "{{.*}}", 
+// CHECK-NEXT:      "line": 25
+// CHECK-NEXT:     }
+// CHECK-NEXT:    }, 
+// CHECK-NEXT:    "inner": [
+// CHECK-NEXT:     {
+// CHECK-NEXT:      "id": "0x{{.*}}", 
+// CHECK-NEXT:      "kind": "ImplicitCastExpr", 
+// CHECK-NEXT:      "range": {
+// CHECK-NEXT:       "begin": {
+// CHECK-NEXT:        "col": 3, 
+// CHECK-NEXT:        "file": "{{.*}}", 
+// CHECK-NEXT:        "line": 23
+// CHECK-NEXT:       }, 
+// CHECK-NEXT:       "end": {
+// CHECK-NEXT:        "col": 14, 
+// CHECK-NEXT:        "file": "{{.*}}", 
+// CHECK-NEXT:        "line": 23
+// CHECK-NEXT:       }
+// CHECK-NEXT:      }, 
+// CHECK-NEXT:      "type": {
+// CHECK-NEXT:       "qualType": "char *"
+// CHECK-NEXT:      }, 
+// CHECK-NEXT:      "valueCategory": "rvalue", 
+// CHECK-NEXT:      "castKind": "ArrayToPointerDecay", 
+// CHECK-NEXT:      "inner": [
+// CHECK-NEXT:       {
+// CHECK-NEXT:        "id": "0x{{.*}}", 
+// CHECK-NEXT:        "kind": "ObjCEncodeExpr", 
+// CHECK-NEXT:        "range": {
+// CHECK-NEXT:         "begin": {
+// CHECK-NEXT:          "col": 3, 
+// CHECK-NEXT:          "file": "{{.*}}", 
+// CHECK-NEXT:          "line": 23
+// CHECK-NEXT:         }, 
+// CHECK-NEXT:         "end": {
+// CHECK-NEXT:          "col": 14, 
+// CHECK-NEXT:          "file": "{{.*}}", 
+// CHECK-NEXT:          "line": 23
+// CHECK-NEXT:         }
+// CHECK-NEXT:        }, 
+// CHECK-NEXT:        "type": {
+// CHECK-NEXT:         "qualType": "char [2]"
+// CHECK-NEXT:        }, 
+// CHECK-NEXT:        "valueCategory": "lvalue", 
+// CHECK-NEXT:        "encodedType": {
+// CHECK-NEXT:         "qualType": "int"
+// CHECK-NEXT:        }
+// CHECK-NEXT:       }
+// CHECK-NEXT:      ]
+// CHECK-NEXT:     }, 
+// CHECK-NEXT:     {
+// CHECK-NEXT:      "id": "0x{{.*}}", 
+// CHECK-NEXT:      "kind": "ImplicitCastExpr", 
+// CHECK-NEXT:      "range": {
+// CHECK-NEXT:       "begin": {
+// CHECK-NEXT:        "col": 3, 
+// CHECK-NEXT:        "file": "{{.*}}", 
+// CHECK-NEXT:        "line": 24
+// CHECK-NEXT:       }, 
+// CHECK-NEXT:       "end": {
+// CHECK-NEXT:        "col": 23, 
+// CHECK-NEXT:        "file": "{{.*}}", 
+// CHECK-NEXT:        "line": 24
+// CHECK-NEXT:       }
+// CHECK-NEXT:      }, 
+// CHECK-NEXT:      "type": {
+// CHECK-NEXT:       "qualType": "char *"
+// CHECK-NEXT:      }, 
+// CHECK-NEXT:      "valueCategory": "rvalue", 
+// CHECK-NEXT:      "castKind": "ArrayToPointerDecay", 
+// CHECK-NEXT:      "inner": [
+// CHECK-NEXT:       {
+// CHECK-NEXT:        "id": "0x{{.*}}", 
+// CHECK-NEXT:        "kind": "ObjCEncodeExpr", 
+// CHECK-NEXT:        "range": {
+// CHECK-NEXT:         "begin": {
+// CHECK-NEXT:          "col": 3, 
+// CHECK-NEXT:          "file": "{{.*}}", 
+// CHECK-NEXT:          "line": 24
+// CHECK-NEXT:         }, 
+// CHECK-NEXT:         "end": {
+// CHECK-NEXT:          "col": 23, 
+// CHECK-NEXT:          "file": "{{.*}}", 
+// CHECK-NEXT:          "line": 24
+// CHECK-NEXT:         }
+// CHECK-NEXT:        }, 
+// CHECK-NEXT:        "type": {
+// CHECK-NEXT:         "qualType": "char [3]"
+// CHECK-NEXT:        }, 
+// CHECK-NEXT:        "valueCategory": "lvalue", 
+// CHECK-NEXT:        "encodedType": {
+// CHECK-NEXT:         "desugaredQualType": "void (^)(void)", 
+// CHECK-NEXT:         "qualType": "typeof (^{ })"
+// CHECK-NEXT:        }
+// CHECK-NEXT:       }
+// CHECK-NEXT:      ]
+// CHECK-NEXT:     }
+// CHECK-NEXT:    ]
+// CHECK-NEXT:   }
+// CHECK-NEXT:  ]
+// CHECK-NEXT: }