implement dumper support for the rest of expressions.

llvm-svn: 40968
This commit is contained in:
Chris Lattner 2007-08-09 17:35:30 +00:00
parent 3f5e4680fb
commit db3b3ff74b
1 changed files with 54 additions and 75 deletions

View File

@ -355,21 +355,17 @@ void StmtDumper::VisitParenExpr(ParenExpr *Node) {
fprintf(F, ")"); fprintf(F, ")");
} }
void StmtDumper::VisitUnaryOperator(UnaryOperator *Node) { void StmtDumper::VisitUnaryOperator(UnaryOperator *Node) {
#if 0 DumpExpr(Node);
if (!Node->isPostfix()) fprintf(F, " %s '%s'\n", Node->isPostfix() ? "postfix" : "prefix",
OS << UnaryOperator::getOpcodeStr(Node->getOpcode()); UnaryOperator::getOpcodeStr(Node->getOpcode()));
DumpExpr(Node->getSubExpr()); DumpSubTree(Node->getSubExpr());
fprintf(F, ")");
if (Node->isPostfix())
OS << UnaryOperator::getOpcodeStr(Node->getOpcode());
#endif
} }
void StmtDumper::VisitSizeOfAlignOfTypeExpr(SizeOfAlignOfTypeExpr *Node) { void StmtDumper::VisitSizeOfAlignOfTypeExpr(SizeOfAlignOfTypeExpr *Node) {
#if 0 DumpExpr(Node);
OS << (Node->isSizeOf() ? "sizeof(" : "__alignof("); fprintf(F, " %s ", Node->isSizeOf() ? "sizeof" : "alignof");
OS << Node->getArgumentType().getAsString() << ")"; DumpType(Node->getArgumentType());
#endif fprintf(F, ")");
} }
void StmtDumper::VisitArraySubscriptExpr(ArraySubscriptExpr *Node) { void StmtDumper::VisitArraySubscriptExpr(ArraySubscriptExpr *Node) {
DumpExpr(Node); DumpExpr(Node);
@ -391,34 +387,31 @@ void StmtDumper::VisitCallExpr(CallExpr *Node) {
} }
fprintf(F, ")"); fprintf(F, ")");
} }
void StmtDumper::VisitMemberExpr(MemberExpr *Node) {
#if 0
DumpExpr(Node->getBase());
OS << (Node->isArrow() ? "->" : ".");
FieldDecl *Field = Node->getMemberDecl(); void StmtDumper::VisitMemberExpr(MemberExpr *Node) {
assert(Field && "MemberExpr should alway reference a field!"); DumpExpr(Node);
OS << Field->getName(); fprintf(F, " %s%s %p\n", Node->isArrow() ? "->" : ".",
#endif Node->getMemberDecl()->getName(), (void*)Node->getMemberDecl());
DumpSubTree(Node->getBase());
fprintf(F, ")");
} }
void StmtDumper::VisitOCUVectorElementExpr(OCUVectorElementExpr *Node) { void StmtDumper::VisitOCUVectorElementExpr(OCUVectorElementExpr *Node) {
#if 0 DumpExpr(Node);
DumpExpr(Node->getBase()); fprintf(F, " %s\n", Node->getAccessor().getName());
OS << "."; DumpSubTree(Node->getBase());
OS << Node->getAccessor().getName(); fprintf(F, ")");
#endif
} }
void StmtDumper::VisitCastExpr(CastExpr *Node) { void StmtDumper::VisitCastExpr(CastExpr *Node) {
#if 0 DumpExpr(Node);
OS << "(" << Node->getType().getAsString() << ")"; fprintf(F, "\n");
DumpExpr(Node->getSubExpr()); DumpSubTree(Node->getSubExpr());
#endif fprintf(F, ")");
} }
void StmtDumper::VisitCompoundLiteralExpr(CompoundLiteralExpr *Node) { void StmtDumper::VisitCompoundLiteralExpr(CompoundLiteralExpr *Node) {
#if 0 DumpExpr(Node);
OS << "(" << Node->getType().getAsString() << ")"; fprintf(F, "\n");
DumpExpr(Node->getInitializer()); DumpSubTree(Node->getInitializer());
#endif fprintf(F, ")");
} }
void StmtDumper::VisitImplicitCastExpr(ImplicitCastExpr *Node) { void StmtDumper::VisitImplicitCastExpr(ImplicitCastExpr *Node) {
DumpExpr(Node); DumpExpr(Node);
@ -448,63 +441,49 @@ void StmtDumper::VisitConditionalOperator(ConditionalOperator *Node) {
// GNU extensions. // GNU extensions.
void StmtDumper::VisitAddrLabelExpr(AddrLabelExpr *Node) { void StmtDumper::VisitAddrLabelExpr(AddrLabelExpr *Node) {
#if 0 DumpExpr(Node);
OS << "&&" << Node->getLabel()->getName(); fprintf(F, " %s %p)", Node->getLabel()->getName(), (void*)Node->getLabel());
#endif
} }
void StmtDumper::VisitStmtExpr(StmtExpr *E) { void StmtDumper::VisitStmtExpr(StmtExpr *Node) {
#if 0 DumpExpr(Node);
OS << "("; fprintf(F, "\n");
DumpSubTree(E->getSubStmt()); DumpSubTree(Node->getSubStmt());
OS << ")"; fprintf(F, ")");
#endif
} }
void StmtDumper::VisitTypesCompatibleExpr(TypesCompatibleExpr *Node) { void StmtDumper::VisitTypesCompatibleExpr(TypesCompatibleExpr *Node) {
#if 0 DumpExpr(Node);
OS << "__builtin_types_compatible_p("; fprintf(F, " ");
OS << Node->getArgType1().getAsString() << ","; DumpType(Node->getArgType1());
OS << Node->getArgType2().getAsString() << ")"; fprintf(F, " ");
#endif DumpType(Node->getArgType2());
fprintf(F, ")");
} }
void StmtDumper::VisitChooseExpr(ChooseExpr *Node) { void StmtDumper::VisitChooseExpr(ChooseExpr *Node) {
#if 0 DumpExpr(Node);
OS << "__builtin_choose_expr("; fprintf(F, "\n");
DumpExpr(Node->getCond()); DumpSubTree(Node->getCond());
OS << ", "; fprintf(F, "\n");
DumpExpr(Node->getLHS()); DumpSubTree(Node->getLHS());
OS << ", "; fprintf(F, "\n");
DumpExpr(Node->getRHS()); DumpSubTree(Node->getRHS());
OS << ")"; fprintf(F, ")");
#endif
} }
// C++ // C++
void StmtDumper::VisitCXXCastExpr(CXXCastExpr *Node) { void StmtDumper::VisitCXXCastExpr(CXXCastExpr *Node) {
#if 0 DumpExpr(Node);
switch (Node->getOpcode()) { fprintf(F, " %s\n", CXXCastExpr::getOpcodeStr(Node->getOpcode()));
default: DumpSubTree(Node->getSubExpr());
assert(0 && "Not a C++ cast expression"); fprintf(F, ")");
abort();
case CXXCastExpr::ConstCast: OS << "const_cast<"; break;
case CXXCastExpr::DynamicCast: OS << "dynamic_cast<"; break;
case CXXCastExpr::ReinterpretCast: OS << "reinterpret_cast<"; break;
case CXXCastExpr::StaticCast: OS << "static_cast<"; break;
}
OS << Node->getDestType().getAsString() << ">(";
DumpExpr(Node->getSubExpr());
OS << ")";
#endif
} }
void StmtDumper::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *Node) { void StmtDumper::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *Node) {
#if 0 DumpExpr(Node);
OS << (Node->getValue() ? "true" : "false"); fprintf(F, " %s)", Node->getValue() ? "true" : "false");
#endif
} }