[PATCH] D55340: NFC: Move dump of individual Stmts to TextNodeDumper
steveire closed this revision. steveire added a comment. Closing after it was reopened by spammer. Repository: rL LLVM CHANGES SINCE LAST ACTION https://reviews.llvm.org/D55340/new/ https://reviews.llvm.org/D55340 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D55340: NFC: Move dump of individual Stmts to TextNodeDumper
ham99922 reopened this revision. ham99922 added a comment. This revision is now accepted and ready to land. https://accounts.snapchat.com/accounts/login?continue=https%3A%2F%2Faccounts.snapchat.com%2Faccounts%2Fchang{F7814861} Repository: rL LLVM CHANGES SINCE LAST ACTION https://reviews.llvm.org/D55340/new/ https://reviews.llvm.org/D55340 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D55340: NFC: Move dump of individual Stmts to TextNodeDumper
This revision was automatically updated to reflect the committed changes. Closed by commit rL351014: [ASTDump] NFC: Move dump of individual Stmts to TextNodeDumper (authored by steveire, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D55340?vs=176871=181447#toc Repository: rL LLVM CHANGES SINCE LAST ACTION https://reviews.llvm.org/D55340/new/ https://reviews.llvm.org/D55340 Files: cfe/trunk/include/clang/AST/TextNodeDumper.h cfe/trunk/lib/AST/ASTDumper.cpp cfe/trunk/lib/AST/TextNodeDumper.cpp Index: cfe/trunk/include/clang/AST/TextNodeDumper.h === --- cfe/trunk/include/clang/AST/TextNodeDumper.h +++ cfe/trunk/include/clang/AST/TextNodeDumper.h @@ -20,6 +20,7 @@ #include "clang/AST/CommentCommandTraits.h" #include "clang/AST/CommentVisitor.h" #include "clang/AST/ExprCXX.h" +#include "clang/AST/StmtVisitor.h" #include "clang/AST/TemplateArgumentVisitor.h" namespace clang { @@ -125,7 +126,8 @@ public comments::ConstCommentVisitor, public ConstAttrVisitor, - public ConstTemplateArgumentVisitor { + public ConstTemplateArgumentVisitor, + public ConstStmtVisitor { raw_ostream const bool ShowColors; @@ -155,6 +157,8 @@ void Visit(const TemplateArgument , SourceRange R, const Decl *From = nullptr, StringRef Label = {}); + void Visit(const Stmt *Node); + void dumpPointer(const void *Ptr); void dumpLocation(SourceLocation Loc); void dumpSourceRange(SourceRange R); @@ -201,6 +205,56 @@ void VisitTemplateExpansionTemplateArgument(const TemplateArgument ); void VisitExpressionTemplateArgument(const TemplateArgument ); void VisitPackTemplateArgument(const TemplateArgument ); + + void VisitIfStmt(const IfStmt *Node); + void VisitSwitchStmt(const SwitchStmt *Node); + void VisitWhileStmt(const WhileStmt *Node); + void VisitLabelStmt(const LabelStmt *Node); + void VisitGotoStmt(const GotoStmt *Node); + void VisitCaseStmt(const CaseStmt *Node); + void VisitCallExpr(const CallExpr *Node); + void VisitCastExpr(const CastExpr *Node); + void VisitImplicitCastExpr(const ImplicitCastExpr *Node); + void VisitDeclRefExpr(const DeclRefExpr *Node); + void VisitPredefinedExpr(const PredefinedExpr *Node); + void VisitCharacterLiteral(const CharacterLiteral *Node); + void VisitIntegerLiteral(const IntegerLiteral *Node); + void VisitFixedPointLiteral(const FixedPointLiteral *Node); + void VisitFloatingLiteral(const FloatingLiteral *Node); + void VisitStringLiteral(const StringLiteral *Str); + void VisitInitListExpr(const InitListExpr *ILE); + void VisitUnaryOperator(const UnaryOperator *Node); + void VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *Node); + void VisitMemberExpr(const MemberExpr *Node); + void VisitExtVectorElementExpr(const ExtVectorElementExpr *Node); + void VisitBinaryOperator(const BinaryOperator *Node); + void VisitCompoundAssignOperator(const CompoundAssignOperator *Node); + void VisitAddrLabelExpr(const AddrLabelExpr *Node); + void VisitCXXNamedCastExpr(const CXXNamedCastExpr *Node); + void VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *Node); + void VisitCXXThisExpr(const CXXThisExpr *Node); + void VisitCXXFunctionalCastExpr(const CXXFunctionalCastExpr *Node); + void VisitCXXUnresolvedConstructExpr(const CXXUnresolvedConstructExpr *Node); + void VisitCXXConstructExpr(const CXXConstructExpr *Node); + void VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *Node); + void VisitCXXNewExpr(const CXXNewExpr *Node); + void VisitCXXDeleteExpr(const CXXDeleteExpr *Node); + void VisitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *Node); + void VisitExprWithCleanups(const ExprWithCleanups *Node); + void VisitUnresolvedLookupExpr(const UnresolvedLookupExpr *Node); + void VisitSizeOfPackExpr(const SizeOfPackExpr *Node); + void + VisitCXXDependentScopeMemberExpr(const CXXDependentScopeMemberExpr *Node); + void VisitObjCAtCatchStmt(const ObjCAtCatchStmt *Node); + void VisitObjCEncodeExpr(const ObjCEncodeExpr *Node); + void VisitObjCMessageExpr(const ObjCMessageExpr *Node); + void VisitObjCBoxedExpr(const ObjCBoxedExpr *Node); + void VisitObjCSelectorExpr(const ObjCSelectorExpr *Node); + void VisitObjCProtocolExpr(const ObjCProtocolExpr *Node); + void VisitObjCPropertyRefExpr(const ObjCPropertyRefExpr *Node); + void VisitObjCSubscriptRefExpr(const ObjCSubscriptRefExpr *Node); + void VisitObjCIvarRefExpr(const ObjCIvarRefExpr *Node); + void VisitObjCBoolLiteralExpr(const ObjCBoolLiteralExpr *Node); }; } // namespace clang Index: cfe/trunk/lib/AST/ASTDumper.cpp === --- cfe/trunk/lib/AST/ASTDumper.cpp +++ cfe/trunk/lib/AST/ASTDumper.cpp @@ -372,72 +372,26 @@ // Stmts. void VisitDeclStmt(const DeclStmt *Node); void VisitAttributedStmt(const AttributedStmt
[PATCH] D55340: NFC: Move dump of individual Stmts to TextNodeDumper
aaron.ballman accepted this revision. aaron.ballman added a comment. This revision is now accepted and ready to land. LGTM aside from some small nits. Comment at: lib/AST/TextNodeDumper.cpp:685 +void TextNodeDumper::VisitObjCSelectorExpr(const ObjCSelectorExpr *Node) { + + OS << " "; Extra whitespace that wasn't there before. Comment at: lib/AST/TextNodeDumper.cpp:691 +void TextNodeDumper::VisitObjCProtocolExpr(const ObjCProtocolExpr *Node) { + + OS << ' ' << *Node->getProtocol(); Extra whitespace that wasn't there before. Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D55340/new/ https://reviews.llvm.org/D55340 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D55340: NFC: Move dump of individual Stmts to TextNodeDumper
steveire created this revision. steveire added a reviewer: aaron.ballman. Herald added a subscriber: cfe-commits. Repository: rC Clang https://reviews.llvm.org/D55340 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 @@ -42,6 +42,60 @@ const comments::FullComment *>::visit(C, FC); } +void TextNodeDumper::Visit(const Stmt *Node) { + if (!Node) { +ColorScope Color(OS, ShowColors, NullColor); +OS << "<<>>"; +return; + } + { +ColorScope Color(OS, ShowColors, StmtColor); +OS << Node->getStmtClassName(); + } + dumpPointer(Node); + dumpSourceRange(Node->getSourceRange()); + + if (auto E = dyn_cast(Node)) { +dumpType(E->getType()); + +{ + ColorScope Color(OS, ShowColors, ValueKindColor); + switch (E->getValueKind()) { + case VK_RValue: +break; + case VK_LValue: +OS << " lvalue"; +break; + case VK_XValue: +OS << " xvalue"; +break; + } +} + +{ + ColorScope Color(OS, ShowColors, ObjectKindColor); + switch (E->getObjectKind()) { + case OK_Ordinary: +break; + case OK_BitField: +OS << " bitfield"; +break; + case OK_ObjCProperty: +OS << " objcproperty"; +break; + case OK_ObjCSubscript: +OS << " objcsubscript"; +break; + case OK_VectorComponent: +OS << " vectorcomponent"; +break; + } +} + } + + ConstStmtVisitor::Visit(Node); +} + void TextNodeDumper::dumpPointer(const void *Ptr) { ColorScope Color(OS, ShowColors, AddressColor); OS << ' ' << Ptr; @@ -295,3 +349,408 @@ const comments::VerbatimLineComment *C, const comments::FullComment *) { OS << " Text=\"" << C->getText() << "\""; } + +void TextNodeDumper::VisitIfStmt(const IfStmt *Node) { + if (Node->hasInitStorage()) +OS << " has_init"; + if (Node->hasVarStorage()) +OS << " has_var"; + if (Node->hasElseStorage()) +OS << " has_else"; +} + +void TextNodeDumper::VisitSwitchStmt(const SwitchStmt *Node) { + if (Node->hasInitStorage()) +OS << " has_init"; + if (Node->hasVarStorage()) +OS << " has_var"; +} + +void TextNodeDumper::VisitWhileStmt(const WhileStmt *Node) { + if (Node->hasVarStorage()) +OS << " has_var"; +} + +void TextNodeDumper::VisitLabelStmt(const LabelStmt *Node) { + OS << " '" << Node->getName() << "'"; +} + +void TextNodeDumper::VisitGotoStmt(const GotoStmt *Node) { + OS << " '" << Node->getLabel()->getName() << "'"; + dumpPointer(Node->getLabel()); +} + +void TextNodeDumper::VisitCaseStmt(const CaseStmt *Node) { + if (Node->caseStmtIsGNURange()) +OS << " gnu_range"; +} + +static void dumpBasePath(raw_ostream , const CastExpr *Node) { + if (Node->path_empty()) +return; + + OS << " ("; + bool First = true; + for (CastExpr::path_const_iterator I = Node->path_begin(), + E = Node->path_end(); + I != E; ++I) { +const CXXBaseSpecifier *Base = *I; +if (!First) + OS << " -> "; + +const CXXRecordDecl *RD = +cast(Base->getType()->getAs()->getDecl()); + +if (Base->isVirtual()) + OS << "virtual "; +OS << RD->getName(); +First = false; + } + + OS << ')'; +} + +void TextNodeDumper::VisitCastExpr(const CastExpr *Node) { + OS << " <"; + { +ColorScope Color(OS, ShowColors, CastColor); +OS << Node->getCastKindName(); + } + dumpBasePath(OS, Node); + OS << ">"; +} + +void TextNodeDumper::VisitImplicitCastExpr(const ImplicitCastExpr *Node) { + VisitCastExpr(Node); + if (Node->isPartOfExplicitCast()) +OS << " part_of_explicit_cast"; +} + +void TextNodeDumper::VisitDeclRefExpr(const DeclRefExpr *Node) { + + OS << " "; + dumpBareDeclRef(Node->getDecl()); + if (Node->getDecl() != Node->getFoundDecl()) { +OS << " ("; +dumpBareDeclRef(Node->getFoundDecl()); +OS << ")"; + } +} + +void TextNodeDumper::VisitUnresolvedLookupExpr( +const UnresolvedLookupExpr *Node) { + OS << " ("; + if (!Node->requiresADL()) +OS << "no "; + OS << "ADL) = '" << Node->getName() << '\''; + + UnresolvedLookupExpr::decls_iterator I = Node->decls_begin(), + E = Node->decls_end(); + if (I == E) +OS << " empty"; + for (; I != E; ++I) +dumpPointer(*I); +} + +void TextNodeDumper::VisitObjCIvarRefExpr(const ObjCIvarRefExpr *Node) { + + { +ColorScope Color(OS, ShowColors, DeclKindNameColor); +OS << " " << Node->getDecl()->getDeclKindName() << "Decl"; + } + OS << "='" << *Node->getDecl() << "'"; + dumpPointer(Node->getDecl()); + if (Node->isFreeIvar()) +OS << " isFreeIvar"; +} + +void TextNodeDumper::VisitPredefinedExpr(const PredefinedExpr *Node) { + OS << " " <<