blob: 22af23cc0e0d597be0e6083c65a1ed720d575d4a [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//
5// This file was developed by Chris Lattner and is distributed under
6// the University of Illinois Open Source License. See LICENSE.TXT for details.
7//
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"
16#include "clang/AST/Decl.h"
17#include "clang/AST/ExprCXX.h"
18#include "clang/Lex/IdentifierTable.h"
19#include "llvm/Support/Compiler.h"
20#include <cstdio>
21using namespace clang;
22
23//===----------------------------------------------------------------------===//
24// StmtDumper Visitor
25//===----------------------------------------------------------------------===//
26
27namespace {
Chris Lattnerc5598cb2007-08-21 04:04:25 +000028 class VISIBILITY_HIDDEN StmtDumper : public StmtVisitor<StmtDumper> {
Chris Lattner6000dac2007-08-08 22:51:59 +000029 FILE *F;
30 unsigned IndentLevel;
31
32 /// MaxDepth - When doing a normal dump (not dumpAll) we only want to dump
33 /// the first few levels of an AST. This keeps track of how many ast levels
34 /// are left.
35 unsigned MaxDepth;
36 public:
37 StmtDumper(FILE *f, unsigned maxDepth)
38 : F(f), IndentLevel(0), MaxDepth(maxDepth) {}
39
Chris Lattnerf9e05812007-08-09 18:03:18 +000040 void DumpSubTree(Stmt *S) {
Chris Lattner6000dac2007-08-08 22:51:59 +000041 // Prune the recursion if not using dump all.
42 if (MaxDepth == 0) return;
43
Chris Lattnerf9e05812007-08-09 18:03:18 +000044 ++IndentLevel;
Chris Lattner6000dac2007-08-08 22:51:59 +000045 if (S) {
Chris Lattnerc5598cb2007-08-21 04:04:25 +000046 Visit(S);
Chris Lattner6000dac2007-08-08 22:51:59 +000047 } else {
48 Indent();
49 fprintf(F, "<<<NULL>>>\n");
50 }
Chris Lattnerf9e05812007-08-09 18:03:18 +000051 --IndentLevel;
Chris Lattner6000dac2007-08-08 22:51:59 +000052 }
53
Chris Lattnerf9e05812007-08-09 18:03:18 +000054 void DumpDeclarator(Decl *D);
Chris Lattner6000dac2007-08-08 22:51:59 +000055
56 void Indent() const {
57 for (int i = 0, e = IndentLevel; i < e; ++i)
58 fprintf(F, " ");
59 }
60
Chris Lattnerfd8f7da2007-08-09 00:36:22 +000061 void DumpType(QualType T) const {
62 fprintf(F, "'%s'", T.getAsString().c_str());
63
64 // If the type is directly a typedef, strip off typedefness to give at
65 // least one level of concreteness.
66 if (TypedefType *TDT = dyn_cast<TypedefType>(T))
67 fprintf(F, ":'%s'", TDT->LookThroughTypedefs().getAsString().c_str());
68 }
69
Chris Lattner6000dac2007-08-08 22:51:59 +000070 void DumpStmt(const Stmt *Node) const {
71 Indent();
72 fprintf(F, "(%s %p", Node->getStmtClassName(), (void*)Node);
73 }
74
75 void DumpExpr(Expr *Node) const {
76 DumpStmt(Node);
Chris Lattnerfd8f7da2007-08-09 00:36:22 +000077 fprintf(F, " ");
78 DumpType(Node->getType());
Chris Lattner6000dac2007-08-08 22:51:59 +000079 }
80
Chris Lattnerc5598cb2007-08-21 04:04:25 +000081 void VisitStmt(Stmt *Node);
Chris Lattner6000dac2007-08-08 22:51:59 +000082#define STMT(N, CLASS, PARENT) \
Chris Lattnerc5598cb2007-08-21 04:04:25 +000083 void Visit##CLASS(CLASS *Node);
Chris Lattner6000dac2007-08-08 22:51:59 +000084#include "clang/AST/StmtNodes.def"
85 };
86}
87
88//===----------------------------------------------------------------------===//
89// Stmt printing methods.
90//===----------------------------------------------------------------------===//
91
92void StmtDumper::VisitStmt(Stmt *Node) {
93 Indent();
94 fprintf(F, "<<unknown stmt type>>\n");
95}
96
Chris Lattnerf9e05812007-08-09 18:03:18 +000097void StmtDumper::DumpDeclarator(Decl *D) {
Chris Lattner6000dac2007-08-08 22:51:59 +000098 // FIXME: Need to complete/beautify this... this code simply shows the
99 // nodes are where they need to be.
100 if (TypedefDecl *localType = dyn_cast<TypedefDecl>(D)) {
Chris Lattnerf9e05812007-08-09 18:03:18 +0000101 fprintf(F, "\"typedef %s %s\"",
102 localType->getUnderlyingType().getAsString().c_str(),
103 localType->getName());
Chris Lattner6000dac2007-08-08 22:51:59 +0000104 } else if (ValueDecl *VD = dyn_cast<ValueDecl>(D)) {
Chris Lattnerf9e05812007-08-09 18:03:18 +0000105 fprintf(F, "\"");
Chris Lattner6000dac2007-08-08 22:51:59 +0000106 // Emit storage class for vardecls.
107 if (VarDecl *V = dyn_cast<VarDecl>(VD)) {
108 switch (V->getStorageClass()) {
Chris Lattnerf9e05812007-08-09 18:03:18 +0000109 default: assert(0 && "Unknown storage class!");
110 case VarDecl::None: break;
111 case VarDecl::Extern: fprintf(F, "extern "); break;
112 case VarDecl::Static: fprintf(F, "static "); break;
113 case VarDecl::Auto: fprintf(F, "auto "); break;
114 case VarDecl::Register: fprintf(F, "register "); break;
Chris Lattner6000dac2007-08-08 22:51:59 +0000115 }
116 }
117
118 std::string Name = VD->getName();
119 VD->getType().getAsStringInternal(Name);
Chris Lattnerf9e05812007-08-09 18:03:18 +0000120 fprintf(F, "%s", Name.c_str());
Chris Lattner6000dac2007-08-08 22:51:59 +0000121
122 // If this is a vardecl with an initializer, emit it.
123 if (VarDecl *V = dyn_cast<VarDecl>(VD)) {
124 if (V->getInit()) {
Chris Lattnerf9e05812007-08-09 18:03:18 +0000125 fprintf(F, " =\n");
126 DumpSubTree(V->getInit());
Chris Lattner6000dac2007-08-08 22:51:59 +0000127 }
128 }
Chris Lattnerf9e05812007-08-09 18:03:18 +0000129 fprintf(F, "\"");
Chris Lattner6000dac2007-08-08 22:51:59 +0000130 } else {
131 // FIXME: "struct x;"
132 assert(0 && "Unexpected decl");
133 }
Chris Lattner6000dac2007-08-08 22:51:59 +0000134}
135
136
137void StmtDumper::VisitNullStmt(NullStmt *Node) {
138 DumpStmt(Node);
139 fprintf(F, ")");
140}
141
142void StmtDumper::VisitDeclStmt(DeclStmt *Node) {
143 DumpStmt(Node);
Chris Lattnerf9e05812007-08-09 18:03:18 +0000144 fprintf(F, "\n");
Chris Lattner6000dac2007-08-08 22:51:59 +0000145 for (Decl *D = Node->getDecl(); D; D = D->getNextDeclarator()) {
Chris Lattnerf9e05812007-08-09 18:03:18 +0000146 ++IndentLevel;
Chris Lattner6000dac2007-08-08 22:51:59 +0000147 Indent();
Chris Lattnerf9e05812007-08-09 18:03:18 +0000148 fprintf(F, "%p ", (void*)D);
149 DumpDeclarator(D);
150 if (D->getNextDeclarator())
151 fprintf(F, "\n");
152 --IndentLevel;
Chris Lattner6000dac2007-08-08 22:51:59 +0000153 }
Chris Lattnerf9e05812007-08-09 18:03:18 +0000154
155 fprintf(F, ")");
Chris Lattner6000dac2007-08-08 22:51:59 +0000156}
157
158void StmtDumper::VisitCompoundStmt(CompoundStmt *Node) {
159 DumpStmt(Node);
160 if (!Node->body_empty()) fprintf(F, "\n");
161
162 for (CompoundStmt::body_iterator I = Node->body_begin(), E = Node->body_end();
163 I != E; ) {
164 DumpSubTree(*I);
165 ++I;
166 if (I != E)
167 fprintf(F, "\n");
168 }
169 fprintf(F, ")");
170}
171
172void StmtDumper::VisitCaseStmt(CaseStmt *Node) {
Chris Lattnera0df31a2007-08-09 01:04:32 +0000173 DumpStmt(Node);
174 fprintf(F, "\n");
175 DumpSubTree(Node->getLHS());
176 fprintf(F, "\n");
177 DumpSubTree(Node->getRHS());
178 fprintf(F, "\n");
179 DumpSubTree(Node->getSubStmt());
180 fprintf(F, ")");
Chris Lattner6000dac2007-08-08 22:51:59 +0000181}
182
183void StmtDumper::VisitDefaultStmt(DefaultStmt *Node) {
184 DumpStmt(Node);
185 fprintf(F, "\n");
186 DumpSubTree(Node->getSubStmt());
187 fprintf(F, ")");
188}
189
190void StmtDumper::VisitLabelStmt(LabelStmt *Node) {
191 DumpStmt(Node);
192 fprintf(F, " '%s'\n", Node->getName());
193 DumpSubTree(Node->getSubStmt());
194 fprintf(F, "\n");
195}
196
197void StmtDumper::VisitIfStmt(IfStmt *Node) {
198 DumpStmt(Node);
199 fprintf(F, "\n");
200 DumpSubTree(Node->getCond());
201 fprintf(F, "\n");
202 DumpSubTree(Node->getThen());
203 fprintf(F, "\n");
204 DumpSubTree(Node->getElse());
205 fprintf(F, ")");
206}
207
208void StmtDumper::VisitSwitchStmt(SwitchStmt *Node) {
209 DumpStmt(Node);
210 fprintf(F, "\n");
211 DumpSubTree(Node->getCond());
212 fprintf(F, "\n");
213 DumpSubTree(Node->getBody());
214 fprintf(F, ")");
215}
216
217void StmtDumper::VisitSwitchCase(SwitchCase*) {
218 assert(0 && "SwitchCase is an abstract class");
219}
220
221void StmtDumper::VisitWhileStmt(WhileStmt *Node) {
222 DumpStmt(Node);
223 fprintf(F, "\n");
224 DumpSubTree(Node->getCond());
225 fprintf(F, "\n");
226 DumpSubTree(Node->getBody());
227 fprintf(F, ")");
228}
229
230void StmtDumper::VisitDoStmt(DoStmt *Node) {
231 DumpStmt(Node);
232 fprintf(F, "\n");
233 DumpSubTree(Node->getBody());
234 fprintf(F, "\n");
235 DumpSubTree(Node->getCond());
236 fprintf(F, ")");
237}
238
239void StmtDumper::VisitForStmt(ForStmt *Node) {
240 DumpStmt(Node);
241 fprintf(F, "\n");
242 DumpSubTree(Node->getInit());
243 fprintf(F, "\n");
244 DumpSubTree(Node->getCond());
245 fprintf(F, "\n");
246 DumpSubTree(Node->getInc());
247 fprintf(F, "\n");
248 DumpSubTree(Node->getBody());
249 fprintf(F, ")");
250}
251
252void StmtDumper::VisitGotoStmt(GotoStmt *Node) {
253 DumpStmt(Node);
254 fprintf(F, " '%s':%p)", Node->getLabel()->getName(), (void*)Node->getLabel());
255}
256
257void StmtDumper::VisitIndirectGotoStmt(IndirectGotoStmt *Node) {
258 DumpStmt(Node);
259 fprintf(F, "\n");
260 DumpSubTree(Node->getTarget());
261 fprintf(F, ")");
262}
263
264void StmtDumper::VisitContinueStmt(ContinueStmt *Node) {
265 DumpStmt(Node);
266 fprintf(F, ")");
267}
268
269void StmtDumper::VisitBreakStmt(BreakStmt *Node) {
270 DumpStmt(Node);
271 fprintf(F, ")");
272}
273
274
275void StmtDumper::VisitReturnStmt(ReturnStmt *Node) {
276 DumpStmt(Node);
277 if (Expr *RV = Node->getRetValue()) {
278 fprintf(F, "\n");
279 DumpSubTree(RV);
280 }
281 fprintf(F, ")");
282}
283
284//===----------------------------------------------------------------------===//
285// Expr printing methods.
286//===----------------------------------------------------------------------===//
287
288void StmtDumper::VisitExpr(Expr *Node) {
289 DumpExpr(Node);
290 fprintf(F, ": UNKNOWN EXPR to StmtDumper)");
291}
292
293void StmtDumper::VisitDeclRefExpr(DeclRefExpr *Node) {
294 DumpExpr(Node);
295 fprintf(F, " Decl='%s' %p)", Node->getDecl()->getName(),
296 (void*)Node->getDecl());
297}
298
299void StmtDumper::VisitPreDefinedExpr(PreDefinedExpr *Node) {
300 DumpExpr(Node);
301 switch (Node->getIdentType()) {
302 default:
303 assert(0 && "unknown case");
304 case PreDefinedExpr::Func:
305 fprintf(F, " __func__)");
306 break;
307 case PreDefinedExpr::Function:
308 fprintf(F, " __FUNCTION__)");
309 break;
310 case PreDefinedExpr::PrettyFunction:
311 fprintf(F, " __PRETTY_FUNCTION__)");
312 break;
313 }
314}
315
316void StmtDumper::VisitCharacterLiteral(CharacterLiteral *Node) {
Chris Lattnera0df31a2007-08-09 01:04:32 +0000317 DumpExpr(Node);
318 fprintf(F, " %d)", Node->getValue());
Chris Lattner6000dac2007-08-08 22:51:59 +0000319}
320
321void StmtDumper::VisitIntegerLiteral(IntegerLiteral *Node) {
322 DumpExpr(Node);
323
324 bool isSigned = Node->getType()->isSignedIntegerType();
325 fprintf(F, " %s)", Node->getValue().toString(10, isSigned).c_str());
326}
327void StmtDumper::VisitFloatingLiteral(FloatingLiteral *Node) {
328 DumpExpr(Node);
329 fprintf(F, " %f)", Node->getValue());
330}
331void StmtDumper::VisitStringLiteral(StringLiteral *Str) {
Chris Lattnera0df31a2007-08-09 01:04:32 +0000332 DumpExpr(Str);
333 // FIXME: this doesn't print wstrings right.
Chris Lattner5fc61072007-08-09 17:14:24 +0000334 fprintf(F, " %s\"", Str->isWide() ? "L" : "");
Chris Lattnera0df31a2007-08-09 01:04:32 +0000335
Chris Lattner6000dac2007-08-08 22:51:59 +0000336 for (unsigned i = 0, e = Str->getByteLength(); i != e; ++i) {
Chris Lattner5fc61072007-08-09 17:14:24 +0000337 switch (char C = Str->getStrData()[i]) {
338 default:
339 if (isprint(C))
340 fputc(C, F);
341 else
342 fprintf(F, "\\%03o", C);
343 break;
Chris Lattner6000dac2007-08-08 22:51:59 +0000344 // Handle some common ones to make dumps prettier.
Chris Lattner5fc61072007-08-09 17:14:24 +0000345 case '\\': fprintf(F, "\\\\"); break;
346 case '"': fprintf(F, "\\\""); break;
347 case '\n': fprintf(F, "\\n"); break;
348 case '\t': fprintf(F, "\\t"); break;
349 case '\a': fprintf(F, "\\a"); break;
350 case '\b': fprintf(F, "\\b"); break;
Chris Lattner6000dac2007-08-08 22:51:59 +0000351 }
352 }
Chris Lattner5fc61072007-08-09 17:14:24 +0000353 fprintf(F, "\")");
Chris Lattner6000dac2007-08-08 22:51:59 +0000354}
355void StmtDumper::VisitParenExpr(ParenExpr *Node) {
356 DumpExpr(Node);
357 fprintf(F, "\n");
358 DumpSubTree(Node->getSubExpr());
359 fprintf(F, ")");
360}
361void StmtDumper::VisitUnaryOperator(UnaryOperator *Node) {
Chris Lattner13cb21f2007-08-09 17:35:30 +0000362 DumpExpr(Node);
363 fprintf(F, " %s '%s'\n", Node->isPostfix() ? "postfix" : "prefix",
364 UnaryOperator::getOpcodeStr(Node->getOpcode()));
365 DumpSubTree(Node->getSubExpr());
366 fprintf(F, ")");
Chris Lattner6000dac2007-08-08 22:51:59 +0000367}
368void StmtDumper::VisitSizeOfAlignOfTypeExpr(SizeOfAlignOfTypeExpr *Node) {
Chris Lattner13cb21f2007-08-09 17:35:30 +0000369 DumpExpr(Node);
370 fprintf(F, " %s ", Node->isSizeOf() ? "sizeof" : "alignof");
371 DumpType(Node->getArgumentType());
372 fprintf(F, ")");
Chris Lattner6000dac2007-08-08 22:51:59 +0000373}
374void StmtDumper::VisitArraySubscriptExpr(ArraySubscriptExpr *Node) {
375 DumpExpr(Node);
376 fprintf(F, "\n");
Ted Kremenek23245122007-08-20 16:18:38 +0000377 DumpSubTree(Node->getLHS());
Chris Lattner6000dac2007-08-08 22:51:59 +0000378 fprintf(F, "\n");
Ted Kremenek23245122007-08-20 16:18:38 +0000379 DumpSubTree(Node->getRHS());
Chris Lattner6000dac2007-08-08 22:51:59 +0000380 fprintf(F, ")");
381}
382
383void StmtDumper::VisitCallExpr(CallExpr *Node) {
384 DumpExpr(Node);
385 fprintf(F, "\n");
386 DumpSubTree(Node->getCallee());
387
388 for (unsigned i = 0, e = Node->getNumArgs(); i != e; ++i) {
389 fprintf(F, "\n");
390 DumpSubTree(Node->getArg(i));
391 }
392 fprintf(F, ")");
393}
Chris Lattner13cb21f2007-08-09 17:35:30 +0000394
Chris Lattner6000dac2007-08-08 22:51:59 +0000395void StmtDumper::VisitMemberExpr(MemberExpr *Node) {
Chris Lattner13cb21f2007-08-09 17:35:30 +0000396 DumpExpr(Node);
397 fprintf(F, " %s%s %p\n", Node->isArrow() ? "->" : ".",
398 Node->getMemberDecl()->getName(), (void*)Node->getMemberDecl());
399 DumpSubTree(Node->getBase());
400 fprintf(F, ")");
Chris Lattner6000dac2007-08-08 22:51:59 +0000401}
402void StmtDumper::VisitOCUVectorElementExpr(OCUVectorElementExpr *Node) {
Chris Lattner13cb21f2007-08-09 17:35:30 +0000403 DumpExpr(Node);
404 fprintf(F, " %s\n", Node->getAccessor().getName());
405 DumpSubTree(Node->getBase());
406 fprintf(F, ")");
Chris Lattner6000dac2007-08-08 22:51:59 +0000407}
408void StmtDumper::VisitCastExpr(CastExpr *Node) {
Chris Lattner13cb21f2007-08-09 17:35:30 +0000409 DumpExpr(Node);
410 fprintf(F, "\n");
411 DumpSubTree(Node->getSubExpr());
412 fprintf(F, ")");
Chris Lattner6000dac2007-08-08 22:51:59 +0000413}
414void StmtDumper::VisitCompoundLiteralExpr(CompoundLiteralExpr *Node) {
Chris Lattner13cb21f2007-08-09 17:35:30 +0000415 DumpExpr(Node);
416 fprintf(F, "\n");
417 DumpSubTree(Node->getInitializer());
418 fprintf(F, ")");
Chris Lattner6000dac2007-08-08 22:51:59 +0000419}
420void StmtDumper::VisitImplicitCastExpr(ImplicitCastExpr *Node) {
421 DumpExpr(Node);
422 fprintf(F, "\n");
423 DumpSubTree(Node->getSubExpr());
424 fprintf(F, ")");
425}
426void StmtDumper::VisitBinaryOperator(BinaryOperator *Node) {
427 DumpExpr(Node);
428 fprintf(F, " '%s'\n", BinaryOperator::getOpcodeStr(Node->getOpcode()));
429 DumpSubTree(Node->getLHS());
430 fprintf(F, "\n");
431 DumpSubTree(Node->getRHS());
432 fprintf(F, ")");
433}
434void StmtDumper::VisitConditionalOperator(ConditionalOperator *Node) {
435 DumpExpr(Node);
436 fprintf(F, "\n");
437 DumpSubTree(Node->getCond());
438 fprintf(F, "\n");
439 DumpSubTree(Node->getLHS());
440 fprintf(F, "\n");
441 DumpSubTree(Node->getRHS());
442 fprintf(F, ")");
443}
444
445// GNU extensions.
446
447void StmtDumper::VisitAddrLabelExpr(AddrLabelExpr *Node) {
Chris Lattner13cb21f2007-08-09 17:35:30 +0000448 DumpExpr(Node);
449 fprintf(F, " %s %p)", Node->getLabel()->getName(), (void*)Node->getLabel());
Chris Lattner6000dac2007-08-08 22:51:59 +0000450}
451
Chris Lattner13cb21f2007-08-09 17:35:30 +0000452void StmtDumper::VisitStmtExpr(StmtExpr *Node) {
453 DumpExpr(Node);
454 fprintf(F, "\n");
455 DumpSubTree(Node->getSubStmt());
456 fprintf(F, ")");
Chris Lattner6000dac2007-08-08 22:51:59 +0000457}
458
459void StmtDumper::VisitTypesCompatibleExpr(TypesCompatibleExpr *Node) {
Chris Lattner13cb21f2007-08-09 17:35:30 +0000460 DumpExpr(Node);
461 fprintf(F, " ");
462 DumpType(Node->getArgType1());
463 fprintf(F, " ");
464 DumpType(Node->getArgType2());
465 fprintf(F, ")");
Chris Lattner6000dac2007-08-08 22:51:59 +0000466}
467
468void StmtDumper::VisitChooseExpr(ChooseExpr *Node) {
Chris Lattner13cb21f2007-08-09 17:35:30 +0000469 DumpExpr(Node);
470 fprintf(F, "\n");
471 DumpSubTree(Node->getCond());
472 fprintf(F, "\n");
473 DumpSubTree(Node->getLHS());
474 fprintf(F, "\n");
475 DumpSubTree(Node->getRHS());
476 fprintf(F, ")");
Chris Lattner6000dac2007-08-08 22:51:59 +0000477}
478
Chris Lattnerf9e05812007-08-09 18:03:18 +0000479//===----------------------------------------------------------------------===//
480// C++ Expressions
481//===----------------------------------------------------------------------===//
Chris Lattner6000dac2007-08-08 22:51:59 +0000482
483void StmtDumper::VisitCXXCastExpr(CXXCastExpr *Node) {
Chris Lattner13cb21f2007-08-09 17:35:30 +0000484 DumpExpr(Node);
485 fprintf(F, " %s\n", CXXCastExpr::getOpcodeStr(Node->getOpcode()));
486 DumpSubTree(Node->getSubExpr());
487 fprintf(F, ")");
Chris Lattner6000dac2007-08-08 22:51:59 +0000488}
489
490void StmtDumper::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *Node) {
Chris Lattner13cb21f2007-08-09 17:35:30 +0000491 DumpExpr(Node);
492 fprintf(F, " %s)", Node->getValue() ? "true" : "false");
Chris Lattner6000dac2007-08-08 22:51:59 +0000493}
494
Anders Carlsson55085182007-08-21 17:43:55 +0000495//===----------------------------------------------------------------------===//
496// Obj-C Expressions
497//===----------------------------------------------------------------------===//
498
499void StmtDumper::VisitObjCStringLiteral(ObjCStringLiteral *Node) {
500 DumpExpr(Node);
501 fprintf(F, "\n");
502 DumpSubTree(Node->getString());
503 fprintf(F, ")");
504}
Chris Lattner6000dac2007-08-08 22:51:59 +0000505
506//===----------------------------------------------------------------------===//
507// Stmt method implementations
508//===----------------------------------------------------------------------===//
509
510/// dump - This does a local dump of the specified AST fragment. It dumps the
511/// specified node and a few nodes underneath it, but not the whole subtree.
512/// This is useful in a debugger.
513void Stmt::dump() const {
514 StmtDumper P(stderr, 4);
Chris Lattnerc5598cb2007-08-21 04:04:25 +0000515 P.Visit(const_cast<Stmt*>(this));
Chris Lattneree41ce52007-08-10 21:51:12 +0000516 fprintf(stderr, "\n");
Chris Lattner6000dac2007-08-08 22:51:59 +0000517}
518
519/// dumpAll - This does a dump of the specified AST fragment and all subtrees.
520void Stmt::dumpAll() const {
521 StmtDumper P(stderr, ~0U);
Chris Lattnerc5598cb2007-08-21 04:04:25 +0000522 P.Visit(const_cast<Stmt*>(this));
Chris Lattneree41ce52007-08-10 21:51:12 +0000523 fprintf(stderr, "\n");
Chris Lattner6000dac2007-08-08 22:51:59 +0000524}