[PATCH] D56960: NFC: Implement GenericSelectionExpr::Association dump with Visitor

Stephen Kelly via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 29 14:22:59 PST 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rC352552: NFC: Implement GenericSelectionExpr::Association dump with Visitor (authored by steveire, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D56960?vs=182673&id=184178#toc

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56960/new/

https://reviews.llvm.org/D56960

Files:
  include/clang/AST/TextNodeDumper.h
  lib/AST/ASTDumper.cpp
  lib/AST/TextNodeDumper.cpp


Index: lib/AST/ASTDumper.cpp
===================================================================
--- lib/AST/ASTDumper.cpp
+++ lib/AST/ASTDumper.cpp
@@ -297,6 +297,7 @@
     void VisitInitListExpr(const InitListExpr *ILE);
     void VisitBlockExpr(const BlockExpr *Node);
     void VisitOpaqueValueExpr(const OpaqueValueExpr *Node);
+    void Visit(const GenericSelectionExpr::ConstAssociation &A);
     void VisitGenericSelectionExpr(const GenericSelectionExpr *E);
 
     // C++
@@ -1456,6 +1457,15 @@
     dumpStmt(Source);
 }
 
+void ASTDumper::Visit(const GenericSelectionExpr::ConstAssociation &A) {
+  dumpChild([=] {
+    NodeDumper.Visit(A);
+    if (const TypeSourceInfo *TSI = A.getTypeSourceInfo())
+      dumpTypeAsChild(TSI->getType());
+    dumpStmt(A.getAssociationExpr());
+  });
+}
+
 void ASTDumper::VisitGenericSelectionExpr(const GenericSelectionExpr *E) {
   if (E->isResultDependent())
     OS << " result_dependent";
@@ -1463,21 +1473,7 @@
   dumpTypeAsChild(E->getControllingExpr()->getType()); // FIXME: remove
 
   for (const auto &Assoc : E->associations()) {
-    dumpChild([=] {
-      if (const TypeSourceInfo *TSI = Assoc.getTypeSourceInfo()) {
-        OS << "case ";
-        NodeDumper.dumpType(TSI->getType());
-      } else {
-        OS << "default";
-      }
-
-      if (Assoc.isSelected())
-        OS << " selected";
-
-      if (const TypeSourceInfo *TSI = Assoc.getTypeSourceInfo())
-        dumpTypeAsChild(TSI->getType());
-      dumpStmt(Assoc.getAssociationExpr());
-    });
+    Visit(Assoc);
   }
 }
 
Index: lib/AST/TextNodeDumper.cpp
===================================================================
--- lib/AST/TextNodeDumper.cpp
+++ lib/AST/TextNodeDumper.cpp
@@ -312,6 +312,19 @@
     OS << " <implicit>";
 }
 
+void TextNodeDumper::Visit(const GenericSelectionExpr::ConstAssociation &A) {
+  const TypeSourceInfo *TSI = A.getTypeSourceInfo();
+  if (TSI) {
+    OS << "case ";
+    dumpType(TSI->getType());
+  } else {
+    OS << "default";
+  }
+
+  if (A.isSelected())
+    OS << " selected";
+}
+
 void TextNodeDumper::dumpPointer(const void *Ptr) {
   ColorScope Color(OS, ShowColors, AddressColor);
   OS << ' ' << Ptr;
Index: include/clang/AST/TextNodeDumper.h
===================================================================
--- include/clang/AST/TextNodeDumper.h
+++ include/clang/AST/TextNodeDumper.h
@@ -172,6 +172,8 @@
 
   void Visit(const BlockDecl::Capture &C);
 
+  void Visit(const GenericSelectionExpr::ConstAssociation &A);
+
   void dumpPointer(const void *Ptr);
   void dumpLocation(SourceLocation Loc);
   void dumpSourceRange(SourceRange R);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56960.184178.patch
Type: text/x-patch
Size: 2626 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190129/59403aad/attachment-0001.bin>


More information about the cfe-commits mailing list