r361767 - When dumping the AST to JSON, dump the declared name of a MemberExpr operand.

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Mon May 27 07:25:05 PDT 2019


Author: aaronballman
Date: Mon May 27 07:25:04 2019
New Revision: 361767

URL: http://llvm.org/viewvc/llvm-project?rev=361767&view=rev
Log:
When dumping the AST to JSON, dump the declared name of a MemberExpr operand.

Modified:
    cfe/trunk/lib/AST/JSONNodeDumper.cpp
    cfe/trunk/test/AST/ast-dump-expr-json.c
    cfe/trunk/test/AST/ast-dump-expr-json.cpp
    cfe/trunk/test/AST/ast-dump-stmt-json.cpp

Modified: cfe/trunk/lib/AST/JSONNodeDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/JSONNodeDumper.cpp?rev=361767&r1=361766&r2=361767&view=diff
==============================================================================
--- cfe/trunk/lib/AST/JSONNodeDumper.cpp (original)
+++ cfe/trunk/lib/AST/JSONNodeDumper.cpp Mon May 27 07:25:04 2019
@@ -829,9 +829,10 @@ void JSONNodeDumper::VisitCompoundAssign
 void JSONNodeDumper::VisitMemberExpr(const MemberExpr *ME) {
   // Note, we always write this Boolean field because the information it conveys
   // is critical to understanding the AST node.
+  ValueDecl *VD = ME->getMemberDecl();
+  JOS.attribute("name", VD && VD->getDeclName() ? VD->getNameAsString() : "");
   JOS.attribute("isArrow", ME->isArrow());
-  JOS.attribute("referencedMemberDecl",
-                createPointerRepresentation(ME->getMemberDecl()));
+  JOS.attribute("referencedMemberDecl", createPointerRepresentation(VD));
 }
 
 void JSONNodeDumper::VisitCXXNewExpr(const CXXNewExpr *NE) {

Modified: cfe/trunk/test/AST/ast-dump-expr-json.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/ast-dump-expr-json.c?rev=361767&r1=361766&r2=361767&view=diff
==============================================================================
--- cfe/trunk/test/AST/ast-dump-expr-json.c (original)
+++ cfe/trunk/test/AST/ast-dump-expr-json.c Mon May 27 07:25:04 2019
@@ -4433,6 +4433,7 @@ void PrimaryExpressions(int a) {
 // CHECK-NEXT:         "qualType": "int"
 // CHECK-NEXT:        },
 // CHECK-NEXT:        "valueCategory": "lvalue",
+// CHECK-NEXT:        "name": "a",
 // CHECK-NEXT:        "isArrow": false,
 // CHECK-NEXT:        "referencedMemberDecl": "0x{{.*}}",
 // CHECK-NEXT:        "inner": [
@@ -4510,6 +4511,7 @@ void PrimaryExpressions(int a) {
 // CHECK-NEXT:         "qualType": "int"
 // CHECK-NEXT:        },
 // CHECK-NEXT:        "valueCategory": "lvalue",
+// CHECK-NEXT:        "name": "a",
 // CHECK-NEXT:        "isArrow": true,
 // CHECK-NEXT:        "referencedMemberDecl": "0x{{.*}}",
 // CHECK-NEXT:        "inner": [

Modified: cfe/trunk/test/AST/ast-dump-expr-json.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/ast-dump-expr-json.cpp?rev=361767&r1=361766&r2=361767&view=diff
==============================================================================
--- cfe/trunk/test/AST/ast-dump-expr-json.cpp (original)
+++ cfe/trunk/test/AST/ast-dump-expr-json.cpp Mon May 27 07:25:04 2019
@@ -2584,6 +2584,7 @@ void TestNonADLCall3() {
 // CHECK-NEXT:         "qualType": "<bound member function type>"
 // CHECK-NEXT:        },
 // CHECK-NEXT:        "valueCategory": "rvalue",
+// CHECK-NEXT:        "name": "func",
 // CHECK-NEXT:        "isArrow": false,
 // CHECK-NEXT:        "referencedMemberDecl": "0x{{.*}}",
 // CHECK-NEXT:        "inner": [
@@ -2679,6 +2680,7 @@ void TestNonADLCall3() {
 // CHECK-NEXT:         "qualType": "<bound member function type>"
 // CHECK-NEXT:        },
 // CHECK-NEXT:        "valueCategory": "rvalue",
+// CHECK-NEXT:        "name": "func",
 // CHECK-NEXT:        "isArrow": true,
 // CHECK-NEXT:        "referencedMemberDecl": "0x{{.*}}",
 // CHECK-NEXT:        "inner": [
@@ -2798,6 +2800,7 @@ void TestNonADLCall3() {
 // CHECK-NEXT:         "qualType": "<bound member function type>"
 // CHECK-NEXT:        },
 // CHECK-NEXT:        "valueCategory": "rvalue",
+// CHECK-NEXT:        "name": "foo",
 // CHECK-NEXT:        "isArrow": true,
 // CHECK-NEXT:        "referencedMemberDecl": "0x{{.*}}",
 // CHECK-NEXT:        "inner": [
@@ -2896,6 +2899,7 @@ void TestNonADLCall3() {
 // CHECK-NEXT:         "qualType": "<bound member function type>"
 // CHECK-NEXT:        },
 // CHECK-NEXT:        "valueCategory": "rvalue",
+// CHECK-NEXT:        "name": "foo",
 // CHECK-NEXT:        "isArrow": false,
 // CHECK-NEXT:        "referencedMemberDecl": "0x{{.*}}",
 // CHECK-NEXT:        "inner": [
@@ -2970,6 +2974,7 @@ void TestNonADLCall3() {
 // CHECK-NEXT:         "qualType": "<bound member function type>"
 // CHECK-NEXT:        },
 // CHECK-NEXT:        "valueCategory": "rvalue",
+// CHECK-NEXT:        "name": "~S",
 // CHECK-NEXT:        "isArrow": true,
 // CHECK-NEXT:        "referencedMemberDecl": "0x{{.*}}",
 // CHECK-NEXT:        "inner": [
@@ -3067,6 +3072,7 @@ void TestNonADLCall3() {
 // CHECK-NEXT:         "qualType": "<bound member function type>"
 // CHECK-NEXT:        },
 // CHECK-NEXT:        "valueCategory": "rvalue",
+// CHECK-NEXT:        "name": "~S",
 // CHECK-NEXT:        "isArrow": false,
 // CHECK-NEXT:        "referencedMemberDecl": "0x{{.*}}",
 // CHECK-NEXT:        "inner": [
@@ -3141,6 +3147,7 @@ void TestNonADLCall3() {
 // CHECK-NEXT:         "qualType": "<bound member function type>"
 // CHECK-NEXT:        },
 // CHECK-NEXT:        "valueCategory": "rvalue",
+// CHECK-NEXT:        "name": "~S",
 // CHECK-NEXT:        "isArrow": false,
 // CHECK-NEXT:        "referencedMemberDecl": "0x{{.*}}",
 // CHECK-NEXT:        "inner": [
@@ -3215,6 +3222,7 @@ void TestNonADLCall3() {
 // CHECK-NEXT:         "qualType": "<bound member function type>"
 // CHECK-NEXT:        },
 // CHECK-NEXT:        "valueCategory": "rvalue",
+// CHECK-NEXT:        "name": "~S",
 // CHECK-NEXT:        "isArrow": true,
 // CHECK-NEXT:        "referencedMemberDecl": "0x{{.*}}",
 // CHECK-NEXT:        "inner": [
@@ -3312,6 +3320,7 @@ void TestNonADLCall3() {
 // CHECK-NEXT:         "qualType": "<bound member function type>"
 // CHECK-NEXT:        },
 // CHECK-NEXT:        "valueCategory": "rvalue",
+// CHECK-NEXT:        "name": "~U",
 // CHECK-NEXT:        "isArrow": true,
 // CHECK-NEXT:        "referencedMemberDecl": "0x{{.*}}",
 // CHECK-NEXT:        "inner": [

Modified: cfe/trunk/test/AST/ast-dump-stmt-json.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/ast-dump-stmt-json.cpp?rev=361767&r1=361766&r2=361767&view=diff
==============================================================================
--- cfe/trunk/test/AST/ast-dump-stmt-json.cpp (original)
+++ cfe/trunk/test/AST/ast-dump-stmt-json.cpp Mon May 27 07:25:04 2019
@@ -4653,6 +4653,7 @@ void TestIteration() {
 // CHECK-NEXT:               "qualType": "<bound member function type>"
 // CHECK-NEXT:              },
 // CHECK-NEXT:              "valueCategory": "rvalue",
+// CHECK-NEXT:              "name": "begin",
 // CHECK-NEXT:              "isArrow": false,
 // CHECK-NEXT:              "referencedMemberDecl": "0x{{.*}}",
 // CHECK-NEXT:              "inner": [
@@ -4799,6 +4800,7 @@ void TestIteration() {
 // CHECK-NEXT:               "qualType": "<bound member function type>"
 // CHECK-NEXT:              },
 // CHECK-NEXT:              "valueCategory": "rvalue",
+// CHECK-NEXT:              "name": "end",
 // CHECK-NEXT:              "isArrow": false,
 // CHECK-NEXT:              "referencedMemberDecl": "0x{{.*}}",
 // CHECK-NEXT:              "inner": [




More information about the cfe-commits mailing list