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

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 21 05:23:06 PST 2019


aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM with a few small cosmetic changes.



================
Comment at: lib/AST/ASTDumper.cpp:1463-1464
+    NodeDumper.Visit(A);
+    const TypeSourceInfo *TSI = A.getTypeSourceInfo();
+    if (TSI)
+      dumpTypeAsChild(TSI->getType());
----------------
These can be combined into a single `if` statement.


================
Comment at: lib/AST/ASTDumper.cpp:1476-1477
 
   for (unsigned I = 0, N = E->getNumAssocs(); I != N; ++I) {
-    dumpChild([=] {
-      const auto Assoc = E->getAssociation(I);
-      const TypeSourceInfo *TSI = Assoc.getTypeSourceInfo();
-      if (TSI) {
-        OS << "case ";
-        NodeDumper.dumpType(TSI->getType());
-      } else {
-        OS << "default";
-      }
-
-      if (Assoc.IsSelected())
-        OS << " selected";
-
-      if (TSI)
-        dumpTypeAsChild(TSI->getType());
-      dumpStmt(Assoc.getExpr());
-    });
+    Visit(E->getAssociation(I));
   }
----------------
You can change this to be a range-based for loop over the associations to clean it up even further. `for (const auto *A = E->getAssocExprs())`


Repository:
  rC Clang

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

https://reviews.llvm.org/D56960





More information about the cfe-commits mailing list