blob: 5c236a45a690cfa8ca072b4c8f247000785858ac [file] [log] [blame]
Chris Lattner6000dac2007-08-08 22:51:59 +00001//===--- StmtDumper.cpp - Dumping implementation for Stmt ASTs ------------===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner0bc735f2007-12-29 19:59:25 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Chris Lattner6000dac2007-08-08 22:51:59 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file implements the Stmt::dump/Stmt::print methods, which dump out the
11// AST in a form that exposes type details and other fields.
12//
13//===----------------------------------------------------------------------===//
14
15#include "clang/AST/StmtVisitor.h"
Ted Kremenek91d1d7a2007-10-17 18:36:42 +000016#include "clang/AST/DeclObjC.h"
Douglas Gregor2a3009a2009-02-03 19:21:40 +000017#include "clang/AST/DeclCXX.h"
Douglas Gregord249e1d1f2009-05-29 20:38:28 +000018#include "clang/AST/PrettyPrinter.h"
Chris Lattnere300c872007-08-30 06:17:34 +000019#include "clang/Basic/SourceManager.h"
Daniel Dunbar806c12e2009-12-03 09:13:13 +000020#include "llvm/Support/raw_ostream.h"
Chris Lattner6000dac2007-08-08 22:51:59 +000021using namespace clang;
22
23//===----------------------------------------------------------------------===//
24// StmtDumper Visitor
25//===----------------------------------------------------------------------===//
26
27namespace {
Benjamin Kramer770b4a82009-11-28 19:03:38 +000028 class StmtDumper : public StmtVisitor<StmtDumper> {
Chris Lattnere300c872007-08-30 06:17:34 +000029 SourceManager *SM;
Daniel Dunbar806c12e2009-12-03 09:13:13 +000030 llvm::raw_ostream &OS;
Chris Lattner6000dac2007-08-08 22:51:59 +000031 unsigned IndentLevel;
Mike Stump1eb44332009-09-09 15:08:12 +000032
Chris Lattner6000dac2007-08-08 22:51:59 +000033 /// MaxDepth - When doing a normal dump (not dumpAll) we only want to dump
34 /// the first few levels of an AST. This keeps track of how many ast levels
35 /// are left.
36 unsigned MaxDepth;
Mike Stump1eb44332009-09-09 15:08:12 +000037
Chris Lattnere300c872007-08-30 06:17:34 +000038 /// LastLocFilename/LastLocLine - Keep track of the last location we print
39 /// out so that we can print out deltas from then on out.
40 const char *LastLocFilename;
41 unsigned LastLocLine;
Douglas Gregord249e1d1f2009-05-29 20:38:28 +000042
Chris Lattner6000dac2007-08-08 22:51:59 +000043 public:
Daniel Dunbar806c12e2009-12-03 09:13:13 +000044 StmtDumper(SourceManager *sm, llvm::raw_ostream &os, unsigned maxDepth)
45 : SM(sm), OS(os), IndentLevel(0-1), MaxDepth(maxDepth) {
Chris Lattnere300c872007-08-30 06:17:34 +000046 LastLocFilename = "";
47 LastLocLine = ~0U;
48 }
Mike Stump1eb44332009-09-09 15:08:12 +000049
Chris Lattnerf9e05812007-08-09 18:03:18 +000050 void DumpSubTree(Stmt *S) {
Chris Lattner6000dac2007-08-08 22:51:59 +000051 // Prune the recursion if not using dump all.
52 if (MaxDepth == 0) return;
Mike Stump1eb44332009-09-09 15:08:12 +000053
Chris Lattnerf9e05812007-08-09 18:03:18 +000054 ++IndentLevel;
Chris Lattner6000dac2007-08-08 22:51:59 +000055 if (S) {
Ted Kremenek5399ce22007-12-12 06:59:42 +000056 if (DeclStmt* DS = dyn_cast<DeclStmt>(S))
57 VisitDeclStmt(DS);
Mike Stump1eb44332009-09-09 15:08:12 +000058 else {
Ted Kremenek5399ce22007-12-12 06:59:42 +000059 Visit(S);
Mike Stump1eb44332009-09-09 15:08:12 +000060
Ted Kremenek5399ce22007-12-12 06:59:42 +000061 // Print out children.
62 Stmt::child_iterator CI = S->child_begin(), CE = S->child_end();
63 if (CI != CE) {
64 while (CI != CE) {
Daniel Dunbar806c12e2009-12-03 09:13:13 +000065 OS << '\n';
Ted Kremenek5399ce22007-12-12 06:59:42 +000066 DumpSubTree(*CI++);
67 }
Fariborz Jahanianf9b949f2010-08-31 18:02:20 +000068 if (const ConditionalOperator *CO =
69 dyn_cast<ConditionalOperator>(S)) {
70 if (CO->getSAVE()) {
71 OS << '\n';
72 DumpSubTree(CO->getSAVE());
73 }
74 }
Chris Lattnerb3938792007-08-30 00:53:54 +000075 }
76 }
Chris Lattnera46325e2010-05-25 17:56:43 +000077 OS << ')';
Chris Lattner6000dac2007-08-08 22:51:59 +000078 } else {
79 Indent();
Daniel Dunbar806c12e2009-12-03 09:13:13 +000080 OS << "<<<NULL>>>";
Chris Lattner6000dac2007-08-08 22:51:59 +000081 }
Chris Lattnerf9e05812007-08-09 18:03:18 +000082 --IndentLevel;
Chris Lattner6000dac2007-08-08 22:51:59 +000083 }
Mike Stump1eb44332009-09-09 15:08:12 +000084
Chris Lattnerf9e05812007-08-09 18:03:18 +000085 void DumpDeclarator(Decl *D);
Mike Stump1eb44332009-09-09 15:08:12 +000086
Chris Lattner6000dac2007-08-08 22:51:59 +000087 void Indent() const {
88 for (int i = 0, e = IndentLevel; i < e; ++i)
Daniel Dunbar806c12e2009-12-03 09:13:13 +000089 OS << " ";
Chris Lattner6000dac2007-08-08 22:51:59 +000090 }
Mike Stump1eb44332009-09-09 15:08:12 +000091
Steve Naroff9dcbfa42007-09-01 21:08:38 +000092 void DumpType(QualType T) {
Daniel Dunbar806c12e2009-12-03 09:13:13 +000093 OS << "'" << T.getAsString() << "'";
Chris Lattnerfd8f7da2007-08-09 00:36:22 +000094
Douglas Gregor61366e92008-12-24 00:01:03 +000095 if (!T.isNull()) {
John McCall0953e762009-09-24 19:53:00 +000096 // If the type is sugared, also dump a (shallow) desugared type.
97 QualType Simplified = T.getDesugaredType();
98 if (Simplified != T)
Daniel Dunbar806c12e2009-12-03 09:13:13 +000099 OS << ":'" << Simplified.getAsString() << "'";
Chris Lattnerbad37852008-04-02 05:06:23 +0000100 }
Chris Lattnerfd8f7da2007-08-09 00:36:22 +0000101 }
Steve Naroff9dcbfa42007-09-01 21:08:38 +0000102 void DumpStmt(const Stmt *Node) {
Chris Lattner6000dac2007-08-08 22:51:59 +0000103 Indent();
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000104 OS << "(" << Node->getStmtClassName()
105 << " " << (void*)Node;
Steve Naroff9dcbfa42007-09-01 21:08:38 +0000106 DumpSourceRange(Node);
Chris Lattner6000dac2007-08-08 22:51:59 +0000107 }
Steve Naroff9dcbfa42007-09-01 21:08:38 +0000108 void DumpExpr(const Expr *Node) {
Chris Lattner6000dac2007-08-08 22:51:59 +0000109 DumpStmt(Node);
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000110 OS << ' ';
Chris Lattnerfd8f7da2007-08-09 00:36:22 +0000111 DumpType(Node->getType());
Chris Lattner6000dac2007-08-08 22:51:59 +0000112 }
Steve Naroff9dcbfa42007-09-01 21:08:38 +0000113 void DumpSourceRange(const Stmt *Node);
Chris Lattnere300c872007-08-30 06:17:34 +0000114 void DumpLocation(SourceLocation Loc);
Mike Stump1eb44332009-09-09 15:08:12 +0000115
Chris Lattner17a1a722007-08-30 01:00:35 +0000116 // Stmts.
Chris Lattnerc5598cb2007-08-21 04:04:25 +0000117 void VisitStmt(Stmt *Node);
Ted Kremenek5399ce22007-12-12 06:59:42 +0000118 void VisitDeclStmt(DeclStmt *Node);
Chris Lattner17a1a722007-08-30 01:00:35 +0000119 void VisitLabelStmt(LabelStmt *Node);
120 void VisitGotoStmt(GotoStmt *Node);
Mike Stump1eb44332009-09-09 15:08:12 +0000121
Chris Lattner17a1a722007-08-30 01:00:35 +0000122 // Exprs
123 void VisitExpr(Expr *Node);
Anders Carlsson27a5b9b2009-08-22 23:33:40 +0000124 void VisitCastExpr(CastExpr *Node);
Anders Carlsson0e489ea2009-11-14 22:35:18 +0000125 void VisitImplicitCastExpr(ImplicitCastExpr *Node);
Chris Lattner17a1a722007-08-30 01:00:35 +0000126 void VisitDeclRefExpr(DeclRefExpr *Node);
Chris Lattnerd9f69102008-08-10 01:53:14 +0000127 void VisitPredefinedExpr(PredefinedExpr *Node);
Chris Lattner17a1a722007-08-30 01:00:35 +0000128 void VisitCharacterLiteral(CharacterLiteral *Node);
129 void VisitIntegerLiteral(IntegerLiteral *Node);
130 void VisitFloatingLiteral(FloatingLiteral *Node);
131 void VisitStringLiteral(StringLiteral *Str);
132 void VisitUnaryOperator(UnaryOperator *Node);
Sebastian Redl05189992008-11-11 17:56:53 +0000133 void VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *Node);
Chris Lattner17a1a722007-08-30 01:00:35 +0000134 void VisitMemberExpr(MemberExpr *Node);
Nate Begeman213541a2008-04-18 23:10:10 +0000135 void VisitExtVectorElementExpr(ExtVectorElementExpr *Node);
Chris Lattner17a1a722007-08-30 01:00:35 +0000136 void VisitBinaryOperator(BinaryOperator *Node);
137 void VisitCompoundAssignOperator(CompoundAssignOperator *Node);
138 void VisitAddrLabelExpr(AddrLabelExpr *Node);
139 void VisitTypesCompatibleExpr(TypesCompatibleExpr *Node);
140
141 // C++
Douglas Gregor49badde2008-10-27 19:41:14 +0000142 void VisitCXXNamedCastExpr(CXXNamedCastExpr *Node);
Chris Lattner17a1a722007-08-30 01:00:35 +0000143 void VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *Node);
Douglas Gregorcd9b46e2008-11-04 14:56:14 +0000144 void VisitCXXThisExpr(CXXThisExpr *Node);
Douglas Gregor49badde2008-10-27 19:41:14 +0000145 void VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *Node);
Anders Carlsson0eca1b62009-08-12 00:21:52 +0000146 void VisitCXXConstructExpr(CXXConstructExpr *Node);
147 void VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *Node);
148 void VisitCXXExprWithTemporaries(CXXExprWithTemporaries *Node);
John McCall9d5f35e2009-12-11 21:50:11 +0000149 void VisitUnresolvedLookupExpr(UnresolvedLookupExpr *Node);
Anders Carlsson0eca1b62009-08-12 00:21:52 +0000150 void DumpCXXTemporary(CXXTemporary *Temporary);
Mike Stump1eb44332009-09-09 15:08:12 +0000151
Chris Lattner17a1a722007-08-30 01:00:35 +0000152 // ObjC
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +0000153 void VisitObjCAtCatchStmt(ObjCAtCatchStmt *Node);
Chris Lattner17a1a722007-08-30 01:00:35 +0000154 void VisitObjCEncodeExpr(ObjCEncodeExpr *Node);
Ted Kremenekb3d914b2008-02-29 22:04:05 +0000155 void VisitObjCMessageExpr(ObjCMessageExpr* Node);
Fariborz Jahanianb62f6812007-10-16 20:40:23 +0000156 void VisitObjCSelectorExpr(ObjCSelectorExpr *Node);
Fariborz Jahanian390d50a2007-10-17 16:58:11 +0000157 void VisitObjCProtocolExpr(ObjCProtocolExpr *Node);
Daniel Dunbar7f8ea5c2008-08-30 05:35:15 +0000158 void VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *Node);
Fariborz Jahanian09105f52009-08-20 17:02:02 +0000159 void VisitObjCImplicitSetterGetterRefExpr(
160 ObjCImplicitSetterGetterRefExpr *Node);
Steve Naroff3c64d9e2008-03-12 13:19:12 +0000161 void VisitObjCIvarRefExpr(ObjCIvarRefExpr *Node);
Douglas Gregorcd9b46e2008-11-04 14:56:14 +0000162 void VisitObjCSuperExpr(ObjCSuperExpr *Node);
Chris Lattner6000dac2007-08-08 22:51:59 +0000163 };
164}
165
166//===----------------------------------------------------------------------===//
Chris Lattnere300c872007-08-30 06:17:34 +0000167// Utilities
168//===----------------------------------------------------------------------===//
169
170void StmtDumper::DumpLocation(SourceLocation Loc) {
Chris Lattnerdf7c17a2009-01-16 07:00:02 +0000171 SourceLocation SpellingLoc = SM->getSpellingLoc(Loc);
Mike Stump1eb44332009-09-09 15:08:12 +0000172
Chris Lattnerb9c3f962009-01-27 07:57:44 +0000173 if (SpellingLoc.isInvalid()) {
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000174 OS << "<invalid sloc>";
Chris Lattnerb9c3f962009-01-27 07:57:44 +0000175 return;
176 }
Chris Lattnere300c872007-08-30 06:17:34 +0000177
178 // The general format we print out is filename:line:col, but we drop pieces
179 // that haven't changed since the last loc printed.
Chris Lattnerb9c3f962009-01-27 07:57:44 +0000180 PresumedLoc PLoc = SM->getPresumedLoc(SpellingLoc);
181
182 if (strcmp(PLoc.getFilename(), LastLocFilename) != 0) {
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000183 OS << PLoc.getFilename() << ':' << PLoc.getLine()
184 << ':' << PLoc.getColumn();
Chris Lattnerb9c3f962009-01-27 07:57:44 +0000185 LastLocFilename = PLoc.getFilename();
186 LastLocLine = PLoc.getLine();
187 } else if (PLoc.getLine() != LastLocLine) {
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000188 OS << "line" << ':' << PLoc.getLine()
189 << ':' << PLoc.getColumn();
Chris Lattnerb9c3f962009-01-27 07:57:44 +0000190 LastLocLine = PLoc.getLine();
Chris Lattnere300c872007-08-30 06:17:34 +0000191 } else {
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000192 OS << "col" << ':' << PLoc.getColumn();
Chris Lattnere300c872007-08-30 06:17:34 +0000193 }
194}
195
Steve Naroff9dcbfa42007-09-01 21:08:38 +0000196void StmtDumper::DumpSourceRange(const Stmt *Node) {
Chris Lattnere300c872007-08-30 06:17:34 +0000197 // Can't translate locations if a SourceManager isn't available.
198 if (SM == 0) return;
Mike Stump1eb44332009-09-09 15:08:12 +0000199
Chris Lattnere300c872007-08-30 06:17:34 +0000200 // TODO: If the parent expression is available, we can print a delta vs its
201 // location.
202 SourceRange R = Node->getSourceRange();
Mike Stump1eb44332009-09-09 15:08:12 +0000203
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000204 OS << " <";
Chris Lattner311ff022007-10-16 22:36:42 +0000205 DumpLocation(R.getBegin());
206 if (R.getBegin() != R.getEnd()) {
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000207 OS << ", ";
Chris Lattner311ff022007-10-16 22:36:42 +0000208 DumpLocation(R.getEnd());
Chris Lattnere300c872007-08-30 06:17:34 +0000209 }
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000210 OS << ">";
Mike Stump1eb44332009-09-09 15:08:12 +0000211
Chris Lattnere300c872007-08-30 06:17:34 +0000212 // <t2.c:123:421[blah], t2.c:412:321>
213
214}
215
216
217//===----------------------------------------------------------------------===//
Chris Lattner6000dac2007-08-08 22:51:59 +0000218// Stmt printing methods.
219//===----------------------------------------------------------------------===//
220
221void StmtDumper::VisitStmt(Stmt *Node) {
Chris Lattner17a1a722007-08-30 01:00:35 +0000222 DumpStmt(Node);
Chris Lattner6000dac2007-08-08 22:51:59 +0000223}
224
Chris Lattnerf9e05812007-08-09 18:03:18 +0000225void StmtDumper::DumpDeclarator(Decl *D) {
Chris Lattner6000dac2007-08-08 22:51:59 +0000226 // FIXME: Need to complete/beautify this... this code simply shows the
227 // nodes are where they need to be.
228 if (TypedefDecl *localType = dyn_cast<TypedefDecl>(D)) {
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000229 OS << "\"typedef " << localType->getUnderlyingType().getAsString()
Benjamin Kramer900fc632010-04-17 09:33:03 +0000230 << ' ' << localType << '"';
Chris Lattner6000dac2007-08-08 22:51:59 +0000231 } else if (ValueDecl *VD = dyn_cast<ValueDecl>(D)) {
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000232 OS << "\"";
Chris Lattner6000dac2007-08-08 22:51:59 +0000233 // Emit storage class for vardecls.
234 if (VarDecl *V = dyn_cast<VarDecl>(VD)) {
John McCalld931b082010-08-26 03:08:43 +0000235 if (V->getStorageClass() != SC_None)
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000236 OS << VarDecl::getStorageClassSpecifierString(V->getStorageClass())
237 << " ";
Chris Lattner6000dac2007-08-08 22:51:59 +0000238 }
Mike Stump1eb44332009-09-09 15:08:12 +0000239
Chris Lattner39f34e92008-11-24 04:00:27 +0000240 std::string Name = VD->getNameAsString();
Mike Stump1eb44332009-09-09 15:08:12 +0000241 VD->getType().getAsStringInternal(Name,
Chris Lattnere4f21422009-06-30 01:26:17 +0000242 PrintingPolicy(VD->getASTContext().getLangOptions()));
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000243 OS << Name;
Mike Stump1eb44332009-09-09 15:08:12 +0000244
Chris Lattner6000dac2007-08-08 22:51:59 +0000245 // If this is a vardecl with an initializer, emit it.
246 if (VarDecl *V = dyn_cast<VarDecl>(VD)) {
247 if (V->getInit()) {
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000248 OS << " =\n";
Chris Lattnerf9e05812007-08-09 18:03:18 +0000249 DumpSubTree(V->getInit());
Chris Lattner6000dac2007-08-08 22:51:59 +0000250 }
251 }
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000252 OS << '"';
Steve Naroff92199282007-11-17 21:37:36 +0000253 } else if (TagDecl *TD = dyn_cast<TagDecl>(D)) {
254 // print a free standing tag decl (e.g. "struct x;").
255 const char *tagname;
256 if (const IdentifierInfo *II = TD->getIdentifier())
Daniel Dunbare013d682009-10-18 20:26:12 +0000257 tagname = II->getNameStart();
Steve Naroff92199282007-11-17 21:37:36 +0000258 else
259 tagname = "<anonymous>";
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000260 OS << '"' << TD->getKindName() << ' ' << tagname << ";\"";
Steve Naroff92199282007-11-17 21:37:36 +0000261 // FIXME: print tag bodies.
Douglas Gregor2a3009a2009-02-03 19:21:40 +0000262 } else if (UsingDirectiveDecl *UD = dyn_cast<UsingDirectiveDecl>(D)) {
263 // print using-directive decl (e.g. "using namespace x;")
264 const char *ns;
265 if (const IdentifierInfo *II = UD->getNominatedNamespace()->getIdentifier())
Daniel Dunbare013d682009-10-18 20:26:12 +0000266 ns = II->getNameStart();
Douglas Gregor2a3009a2009-02-03 19:21:40 +0000267 else
268 ns = "<anonymous>";
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000269 OS << '"' << UD->getDeclKindName() << ns << ";\"";
Sebastian Redl0ca43592010-05-04 10:20:17 +0000270 } else if (UsingDecl *UD = dyn_cast<UsingDecl>(D)) {
271 // print using decl (e.g. "using std::string;")
272 const char *tn = UD->isTypeName() ? "typename " : "";
273 OS << '"' << UD->getDeclKindName() << tn;
274 UD->getTargetNestedNameDecl()->print(OS,
275 PrintingPolicy(UD->getASTContext().getLangOptions()));
276 OS << ";\"";
Chris Lattner6000dac2007-08-08 22:51:59 +0000277 } else {
Chris Lattner6000dac2007-08-08 22:51:59 +0000278 assert(0 && "Unexpected decl");
279 }
Chris Lattner6000dac2007-08-08 22:51:59 +0000280}
281
Ted Kremenek5399ce22007-12-12 06:59:42 +0000282void StmtDumper::VisitDeclStmt(DeclStmt *Node) {
283 DumpStmt(Node);
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000284 OS << "\n";
Ted Kremenek04a72b72008-10-06 18:38:35 +0000285 for (DeclStmt::decl_iterator DI = Node->decl_begin(), DE = Node->decl_end();
286 DI != DE; ++DI) {
Douglas Gregor4afa39d2009-01-20 01:17:11 +0000287 Decl* D = *DI;
Ted Kremenek5399ce22007-12-12 06:59:42 +0000288 ++IndentLevel;
289 Indent();
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000290 OS << (void*) D << " ";
Ted Kremenek5399ce22007-12-12 06:59:42 +0000291 DumpDeclarator(D);
Chris Lattnerf2797252009-03-29 16:04:50 +0000292 if (DI+1 != DE)
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000293 OS << "\n";
Ted Kremenek5399ce22007-12-12 06:59:42 +0000294 --IndentLevel;
295 }
296}
297
Chris Lattner6000dac2007-08-08 22:51:59 +0000298void StmtDumper::VisitLabelStmt(LabelStmt *Node) {
299 DumpStmt(Node);
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000300 OS << " '" << Node->getName() << "'";
Chris Lattner6000dac2007-08-08 22:51:59 +0000301}
302
Chris Lattner6000dac2007-08-08 22:51:59 +0000303void StmtDumper::VisitGotoStmt(GotoStmt *Node) {
304 DumpStmt(Node);
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000305 OS << " '" << Node->getLabel()->getName()
306 << "':" << (void*)Node->getLabel();
Chris Lattner6000dac2007-08-08 22:51:59 +0000307}
308
Chris Lattner6000dac2007-08-08 22:51:59 +0000309//===----------------------------------------------------------------------===//
310// Expr printing methods.
311//===----------------------------------------------------------------------===//
312
313void StmtDumper::VisitExpr(Expr *Node) {
314 DumpExpr(Node);
Chris Lattner6000dac2007-08-08 22:51:59 +0000315}
316
Anders Carlsson5cf86ba2010-04-24 19:06:50 +0000317static void DumpBasePath(llvm::raw_ostream &OS, CastExpr *Node) {
John McCallf871d0c2010-08-07 06:22:56 +0000318 if (Node->path_empty())
Anders Carlsson5cf86ba2010-04-24 19:06:50 +0000319 return;
320
321 OS << " (";
322 bool First = true;
John McCallf871d0c2010-08-07 06:22:56 +0000323 for (CastExpr::path_iterator
324 I = Node->path_begin(), E = Node->path_end(); I != E; ++I) {
Anders Carlsson5cf86ba2010-04-24 19:06:50 +0000325 const CXXBaseSpecifier *Base = *I;
326 if (!First)
327 OS << " -> ";
328
329 const CXXRecordDecl *RD =
330 cast<CXXRecordDecl>(Base->getType()->getAs<RecordType>()->getDecl());
331
332 if (Base->isVirtual())
333 OS << "virtual ";
334 OS << RD->getName();
335 First = false;
336 }
337
338 OS << ')';
339}
340
Anders Carlsson27a5b9b2009-08-22 23:33:40 +0000341void StmtDumper::VisitCastExpr(CastExpr *Node) {
342 DumpExpr(Node);
Anders Carlsson5cf86ba2010-04-24 19:06:50 +0000343 OS << " <" << Node->getCastKindName();
344 DumpBasePath(OS, Node);
345 OS << ">";
Anders Carlsson27a5b9b2009-08-22 23:33:40 +0000346}
347
Anders Carlsson0e489ea2009-11-14 22:35:18 +0000348void StmtDumper::VisitImplicitCastExpr(ImplicitCastExpr *Node) {
349 VisitCastExpr(Node);
John McCall5baba9d2010-08-25 10:28:54 +0000350 switch (Node->getValueKind()) {
351 case VK_LValue:
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000352 OS << " lvalue";
Sebastian Redl906082e2010-07-20 04:20:21 +0000353 break;
John McCall5baba9d2010-08-25 10:28:54 +0000354 case VK_XValue:
Sebastian Redl906082e2010-07-20 04:20:21 +0000355 OS << " xvalue";
356 break;
John McCall5baba9d2010-08-25 10:28:54 +0000357 case VK_RValue:
Sebastian Redl906082e2010-07-20 04:20:21 +0000358 break;
359 }
Anders Carlsson0e489ea2009-11-14 22:35:18 +0000360}
361
Chris Lattner6000dac2007-08-08 22:51:59 +0000362void StmtDumper::VisitDeclRefExpr(DeclRefExpr *Node) {
363 DumpExpr(Node);
Ted Kremenekeb641f92007-09-10 17:32:55 +0000364
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000365 OS << " ";
Ted Kremenekeb641f92007-09-10 17:32:55 +0000366 switch (Node->getDecl()->getKind()) {
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000367 default: OS << "Decl"; break;
368 case Decl::Function: OS << "FunctionDecl"; break;
369 case Decl::Var: OS << "Var"; break;
370 case Decl::ParmVar: OS << "ParmVar"; break;
371 case Decl::EnumConstant: OS << "EnumConstant"; break;
372 case Decl::Typedef: OS << "Typedef"; break;
373 case Decl::Record: OS << "Record"; break;
374 case Decl::Enum: OS << "Enum"; break;
375 case Decl::CXXRecord: OS << "CXXRecord"; break;
376 case Decl::ObjCInterface: OS << "ObjCInterface"; break;
377 case Decl::ObjCClass: OS << "ObjCClass"; break;
Ted Kremenekeb641f92007-09-10 17:32:55 +0000378 }
Mike Stump1eb44332009-09-09 15:08:12 +0000379
Benjamin Kramer900fc632010-04-17 09:33:03 +0000380 OS << "='" << Node->getDecl() << "' " << (void*)Node->getDecl();
Chris Lattner6000dac2007-08-08 22:51:59 +0000381}
382
John McCall9d5f35e2009-12-11 21:50:11 +0000383void StmtDumper::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *Node) {
384 DumpExpr(Node);
385 OS << " (";
386 if (!Node->requiresADL()) OS << "no ";
Benjamin Kramer900fc632010-04-17 09:33:03 +0000387 OS << "ADL) = '" << Node->getName() << '\'';
John McCall9d5f35e2009-12-11 21:50:11 +0000388
389 UnresolvedLookupExpr::decls_iterator
390 I = Node->decls_begin(), E = Node->decls_end();
391 if (I == E) OS << " empty";
392 for (; I != E; ++I)
393 OS << " " << (void*) *I;
394}
395
Steve Naroff3c64d9e2008-03-12 13:19:12 +0000396void StmtDumper::VisitObjCIvarRefExpr(ObjCIvarRefExpr *Node) {
Steve Naroff466c2e32008-05-23 00:59:14 +0000397 DumpExpr(Node);
Steve Naroff3c64d9e2008-03-12 13:19:12 +0000398
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000399 OS << " " << Node->getDecl()->getDeclKindName()
Benjamin Kramer900fc632010-04-17 09:33:03 +0000400 << "Decl='" << Node->getDecl()
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000401 << "' " << (void*)Node->getDecl();
Steve Naroff218543b2008-05-23 22:01:24 +0000402 if (Node->isFreeIvar())
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000403 OS << " isFreeIvar";
Steve Naroff3c64d9e2008-03-12 13:19:12 +0000404}
405
Chris Lattnerd9f69102008-08-10 01:53:14 +0000406void StmtDumper::VisitPredefinedExpr(PredefinedExpr *Node) {
Chris Lattner6000dac2007-08-08 22:51:59 +0000407 DumpExpr(Node);
408 switch (Node->getIdentType()) {
Chris Lattner0d17f6f2008-06-21 18:04:54 +0000409 default: assert(0 && "unknown case");
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000410 case PredefinedExpr::Func: OS << " __func__"; break;
411 case PredefinedExpr::Function: OS << " __FUNCTION__"; break;
412 case PredefinedExpr::PrettyFunction: OS << " __PRETTY_FUNCTION__";break;
Chris Lattner6000dac2007-08-08 22:51:59 +0000413 }
414}
415
416void StmtDumper::VisitCharacterLiteral(CharacterLiteral *Node) {
Chris Lattnera0df31a2007-08-09 01:04:32 +0000417 DumpExpr(Node);
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000418 OS << Node->getValue();
Chris Lattner6000dac2007-08-08 22:51:59 +0000419}
420
421void StmtDumper::VisitIntegerLiteral(IntegerLiteral *Node) {
422 DumpExpr(Node);
423
424 bool isSigned = Node->getType()->isSignedIntegerType();
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000425 OS << " " << Node->getValue().toString(10, isSigned);
Chris Lattner6000dac2007-08-08 22:51:59 +0000426}
427void StmtDumper::VisitFloatingLiteral(FloatingLiteral *Node) {
428 DumpExpr(Node);
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000429 OS << " " << Node->getValueAsApproximateDouble();
Chris Lattner6000dac2007-08-08 22:51:59 +0000430}
Chris Lattner5d661452007-08-26 03:42:43 +0000431
Chris Lattner6000dac2007-08-08 22:51:59 +0000432void StmtDumper::VisitStringLiteral(StringLiteral *Str) {
Chris Lattnera0df31a2007-08-09 01:04:32 +0000433 DumpExpr(Str);
434 // FIXME: this doesn't print wstrings right.
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000435 OS << " ";
436 if (Str->isWide())
437 OS << "L";
438 OS << '"';
Benjamin Kramer2f4eaef2010-08-17 12:54:38 +0000439 OS.write_escaped(Str->getString());
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000440 OS << '"';
Chris Lattner6000dac2007-08-08 22:51:59 +0000441}
Chris Lattner17a1a722007-08-30 01:00:35 +0000442
Chris Lattner6000dac2007-08-08 22:51:59 +0000443void StmtDumper::VisitUnaryOperator(UnaryOperator *Node) {
Chris Lattner13cb21f2007-08-09 17:35:30 +0000444 DumpExpr(Node);
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000445 OS << " " << (Node->isPostfix() ? "postfix" : "prefix")
446 << " '" << UnaryOperator::getOpcodeStr(Node->getOpcode()) << "'";
Chris Lattner6000dac2007-08-08 22:51:59 +0000447}
Sebastian Redl05189992008-11-11 17:56:53 +0000448void StmtDumper::VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *Node) {
Chris Lattner13cb21f2007-08-09 17:35:30 +0000449 DumpExpr(Node);
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000450 OS << " " << (Node->isSizeOf() ? "sizeof" : "alignof") << " ";
Sebastian Redl05189992008-11-11 17:56:53 +0000451 if (Node->isArgumentType())
452 DumpType(Node->getArgumentType());
Chris Lattner6000dac2007-08-08 22:51:59 +0000453}
Chris Lattner13cb21f2007-08-09 17:35:30 +0000454
Chris Lattner6000dac2007-08-08 22:51:59 +0000455void StmtDumper::VisitMemberExpr(MemberExpr *Node) {
Chris Lattner13cb21f2007-08-09 17:35:30 +0000456 DumpExpr(Node);
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000457 OS << " " << (Node->isArrow() ? "->" : ".")
Benjamin Kramer900fc632010-04-17 09:33:03 +0000458 << Node->getMemberDecl() << ' '
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000459 << (void*)Node->getMemberDecl();
Chris Lattner6000dac2007-08-08 22:51:59 +0000460}
Nate Begeman213541a2008-04-18 23:10:10 +0000461void StmtDumper::VisitExtVectorElementExpr(ExtVectorElementExpr *Node) {
Chris Lattner13cb21f2007-08-09 17:35:30 +0000462 DumpExpr(Node);
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000463 OS << " " << Node->getAccessor().getNameStart();
Chris Lattner6000dac2007-08-08 22:51:59 +0000464}
Chris Lattner6000dac2007-08-08 22:51:59 +0000465void StmtDumper::VisitBinaryOperator(BinaryOperator *Node) {
466 DumpExpr(Node);
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000467 OS << " '" << BinaryOperator::getOpcodeStr(Node->getOpcode()) << "'";
Chris Lattnereb14fe82007-08-25 02:00:02 +0000468}
469void StmtDumper::VisitCompoundAssignOperator(CompoundAssignOperator *Node) {
470 DumpExpr(Node);
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000471 OS << " '" << BinaryOperator::getOpcodeStr(Node->getOpcode())
472 << "' ComputeLHSTy=";
Eli Friedmanab3a8522009-03-28 01:22:36 +0000473 DumpType(Node->getComputationLHSType());
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000474 OS << " ComputeResultTy=";
Eli Friedmanab3a8522009-03-28 01:22:36 +0000475 DumpType(Node->getComputationResultType());
Chris Lattner6000dac2007-08-08 22:51:59 +0000476}
Chris Lattner6000dac2007-08-08 22:51:59 +0000477
478// GNU extensions.
479
480void StmtDumper::VisitAddrLabelExpr(AddrLabelExpr *Node) {
Chris Lattner13cb21f2007-08-09 17:35:30 +0000481 DumpExpr(Node);
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000482 OS << " " << Node->getLabel()->getName()
483 << " " << (void*)Node->getLabel();
Chris Lattner6000dac2007-08-08 22:51:59 +0000484}
485
Chris Lattner6000dac2007-08-08 22:51:59 +0000486void StmtDumper::VisitTypesCompatibleExpr(TypesCompatibleExpr *Node) {
Chris Lattner13cb21f2007-08-09 17:35:30 +0000487 DumpExpr(Node);
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000488 OS << " ";
Chris Lattner13cb21f2007-08-09 17:35:30 +0000489 DumpType(Node->getArgType1());
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000490 OS << " ";
Chris Lattner13cb21f2007-08-09 17:35:30 +0000491 DumpType(Node->getArgType2());
Chris Lattner6000dac2007-08-08 22:51:59 +0000492}
493
Chris Lattnerf9e05812007-08-09 18:03:18 +0000494//===----------------------------------------------------------------------===//
495// C++ Expressions
496//===----------------------------------------------------------------------===//
Chris Lattner6000dac2007-08-08 22:51:59 +0000497
Douglas Gregor49badde2008-10-27 19:41:14 +0000498void StmtDumper::VisitCXXNamedCastExpr(CXXNamedCastExpr *Node) {
Chris Lattner13cb21f2007-08-09 17:35:30 +0000499 DumpExpr(Node);
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000500 OS << " " << Node->getCastName()
501 << "<" << Node->getTypeAsWritten().getAsString() << ">"
Anders Carlsson5cf86ba2010-04-24 19:06:50 +0000502 << " <" << Node->getCastKindName();
503 DumpBasePath(OS, Node);
504 OS << ">";
Chris Lattner6000dac2007-08-08 22:51:59 +0000505}
506
507void StmtDumper::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *Node) {
Chris Lattner13cb21f2007-08-09 17:35:30 +0000508 DumpExpr(Node);
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000509 OS << " " << (Node->getValue() ? "true" : "false");
Chris Lattner6000dac2007-08-08 22:51:59 +0000510}
511
Douglas Gregorcd9b46e2008-11-04 14:56:14 +0000512void StmtDumper::VisitCXXThisExpr(CXXThisExpr *Node) {
513 DumpExpr(Node);
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000514 OS << " this";
Douglas Gregorcd9b46e2008-11-04 14:56:14 +0000515}
516
Douglas Gregor49badde2008-10-27 19:41:14 +0000517void StmtDumper::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *Node) {
518 DumpExpr(Node);
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000519 OS << " functional cast to " << Node->getTypeAsWritten().getAsString();
Douglas Gregor49badde2008-10-27 19:41:14 +0000520}
521
Anders Carlsson0eca1b62009-08-12 00:21:52 +0000522void StmtDumper::VisitCXXConstructExpr(CXXConstructExpr *Node) {
523 DumpExpr(Node);
John McCalld4bbdfe2010-02-02 19:03:45 +0000524 CXXConstructorDecl *Ctor = Node->getConstructor();
525 DumpType(Ctor->getType());
Anders Carlsson0eca1b62009-08-12 00:21:52 +0000526 if (Node->isElidable())
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000527 OS << " elidable";
John McCallf8cf0b02010-08-07 06:38:55 +0000528 if (Node->requiresZeroInitialization())
529 OS << " zeroing";
Anders Carlsson0eca1b62009-08-12 00:21:52 +0000530}
531
532void StmtDumper::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *Node) {
533 DumpExpr(Node);
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000534 OS << " ";
Anders Carlsson0eca1b62009-08-12 00:21:52 +0000535 DumpCXXTemporary(Node->getTemporary());
536}
537
538void StmtDumper::VisitCXXExprWithTemporaries(CXXExprWithTemporaries *Node) {
539 DumpExpr(Node);
540 ++IndentLevel;
541 for (unsigned i = 0, e = Node->getNumTemporaries(); i != e; ++i) {
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000542 OS << "\n";
Anders Carlsson0eca1b62009-08-12 00:21:52 +0000543 Indent();
544 DumpCXXTemporary(Node->getTemporary(i));
545 }
546 --IndentLevel;
547}
548
549void StmtDumper::DumpCXXTemporary(CXXTemporary *Temporary) {
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000550 OS << "(CXXTemporary " << (void *)Temporary << ")";
Anders Carlsson0eca1b62009-08-12 00:21:52 +0000551}
552
Anders Carlsson55085182007-08-21 17:43:55 +0000553//===----------------------------------------------------------------------===//
554// Obj-C Expressions
555//===----------------------------------------------------------------------===//
556
Ted Kremenekb3d914b2008-02-29 22:04:05 +0000557void StmtDumper::VisitObjCMessageExpr(ObjCMessageExpr* Node) {
558 DumpExpr(Node);
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000559 OS << " selector=" << Node->getSelector().getAsString();
Douglas Gregor04badcf2010-04-21 00:45:42 +0000560 switch (Node->getReceiverKind()) {
561 case ObjCMessageExpr::Instance:
562 break;
563
564 case ObjCMessageExpr::Class:
565 OS << " class=";
566 DumpType(Node->getClassReceiver());
567 break;
568
569 case ObjCMessageExpr::SuperInstance:
570 OS << " super (instance)";
571 break;
572
573 case ObjCMessageExpr::SuperClass:
574 OS << " super (class)";
575 break;
576 }
Ted Kremenekb3d914b2008-02-29 22:04:05 +0000577}
578
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +0000579void StmtDumper::VisitObjCAtCatchStmt(ObjCAtCatchStmt *Node) {
580 DumpStmt(Node);
Douglas Gregorc00d8e12010-04-26 16:46:50 +0000581 if (VarDecl *CatchParam = Node->getCatchParamDecl()) {
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +0000582 OS << " catch parm = ";
583 DumpDeclarator(CatchParam);
584 } else {
585 OS << " catch all";
586 }
587}
588
Anders Carlssonf9bcf012007-08-22 15:14:15 +0000589void StmtDumper::VisitObjCEncodeExpr(ObjCEncodeExpr *Node) {
590 DumpExpr(Node);
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000591 OS << " ";
Anders Carlssonf9bcf012007-08-22 15:14:15 +0000592 DumpType(Node->getEncodedType());
Anders Carlssonf9bcf012007-08-22 15:14:15 +0000593}
594
Fariborz Jahanianb62f6812007-10-16 20:40:23 +0000595void StmtDumper::VisitObjCSelectorExpr(ObjCSelectorExpr *Node) {
596 DumpExpr(Node);
Mike Stump1eb44332009-09-09 15:08:12 +0000597
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000598 OS << " " << Node->getSelector().getAsString();
Fariborz Jahanianb62f6812007-10-16 20:40:23 +0000599}
600
Fariborz Jahanian390d50a2007-10-17 16:58:11 +0000601void StmtDumper::VisitObjCProtocolExpr(ObjCProtocolExpr *Node) {
602 DumpExpr(Node);
Mike Stump1eb44332009-09-09 15:08:12 +0000603
Benjamin Kramer900fc632010-04-17 09:33:03 +0000604 OS << ' ' << Node->getProtocol();
Fariborz Jahanian390d50a2007-10-17 16:58:11 +0000605}
Daniel Dunbar7f8ea5c2008-08-30 05:35:15 +0000606
607void StmtDumper::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *Node) {
608 DumpExpr(Node);
Daniel Dunbare66f4e32008-09-03 00:27:26 +0000609
Benjamin Kramer900fc632010-04-17 09:33:03 +0000610 OS << " Kind=PropertyRef Property=\"" << Node->getProperty() << '"';
Fariborz Jahanian5daf5702008-11-22 18:39:36 +0000611}
612
Fariborz Jahanian09105f52009-08-20 17:02:02 +0000613void StmtDumper::VisitObjCImplicitSetterGetterRefExpr(
614 ObjCImplicitSetterGetterRefExpr *Node) {
Fariborz Jahanian5daf5702008-11-22 18:39:36 +0000615 DumpExpr(Node);
Mike Stump1eb44332009-09-09 15:08:12 +0000616
Fariborz Jahanian5daf5702008-11-22 18:39:36 +0000617 ObjCMethodDecl *Getter = Node->getGetterMethod();
618 ObjCMethodDecl *Setter = Node->getSetterMethod();
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000619 OS << " Kind=MethodRef Getter=\""
620 << Getter->getSelector().getAsString()
621 << "\" Setter=\"";
622 if (Setter)
623 OS << Setter->getSelector().getAsString();
624 else
625 OS << "(null)";
626 OS << "\"";
Daniel Dunbar7f8ea5c2008-08-30 05:35:15 +0000627}
628
Douglas Gregorcd9b46e2008-11-04 14:56:14 +0000629void StmtDumper::VisitObjCSuperExpr(ObjCSuperExpr *Node) {
630 DumpExpr(Node);
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000631 OS << " super";
Douglas Gregorcd9b46e2008-11-04 14:56:14 +0000632}
633
Chris Lattner6000dac2007-08-08 22:51:59 +0000634//===----------------------------------------------------------------------===//
635// Stmt method implementations
636//===----------------------------------------------------------------------===//
637
638/// dump - This does a local dump of the specified AST fragment. It dumps the
639/// specified node and a few nodes underneath it, but not the whole subtree.
640/// This is useful in a debugger.
Chris Lattnere300c872007-08-30 06:17:34 +0000641void Stmt::dump(SourceManager &SM) const {
Argyrios Kyrtzidis96680332010-08-09 10:54:31 +0000642 dump(llvm::errs(), SM);
643}
644
645void Stmt::dump(llvm::raw_ostream &OS, SourceManager &SM) const {
646 StmtDumper P(&SM, OS, 4);
Chris Lattnerb3938792007-08-30 00:53:54 +0000647 P.DumpSubTree(const_cast<Stmt*>(this));
Argyrios Kyrtzidis96680332010-08-09 10:54:31 +0000648 OS << "\n";
Chris Lattner0c727a32007-08-30 00:40:08 +0000649}
650
651/// dump - This does a local dump of the specified AST fragment. It dumps the
652/// specified node and a few nodes underneath it, but not the whole subtree.
653/// This is useful in a debugger.
Chris Lattner6000dac2007-08-08 22:51:59 +0000654void Stmt::dump() const {
Argyrios Kyrtzidis96680332010-08-09 10:54:31 +0000655 StmtDumper P(0, llvm::errs(), 4);
Chris Lattnerb3938792007-08-30 00:53:54 +0000656 P.DumpSubTree(const_cast<Stmt*>(this));
Argyrios Kyrtzidis96680332010-08-09 10:54:31 +0000657 llvm::errs() << "\n";
Chris Lattner0c727a32007-08-30 00:40:08 +0000658}
659
660/// dumpAll - This does a dump of the specified AST fragment and all subtrees.
Chris Lattnere300c872007-08-30 06:17:34 +0000661void Stmt::dumpAll(SourceManager &SM) const {
Argyrios Kyrtzidis96680332010-08-09 10:54:31 +0000662 StmtDumper P(&SM, llvm::errs(), ~0U);
Chris Lattnerb3938792007-08-30 00:53:54 +0000663 P.DumpSubTree(const_cast<Stmt*>(this));
Argyrios Kyrtzidis96680332010-08-09 10:54:31 +0000664 llvm::errs() << "\n";
Chris Lattner6000dac2007-08-08 22:51:59 +0000665}
666
667/// dumpAll - This does a dump of the specified AST fragment and all subtrees.
668void Stmt::dumpAll() const {
Argyrios Kyrtzidis96680332010-08-09 10:54:31 +0000669 StmtDumper P(0, llvm::errs(), ~0U);
Chris Lattnerb3938792007-08-30 00:53:54 +0000670 P.DumpSubTree(const_cast<Stmt*>(this));
Argyrios Kyrtzidis96680332010-08-09 10:54:31 +0000671 llvm::errs() << "\n";
Chris Lattner6000dac2007-08-08 22:51:59 +0000672}