2007-08-09 06:51:59 +08:00
|
|
|
//===--- StmtDumper.cpp - Dumping implementation for Stmt ASTs ------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-30 03:59:25 +08:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2007-08-09 06:51:59 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// 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"
|
2007-10-18 02:36:42 +08:00
|
|
|
#include "clang/AST/DeclObjC.h"
|
2009-02-04 03:21:40 +08:00
|
|
|
#include "clang/AST/DeclCXX.h"
|
2009-05-30 04:38:28 +08:00
|
|
|
#include "clang/AST/PrettyPrinter.h"
|
2007-08-30 14:17:34 +08:00
|
|
|
#include "clang/Basic/SourceManager.h"
|
2009-12-03 17:13:13 +08:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2007-08-09 06:51:59 +08:00
|
|
|
using namespace clang;
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// StmtDumper Visitor
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
namespace {
|
2009-11-29 03:03:38 +08:00
|
|
|
class StmtDumper : public StmtVisitor<StmtDumper> {
|
2007-08-30 14:17:34 +08:00
|
|
|
SourceManager *SM;
|
2009-12-03 17:13:13 +08:00
|
|
|
llvm::raw_ostream &OS;
|
2007-08-09 06:51:59 +08:00
|
|
|
unsigned IndentLevel;
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2007-08-09 06:51:59 +08:00
|
|
|
/// 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;
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2007-08-30 14:17:34 +08:00
|
|
|
/// LastLocFilename/LastLocLine - Keep track of the last location we print
|
|
|
|
/// out so that we can print out deltas from then on out.
|
|
|
|
const char *LastLocFilename;
|
|
|
|
unsigned LastLocLine;
|
2009-05-30 04:38:28 +08:00
|
|
|
|
2007-08-09 06:51:59 +08:00
|
|
|
public:
|
2009-12-03 17:13:13 +08:00
|
|
|
StmtDumper(SourceManager *sm, llvm::raw_ostream &os, unsigned maxDepth)
|
|
|
|
: SM(sm), OS(os), IndentLevel(0-1), MaxDepth(maxDepth) {
|
2007-08-30 14:17:34 +08:00
|
|
|
LastLocFilename = "";
|
|
|
|
LastLocLine = ~0U;
|
|
|
|
}
|
2009-09-09 23:08:12 +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;
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2007-08-10 02:03:18 +08:00
|
|
|
++IndentLevel;
|
2007-08-09 06:51:59 +08:00
|
|
|
if (S) {
|
2007-12-12 14:59:42 +08:00
|
|
|
if (DeclStmt* DS = dyn_cast<DeclStmt>(S))
|
|
|
|
VisitDeclStmt(DS);
|
2009-09-09 23:08:12 +08:00
|
|
|
else {
|
2007-12-12 14:59:42 +08:00
|
|
|
Visit(S);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2007-12-12 14:59:42 +08:00
|
|
|
// Print out children.
|
|
|
|
Stmt::child_iterator CI = S->child_begin(), CE = S->child_end();
|
|
|
|
if (CI != CE) {
|
|
|
|
while (CI != CE) {
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << '\n';
|
2007-12-12 14:59:42 +08:00
|
|
|
DumpSubTree(*CI++);
|
|
|
|
}
|
2010-09-01 02:02:20 +08:00
|
|
|
if (const ConditionalOperator *CO =
|
|
|
|
dyn_cast<ConditionalOperator>(S)) {
|
|
|
|
if (CO->getSAVE()) {
|
|
|
|
OS << '\n';
|
|
|
|
DumpSubTree(CO->getSAVE());
|
|
|
|
}
|
|
|
|
}
|
2007-08-30 08:53:54 +08:00
|
|
|
}
|
|
|
|
}
|
2010-05-26 01:56:43 +08:00
|
|
|
OS << ')';
|
2007-08-09 06:51:59 +08:00
|
|
|
} else {
|
|
|
|
Indent();
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << "<<<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
|
|
|
}
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2007-08-10 02:03:18 +08:00
|
|
|
void DumpDeclarator(Decl *D);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2007-08-09 06:51:59 +08:00
|
|
|
void Indent() const {
|
|
|
|
for (int i = 0, e = IndentLevel; i < e; ++i)
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << " ";
|
2007-08-09 06:51:59 +08:00
|
|
|
}
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2007-09-02 05:08:38 +08:00
|
|
|
void DumpType(QualType T) {
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << "'" << T.getAsString() << "'";
|
2007-08-09 08:36:22 +08:00
|
|
|
|
2008-12-24 08:01:03 +08:00
|
|
|
if (!T.isNull()) {
|
2009-09-25 03:53:00 +08:00
|
|
|
// If the type is sugared, also dump a (shallow) desugared type.
|
|
|
|
QualType Simplified = T.getDesugaredType();
|
|
|
|
if (Simplified != T)
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << ":'" << Simplified.getAsString() << "'";
|
2008-04-02 13:06:23 +08:00
|
|
|
}
|
2007-08-09 08:36:22 +08:00
|
|
|
}
|
2007-09-02 05:08:38 +08:00
|
|
|
void DumpStmt(const Stmt *Node) {
|
2007-08-09 06:51:59 +08:00
|
|
|
Indent();
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << "(" << Node->getStmtClassName()
|
|
|
|
<< " " << (void*)Node;
|
2007-09-02 05:08:38 +08:00
|
|
|
DumpSourceRange(Node);
|
2007-08-09 06:51:59 +08:00
|
|
|
}
|
2007-09-02 05:08:38 +08:00
|
|
|
void DumpExpr(const Expr *Node) {
|
2007-08-09 06:51:59 +08:00
|
|
|
DumpStmt(Node);
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << ' ';
|
2007-08-09 08:36:22 +08:00
|
|
|
DumpType(Node->getType());
|
2007-08-09 06:51:59 +08:00
|
|
|
}
|
2007-09-02 05:08:38 +08:00
|
|
|
void DumpSourceRange(const Stmt *Node);
|
2007-08-30 14:17:34 +08:00
|
|
|
void DumpLocation(SourceLocation Loc);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2007-08-30 09:00:35 +08:00
|
|
|
// Stmts.
|
2007-08-21 12:04:25 +08:00
|
|
|
void VisitStmt(Stmt *Node);
|
2007-12-12 14:59:42 +08:00
|
|
|
void VisitDeclStmt(DeclStmt *Node);
|
2007-08-30 09:00:35 +08:00
|
|
|
void VisitLabelStmt(LabelStmt *Node);
|
|
|
|
void VisitGotoStmt(GotoStmt *Node);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2007-08-30 09:00:35 +08:00
|
|
|
// Exprs
|
|
|
|
void VisitExpr(Expr *Node);
|
2009-08-23 07:33:40 +08:00
|
|
|
void VisitCastExpr(CastExpr *Node);
|
2009-11-15 06:35:18 +08:00
|
|
|
void VisitImplicitCastExpr(ImplicitCastExpr *Node);
|
2007-08-30 09:00:35 +08:00
|
|
|
void VisitDeclRefExpr(DeclRefExpr *Node);
|
2008-08-10 09:53:14 +08:00
|
|
|
void VisitPredefinedExpr(PredefinedExpr *Node);
|
2007-08-30 09:00:35 +08:00
|
|
|
void VisitCharacterLiteral(CharacterLiteral *Node);
|
|
|
|
void VisitIntegerLiteral(IntegerLiteral *Node);
|
|
|
|
void VisitFloatingLiteral(FloatingLiteral *Node);
|
|
|
|
void VisitStringLiteral(StringLiteral *Str);
|
|
|
|
void VisitUnaryOperator(UnaryOperator *Node);
|
2008-11-12 01:56:53 +08:00
|
|
|
void VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *Node);
|
2007-08-30 09:00:35 +08:00
|
|
|
void VisitMemberExpr(MemberExpr *Node);
|
2008-04-19 07:10:10 +08:00
|
|
|
void VisitExtVectorElementExpr(ExtVectorElementExpr *Node);
|
2007-08-30 09:00:35 +08:00
|
|
|
void VisitBinaryOperator(BinaryOperator *Node);
|
|
|
|
void VisitCompoundAssignOperator(CompoundAssignOperator *Node);
|
|
|
|
void VisitAddrLabelExpr(AddrLabelExpr *Node);
|
|
|
|
void VisitTypesCompatibleExpr(TypesCompatibleExpr *Node);
|
|
|
|
|
|
|
|
// C++
|
2008-10-28 03:41:14 +08:00
|
|
|
void VisitCXXNamedCastExpr(CXXNamedCastExpr *Node);
|
2007-08-30 09:00:35 +08:00
|
|
|
void VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *Node);
|
2008-11-04 22:56:14 +08:00
|
|
|
void VisitCXXThisExpr(CXXThisExpr *Node);
|
2008-10-28 03:41:14 +08:00
|
|
|
void VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *Node);
|
2009-08-12 08:21:52 +08:00
|
|
|
void VisitCXXConstructExpr(CXXConstructExpr *Node);
|
|
|
|
void VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *Node);
|
|
|
|
void VisitCXXExprWithTemporaries(CXXExprWithTemporaries *Node);
|
2009-12-12 05:50:11 +08:00
|
|
|
void VisitUnresolvedLookupExpr(UnresolvedLookupExpr *Node);
|
2009-08-12 08:21:52 +08:00
|
|
|
void DumpCXXTemporary(CXXTemporary *Temporary);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2007-08-30 09:00:35 +08:00
|
|
|
// ObjC
|
2010-04-24 06:50:49 +08:00
|
|
|
void VisitObjCAtCatchStmt(ObjCAtCatchStmt *Node);
|
2007-08-30 09:00:35 +08:00
|
|
|
void VisitObjCEncodeExpr(ObjCEncodeExpr *Node);
|
2008-03-01 06:04:05 +08:00
|
|
|
void VisitObjCMessageExpr(ObjCMessageExpr* Node);
|
2007-10-17 04:40:23 +08:00
|
|
|
void VisitObjCSelectorExpr(ObjCSelectorExpr *Node);
|
2007-10-18 00:58:11 +08:00
|
|
|
void VisitObjCProtocolExpr(ObjCProtocolExpr *Node);
|
2008-08-30 13:35:15 +08:00
|
|
|
void VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *Node);
|
2009-08-21 01:02:02 +08:00
|
|
|
void VisitObjCImplicitSetterGetterRefExpr(
|
|
|
|
ObjCImplicitSetterGetterRefExpr *Node);
|
2008-03-12 21:19:12 +08:00
|
|
|
void VisitObjCIvarRefExpr(ObjCIvarRefExpr *Node);
|
2007-08-09 06:51:59 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2007-08-30 14:17:34 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Utilities
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
void StmtDumper::DumpLocation(SourceLocation Loc) {
|
2009-01-16 15:00:02 +08:00
|
|
|
SourceLocation SpellingLoc = SM->getSpellingLoc(Loc);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-01-27 15:57:44 +08:00
|
|
|
if (SpellingLoc.isInvalid()) {
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << "<invalid sloc>";
|
2009-01-27 15:57:44 +08:00
|
|
|
return;
|
|
|
|
}
|
2007-08-30 14:17:34 +08:00
|
|
|
|
|
|
|
// The general format we print out is filename:line:col, but we drop pieces
|
|
|
|
// that haven't changed since the last loc printed.
|
2009-01-27 15:57:44 +08:00
|
|
|
PresumedLoc PLoc = SM->getPresumedLoc(SpellingLoc);
|
|
|
|
|
|
|
|
if (strcmp(PLoc.getFilename(), LastLocFilename) != 0) {
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << PLoc.getFilename() << ':' << PLoc.getLine()
|
|
|
|
<< ':' << PLoc.getColumn();
|
2009-01-27 15:57:44 +08:00
|
|
|
LastLocFilename = PLoc.getFilename();
|
|
|
|
LastLocLine = PLoc.getLine();
|
|
|
|
} else if (PLoc.getLine() != LastLocLine) {
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << "line" << ':' << PLoc.getLine()
|
|
|
|
<< ':' << PLoc.getColumn();
|
2009-01-27 15:57:44 +08:00
|
|
|
LastLocLine = PLoc.getLine();
|
2007-08-30 14:17:34 +08:00
|
|
|
} else {
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << "col" << ':' << PLoc.getColumn();
|
2007-08-30 14:17:34 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-02 05:08:38 +08:00
|
|
|
void StmtDumper::DumpSourceRange(const Stmt *Node) {
|
2007-08-30 14:17:34 +08:00
|
|
|
// Can't translate locations if a SourceManager isn't available.
|
|
|
|
if (SM == 0) return;
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2007-08-30 14:17:34 +08:00
|
|
|
// TODO: If the parent expression is available, we can print a delta vs its
|
|
|
|
// location.
|
|
|
|
SourceRange R = Node->getSourceRange();
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << " <";
|
2007-10-17 06:36:42 +08:00
|
|
|
DumpLocation(R.getBegin());
|
|
|
|
if (R.getBegin() != R.getEnd()) {
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << ", ";
|
2007-10-17 06:36:42 +08:00
|
|
|
DumpLocation(R.getEnd());
|
2007-08-30 14:17:34 +08:00
|
|
|
}
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << ">";
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2007-08-30 14:17:34 +08:00
|
|
|
// <t2.c:123:421[blah], t2.c:412:321>
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-09 06:51:59 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Stmt printing methods.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
void StmtDumper::VisitStmt(Stmt *Node) {
|
2007-08-30 09:00:35 +08:00
|
|
|
DumpStmt(Node);
|
2007-08-09 06:51:59 +08:00
|
|
|
}
|
|
|
|
|
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)) {
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << "\"typedef " << localType->getUnderlyingType().getAsString()
|
2010-04-17 17:33:03 +08:00
|
|
|
<< ' ' << localType << '"';
|
2007-08-09 06:51:59 +08:00
|
|
|
} else if (ValueDecl *VD = dyn_cast<ValueDecl>(D)) {
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << "\"";
|
2007-08-09 06:51:59 +08:00
|
|
|
// Emit storage class for vardecls.
|
|
|
|
if (VarDecl *V = dyn_cast<VarDecl>(VD)) {
|
2010-08-26 11:08:43 +08:00
|
|
|
if (V->getStorageClass() != SC_None)
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << VarDecl::getStorageClassSpecifierString(V->getStorageClass())
|
|
|
|
<< " ";
|
2007-08-09 06:51:59 +08:00
|
|
|
}
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2008-11-24 12:00:27 +08:00
|
|
|
std::string Name = VD->getNameAsString();
|
2009-09-09 23:08:12 +08:00
|
|
|
VD->getType().getAsStringInternal(Name,
|
2009-06-30 09:26:17 +08:00
|
|
|
PrintingPolicy(VD->getASTContext().getLangOptions()));
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << Name;
|
2009-09-09 23:08:12 +08:00
|
|
|
|
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()) {
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << " =\n";
|
2007-08-10 02:03:18 +08:00
|
|
|
DumpSubTree(V->getInit());
|
2007-08-09 06:51:59 +08:00
|
|
|
}
|
|
|
|
}
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << '"';
|
2007-11-18 05:37:36 +08:00
|
|
|
} else if (TagDecl *TD = dyn_cast<TagDecl>(D)) {
|
|
|
|
// print a free standing tag decl (e.g. "struct x;").
|
|
|
|
const char *tagname;
|
|
|
|
if (const IdentifierInfo *II = TD->getIdentifier())
|
2009-10-19 04:26:12 +08:00
|
|
|
tagname = II->getNameStart();
|
2007-11-18 05:37:36 +08:00
|
|
|
else
|
|
|
|
tagname = "<anonymous>";
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << '"' << TD->getKindName() << ' ' << tagname << ";\"";
|
2007-11-18 05:37:36 +08:00
|
|
|
// FIXME: print tag bodies.
|
2009-02-04 03:21:40 +08:00
|
|
|
} else if (UsingDirectiveDecl *UD = dyn_cast<UsingDirectiveDecl>(D)) {
|
|
|
|
// print using-directive decl (e.g. "using namespace x;")
|
|
|
|
const char *ns;
|
|
|
|
if (const IdentifierInfo *II = UD->getNominatedNamespace()->getIdentifier())
|
2009-10-19 04:26:12 +08:00
|
|
|
ns = II->getNameStart();
|
2009-02-04 03:21:40 +08:00
|
|
|
else
|
|
|
|
ns = "<anonymous>";
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << '"' << UD->getDeclKindName() << ns << ";\"";
|
2010-05-04 18:20:17 +08:00
|
|
|
} else if (UsingDecl *UD = dyn_cast<UsingDecl>(D)) {
|
|
|
|
// print using decl (e.g. "using std::string;")
|
|
|
|
const char *tn = UD->isTypeName() ? "typename " : "";
|
|
|
|
OS << '"' << UD->getDeclKindName() << tn;
|
|
|
|
UD->getTargetNestedNameDecl()->print(OS,
|
|
|
|
PrintingPolicy(UD->getASTContext().getLangOptions()));
|
|
|
|
OS << ";\"";
|
2007-08-09 06:51:59 +08:00
|
|
|
} else {
|
|
|
|
assert(0 && "Unexpected decl");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-12-12 14:59:42 +08:00
|
|
|
void StmtDumper::VisitDeclStmt(DeclStmt *Node) {
|
|
|
|
DumpStmt(Node);
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << "\n";
|
2008-10-07 02:38:35 +08:00
|
|
|
for (DeclStmt::decl_iterator DI = Node->decl_begin(), DE = Node->decl_end();
|
|
|
|
DI != DE; ++DI) {
|
2009-01-20 09:17:11 +08:00
|
|
|
Decl* D = *DI;
|
2007-12-12 14:59:42 +08:00
|
|
|
++IndentLevel;
|
|
|
|
Indent();
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << (void*) D << " ";
|
2007-12-12 14:59:42 +08:00
|
|
|
DumpDeclarator(D);
|
2009-03-30 00:04:50 +08:00
|
|
|
if (DI+1 != DE)
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << "\n";
|
2007-12-12 14:59:42 +08:00
|
|
|
--IndentLevel;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-08-09 06:51:59 +08:00
|
|
|
void StmtDumper::VisitLabelStmt(LabelStmt *Node) {
|
|
|
|
DumpStmt(Node);
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << " '" << Node->getName() << "'";
|
2007-08-09 06:51:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void StmtDumper::VisitGotoStmt(GotoStmt *Node) {
|
|
|
|
DumpStmt(Node);
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << " '" << Node->getLabel()->getName()
|
|
|
|
<< "':" << (void*)Node->getLabel();
|
2007-08-09 06:51:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Expr printing methods.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
void StmtDumper::VisitExpr(Expr *Node) {
|
|
|
|
DumpExpr(Node);
|
|
|
|
}
|
|
|
|
|
2010-04-25 03:06:50 +08:00
|
|
|
static void DumpBasePath(llvm::raw_ostream &OS, CastExpr *Node) {
|
2010-08-07 14:22:56 +08:00
|
|
|
if (Node->path_empty())
|
2010-04-25 03:06:50 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
OS << " (";
|
|
|
|
bool First = true;
|
2010-08-07 14:22:56 +08:00
|
|
|
for (CastExpr::path_iterator
|
|
|
|
I = Node->path_begin(), E = Node->path_end(); I != E; ++I) {
|
2010-04-25 03:06:50 +08:00
|
|
|
const CXXBaseSpecifier *Base = *I;
|
|
|
|
if (!First)
|
|
|
|
OS << " -> ";
|
|
|
|
|
|
|
|
const CXXRecordDecl *RD =
|
|
|
|
cast<CXXRecordDecl>(Base->getType()->getAs<RecordType>()->getDecl());
|
|
|
|
|
|
|
|
if (Base->isVirtual())
|
|
|
|
OS << "virtual ";
|
|
|
|
OS << RD->getName();
|
|
|
|
First = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
OS << ')';
|
|
|
|
}
|
|
|
|
|
2009-08-23 07:33:40 +08:00
|
|
|
void StmtDumper::VisitCastExpr(CastExpr *Node) {
|
|
|
|
DumpExpr(Node);
|
2010-04-25 03:06:50 +08:00
|
|
|
OS << " <" << Node->getCastKindName();
|
|
|
|
DumpBasePath(OS, Node);
|
|
|
|
OS << ">";
|
2009-08-23 07:33:40 +08:00
|
|
|
}
|
|
|
|
|
2009-11-15 06:35:18 +08:00
|
|
|
void StmtDumper::VisitImplicitCastExpr(ImplicitCastExpr *Node) {
|
|
|
|
VisitCastExpr(Node);
|
2010-08-25 18:28:54 +08:00
|
|
|
switch (Node->getValueKind()) {
|
|
|
|
case VK_LValue:
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << " lvalue";
|
2010-07-20 12:20:21 +08:00
|
|
|
break;
|
2010-08-25 18:28:54 +08:00
|
|
|
case VK_XValue:
|
2010-07-20 12:20:21 +08:00
|
|
|
OS << " xvalue";
|
|
|
|
break;
|
2010-08-25 18:28:54 +08:00
|
|
|
case VK_RValue:
|
2010-07-20 12:20:21 +08:00
|
|
|
break;
|
|
|
|
}
|
2009-11-15 06:35:18 +08:00
|
|
|
}
|
|
|
|
|
2007-08-09 06:51:59 +08:00
|
|
|
void StmtDumper::VisitDeclRefExpr(DeclRefExpr *Node) {
|
|
|
|
DumpExpr(Node);
|
2007-09-11 01:32:55 +08:00
|
|
|
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << " ";
|
2007-09-11 01:32:55 +08:00
|
|
|
switch (Node->getDecl()->getKind()) {
|
2009-12-03 17:13:13 +08:00
|
|
|
default: OS << "Decl"; break;
|
|
|
|
case Decl::Function: OS << "FunctionDecl"; break;
|
|
|
|
case Decl::Var: OS << "Var"; break;
|
|
|
|
case Decl::ParmVar: OS << "ParmVar"; break;
|
|
|
|
case Decl::EnumConstant: OS << "EnumConstant"; break;
|
|
|
|
case Decl::Typedef: OS << "Typedef"; break;
|
|
|
|
case Decl::Record: OS << "Record"; break;
|
|
|
|
case Decl::Enum: OS << "Enum"; break;
|
|
|
|
case Decl::CXXRecord: OS << "CXXRecord"; break;
|
|
|
|
case Decl::ObjCInterface: OS << "ObjCInterface"; break;
|
|
|
|
case Decl::ObjCClass: OS << "ObjCClass"; break;
|
2007-09-11 01:32:55 +08:00
|
|
|
}
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2010-04-17 17:33:03 +08:00
|
|
|
OS << "='" << Node->getDecl() << "' " << (void*)Node->getDecl();
|
2007-08-09 06:51:59 +08:00
|
|
|
}
|
|
|
|
|
2009-12-12 05:50:11 +08:00
|
|
|
void StmtDumper::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *Node) {
|
|
|
|
DumpExpr(Node);
|
|
|
|
OS << " (";
|
|
|
|
if (!Node->requiresADL()) OS << "no ";
|
2010-04-17 17:33:03 +08:00
|
|
|
OS << "ADL) = '" << Node->getName() << '\'';
|
2009-12-12 05:50:11 +08:00
|
|
|
|
|
|
|
UnresolvedLookupExpr::decls_iterator
|
|
|
|
I = Node->decls_begin(), E = Node->decls_end();
|
|
|
|
if (I == E) OS << " empty";
|
|
|
|
for (; I != E; ++I)
|
|
|
|
OS << " " << (void*) *I;
|
|
|
|
}
|
|
|
|
|
2008-03-12 21:19:12 +08:00
|
|
|
void StmtDumper::VisitObjCIvarRefExpr(ObjCIvarRefExpr *Node) {
|
2008-05-23 08:59:14 +08:00
|
|
|
DumpExpr(Node);
|
2008-03-12 21:19:12 +08:00
|
|
|
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << " " << Node->getDecl()->getDeclKindName()
|
2010-04-17 17:33:03 +08:00
|
|
|
<< "Decl='" << Node->getDecl()
|
2009-12-03 17:13:13 +08:00
|
|
|
<< "' " << (void*)Node->getDecl();
|
2008-05-24 06:01:24 +08:00
|
|
|
if (Node->isFreeIvar())
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << " isFreeIvar";
|
2008-03-12 21:19:12 +08:00
|
|
|
}
|
|
|
|
|
2008-08-10 09:53:14 +08:00
|
|
|
void StmtDumper::VisitPredefinedExpr(PredefinedExpr *Node) {
|
2007-08-09 06:51:59 +08:00
|
|
|
DumpExpr(Node);
|
|
|
|
switch (Node->getIdentType()) {
|
2008-06-22 02:04:54 +08:00
|
|
|
default: assert(0 && "unknown case");
|
2009-12-03 17:13:13 +08:00
|
|
|
case PredefinedExpr::Func: OS << " __func__"; break;
|
|
|
|
case PredefinedExpr::Function: OS << " __FUNCTION__"; break;
|
|
|
|
case PredefinedExpr::PrettyFunction: OS << " __PRETTY_FUNCTION__";break;
|
2007-08-09 06:51:59 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtDumper::VisitCharacterLiteral(CharacterLiteral *Node) {
|
2007-08-09 09:04:32 +08:00
|
|
|
DumpExpr(Node);
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << Node->getValue();
|
2007-08-09 06:51:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void StmtDumper::VisitIntegerLiteral(IntegerLiteral *Node) {
|
|
|
|
DumpExpr(Node);
|
|
|
|
|
|
|
|
bool isSigned = Node->getType()->isSignedIntegerType();
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << " " << Node->getValue().toString(10, isSigned);
|
2007-08-09 06:51:59 +08:00
|
|
|
}
|
|
|
|
void StmtDumper::VisitFloatingLiteral(FloatingLiteral *Node) {
|
|
|
|
DumpExpr(Node);
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << " " << Node->getValueAsApproximateDouble();
|
2007-08-09 06:51:59 +08:00
|
|
|
}
|
2007-08-26 11:42:43 +08:00
|
|
|
|
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.
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << " ";
|
|
|
|
if (Str->isWide())
|
|
|
|
OS << "L";
|
|
|
|
OS << '"';
|
2010-08-17 20:54:38 +08:00
|
|
|
OS.write_escaped(Str->getString());
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << '"';
|
2007-08-09 06:51:59 +08:00
|
|
|
}
|
2007-08-30 09:00:35 +08:00
|
|
|
|
2007-08-09 06:51:59 +08:00
|
|
|
void StmtDumper::VisitUnaryOperator(UnaryOperator *Node) {
|
2007-08-10 01:35:30 +08:00
|
|
|
DumpExpr(Node);
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << " " << (Node->isPostfix() ? "postfix" : "prefix")
|
|
|
|
<< " '" << UnaryOperator::getOpcodeStr(Node->getOpcode()) << "'";
|
2007-08-09 06:51:59 +08:00
|
|
|
}
|
2008-11-12 01:56:53 +08:00
|
|
|
void StmtDumper::VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *Node) {
|
2007-08-10 01:35:30 +08:00
|
|
|
DumpExpr(Node);
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << " " << (Node->isSizeOf() ? "sizeof" : "alignof") << " ";
|
2008-11-12 01:56:53 +08:00
|
|
|
if (Node->isArgumentType())
|
|
|
|
DumpType(Node->getArgumentType());
|
2007-08-09 06:51:59 +08:00
|
|
|
}
|
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);
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << " " << (Node->isArrow() ? "->" : ".")
|
2010-04-17 17:33:03 +08:00
|
|
|
<< Node->getMemberDecl() << ' '
|
2009-12-03 17:13:13 +08:00
|
|
|
<< (void*)Node->getMemberDecl();
|
2007-08-09 06:51:59 +08:00
|
|
|
}
|
2008-04-19 07:10:10 +08:00
|
|
|
void StmtDumper::VisitExtVectorElementExpr(ExtVectorElementExpr *Node) {
|
2007-08-10 01:35:30 +08:00
|
|
|
DumpExpr(Node);
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << " " << Node->getAccessor().getNameStart();
|
2007-08-09 06:51:59 +08:00
|
|
|
}
|
|
|
|
void StmtDumper::VisitBinaryOperator(BinaryOperator *Node) {
|
|
|
|
DumpExpr(Node);
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << " '" << BinaryOperator::getOpcodeStr(Node->getOpcode()) << "'";
|
2007-08-25 10:00:02 +08:00
|
|
|
}
|
|
|
|
void StmtDumper::VisitCompoundAssignOperator(CompoundAssignOperator *Node) {
|
|
|
|
DumpExpr(Node);
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << " '" << BinaryOperator::getOpcodeStr(Node->getOpcode())
|
|
|
|
<< "' ComputeLHSTy=";
|
2009-03-28 09:22:36 +08:00
|
|
|
DumpType(Node->getComputationLHSType());
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << " ComputeResultTy=";
|
2009-03-28 09:22:36 +08:00
|
|
|
DumpType(Node->getComputationResultType());
|
2007-08-09 06:51:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// GNU extensions.
|
|
|
|
|
|
|
|
void StmtDumper::VisitAddrLabelExpr(AddrLabelExpr *Node) {
|
2007-08-10 01:35:30 +08:00
|
|
|
DumpExpr(Node);
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << " " << Node->getLabel()->getName()
|
|
|
|
<< " " << (void*)Node->getLabel();
|
2007-08-09 06:51:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void StmtDumper::VisitTypesCompatibleExpr(TypesCompatibleExpr *Node) {
|
2007-08-10 01:35:30 +08:00
|
|
|
DumpExpr(Node);
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << " ";
|
2007-08-10 01:35:30 +08:00
|
|
|
DumpType(Node->getArgType1());
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << " ";
|
2007-08-10 01:35:30 +08:00
|
|
|
DumpType(Node->getArgType2());
|
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
|
|
|
|
2008-10-28 03:41:14 +08:00
|
|
|
void StmtDumper::VisitCXXNamedCastExpr(CXXNamedCastExpr *Node) {
|
2007-08-10 01:35:30 +08:00
|
|
|
DumpExpr(Node);
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << " " << Node->getCastName()
|
|
|
|
<< "<" << Node->getTypeAsWritten().getAsString() << ">"
|
2010-04-25 03:06:50 +08:00
|
|
|
<< " <" << Node->getCastKindName();
|
|
|
|
DumpBasePath(OS, Node);
|
|
|
|
OS << ">";
|
2007-08-09 06:51:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void StmtDumper::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *Node) {
|
2007-08-10 01:35:30 +08:00
|
|
|
DumpExpr(Node);
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << " " << (Node->getValue() ? "true" : "false");
|
2007-08-09 06:51:59 +08:00
|
|
|
}
|
|
|
|
|
2008-11-04 22:56:14 +08:00
|
|
|
void StmtDumper::VisitCXXThisExpr(CXXThisExpr *Node) {
|
|
|
|
DumpExpr(Node);
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << " this";
|
2008-11-04 22:56:14 +08:00
|
|
|
}
|
|
|
|
|
2008-10-28 03:41:14 +08:00
|
|
|
void StmtDumper::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *Node) {
|
|
|
|
DumpExpr(Node);
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << " functional cast to " << Node->getTypeAsWritten().getAsString();
|
2008-10-28 03:41:14 +08:00
|
|
|
}
|
|
|
|
|
2009-08-12 08:21:52 +08:00
|
|
|
void StmtDumper::VisitCXXConstructExpr(CXXConstructExpr *Node) {
|
|
|
|
DumpExpr(Node);
|
2010-02-03 03:03:45 +08:00
|
|
|
CXXConstructorDecl *Ctor = Node->getConstructor();
|
|
|
|
DumpType(Ctor->getType());
|
2009-08-12 08:21:52 +08:00
|
|
|
if (Node->isElidable())
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << " elidable";
|
2010-08-07 14:38:55 +08:00
|
|
|
if (Node->requiresZeroInitialization())
|
|
|
|
OS << " zeroing";
|
2009-08-12 08:21:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void StmtDumper::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *Node) {
|
|
|
|
DumpExpr(Node);
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << " ";
|
2009-08-12 08:21:52 +08:00
|
|
|
DumpCXXTemporary(Node->getTemporary());
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtDumper::VisitCXXExprWithTemporaries(CXXExprWithTemporaries *Node) {
|
|
|
|
DumpExpr(Node);
|
|
|
|
++IndentLevel;
|
|
|
|
for (unsigned i = 0, e = Node->getNumTemporaries(); i != e; ++i) {
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << "\n";
|
2009-08-12 08:21:52 +08:00
|
|
|
Indent();
|
|
|
|
DumpCXXTemporary(Node->getTemporary(i));
|
|
|
|
}
|
|
|
|
--IndentLevel;
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtDumper::DumpCXXTemporary(CXXTemporary *Temporary) {
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << "(CXXTemporary " << (void *)Temporary << ")";
|
2009-08-12 08:21:52 +08:00
|
|
|
}
|
|
|
|
|
2007-08-22 01:43:55 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Obj-C Expressions
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2008-03-01 06:04:05 +08:00
|
|
|
void StmtDumper::VisitObjCMessageExpr(ObjCMessageExpr* Node) {
|
|
|
|
DumpExpr(Node);
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << " selector=" << Node->getSelector().getAsString();
|
Overhaul the AST representation of Objective-C message send
expressions, to improve source-location information, clarify the
actual receiver of the message, and pave the way for proper C++
support. The ObjCMessageExpr node represents four different kinds of
message sends in a single AST node:
1) Send to a object instance described by an expression (e.g., [x method:5])
2) Send to a class described by the class name (e.g., [NSString method:5])
3) Send to a superclass class (e.g, [super method:5] in class method)
4) Send to a superclass instance (e.g., [super method:5] in instance method)
Previously these four cases where tangled together. Now, they have
more distinct representations. Specific changes:
1) Unchanged; the object instance is represented by an Expr*.
2) Previously stored the ObjCInterfaceDecl* referring to the class
receiving the message. Now stores a TypeSourceInfo* so that we know
how the class was spelled. This both maintains typedef information
and opens the door for more complicated C++ types (e.g., dependent
types). There was an alternative, unused representation of these
sends by naming the class via an IdentifierInfo *. In practice, we
either had an ObjCInterfaceDecl *, from which we would get the
IdentifierInfo *, or we fell into the case below...
3) Previously represented by a class message whose IdentifierInfo *
referred to "super". Sema and CodeGen would use isStr("super") to
determine if they had a send to super. Now represented as a
"class super" send, where we have both the location of the "super"
keyword and the ObjCInterfaceDecl* of the superclass we're
targetting (statically).
4) Previously represented by an instance message whose receiver is a
an ObjCSuperExpr, which Sema and CodeGen would check for via
isa<ObjCSuperExpr>(). Now represented as an "instance super" send,
where we have both the location of the "super" keyword and the
ObjCInterfaceDecl* of the superclass we're targetting
(statically). Note that ObjCSuperExpr only has one remaining use in
the AST, which is for "super.prop" references.
The new representation of ObjCMessageExpr is 2 pointers smaller than
the old one, since it combines more storage. It also eliminates a leak
when we loaded message-send expressions from a precompiled header. The
representation also feels much cleaner to me; comments welcome!
This patch attempts to maintain the same semantics we previously had
with Objective-C message sends. In several places, there are massive
changes that boil down to simply replacing a nested-if structure such
as:
if (message has a receiver expression) {
// instance message
if (isa<ObjCSuperExpr>(...)) {
// send to super
} else {
// send to an object
}
} else {
// class message
if (name->isStr("super")) {
// class send to super
} else {
// send to class
}
}
with a switch
switch (E->getReceiverKind()) {
case ObjCMessageExpr::SuperInstance: ...
case ObjCMessageExpr::Instance: ...
case ObjCMessageExpr::SuperClass: ...
case ObjCMessageExpr::Class:...
}
There are quite a few places (particularly in the checkers) where
send-to-super is effectively ignored. I've placed FIXMEs in most of
them, and attempted to address send-to-super in a reasonable way. This
could use some review.
llvm-svn: 101972
2010-04-21 08:45:42 +08:00
|
|
|
switch (Node->getReceiverKind()) {
|
|
|
|
case ObjCMessageExpr::Instance:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ObjCMessageExpr::Class:
|
|
|
|
OS << " class=";
|
|
|
|
DumpType(Node->getClassReceiver());
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ObjCMessageExpr::SuperInstance:
|
|
|
|
OS << " super (instance)";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ObjCMessageExpr::SuperClass:
|
|
|
|
OS << " super (class)";
|
|
|
|
break;
|
|
|
|
}
|
2008-03-01 06:04:05 +08:00
|
|
|
}
|
|
|
|
|
2010-04-24 06:50:49 +08:00
|
|
|
void StmtDumper::VisitObjCAtCatchStmt(ObjCAtCatchStmt *Node) {
|
|
|
|
DumpStmt(Node);
|
2010-04-27 00:46:50 +08:00
|
|
|
if (VarDecl *CatchParam = Node->getCatchParamDecl()) {
|
2010-04-24 06:50:49 +08:00
|
|
|
OS << " catch parm = ";
|
|
|
|
DumpDeclarator(CatchParam);
|
|
|
|
} else {
|
|
|
|
OS << " catch all";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-08-22 23:14:15 +08:00
|
|
|
void StmtDumper::VisitObjCEncodeExpr(ObjCEncodeExpr *Node) {
|
|
|
|
DumpExpr(Node);
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << " ";
|
2007-08-22 23:14:15 +08:00
|
|
|
DumpType(Node->getEncodedType());
|
|
|
|
}
|
|
|
|
|
2007-10-17 04:40:23 +08:00
|
|
|
void StmtDumper::VisitObjCSelectorExpr(ObjCSelectorExpr *Node) {
|
|
|
|
DumpExpr(Node);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << " " << Node->getSelector().getAsString();
|
2007-10-17 04:40:23 +08:00
|
|
|
}
|
|
|
|
|
2007-10-18 00:58:11 +08:00
|
|
|
void StmtDumper::VisitObjCProtocolExpr(ObjCProtocolExpr *Node) {
|
|
|
|
DumpExpr(Node);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2010-04-17 17:33:03 +08:00
|
|
|
OS << ' ' << Node->getProtocol();
|
2007-10-18 00:58:11 +08:00
|
|
|
}
|
2008-08-30 13:35:15 +08:00
|
|
|
|
|
|
|
void StmtDumper::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *Node) {
|
|
|
|
DumpExpr(Node);
|
2010-10-15 00:04:05 +08:00
|
|
|
if (Node->isSuperReceiver())
|
|
|
|
OS << " Kind=PropertyRef Property=\"" << Node->getProperty() << '"'
|
|
|
|
<< " super";
|
|
|
|
else
|
|
|
|
OS << " Kind=PropertyRef Property=\"" << Node->getProperty() << '"';
|
2008-11-23 02:39:36 +08:00
|
|
|
}
|
|
|
|
|
2009-08-21 01:02:02 +08:00
|
|
|
void StmtDumper::VisitObjCImplicitSetterGetterRefExpr(
|
|
|
|
ObjCImplicitSetterGetterRefExpr *Node) {
|
2008-11-23 02:39:36 +08:00
|
|
|
DumpExpr(Node);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2008-11-23 02:39:36 +08:00
|
|
|
ObjCMethodDecl *Getter = Node->getGetterMethod();
|
|
|
|
ObjCMethodDecl *Setter = Node->getSetterMethod();
|
2009-12-03 17:13:13 +08:00
|
|
|
OS << " Kind=MethodRef Getter=\""
|
|
|
|
<< Getter->getSelector().getAsString()
|
|
|
|
<< "\" Setter=\"";
|
|
|
|
if (Setter)
|
|
|
|
OS << Setter->getSelector().getAsString();
|
|
|
|
else
|
|
|
|
OS << "(null)";
|
|
|
|
OS << "\"";
|
2010-10-15 00:04:05 +08:00
|
|
|
if (Node->isSuperReceiver())
|
|
|
|
OS << " super";
|
2008-11-04 22:56:14 +08:00
|
|
|
}
|
|
|
|
|
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.
|
2007-08-30 14:17:34 +08:00
|
|
|
void Stmt::dump(SourceManager &SM) const {
|
2010-08-09 18:54:31 +08:00
|
|
|
dump(llvm::errs(), SM);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Stmt::dump(llvm::raw_ostream &OS, SourceManager &SM) const {
|
|
|
|
StmtDumper P(&SM, OS, 4);
|
2007-08-30 08:53:54 +08:00
|
|
|
P.DumpSubTree(const_cast<Stmt*>(this));
|
2010-08-09 18:54:31 +08:00
|
|
|
OS << "\n";
|
2007-08-30 08:40:08 +08:00
|
|
|
}
|
|
|
|
|
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 {
|
2010-08-09 18:54:31 +08:00
|
|
|
StmtDumper P(0, llvm::errs(), 4);
|
2007-08-30 08:53:54 +08:00
|
|
|
P.DumpSubTree(const_cast<Stmt*>(this));
|
2010-08-09 18:54:31 +08:00
|
|
|
llvm::errs() << "\n";
|
2007-08-30 08:40:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// dumpAll - This does a dump of the specified AST fragment and all subtrees.
|
2007-08-30 14:17:34 +08:00
|
|
|
void Stmt::dumpAll(SourceManager &SM) const {
|
2010-08-09 18:54:31 +08:00
|
|
|
StmtDumper P(&SM, llvm::errs(), ~0U);
|
2007-08-30 08:53:54 +08:00
|
|
|
P.DumpSubTree(const_cast<Stmt*>(this));
|
2010-08-09 18:54:31 +08:00
|
|
|
llvm::errs() << "\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 {
|
2010-08-09 18:54:31 +08:00
|
|
|
StmtDumper P(0, llvm::errs(), ~0U);
|
2007-08-30 08:53:54 +08:00
|
|
|
P.DumpSubTree(const_cast<Stmt*>(this));
|
2010-08-09 18:54:31 +08:00
|
|
|
llvm::errs() << "\n";
|
2007-08-09 06:51:59 +08:00
|
|
|
}
|