Index: lib/AST/ASTDumper.cpp =================================================================== --- lib/AST/ASTDumper.cpp +++ lib/AST/ASTDumper.cpp @@ -379,7 +379,6 @@ void VisitOMPExecutableDirective(const OMPExecutableDirective *Node); // Exprs - void VisitExpr(const Expr *Node); void VisitCastExpr(const CastExpr *Node); void VisitImplicitCastExpr(const ImplicitCastExpr *Node); void VisitDeclRefExpr(const DeclRefExpr *Node); @@ -415,7 +414,6 @@ void VisitExprWithCleanups(const ExprWithCleanups *Node); void VisitUnresolvedLookupExpr(const UnresolvedLookupExpr *Node); void VisitLambdaExpr(const LambdaExpr *Node) { - VisitExpr(Node); dumpDecl(Node->getLambdaClass()); } void VisitSizeOfPackExpr(const SizeOfPackExpr *Node); @@ -1697,6 +1695,44 @@ NodeDumper.dumpPointer(S); NodeDumper.dumpSourceRange(S->getSourceRange()); + if (auto *E = dyn_cast(S)) { + NodeDumper.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(S); // Some statements have custom mechanisms for dumping their children. @@ -1799,44 +1835,6 @@ // Expr dumping methods. //===----------------------------------------------------------------------===// -void ASTDumper::VisitExpr(const Expr *Node) { - NodeDumper.dumpType(Node->getType()); - - { - ColorScope Color(OS, ShowColors, ValueKindColor); - switch (Node->getValueKind()) { - case VK_RValue: - break; - case VK_LValue: - OS << " lvalue"; - break; - case VK_XValue: - OS << " xvalue"; - break; - } - } - - { - ColorScope Color(OS, ShowColors, ObjectKindColor); - switch (Node->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; - } - } -} - static void dumpBasePath(raw_ostream &OS, const CastExpr *Node) { if (Node->path_empty()) return; @@ -1863,7 +1861,6 @@ } void ASTDumper::VisitCastExpr(const CastExpr *Node) { - VisitExpr(Node); OS << " <"; { ColorScope Color(OS, ShowColors, CastColor); @@ -1880,8 +1877,6 @@ } void ASTDumper::VisitDeclRefExpr(const DeclRefExpr *Node) { - VisitExpr(Node); - OS << " "; NodeDumper.dumpBareDeclRef(Node->getDecl()); if (Node->getDecl() != Node->getFoundDecl()) { @@ -1892,7 +1887,6 @@ } void ASTDumper::VisitUnresolvedLookupExpr(const UnresolvedLookupExpr *Node) { - VisitExpr(Node); OS << " ("; if (!Node->requiresADL()) OS << "no "; @@ -1907,8 +1901,6 @@ } void ASTDumper::VisitObjCIvarRefExpr(const ObjCIvarRefExpr *Node) { - VisitExpr(Node); - { ColorScope Color(OS, ShowColors, DeclKindNameColor); OS << " " << Node->getDecl()->getDeclKindName() << "Decl"; @@ -1920,46 +1912,37 @@ } void ASTDumper::VisitPredefinedExpr(const PredefinedExpr *Node) { - VisitExpr(Node); OS << " " << PredefinedExpr::getIdentKindName(Node->getIdentKind()); } void ASTDumper::VisitCharacterLiteral(const CharacterLiteral *Node) { - VisitExpr(Node); ColorScope Color(OS, ShowColors, ValueColor); OS << " " << Node->getValue(); } void ASTDumper::VisitIntegerLiteral(const IntegerLiteral *Node) { - VisitExpr(Node); - bool isSigned = Node->getType()->isSignedIntegerType(); ColorScope Color(OS, ShowColors, ValueColor); OS << " " << Node->getValue().toString(10, isSigned); } void ASTDumper::VisitFixedPointLiteral(const FixedPointLiteral *Node) { - VisitExpr(Node); - ColorScope Color(OS, ShowColors, ValueColor); OS << " " << Node->getValueAsString(/*Radix=*/10); } void ASTDumper::VisitFloatingLiteral(const FloatingLiteral *Node) { - VisitExpr(Node); ColorScope Color(OS, ShowColors, ValueColor); OS << " " << Node->getValueAsApproximateDouble(); } void ASTDumper::VisitStringLiteral(const StringLiteral *Str) { - VisitExpr(Str); ColorScope Color(OS, ShowColors, ValueColor); OS << " "; Str->outputString(OS); } void ASTDumper::VisitInitListExpr(const InitListExpr *ILE) { - VisitExpr(ILE); if (auto *Filler = ILE->getArrayFiller()) { dumpChild([=] { OS << "array filler"; @@ -1973,7 +1956,6 @@ } void ASTDumper::VisitUnaryOperator(const UnaryOperator *Node) { - VisitExpr(Node); OS << " " << (Node->isPostfix() ? "postfix" : "prefix") << " '" << UnaryOperator::getOpcodeStr(Node->getOpcode()) << "'"; if (!Node->canOverflow()) @@ -1982,7 +1964,6 @@ void ASTDumper::VisitUnaryExprOrTypeTraitExpr( const UnaryExprOrTypeTraitExpr *Node) { - VisitExpr(Node); switch(Node->getKind()) { case UETT_SizeOf: OS << " sizeof"; @@ -2005,24 +1986,20 @@ } void ASTDumper::VisitMemberExpr(const MemberExpr *Node) { - VisitExpr(Node); OS << " " << (Node->isArrow() ? "->" : ".") << *Node->getMemberDecl(); NodeDumper.dumpPointer(Node->getMemberDecl()); } void ASTDumper::VisitExtVectorElementExpr(const ExtVectorElementExpr *Node) { - VisitExpr(Node); OS << " " << Node->getAccessor().getNameStart(); } void ASTDumper::VisitBinaryOperator(const BinaryOperator *Node) { - VisitExpr(Node); OS << " '" << BinaryOperator::getOpcodeStr(Node->getOpcode()) << "'"; } void ASTDumper::VisitCompoundAssignOperator( const CompoundAssignOperator *Node) { - VisitExpr(Node); OS << " '" << BinaryOperator::getOpcodeStr(Node->getOpcode()) << "' ComputeLHSTy="; NodeDumper.dumpBareType(Node->getComputationLHSType()); @@ -2031,19 +2008,15 @@ } void ASTDumper::VisitBlockExpr(const BlockExpr *Node) { - VisitExpr(Node); dumpDecl(Node->getBlockDecl()); } void ASTDumper::VisitOpaqueValueExpr(const OpaqueValueExpr *Node) { - VisitExpr(Node); - if (Expr *Source = Node->getSourceExpr()) dumpStmt(Source); } void ASTDumper::VisitGenericSelectionExpr(const GenericSelectionExpr *E) { - VisitExpr(E); if (E->isResultDependent()) OS << " result_dependent"; dumpStmt(E->getControllingExpr()); @@ -2071,7 +2044,6 @@ // GNU extensions. void ASTDumper::VisitAddrLabelExpr(const AddrLabelExpr *Node) { - VisitExpr(Node); OS << " " << Node->getLabel()->getName(); NodeDumper.dumpPointer(Node->getLabel()); } @@ -2081,7 +2053,6 @@ //===----------------------------------------------------------------------===// void ASTDumper::VisitCXXNamedCastExpr(const CXXNamedCastExpr *Node) { - VisitExpr(Node); OS << " " << Node->getCastName() << "<" << Node->getTypeAsWritten().getAsString() << ">" << " <" << Node->getCastKindName(); @@ -2090,31 +2061,26 @@ } void ASTDumper::VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *Node) { - VisitExpr(Node); OS << " " << (Node->getValue() ? "true" : "false"); } void ASTDumper::VisitCXXThisExpr(const CXXThisExpr *Node) { - VisitExpr(Node); OS << " this"; } void ASTDumper::VisitCXXFunctionalCastExpr(const CXXFunctionalCastExpr *Node) { - VisitExpr(Node); OS << " functional cast to " << Node->getTypeAsWritten().getAsString() << " <" << Node->getCastKindName() << ">"; } void ASTDumper::VisitCXXUnresolvedConstructExpr( const CXXUnresolvedConstructExpr *Node) { - VisitExpr(Node); NodeDumper.dumpType(Node->getTypeAsWritten()); if (Node->isListInitialization()) OS << " list"; } void ASTDumper::VisitCXXConstructExpr(const CXXConstructExpr *Node) { - VisitExpr(Node); CXXConstructorDecl *Ctor = Node->getConstructor(); NodeDumper.dumpType(Ctor->getType()); if (Node->isElidable()) @@ -2128,13 +2094,11 @@ } void ASTDumper::VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *Node) { - VisitExpr(Node); OS << " "; NodeDumper.dumpCXXTemporary(Node->getTemporary()); } void ASTDumper::VisitCXXNewExpr(const CXXNewExpr *Node) { - VisitExpr(Node); if (Node->isGlobalNew()) OS << " global"; if (Node->isArray()) @@ -2148,7 +2112,6 @@ } void ASTDumper::VisitCXXDeleteExpr(const CXXDeleteExpr *Node) { - VisitExpr(Node); if (Node->isGlobalDelete()) OS << " global"; if (Node->isArrayForm()) @@ -2161,7 +2124,6 @@ void ASTDumper::VisitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *Node) { - VisitExpr(Node); if (const ValueDecl *VD = Node->getExtendingDecl()) { OS << " extended by "; NodeDumper.dumpBareDeclRef(VD); @@ -2169,13 +2131,11 @@ } void ASTDumper::VisitExprWithCleanups(const ExprWithCleanups *Node) { - VisitExpr(Node); for (unsigned i = 0, e = Node->getNumObjects(); i != e; ++i) NodeDumper.dumpDeclRef(Node->getObject(i), "cleanup"); } void ASTDumper::VisitSizeOfPackExpr(const SizeOfPackExpr *Node) { - VisitExpr(Node); NodeDumper.dumpPointer(Node->getPack()); NodeDumper.dumpName(Node->getPack()); if (Node->isPartiallySubstituted()) @@ -2185,7 +2145,6 @@ void ASTDumper::VisitCXXDependentScopeMemberExpr( const CXXDependentScopeMemberExpr *Node) { - VisitExpr(Node); OS << " " << (Node->isArrow() ? "->" : ".") << Node->getMember(); } @@ -2194,7 +2153,6 @@ //===----------------------------------------------------------------------===// void ASTDumper::VisitObjCMessageExpr(const ObjCMessageExpr *Node) { - VisitExpr(Node); OS << " selector="; Node->getSelector().print(OS); switch (Node->getReceiverKind()) { @@ -2217,7 +2175,6 @@ } void ASTDumper::VisitObjCBoxedExpr(const ObjCBoxedExpr *Node) { - VisitExpr(Node); if (auto *BoxingMethod = Node->getBoxingMethod()) { OS << " selector="; BoxingMethod->getSelector().print(OS); @@ -2232,25 +2189,19 @@ } void ASTDumper::VisitObjCEncodeExpr(const ObjCEncodeExpr *Node) { - VisitExpr(Node); NodeDumper.dumpType(Node->getEncodedType()); } void ASTDumper::VisitObjCSelectorExpr(const ObjCSelectorExpr *Node) { - VisitExpr(Node); - OS << " "; Node->getSelector().print(OS); } void ASTDumper::VisitObjCProtocolExpr(const ObjCProtocolExpr *Node) { - VisitExpr(Node); - OS << ' ' << *Node->getProtocol(); } void ASTDumper::VisitObjCPropertyRefExpr(const ObjCPropertyRefExpr *Node) { - VisitExpr(Node); if (Node->isImplicitProperty()) { OS << " Kind=MethodRef Getter=\""; if (Node->getImplicitPropertyGetter()) @@ -2281,7 +2232,6 @@ } void ASTDumper::VisitObjCSubscriptRefExpr(const ObjCSubscriptRefExpr *Node) { - VisitExpr(Node); if (Node->isArraySubscriptRefExpr()) OS << " Kind=ArraySubscript GetterForArray=\""; else @@ -2302,7 +2252,6 @@ } void ASTDumper::VisitObjCBoolLiteralExpr(const ObjCBoolLiteralExpr *Node) { - VisitExpr(Node); OS << " " << (Node->getValue() ? "__objc_yes" : "__objc_no"); }