2007-08-09 06:51:59 +08:00
|
|
|
//===--- StmtDumper.cpp - Dumping implementation for Stmt ASTs ------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file was developed by Chris Lattner and is distributed under
|
|
|
|
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file implements the Stmt::dump/Stmt::print methods, which dump out the
|
|
|
|
// AST in a form that exposes type details and other fields.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "clang/AST/StmtVisitor.h"
|
|
|
|
#include "clang/AST/Decl.h"
|
|
|
|
#include "clang/AST/ExprCXX.h"
|
|
|
|
#include "clang/Lex/IdentifierTable.h"
|
|
|
|
#include "llvm/Support/Compiler.h"
|
|
|
|
#include <cstdio>
|
|
|
|
using namespace clang;
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// StmtDumper Visitor
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
namespace {
|
2007-08-21 12:04:25 +08:00
|
|
|
class VISIBILITY_HIDDEN StmtDumper : public StmtVisitor<StmtDumper> {
|
2007-08-30 08:40:08 +08:00
|
|
|
const SourceManager *SM;
|
2007-08-09 06:51:59 +08:00
|
|
|
FILE *F;
|
|
|
|
unsigned IndentLevel;
|
|
|
|
|
|
|
|
/// MaxDepth - When doing a normal dump (not dumpAll) we only want to dump
|
|
|
|
/// the first few levels of an AST. This keeps track of how many ast levels
|
|
|
|
/// are left.
|
|
|
|
unsigned MaxDepth;
|
|
|
|
public:
|
2007-08-30 08:40:08 +08:00
|
|
|
StmtDumper(const SourceManager *sm, FILE *f, unsigned maxDepth)
|
2007-08-30 08:53:54 +08:00
|
|
|
: SM(sm), F(f), IndentLevel(0-1), MaxDepth(maxDepth) {}
|
2007-08-09 06:51:59 +08:00
|
|
|
|
2007-08-10 02:03:18 +08:00
|
|
|
void DumpSubTree(Stmt *S) {
|
2007-08-09 06:51:59 +08:00
|
|
|
// Prune the recursion if not using dump all.
|
|
|
|
if (MaxDepth == 0) return;
|
|
|
|
|
2007-08-10 02:03:18 +08:00
|
|
|
++IndentLevel;
|
2007-08-09 06:51:59 +08:00
|
|
|
if (S) {
|
2007-08-21 12:04:25 +08:00
|
|
|
Visit(S);
|
2007-08-30 08:53:54 +08:00
|
|
|
|
|
|
|
// Print out children.
|
|
|
|
Stmt::child_iterator CI = S->child_begin(), CE = S->child_end();
|
|
|
|
if (CI != CE) {
|
|
|
|
while (CI != CE) {
|
|
|
|
fprintf(F, "\n");
|
|
|
|
DumpSubTree(*CI++);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fprintf(F, ")");
|
2007-08-09 06:51:59 +08:00
|
|
|
} else {
|
|
|
|
Indent();
|
2007-08-26 11:53:29 +08:00
|
|
|
fprintf(F, "<<<NULL>>>");
|
2007-08-09 06:51:59 +08:00
|
|
|
}
|
2007-08-10 02:03:18 +08:00
|
|
|
--IndentLevel;
|
2007-08-09 06:51:59 +08:00
|
|
|
}
|
|
|
|
|
2007-08-10 02:03:18 +08:00
|
|
|
void DumpDeclarator(Decl *D);
|
2007-08-09 06:51:59 +08:00
|
|
|
|
|
|
|
void Indent() const {
|
|
|
|
for (int i = 0, e = IndentLevel; i < e; ++i)
|
|
|
|
fprintf(F, " ");
|
|
|
|
}
|
|
|
|
|
2007-08-09 08:36:22 +08:00
|
|
|
void DumpType(QualType T) const {
|
|
|
|
fprintf(F, "'%s'", T.getAsString().c_str());
|
|
|
|
|
|
|
|
// If the type is directly a typedef, strip off typedefness to give at
|
|
|
|
// least one level of concreteness.
|
|
|
|
if (TypedefType *TDT = dyn_cast<TypedefType>(T))
|
|
|
|
fprintf(F, ":'%s'", TDT->LookThroughTypedefs().getAsString().c_str());
|
|
|
|
}
|
|
|
|
|
2007-08-09 06:51:59 +08:00
|
|
|
void DumpStmt(const Stmt *Node) const {
|
|
|
|
Indent();
|
|
|
|
fprintf(F, "(%s %p", Node->getStmtClassName(), (void*)Node);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DumpExpr(Expr *Node) const {
|
|
|
|
DumpStmt(Node);
|
2007-08-09 08:36:22 +08:00
|
|
|
fprintf(F, " ");
|
|
|
|
DumpType(Node->getType());
|
2007-08-09 06:51:59 +08:00
|
|
|
}
|
|
|
|
|
2007-08-21 12:04:25 +08:00
|
|
|
void VisitStmt(Stmt *Node);
|
2007-08-09 06:51:59 +08:00
|
|
|
#define STMT(N, CLASS, PARENT) \
|
2007-08-21 12:04:25 +08:00
|
|
|
void Visit##CLASS(CLASS *Node);
|
2007-08-09 06:51:59 +08:00
|
|
|
#include "clang/AST/StmtNodes.def"
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Stmt printing methods.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
void StmtDumper::VisitStmt(Stmt *Node) {
|
|
|
|
Indent();
|
|
|
|
fprintf(F, "<<unknown stmt type>>\n");
|
|
|
|
}
|
|
|
|
|
2007-08-10 02:03:18 +08:00
|
|
|
void StmtDumper::DumpDeclarator(Decl *D) {
|
2007-08-09 06:51:59 +08:00
|
|
|
// FIXME: Need to complete/beautify this... this code simply shows the
|
|
|
|
// nodes are where they need to be.
|
|
|
|
if (TypedefDecl *localType = dyn_cast<TypedefDecl>(D)) {
|
2007-08-10 02:03:18 +08:00
|
|
|
fprintf(F, "\"typedef %s %s\"",
|
|
|
|
localType->getUnderlyingType().getAsString().c_str(),
|
|
|
|
localType->getName());
|
2007-08-09 06:51:59 +08:00
|
|
|
} else if (ValueDecl *VD = dyn_cast<ValueDecl>(D)) {
|
2007-08-10 02:03:18 +08:00
|
|
|
fprintf(F, "\"");
|
2007-08-09 06:51:59 +08:00
|
|
|
// Emit storage class for vardecls.
|
|
|
|
if (VarDecl *V = dyn_cast<VarDecl>(VD)) {
|
|
|
|
switch (V->getStorageClass()) {
|
2007-08-10 02:03:18 +08:00
|
|
|
default: assert(0 && "Unknown storage class!");
|
|
|
|
case VarDecl::None: break;
|
|
|
|
case VarDecl::Extern: fprintf(F, "extern "); break;
|
|
|
|
case VarDecl::Static: fprintf(F, "static "); break;
|
|
|
|
case VarDecl::Auto: fprintf(F, "auto "); break;
|
|
|
|
case VarDecl::Register: fprintf(F, "register "); break;
|
2007-08-09 06:51:59 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string Name = VD->getName();
|
|
|
|
VD->getType().getAsStringInternal(Name);
|
2007-08-10 02:03:18 +08:00
|
|
|
fprintf(F, "%s", Name.c_str());
|
2007-08-09 06:51:59 +08:00
|
|
|
|
|
|
|
// If this is a vardecl with an initializer, emit it.
|
|
|
|
if (VarDecl *V = dyn_cast<VarDecl>(VD)) {
|
|
|
|
if (V->getInit()) {
|
2007-08-10 02:03:18 +08:00
|
|
|
fprintf(F, " =\n");
|
|
|
|
DumpSubTree(V->getInit());
|
2007-08-09 06:51:59 +08:00
|
|
|
}
|
|
|
|
}
|
2007-08-10 02:03:18 +08:00
|
|
|
fprintf(F, "\"");
|
2007-08-09 06:51:59 +08:00
|
|
|
} else {
|
|
|
|
// FIXME: "struct x;"
|
|
|
|
assert(0 && "Unexpected decl");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void StmtDumper::VisitNullStmt(NullStmt *Node) {
|
|
|
|
DumpStmt(Node);
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtDumper::VisitDeclStmt(DeclStmt *Node) {
|
|
|
|
DumpStmt(Node);
|
2007-08-10 02:03:18 +08:00
|
|
|
fprintf(F, "\n");
|
2007-08-09 06:51:59 +08:00
|
|
|
for (Decl *D = Node->getDecl(); D; D = D->getNextDeclarator()) {
|
2007-08-10 02:03:18 +08:00
|
|
|
++IndentLevel;
|
2007-08-09 06:51:59 +08:00
|
|
|
Indent();
|
2007-08-10 02:03:18 +08:00
|
|
|
fprintf(F, "%p ", (void*)D);
|
|
|
|
DumpDeclarator(D);
|
|
|
|
if (D->getNextDeclarator())
|
|
|
|
fprintf(F, "\n");
|
|
|
|
--IndentLevel;
|
2007-08-09 06:51:59 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtDumper::VisitCompoundStmt(CompoundStmt *Node) {
|
|
|
|
DumpStmt(Node);
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtDumper::VisitCaseStmt(CaseStmt *Node) {
|
2007-08-09 09:04:32 +08:00
|
|
|
DumpStmt(Node);
|
2007-08-09 06:51:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void StmtDumper::VisitDefaultStmt(DefaultStmt *Node) {
|
|
|
|
DumpStmt(Node);
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtDumper::VisitLabelStmt(LabelStmt *Node) {
|
|
|
|
DumpStmt(Node);
|
|
|
|
fprintf(F, " '%s'\n", Node->getName());
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtDumper::VisitIfStmt(IfStmt *Node) {
|
|
|
|
DumpStmt(Node);
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtDumper::VisitSwitchStmt(SwitchStmt *Node) {
|
|
|
|
DumpStmt(Node);
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtDumper::VisitSwitchCase(SwitchCase*) {
|
|
|
|
assert(0 && "SwitchCase is an abstract class");
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtDumper::VisitWhileStmt(WhileStmt *Node) {
|
|
|
|
DumpStmt(Node);
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtDumper::VisitDoStmt(DoStmt *Node) {
|
|
|
|
DumpStmt(Node);
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtDumper::VisitForStmt(ForStmt *Node) {
|
|
|
|
DumpStmt(Node);
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtDumper::VisitGotoStmt(GotoStmt *Node) {
|
|
|
|
DumpStmt(Node);
|
2007-08-30 08:53:54 +08:00
|
|
|
fprintf(F, " '%s':%p", Node->getLabel()->getName(), (void*)Node->getLabel());
|
2007-08-09 06:51:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void StmtDumper::VisitIndirectGotoStmt(IndirectGotoStmt *Node) {
|
|
|
|
DumpStmt(Node);
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtDumper::VisitContinueStmt(ContinueStmt *Node) {
|
|
|
|
DumpStmt(Node);
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtDumper::VisitBreakStmt(BreakStmt *Node) {
|
|
|
|
DumpStmt(Node);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void StmtDumper::VisitReturnStmt(ReturnStmt *Node) {
|
|
|
|
DumpStmt(Node);
|
|
|
|
}
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Expr printing methods.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
void StmtDumper::VisitExpr(Expr *Node) {
|
|
|
|
DumpExpr(Node);
|
|
|
|
fprintf(F, ": UNKNOWN EXPR to StmtDumper)");
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtDumper::VisitDeclRefExpr(DeclRefExpr *Node) {
|
|
|
|
DumpExpr(Node);
|
2007-08-30 08:53:54 +08:00
|
|
|
fprintf(F, " Decl='%s' %p", Node->getDecl()->getName(),
|
2007-08-09 06:51:59 +08:00
|
|
|
(void*)Node->getDecl());
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtDumper::VisitPreDefinedExpr(PreDefinedExpr *Node) {
|
|
|
|
DumpExpr(Node);
|
|
|
|
switch (Node->getIdentType()) {
|
|
|
|
default:
|
|
|
|
assert(0 && "unknown case");
|
|
|
|
case PreDefinedExpr::Func:
|
2007-08-30 08:53:54 +08:00
|
|
|
fprintf(F, " __func__");
|
2007-08-09 06:51:59 +08:00
|
|
|
break;
|
|
|
|
case PreDefinedExpr::Function:
|
2007-08-30 08:53:54 +08:00
|
|
|
fprintf(F, " __FUNCTION__");
|
2007-08-09 06:51:59 +08:00
|
|
|
break;
|
|
|
|
case PreDefinedExpr::PrettyFunction:
|
2007-08-30 08:53:54 +08:00
|
|
|
fprintf(F, " __PRETTY_FUNCTION__");
|
2007-08-09 06:51:59 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtDumper::VisitCharacterLiteral(CharacterLiteral *Node) {
|
2007-08-09 09:04:32 +08:00
|
|
|
DumpExpr(Node);
|
2007-08-30 08:53:54 +08:00
|
|
|
fprintf(F, " %d", Node->getValue());
|
2007-08-09 06:51:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void StmtDumper::VisitIntegerLiteral(IntegerLiteral *Node) {
|
|
|
|
DumpExpr(Node);
|
|
|
|
|
|
|
|
bool isSigned = Node->getType()->isSignedIntegerType();
|
2007-08-30 08:53:54 +08:00
|
|
|
fprintf(F, " %s", Node->getValue().toString(10, isSigned).c_str());
|
2007-08-09 06:51:59 +08:00
|
|
|
}
|
|
|
|
void StmtDumper::VisitFloatingLiteral(FloatingLiteral *Node) {
|
|
|
|
DumpExpr(Node);
|
2007-08-30 08:53:54 +08:00
|
|
|
fprintf(F, " %f", Node->getValue());
|
2007-08-09 06:51:59 +08:00
|
|
|
}
|
2007-08-26 11:42:43 +08:00
|
|
|
|
|
|
|
void StmtDumper::VisitImaginaryLiteral(ImaginaryLiteral *Node) {
|
|
|
|
DumpExpr(Node);
|
|
|
|
}
|
|
|
|
|
2007-08-09 06:51:59 +08:00
|
|
|
void StmtDumper::VisitStringLiteral(StringLiteral *Str) {
|
2007-08-09 09:04:32 +08:00
|
|
|
DumpExpr(Str);
|
|
|
|
// FIXME: this doesn't print wstrings right.
|
2007-08-10 01:14:24 +08:00
|
|
|
fprintf(F, " %s\"", Str->isWide() ? "L" : "");
|
2007-08-09 09:04:32 +08:00
|
|
|
|
2007-08-09 06:51:59 +08:00
|
|
|
for (unsigned i = 0, e = Str->getByteLength(); i != e; ++i) {
|
2007-08-10 01:14:24 +08:00
|
|
|
switch (char C = Str->getStrData()[i]) {
|
|
|
|
default:
|
|
|
|
if (isprint(C))
|
|
|
|
fputc(C, F);
|
|
|
|
else
|
|
|
|
fprintf(F, "\\%03o", C);
|
|
|
|
break;
|
2007-08-09 06:51:59 +08:00
|
|
|
// Handle some common ones to make dumps prettier.
|
2007-08-10 01:14:24 +08:00
|
|
|
case '\\': fprintf(F, "\\\\"); break;
|
|
|
|
case '"': fprintf(F, "\\\""); break;
|
|
|
|
case '\n': fprintf(F, "\\n"); break;
|
|
|
|
case '\t': fprintf(F, "\\t"); break;
|
|
|
|
case '\a': fprintf(F, "\\a"); break;
|
|
|
|
case '\b': fprintf(F, "\\b"); break;
|
2007-08-09 06:51:59 +08:00
|
|
|
}
|
|
|
|
}
|
2007-08-30 08:53:54 +08:00
|
|
|
fprintf(F, "\"");
|
2007-08-09 06:51:59 +08:00
|
|
|
}
|
|
|
|
void StmtDumper::VisitParenExpr(ParenExpr *Node) {
|
|
|
|
DumpExpr(Node);
|
|
|
|
}
|
|
|
|
void StmtDumper::VisitUnaryOperator(UnaryOperator *Node) {
|
2007-08-10 01:35:30 +08:00
|
|
|
DumpExpr(Node);
|
2007-08-30 08:53:54 +08:00
|
|
|
fprintf(F, " %s '%s'", Node->isPostfix() ? "postfix" : "prefix",
|
2007-08-10 01:35:30 +08:00
|
|
|
UnaryOperator::getOpcodeStr(Node->getOpcode()));
|
2007-08-09 06:51:59 +08:00
|
|
|
}
|
|
|
|
void StmtDumper::VisitSizeOfAlignOfTypeExpr(SizeOfAlignOfTypeExpr *Node) {
|
2007-08-10 01:35:30 +08:00
|
|
|
DumpExpr(Node);
|
|
|
|
fprintf(F, " %s ", Node->isSizeOf() ? "sizeof" : "alignof");
|
|
|
|
DumpType(Node->getArgumentType());
|
2007-08-09 06:51:59 +08:00
|
|
|
}
|
|
|
|
void StmtDumper::VisitArraySubscriptExpr(ArraySubscriptExpr *Node) {
|
|
|
|
DumpExpr(Node);
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtDumper::VisitCallExpr(CallExpr *Node) {
|
|
|
|
DumpExpr(Node);
|
|
|
|
}
|
2007-08-10 01:35:30 +08:00
|
|
|
|
2007-08-09 06:51:59 +08:00
|
|
|
void StmtDumper::VisitMemberExpr(MemberExpr *Node) {
|
2007-08-10 01:35:30 +08:00
|
|
|
DumpExpr(Node);
|
2007-08-30 08:53:54 +08:00
|
|
|
fprintf(F, " %s%s %p", Node->isArrow() ? "->" : ".",
|
2007-08-10 01:35:30 +08:00
|
|
|
Node->getMemberDecl()->getName(), (void*)Node->getMemberDecl());
|
2007-08-09 06:51:59 +08:00
|
|
|
}
|
|
|
|
void StmtDumper::VisitOCUVectorElementExpr(OCUVectorElementExpr *Node) {
|
2007-08-10 01:35:30 +08:00
|
|
|
DumpExpr(Node);
|
2007-08-30 08:53:54 +08:00
|
|
|
fprintf(F, " %s", Node->getAccessor().getName());
|
2007-08-09 06:51:59 +08:00
|
|
|
}
|
|
|
|
void StmtDumper::VisitCastExpr(CastExpr *Node) {
|
2007-08-10 01:35:30 +08:00
|
|
|
DumpExpr(Node);
|
2007-08-09 06:51:59 +08:00
|
|
|
}
|
|
|
|
void StmtDumper::VisitCompoundLiteralExpr(CompoundLiteralExpr *Node) {
|
2007-08-10 01:35:30 +08:00
|
|
|
DumpExpr(Node);
|
2007-08-09 06:51:59 +08:00
|
|
|
}
|
|
|
|
void StmtDumper::VisitImplicitCastExpr(ImplicitCastExpr *Node) {
|
|
|
|
DumpExpr(Node);
|
|
|
|
}
|
|
|
|
void StmtDumper::VisitBinaryOperator(BinaryOperator *Node) {
|
|
|
|
DumpExpr(Node);
|
2007-08-30 08:53:54 +08:00
|
|
|
fprintf(F, " '%s'", BinaryOperator::getOpcodeStr(Node->getOpcode()));
|
2007-08-25 10:00:02 +08:00
|
|
|
}
|
|
|
|
void StmtDumper::VisitCompoundAssignOperator(CompoundAssignOperator *Node) {
|
|
|
|
DumpExpr(Node);
|
|
|
|
fprintf(F, " '%s' ComputeTy=",
|
|
|
|
BinaryOperator::getOpcodeStr(Node->getOpcode()));
|
|
|
|
DumpType(Node->getComputationType());
|
2007-08-09 06:51:59 +08:00
|
|
|
}
|
|
|
|
void StmtDumper::VisitConditionalOperator(ConditionalOperator *Node) {
|
|
|
|
DumpExpr(Node);
|
|
|
|
}
|
|
|
|
|
|
|
|
// GNU extensions.
|
|
|
|
|
|
|
|
void StmtDumper::VisitAddrLabelExpr(AddrLabelExpr *Node) {
|
2007-08-10 01:35:30 +08:00
|
|
|
DumpExpr(Node);
|
2007-08-30 08:53:54 +08:00
|
|
|
fprintf(F, " %s %p", Node->getLabel()->getName(), (void*)Node->getLabel());
|
2007-08-09 06:51:59 +08:00
|
|
|
}
|
|
|
|
|
2007-08-10 01:35:30 +08:00
|
|
|
void StmtDumper::VisitStmtExpr(StmtExpr *Node) {
|
|
|
|
DumpExpr(Node);
|
2007-08-09 06:51:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void StmtDumper::VisitTypesCompatibleExpr(TypesCompatibleExpr *Node) {
|
2007-08-10 01:35:30 +08:00
|
|
|
DumpExpr(Node);
|
|
|
|
fprintf(F, " ");
|
|
|
|
DumpType(Node->getArgType1());
|
|
|
|
fprintf(F, " ");
|
|
|
|
DumpType(Node->getArgType2());
|
2007-08-09 06:51:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void StmtDumper::VisitChooseExpr(ChooseExpr *Node) {
|
2007-08-10 01:35:30 +08:00
|
|
|
DumpExpr(Node);
|
2007-08-09 06:51:59 +08:00
|
|
|
}
|
|
|
|
|
2007-08-10 02:03:18 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// C++ Expressions
|
|
|
|
//===----------------------------------------------------------------------===//
|
2007-08-09 06:51:59 +08:00
|
|
|
|
|
|
|
void StmtDumper::VisitCXXCastExpr(CXXCastExpr *Node) {
|
2007-08-10 01:35:30 +08:00
|
|
|
DumpExpr(Node);
|
2007-08-30 08:53:54 +08:00
|
|
|
fprintf(F, " %s", CXXCastExpr::getOpcodeStr(Node->getOpcode()));
|
2007-08-09 06:51:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void StmtDumper::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *Node) {
|
2007-08-10 01:35:30 +08:00
|
|
|
DumpExpr(Node);
|
2007-08-30 08:53:54 +08:00
|
|
|
fprintf(F, " %s", Node->getValue() ? "true" : "false");
|
2007-08-09 06:51:59 +08:00
|
|
|
}
|
|
|
|
|
2007-08-22 01:43:55 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Obj-C Expressions
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
void StmtDumper::VisitObjCStringLiteral(ObjCStringLiteral *Node) {
|
|
|
|
DumpExpr(Node);
|
|
|
|
}
|
2007-08-09 06:51:59 +08:00
|
|
|
|
2007-08-22 23:14:15 +08:00
|
|
|
void StmtDumper::VisitObjCEncodeExpr(ObjCEncodeExpr *Node) {
|
|
|
|
DumpExpr(Node);
|
|
|
|
|
|
|
|
fprintf(F, " ");
|
|
|
|
DumpType(Node->getEncodedType());
|
|
|
|
}
|
|
|
|
|
2007-08-09 06:51:59 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Stmt method implementations
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2007-08-30 08:40:08 +08:00
|
|
|
/// dump - This does a local dump of the specified AST fragment. It dumps the
|
|
|
|
/// specified node and a few nodes underneath it, but not the whole subtree.
|
|
|
|
/// This is useful in a debugger.
|
|
|
|
void Stmt::dump(const SourceManager &SM) const {
|
|
|
|
StmtDumper P(&SM, stderr, 4);
|
2007-08-30 08:53:54 +08:00
|
|
|
P.DumpSubTree(const_cast<Stmt*>(this));
|
2007-08-30 08:40:08 +08:00
|
|
|
fprintf(stderr, "\n");
|
|
|
|
}
|
|
|
|
|
2007-08-09 06:51:59 +08:00
|
|
|
/// dump - This does a local dump of the specified AST fragment. It dumps the
|
|
|
|
/// specified node and a few nodes underneath it, but not the whole subtree.
|
|
|
|
/// This is useful in a debugger.
|
|
|
|
void Stmt::dump() const {
|
2007-08-30 08:40:08 +08:00
|
|
|
StmtDumper P(0, stderr, 4);
|
2007-08-30 08:53:54 +08:00
|
|
|
P.DumpSubTree(const_cast<Stmt*>(this));
|
2007-08-30 08:40:08 +08:00
|
|
|
fprintf(stderr, "\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/// dumpAll - This does a dump of the specified AST fragment and all subtrees.
|
|
|
|
void Stmt::dumpAll(const SourceManager &SM) const {
|
|
|
|
StmtDumper P(&SM, stderr, ~0U);
|
2007-08-30 08:53:54 +08:00
|
|
|
P.DumpSubTree(const_cast<Stmt*>(this));
|
2007-08-11 05:51:12 +08:00
|
|
|
fprintf(stderr, "\n");
|
2007-08-09 06:51:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// dumpAll - This does a dump of the specified AST fragment and all subtrees.
|
|
|
|
void Stmt::dumpAll() const {
|
2007-08-30 08:40:08 +08:00
|
|
|
StmtDumper P(0, stderr, ~0U);
|
2007-08-30 08:53:54 +08:00
|
|
|
P.DumpSubTree(const_cast<Stmt*>(this));
|
2007-08-11 05:51:12 +08:00
|
|
|
fprintf(stderr, "\n");
|
2007-08-09 06:51:59 +08:00
|
|
|
}
|