]> granicus.if.org Git - clang/commitdiff
When dumping the AST to JSON, dump the declared name of a MemberExpr operand.
authorAaron Ballman <aaron@aaronballman.com>
Mon, 27 May 2019 14:25:04 +0000 (14:25 +0000)
committerAaron Ballman <aaron@aaronballman.com>
Mon, 27 May 2019 14:25:04 +0000 (14:25 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@361767 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/JSONNodeDumper.cpp
test/AST/ast-dump-expr-json.c
test/AST/ast-dump-expr-json.cpp
test/AST/ast-dump-stmt-json.cpp

index a6600c0c84deb796df066e7e9dcb67cb8fefe2b5..760ea338121c3a188f62051ea22c567b5287babf 100644 (file)
@@ -829,9 +829,10 @@ void JSONNodeDumper::VisitCompoundAssignOperator(
 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) {
index a2d6aab142b813afd6cb32f06aed36e7045d3ba8..77183be2f91389ac034ad6d0488ce31416d4aeef 100644 (file)
@@ -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": [
index 0c541666d26b54ad46ce1187238eff8b6e0fa601..15a93a08a8166f6f4c0937ee2a47273673896c43 100644 (file)
@@ -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": [
index 448857ea3e69824e99874f5420caf8c8320b0e78..883ac59409e9f09717be066f7463e2474ebda41b 100644 (file)
@@ -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": [