r363869 - Print out the union field being initialized by an InitListExpr when dumping the AST to JSON.
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 19 12:40:07 PDT 2019
Author: aaronballman
Date: Wed Jun 19 12:40:07 2019
New Revision: 363869
URL: http://llvm.org/viewvc/llvm-project?rev=363869&view=rev
Log:
Print out the union field being initialized by an InitListExpr 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.cpp
Modified: cfe/trunk/include/clang/AST/JSONNodeDumper.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/JSONNodeDumper.h?rev=363869&r1=363868&r2=363869&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/JSONNodeDumper.h (original)
+++ cfe/trunk/include/clang/AST/JSONNodeDumper.h Wed Jun 19 12:40:07 2019
@@ -251,6 +251,7 @@ public:
void VisitAddrLabelExpr(const AddrLabelExpr *ALE);
void VisitCXXTypeidExpr(const CXXTypeidExpr *CTE);
void VisitConstantExpr(const ConstantExpr *CE);
+ void VisitInitListExpr(const InitListExpr *ILE);
void VisitIntegerLiteral(const IntegerLiteral *IL);
void VisitCharacterLiteral(const CharacterLiteral *CL);
Modified: cfe/trunk/lib/AST/JSONNodeDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/JSONNodeDumper.cpp?rev=363869&r1=363868&r2=363869&view=diff
==============================================================================
--- cfe/trunk/lib/AST/JSONNodeDumper.cpp (original)
+++ cfe/trunk/lib/AST/JSONNodeDumper.cpp Wed Jun 19 12:40:07 2019
@@ -984,6 +984,11 @@ void JSONNodeDumper::VisitConstantExpr(c
}
}
+void JSONNodeDumper::VisitInitListExpr(const InitListExpr *ILE) {
+ if (const FieldDecl *FD = ILE->getInitializedFieldInUnion())
+ JOS.attribute("field", createBareDeclRef(FD));
+}
+
void JSONNodeDumper::VisitIntegerLiteral(const IntegerLiteral *IL) {
JOS.attribute("value",
IL->getValue().toString(
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=363869&r1=363868&r2=363869&view=diff
==============================================================================
--- cfe/trunk/test/AST/ast-dump-stmt-json.cpp (original)
+++ cfe/trunk/test/AST/ast-dump-stmt-json.cpp Wed Jun 19 12:40:07 2019
@@ -2415,7 +2415,15 @@ void TestIteration() {
// CHECK-NEXT: "type": {
// CHECK-NEXT: "qualType": "U"
// CHECK-NEXT: },
-// CHECK-NEXT: "valueCategory": "rvalue"
+// CHECK-NEXT: "valueCategory": "rvalue",
+// CHECK-NEXT: "field": {
+// CHECK-NEXT: "id": "0x{{.*}}",
+// CHECK-NEXT: "kind": "FieldDecl",
+// CHECK-NEXT: "name": "i",
+// CHECK-NEXT: "type": {
+// CHECK-NEXT: "qualType": "int"
+// CHECK-NEXT: }
+// CHECK-NEXT: }
// CHECK-NEXT: },
// CHECK-NEXT: {
// CHECK-NEXT: "id": "0x{{.*}}",
@@ -2436,6 +2444,14 @@ void TestIteration() {
// CHECK-NEXT: "qualType": "U"
// CHECK-NEXT: },
// CHECK-NEXT: "valueCategory": "rvalue",
+// CHECK-NEXT: "field": {
+// CHECK-NEXT: "id": "0x{{.*}}",
+// CHECK-NEXT: "kind": "FieldDecl",
+// CHECK-NEXT: "name": "i",
+// CHECK-NEXT: "type": {
+// CHECK-NEXT: "qualType": "int"
+// CHECK-NEXT: }
+// CHECK-NEXT: },
// CHECK-NEXT: "inner": [
// CHECK-NEXT: {
// CHECK-NEXT: "id": "0x{{.*}}",
@@ -5975,4 +5991,3 @@ void TestIteration() {
// CHECK-NEXT: }
// CHECK-NEXT: ]
// CHECK-NEXT: }
-
More information about the cfe-commits
mailing list