[PATCH] D56960: NFC: Implement GenericSelectionExpr::Association dump with Visitor
Stephen Kelly via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Jan 19 04:12:25 PST 2019
steveire created this revision.
steveire added a reviewer: aaron.ballman.
Herald added a subscriber: cfe-commits.
Repository:
rC Clang
https://reviews.llvm.org/D56960
Files:
include/clang/AST/TextNodeDumper.h
lib/AST/ASTDumper.cpp
lib/AST/TextNodeDumper.cpp
Index: lib/AST/TextNodeDumper.cpp
===================================================================
--- lib/AST/TextNodeDumper.cpp
+++ lib/AST/TextNodeDumper.cpp
@@ -312,6 +312,19 @@
OS << " <implicit>";
}
+void TextNodeDumper::Visit(const GenericSelectionExpr::Association &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: 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::Association &A);
void VisitGenericSelectionExpr(const GenericSelectionExpr *E);
// C++
@@ -1456,6 +1457,16 @@
dumpStmt(Source);
}
+void ASTDumper::Visit(const GenericSelectionExpr::Association &A) {
+ dumpChild([=] {
+ NodeDumper.Visit(A);
+ const TypeSourceInfo *TSI = A.getTypeSourceInfo();
+ if (TSI)
+ dumpTypeAsChild(TSI->getType());
+ dumpStmt(A.getExpr());
+ });
+}
+
void ASTDumper::VisitGenericSelectionExpr(const GenericSelectionExpr *E) {
if (E->isResultDependent())
OS << " result_dependent";
@@ -1463,23 +1474,7 @@
dumpTypeAsChild(E->getControllingExpr()->getType()); // FIXME: remove
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));
}
}
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::Association &A);
+
void dumpPointer(const void *Ptr);
void dumpLocation(SourceLocation Loc);
void dumpSourceRange(SourceRange R);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56960.182673.patch
Type: text/x-patch
Size: 2632 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190119/90dbb123/attachment.bin>
More information about the cfe-commits
mailing list