r363966 - Print additional information about @encode expressions when dumping the AST to JSON.
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 20 12:11:35 PDT 2019
Author: aaronballman
Date: Thu Jun 20 12:11:35 2019
New Revision: 363966
URL: http://llvm.org/viewvc/llvm-project?rev=363966&view=rev
Log:
Print additional information about @encode expressions when dumping the AST to JSON.
Modified:
cfe/trunk/include/clang/AST/JSONNodeDumper.h
cfe/trunk/lib/AST/JSONNodeDumper.cpp
cfe/trunk/test/AST/ast-dump-stmt-json.m
Modified: cfe/trunk/include/clang/AST/JSONNodeDumper.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/JSONNodeDumper.h?rev=363966&r1=363965&r2=363966&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/JSONNodeDumper.h (original)
+++ cfe/trunk/include/clang/AST/JSONNodeDumper.h Thu Jun 20 12:11:35 2019
@@ -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);
Modified: cfe/trunk/lib/AST/JSONNodeDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/JSONNodeDumper.cpp?rev=363966&r1=363965&r2=363966&view=diff
==============================================================================
--- cfe/trunk/lib/AST/JSONNodeDumper.cpp (original)
+++ cfe/trunk/lib/AST/JSONNodeDumper.cpp Thu Jun 20 12:11:35 2019
@@ -834,6 +834,10 @@ void JSONNodeDumper::VisitBlockDecl(cons
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())
Modified: cfe/trunk/test/AST/ast-dump-stmt-json.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/ast-dump-stmt-json.m?rev=363966&r1=363965&r2=363966&view=diff
==============================================================================
--- cfe/trunk/test/AST/ast-dump-stmt-json.m (original)
+++ cfe/trunk/test/AST/ast-dump-stmt-json.m Thu Jun 20 12:11:35 2019
@@ -19,6 +19,11 @@ void TestObjCAtCatchStmt() {
}
}
+void TestObjCEncode() {
+ @encode(int);
+ @encode(typeof(^{;}));
+}
+
// CHECK: "kind": "FunctionDecl",
// CHECK-NEXT: "loc": {
@@ -726,6 +731,144 @@ void TestObjCAtCatchStmt() {
// CHECK-NEXT: }
// CHECK-NEXT: ]
// CHECK-NEXT: }
+// CHECK-NEXT: ]
+// 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: ]
More information about the cfe-commits
mailing list