blob: f74556931dfd7270d1df6cb1844095e9bcf624fa [file] [log] [blame]
Chris Lattnercbe4f772007-08-08 22:51:59 +00001//===--- StmtDumper.cpp - Dumping implementation for Stmt ASTs ------------===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner5b12ab82007-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 Lattnercbe4f772007-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 Kremenek5c84c012007-10-17 18:36:42 +000016#include "clang/AST/DeclObjC.h"
Douglas Gregor889ceb72009-02-03 19:21:40 +000017#include "clang/AST/DeclCXX.h"
Douglas Gregor7de59662009-05-29 20:38:28 +000018#include "clang/AST/PrettyPrinter.h"
Chris Lattner11e30d32007-08-30 06:17:34 +000019#include "clang/Basic/SourceManager.h"
Daniel Dunbar34a96c82009-12-03 09:13:13 +000020#include "llvm/Support/raw_ostream.h"
Chris Lattnercbe4f772007-08-08 22:51:59 +000021using namespace clang;
22
23//===----------------------------------------------------------------------===//
24// StmtDumper Visitor
25//===----------------------------------------------------------------------===//
26
27namespace {
Benjamin Kramer26222b62009-11-28 19:03:38 +000028 class StmtDumper : public StmtVisitor<StmtDumper> {
Chris Lattner11e30d32007-08-30 06:17:34 +000029 SourceManager *SM;
Daniel Dunbar34a96c82009-12-03 09:13:13 +000030 llvm::raw_ostream &OS;
Chris Lattnercbe4f772007-08-08 22:51:59 +000031 unsigned IndentLevel;
Mike Stump11289f42009-09-09 15:08:12 +000032
Chris Lattnercbe4f772007-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 Stump11289f42009-09-09 15:08:12 +000037
Chris Lattner11e30d32007-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 Gregor7de59662009-05-29 20:38:28 +000042
Chris Lattnercbe4f772007-08-08 22:51:59 +000043 public:
Daniel Dunbar34a96c82009-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 Lattner11e30d32007-08-30 06:17:34 +000046 LastLocFilename = "";
47 LastLocLine = ~0U;
48 }
Mike Stump11289f42009-09-09 15:08:12 +000049
Chris Lattner8f184b12007-08-09 18:03:18 +000050 void DumpSubTree(Stmt *S) {
Chris Lattnercbe4f772007-08-08 22:51:59 +000051 // Prune the recursion if not using dump all.
52 if (MaxDepth == 0) return;
Mike Stump11289f42009-09-09 15:08:12 +000053
Chris Lattner8f184b12007-08-09 18:03:18 +000054 ++IndentLevel;
Chris Lattnercbe4f772007-08-08 22:51:59 +000055 if (S) {
Ted Kremenek433a4922007-12-12 06:59:42 +000056 if (DeclStmt* DS = dyn_cast<DeclStmt>(S))
57 VisitDeclStmt(DS);
Mike Stump11289f42009-09-09 15:08:12 +000058 else {
Ted Kremenek433a4922007-12-12 06:59:42 +000059 Visit(S);
Mike Stump11289f42009-09-09 15:08:12 +000060
Ted Kremenek433a4922007-12-12 06:59:42 +000061 // Print out children.
John McCall8322c3a2011-02-13 04:07:26 +000062 Stmt::child_range CI = S->children();
63 if (CI) {
64 while (CI) {
Daniel Dunbar34a96c82009-12-03 09:13:13 +000065 OS << '\n';
Ted Kremenek433a4922007-12-12 06:59:42 +000066 DumpSubTree(*CI++);
67 }
Chris Lattnercfb83dd2007-08-30 00:53:54 +000068 }
69 }
Chris Lattneredde8a92010-05-25 17:56:43 +000070 OS << ')';
Chris Lattnercbe4f772007-08-08 22:51:59 +000071 } else {
72 Indent();
Daniel Dunbar34a96c82009-12-03 09:13:13 +000073 OS << "<<<NULL>>>";
Chris Lattnercbe4f772007-08-08 22:51:59 +000074 }
Chris Lattner8f184b12007-08-09 18:03:18 +000075 --IndentLevel;
Chris Lattnercbe4f772007-08-08 22:51:59 +000076 }
Mike Stump11289f42009-09-09 15:08:12 +000077
Chris Lattner8f184b12007-08-09 18:03:18 +000078 void DumpDeclarator(Decl *D);
Mike Stump11289f42009-09-09 15:08:12 +000079
Chris Lattnercbe4f772007-08-08 22:51:59 +000080 void Indent() const {
81 for (int i = 0, e = IndentLevel; i < e; ++i)
Daniel Dunbar34a96c82009-12-03 09:13:13 +000082 OS << " ";
Chris Lattnercbe4f772007-08-08 22:51:59 +000083 }
Mike Stump11289f42009-09-09 15:08:12 +000084
Steve Naroff42a350a2007-09-01 21:08:38 +000085 void DumpType(QualType T) {
John McCall717d9b02010-12-10 11:01:00 +000086 SplitQualType T_split = T.split();
87 OS << "'" << QualType::getAsString(T_split) << "'";
Chris Lattner9bcd9152007-08-09 00:36:22 +000088
Douglas Gregor58354032008-12-24 00:01:03 +000089 if (!T.isNull()) {
John McCall8ccfcb52009-09-24 19:53:00 +000090 // If the type is sugared, also dump a (shallow) desugared type.
John McCall717d9b02010-12-10 11:01:00 +000091 SplitQualType D_split = T.getSplitDesugaredType();
92 if (T_split != D_split)
93 OS << ":'" << QualType::getAsString(D_split) << "'";
Chris Lattner091718d2008-04-02 05:06:23 +000094 }
Chris Lattner9bcd9152007-08-09 00:36:22 +000095 }
John McCall351762c2011-02-07 10:33:21 +000096 void DumpDeclRef(Decl *node);
Steve Naroff42a350a2007-09-01 21:08:38 +000097 void DumpStmt(const Stmt *Node) {
Chris Lattnercbe4f772007-08-08 22:51:59 +000098 Indent();
Daniel Dunbar34a96c82009-12-03 09:13:13 +000099 OS << "(" << Node->getStmtClassName()
100 << " " << (void*)Node;
Steve Naroff42a350a2007-09-01 21:08:38 +0000101 DumpSourceRange(Node);
Chris Lattnercbe4f772007-08-08 22:51:59 +0000102 }
John McCall7decc9e2010-11-18 06:31:45 +0000103 void DumpValueKind(ExprValueKind K) {
104 switch (K) {
105 case VK_RValue: break;
106 case VK_LValue: OS << " lvalue"; break;
107 case VK_XValue: OS << " xvalue"; break;
108 }
109 }
110 void DumpObjectKind(ExprObjectKind K) {
111 switch (K) {
112 case OK_Ordinary: break;
113 case OK_BitField: OS << " bitfield"; break;
114 case OK_ObjCProperty: OS << " objcproperty"; break;
115 case OK_VectorComponent: OS << " vectorcomponent"; break;
116 }
117 }
Steve Naroff42a350a2007-09-01 21:08:38 +0000118 void DumpExpr(const Expr *Node) {
Chris Lattnercbe4f772007-08-08 22:51:59 +0000119 DumpStmt(Node);
Daniel Dunbar34a96c82009-12-03 09:13:13 +0000120 OS << ' ';
Chris Lattner9bcd9152007-08-09 00:36:22 +0000121 DumpType(Node->getType());
John McCall7decc9e2010-11-18 06:31:45 +0000122 DumpValueKind(Node->getValueKind());
123 DumpObjectKind(Node->getObjectKind());
Chris Lattnercbe4f772007-08-08 22:51:59 +0000124 }
Steve Naroff42a350a2007-09-01 21:08:38 +0000125 void DumpSourceRange(const Stmt *Node);
Chris Lattner11e30d32007-08-30 06:17:34 +0000126 void DumpLocation(SourceLocation Loc);
Mike Stump11289f42009-09-09 15:08:12 +0000127
Chris Lattner84ca3762007-08-30 01:00:35 +0000128 // Stmts.
Chris Lattner62249a62007-08-21 04:04:25 +0000129 void VisitStmt(Stmt *Node);
Ted Kremenek433a4922007-12-12 06:59:42 +0000130 void VisitDeclStmt(DeclStmt *Node);
Chris Lattner84ca3762007-08-30 01:00:35 +0000131 void VisitLabelStmt(LabelStmt *Node);
132 void VisitGotoStmt(GotoStmt *Node);
Mike Stump11289f42009-09-09 15:08:12 +0000133
Chris Lattner84ca3762007-08-30 01:00:35 +0000134 // Exprs
135 void VisitExpr(Expr *Node);
Anders Carlssond7923c62009-08-22 23:33:40 +0000136 void VisitCastExpr(CastExpr *Node);
Chris Lattner84ca3762007-08-30 01:00:35 +0000137 void VisitDeclRefExpr(DeclRefExpr *Node);
Chris Lattner6307f192008-08-10 01:53:14 +0000138 void VisitPredefinedExpr(PredefinedExpr *Node);
Chris Lattner84ca3762007-08-30 01:00:35 +0000139 void VisitCharacterLiteral(CharacterLiteral *Node);
140 void VisitIntegerLiteral(IntegerLiteral *Node);
141 void VisitFloatingLiteral(FloatingLiteral *Node);
142 void VisitStringLiteral(StringLiteral *Str);
143 void VisitUnaryOperator(UnaryOperator *Node);
Peter Collingbournee190dee2011-03-11 19:24:49 +0000144 void VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *Node);
Chris Lattner84ca3762007-08-30 01:00:35 +0000145 void VisitMemberExpr(MemberExpr *Node);
Nate Begemance4d7fc2008-04-18 23:10:10 +0000146 void VisitExtVectorElementExpr(ExtVectorElementExpr *Node);
Chris Lattner84ca3762007-08-30 01:00:35 +0000147 void VisitBinaryOperator(BinaryOperator *Node);
148 void VisitCompoundAssignOperator(CompoundAssignOperator *Node);
149 void VisitAddrLabelExpr(AddrLabelExpr *Node);
John McCall351762c2011-02-07 10:33:21 +0000150 void VisitBlockExpr(BlockExpr *Node);
Chris Lattner84ca3762007-08-30 01:00:35 +0000151
152 // C++
Douglas Gregore200adc2008-10-27 19:41:14 +0000153 void VisitCXXNamedCastExpr(CXXNamedCastExpr *Node);
Chris Lattner84ca3762007-08-30 01:00:35 +0000154 void VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *Node);
Douglas Gregor8ea1f532008-11-04 14:56:14 +0000155 void VisitCXXThisExpr(CXXThisExpr *Node);
Douglas Gregore200adc2008-10-27 19:41:14 +0000156 void VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *Node);
Anders Carlsson073846832009-08-12 00:21:52 +0000157 void VisitCXXConstructExpr(CXXConstructExpr *Node);
158 void VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *Node);
John McCall5d413782010-12-06 08:20:24 +0000159 void VisitExprWithCleanups(ExprWithCleanups *Node);
John McCall76d09942009-12-11 21:50:11 +0000160 void VisitUnresolvedLookupExpr(UnresolvedLookupExpr *Node);
Anders Carlsson073846832009-08-12 00:21:52 +0000161 void DumpCXXTemporary(CXXTemporary *Temporary);
Mike Stump11289f42009-09-09 15:08:12 +0000162
Chris Lattner84ca3762007-08-30 01:00:35 +0000163 // ObjC
Douglas Gregor96c79492010-04-23 22:50:49 +0000164 void VisitObjCAtCatchStmt(ObjCAtCatchStmt *Node);
Chris Lattner84ca3762007-08-30 01:00:35 +0000165 void VisitObjCEncodeExpr(ObjCEncodeExpr *Node);
Ted Kremenek36748da2008-02-29 22:04:05 +0000166 void VisitObjCMessageExpr(ObjCMessageExpr* Node);
Fariborz Jahanian4bef4622007-10-16 20:40:23 +0000167 void VisitObjCSelectorExpr(ObjCSelectorExpr *Node);
Fariborz Jahaniana32aaef2007-10-17 16:58:11 +0000168 void VisitObjCProtocolExpr(ObjCProtocolExpr *Node);
Daniel Dunbar4b8c6db2008-08-30 05:35:15 +0000169 void VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *Node);
Steve Naroff5d5efca2008-03-12 13:19:12 +0000170 void VisitObjCIvarRefExpr(ObjCIvarRefExpr *Node);
Chris Lattnercbe4f772007-08-08 22:51:59 +0000171 };
172}
173
174//===----------------------------------------------------------------------===//
Chris Lattner11e30d32007-08-30 06:17:34 +0000175// Utilities
176//===----------------------------------------------------------------------===//
177
178void StmtDumper::DumpLocation(SourceLocation Loc) {
Chris Lattner53e384f2009-01-16 07:00:02 +0000179 SourceLocation SpellingLoc = SM->getSpellingLoc(Loc);
Mike Stump11289f42009-09-09 15:08:12 +0000180
Chris Lattner11e30d32007-08-30 06:17:34 +0000181 // The general format we print out is filename:line:col, but we drop pieces
182 // that haven't changed since the last loc printed.
Chris Lattnerf1ca7d32009-01-27 07:57:44 +0000183 PresumedLoc PLoc = SM->getPresumedLoc(SpellingLoc);
184
Douglas Gregor453b0122010-11-12 07:15:47 +0000185 if (PLoc.isInvalid()) {
186 OS << "<invalid sloc>";
187 return;
188 }
189
Chris Lattnerf1ca7d32009-01-27 07:57:44 +0000190 if (strcmp(PLoc.getFilename(), LastLocFilename) != 0) {
Daniel Dunbar34a96c82009-12-03 09:13:13 +0000191 OS << PLoc.getFilename() << ':' << PLoc.getLine()
192 << ':' << PLoc.getColumn();
Chris Lattnerf1ca7d32009-01-27 07:57:44 +0000193 LastLocFilename = PLoc.getFilename();
194 LastLocLine = PLoc.getLine();
195 } else if (PLoc.getLine() != LastLocLine) {
Daniel Dunbar34a96c82009-12-03 09:13:13 +0000196 OS << "line" << ':' << PLoc.getLine()
197 << ':' << PLoc.getColumn();
Chris Lattnerf1ca7d32009-01-27 07:57:44 +0000198 LastLocLine = PLoc.getLine();
Chris Lattner11e30d32007-08-30 06:17:34 +0000199 } else {
Daniel Dunbar34a96c82009-12-03 09:13:13 +0000200 OS << "col" << ':' << PLoc.getColumn();
Chris Lattner11e30d32007-08-30 06:17:34 +0000201 }
202}
203
Steve Naroff42a350a2007-09-01 21:08:38 +0000204void StmtDumper::DumpSourceRange(const Stmt *Node) {
Chris Lattner11e30d32007-08-30 06:17:34 +0000205 // Can't translate locations if a SourceManager isn't available.
206 if (SM == 0) return;
Mike Stump11289f42009-09-09 15:08:12 +0000207
Chris Lattner11e30d32007-08-30 06:17:34 +0000208 // TODO: If the parent expression is available, we can print a delta vs its
209 // location.
210 SourceRange R = Node->getSourceRange();
Mike Stump11289f42009-09-09 15:08:12 +0000211
Daniel Dunbar34a96c82009-12-03 09:13:13 +0000212 OS << " <";
Chris Lattnera7c19fe2007-10-16 22:36:42 +0000213 DumpLocation(R.getBegin());
214 if (R.getBegin() != R.getEnd()) {
Daniel Dunbar34a96c82009-12-03 09:13:13 +0000215 OS << ", ";
Chris Lattnera7c19fe2007-10-16 22:36:42 +0000216 DumpLocation(R.getEnd());
Chris Lattner11e30d32007-08-30 06:17:34 +0000217 }
Daniel Dunbar34a96c82009-12-03 09:13:13 +0000218 OS << ">";
Mike Stump11289f42009-09-09 15:08:12 +0000219
Chris Lattner11e30d32007-08-30 06:17:34 +0000220 // <t2.c:123:421[blah], t2.c:412:321>
221
222}
223
224
225//===----------------------------------------------------------------------===//
Chris Lattnercbe4f772007-08-08 22:51:59 +0000226// Stmt printing methods.
227//===----------------------------------------------------------------------===//
228
229void StmtDumper::VisitStmt(Stmt *Node) {
Chris Lattner84ca3762007-08-30 01:00:35 +0000230 DumpStmt(Node);
Chris Lattnercbe4f772007-08-08 22:51:59 +0000231}
232
Chris Lattner8f184b12007-08-09 18:03:18 +0000233void StmtDumper::DumpDeclarator(Decl *D) {
Chris Lattnercbe4f772007-08-08 22:51:59 +0000234 // FIXME: Need to complete/beautify this... this code simply shows the
235 // nodes are where they need to be.
236 if (TypedefDecl *localType = dyn_cast<TypedefDecl>(D)) {
Daniel Dunbar34a96c82009-12-03 09:13:13 +0000237 OS << "\"typedef " << localType->getUnderlyingType().getAsString()
Benjamin Kramerb11416d2010-04-17 09:33:03 +0000238 << ' ' << localType << '"';
Richard Smithdda56e42011-04-15 14:24:37 +0000239 } else if (TypeAliasDecl *localType = dyn_cast<TypeAliasDecl>(D)) {
240 OS << "\"using " << localType << " = "
241 << localType->getUnderlyingType().getAsString() << '"';
Chris Lattnercbe4f772007-08-08 22:51:59 +0000242 } else if (ValueDecl *VD = dyn_cast<ValueDecl>(D)) {
Daniel Dunbar34a96c82009-12-03 09:13:13 +0000243 OS << "\"";
Chris Lattnercbe4f772007-08-08 22:51:59 +0000244 // Emit storage class for vardecls.
245 if (VarDecl *V = dyn_cast<VarDecl>(VD)) {
John McCall8e7d6562010-08-26 03:08:43 +0000246 if (V->getStorageClass() != SC_None)
Daniel Dunbar34a96c82009-12-03 09:13:13 +0000247 OS << VarDecl::getStorageClassSpecifierString(V->getStorageClass())
248 << " ";
Chris Lattnercbe4f772007-08-08 22:51:59 +0000249 }
Mike Stump11289f42009-09-09 15:08:12 +0000250
Chris Lattner1cbaacc2008-11-24 04:00:27 +0000251 std::string Name = VD->getNameAsString();
Mike Stump11289f42009-09-09 15:08:12 +0000252 VD->getType().getAsStringInternal(Name,
Chris Lattnerc61089a2009-06-30 01:26:17 +0000253 PrintingPolicy(VD->getASTContext().getLangOptions()));
Daniel Dunbar34a96c82009-12-03 09:13:13 +0000254 OS << Name;
Mike Stump11289f42009-09-09 15:08:12 +0000255
Chris Lattnercbe4f772007-08-08 22:51:59 +0000256 // If this is a vardecl with an initializer, emit it.
257 if (VarDecl *V = dyn_cast<VarDecl>(VD)) {
258 if (V->getInit()) {
Daniel Dunbar34a96c82009-12-03 09:13:13 +0000259 OS << " =\n";
Chris Lattner8f184b12007-08-09 18:03:18 +0000260 DumpSubTree(V->getInit());
Chris Lattnercbe4f772007-08-08 22:51:59 +0000261 }
262 }
Daniel Dunbar34a96c82009-12-03 09:13:13 +0000263 OS << '"';
Steve Naroff14f5f792007-11-17 21:37:36 +0000264 } else if (TagDecl *TD = dyn_cast<TagDecl>(D)) {
265 // print a free standing tag decl (e.g. "struct x;").
266 const char *tagname;
267 if (const IdentifierInfo *II = TD->getIdentifier())
Daniel Dunbar2c422dc92009-10-18 20:26:12 +0000268 tagname = II->getNameStart();
Steve Naroff14f5f792007-11-17 21:37:36 +0000269 else
270 tagname = "<anonymous>";
Daniel Dunbar34a96c82009-12-03 09:13:13 +0000271 OS << '"' << TD->getKindName() << ' ' << tagname << ";\"";
Steve Naroff14f5f792007-11-17 21:37:36 +0000272 // FIXME: print tag bodies.
Douglas Gregor889ceb72009-02-03 19:21:40 +0000273 } else if (UsingDirectiveDecl *UD = dyn_cast<UsingDirectiveDecl>(D)) {
274 // print using-directive decl (e.g. "using namespace x;")
275 const char *ns;
276 if (const IdentifierInfo *II = UD->getNominatedNamespace()->getIdentifier())
Daniel Dunbar2c422dc92009-10-18 20:26:12 +0000277 ns = II->getNameStart();
Douglas Gregor889ceb72009-02-03 19:21:40 +0000278 else
279 ns = "<anonymous>";
Daniel Dunbar34a96c82009-12-03 09:13:13 +0000280 OS << '"' << UD->getDeclKindName() << ns << ";\"";
Sebastian Redl80fecff2010-05-04 10:20:17 +0000281 } else if (UsingDecl *UD = dyn_cast<UsingDecl>(D)) {
282 // print using decl (e.g. "using std::string;")
283 const char *tn = UD->isTypeName() ? "typename " : "";
284 OS << '"' << UD->getDeclKindName() << tn;
Douglas Gregora9d87bc2011-02-25 00:36:19 +0000285 UD->getQualifier()->print(OS,
286 PrintingPolicy(UD->getASTContext().getLangOptions()));
Sebastian Redl80fecff2010-05-04 10:20:17 +0000287 OS << ";\"";
Chris Lattner43e7f312011-02-18 02:08:43 +0000288 } else if (LabelDecl *LD = dyn_cast<LabelDecl>(D)) {
289 OS << "label " << LD->getNameAsString();
Peter Collingbourne7d8a0b52011-03-16 18:37:27 +0000290 } else if (StaticAssertDecl *SAD = dyn_cast<StaticAssertDecl>(D)) {
291 OS << "\"static_assert(\n";
292 DumpSubTree(SAD->getAssertExpr());
293 OS << ",\n";
294 DumpSubTree(SAD->getMessage());
295 OS << ");\"";
Chris Lattnercbe4f772007-08-08 22:51:59 +0000296 } else {
Chris Lattnercbe4f772007-08-08 22:51:59 +0000297 assert(0 && "Unexpected decl");
298 }
Chris Lattnercbe4f772007-08-08 22:51:59 +0000299}
300
Ted Kremenek433a4922007-12-12 06:59:42 +0000301void StmtDumper::VisitDeclStmt(DeclStmt *Node) {
302 DumpStmt(Node);
Daniel Dunbar34a96c82009-12-03 09:13:13 +0000303 OS << "\n";
Ted Kremenek62408482008-10-06 18:38:35 +0000304 for (DeclStmt::decl_iterator DI = Node->decl_begin(), DE = Node->decl_end();
305 DI != DE; ++DI) {
Douglas Gregor6e6ad602009-01-20 01:17:11 +0000306 Decl* D = *DI;
Ted Kremenek433a4922007-12-12 06:59:42 +0000307 ++IndentLevel;
308 Indent();
Daniel Dunbar34a96c82009-12-03 09:13:13 +0000309 OS << (void*) D << " ";
Ted Kremenek433a4922007-12-12 06:59:42 +0000310 DumpDeclarator(D);
Chris Lattner3d954d52009-03-29 16:04:50 +0000311 if (DI+1 != DE)
Daniel Dunbar34a96c82009-12-03 09:13:13 +0000312 OS << "\n";
Ted Kremenek433a4922007-12-12 06:59:42 +0000313 --IndentLevel;
314 }
315}
316
Chris Lattnercbe4f772007-08-08 22:51:59 +0000317void StmtDumper::VisitLabelStmt(LabelStmt *Node) {
318 DumpStmt(Node);
Daniel Dunbar34a96c82009-12-03 09:13:13 +0000319 OS << " '" << Node->getName() << "'";
Chris Lattnercbe4f772007-08-08 22:51:59 +0000320}
321
Chris Lattnercbe4f772007-08-08 22:51:59 +0000322void StmtDumper::VisitGotoStmt(GotoStmt *Node) {
323 DumpStmt(Node);
Daniel Dunbar34a96c82009-12-03 09:13:13 +0000324 OS << " '" << Node->getLabel()->getName()
325 << "':" << (void*)Node->getLabel();
Chris Lattnercbe4f772007-08-08 22:51:59 +0000326}
327
Chris Lattnercbe4f772007-08-08 22:51:59 +0000328//===----------------------------------------------------------------------===//
329// Expr printing methods.
330//===----------------------------------------------------------------------===//
331
332void StmtDumper::VisitExpr(Expr *Node) {
333 DumpExpr(Node);
Chris Lattnercbe4f772007-08-08 22:51:59 +0000334}
335
Anders Carlssona70cff62010-04-24 19:06:50 +0000336static void DumpBasePath(llvm::raw_ostream &OS, CastExpr *Node) {
John McCallcf142162010-08-07 06:22:56 +0000337 if (Node->path_empty())
Anders Carlssona70cff62010-04-24 19:06:50 +0000338 return;
339
340 OS << " (";
341 bool First = true;
John McCallcf142162010-08-07 06:22:56 +0000342 for (CastExpr::path_iterator
343 I = Node->path_begin(), E = Node->path_end(); I != E; ++I) {
Anders Carlssona70cff62010-04-24 19:06:50 +0000344 const CXXBaseSpecifier *Base = *I;
345 if (!First)
346 OS << " -> ";
347
348 const CXXRecordDecl *RD =
349 cast<CXXRecordDecl>(Base->getType()->getAs<RecordType>()->getDecl());
350
351 if (Base->isVirtual())
352 OS << "virtual ";
353 OS << RD->getName();
354 First = false;
355 }
356
357 OS << ')';
358}
359
Anders Carlssond7923c62009-08-22 23:33:40 +0000360void StmtDumper::VisitCastExpr(CastExpr *Node) {
361 DumpExpr(Node);
Anders Carlssona70cff62010-04-24 19:06:50 +0000362 OS << " <" << Node->getCastKindName();
363 DumpBasePath(OS, Node);
364 OS << ">";
Anders Carlssond7923c62009-08-22 23:33:40 +0000365}
366
Chris Lattnercbe4f772007-08-08 22:51:59 +0000367void StmtDumper::VisitDeclRefExpr(DeclRefExpr *Node) {
368 DumpExpr(Node);
Ted Kremenek5f64ca82007-09-10 17:32:55 +0000369
Daniel Dunbar34a96c82009-12-03 09:13:13 +0000370 OS << " ";
John McCall351762c2011-02-07 10:33:21 +0000371 DumpDeclRef(Node->getDecl());
372}
373
374void StmtDumper::DumpDeclRef(Decl *d) {
375 OS << d->getDeclKindName() << ' ' << (void*) d;
376
377 if (NamedDecl *nd = dyn_cast<NamedDecl>(d)) {
378 OS << " '";
379 nd->getDeclName().printName(OS);
380 OS << "'";
Ted Kremenek5f64ca82007-09-10 17:32:55 +0000381 }
Mike Stump11289f42009-09-09 15:08:12 +0000382
John McCall351762c2011-02-07 10:33:21 +0000383 if (ValueDecl *vd = dyn_cast<ValueDecl>(d)) {
384 OS << ' '; DumpType(vd->getType());
385 }
Chris Lattnercbe4f772007-08-08 22:51:59 +0000386}
387
John McCall76d09942009-12-11 21:50:11 +0000388void StmtDumper::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *Node) {
389 DumpExpr(Node);
390 OS << " (";
391 if (!Node->requiresADL()) OS << "no ";
Benjamin Kramerb11416d2010-04-17 09:33:03 +0000392 OS << "ADL) = '" << Node->getName() << '\'';
John McCall76d09942009-12-11 21:50:11 +0000393
394 UnresolvedLookupExpr::decls_iterator
395 I = Node->decls_begin(), E = Node->decls_end();
396 if (I == E) OS << " empty";
397 for (; I != E; ++I)
398 OS << " " << (void*) *I;
399}
400
Steve Naroff5d5efca2008-03-12 13:19:12 +0000401void StmtDumper::VisitObjCIvarRefExpr(ObjCIvarRefExpr *Node) {
Steve Naroffe3fa7132008-05-23 00:59:14 +0000402 DumpExpr(Node);
Steve Naroff5d5efca2008-03-12 13:19:12 +0000403
Daniel Dunbar34a96c82009-12-03 09:13:13 +0000404 OS << " " << Node->getDecl()->getDeclKindName()
Benjamin Kramerb11416d2010-04-17 09:33:03 +0000405 << "Decl='" << Node->getDecl()
Daniel Dunbar34a96c82009-12-03 09:13:13 +0000406 << "' " << (void*)Node->getDecl();
Steve Naroffb3424a92008-05-23 22:01:24 +0000407 if (Node->isFreeIvar())
Daniel Dunbar34a96c82009-12-03 09:13:13 +0000408 OS << " isFreeIvar";
Steve Naroff5d5efca2008-03-12 13:19:12 +0000409}
410
Chris Lattner6307f192008-08-10 01:53:14 +0000411void StmtDumper::VisitPredefinedExpr(PredefinedExpr *Node) {
Chris Lattnercbe4f772007-08-08 22:51:59 +0000412 DumpExpr(Node);
413 switch (Node->getIdentType()) {
Chris Lattnera9b3cae2008-06-21 18:04:54 +0000414 default: assert(0 && "unknown case");
Daniel Dunbar34a96c82009-12-03 09:13:13 +0000415 case PredefinedExpr::Func: OS << " __func__"; break;
416 case PredefinedExpr::Function: OS << " __FUNCTION__"; break;
417 case PredefinedExpr::PrettyFunction: OS << " __PRETTY_FUNCTION__";break;
Chris Lattnercbe4f772007-08-08 22:51:59 +0000418 }
419}
420
421void StmtDumper::VisitCharacterLiteral(CharacterLiteral *Node) {
Chris Lattner273a1ea2007-08-09 01:04:32 +0000422 DumpExpr(Node);
Daniel Dunbar34a96c82009-12-03 09:13:13 +0000423 OS << Node->getValue();
Chris Lattnercbe4f772007-08-08 22:51:59 +0000424}
425
426void StmtDumper::VisitIntegerLiteral(IntegerLiteral *Node) {
427 DumpExpr(Node);
428
429 bool isSigned = Node->getType()->isSignedIntegerType();
Daniel Dunbar34a96c82009-12-03 09:13:13 +0000430 OS << " " << Node->getValue().toString(10, isSigned);
Chris Lattnercbe4f772007-08-08 22:51:59 +0000431}
432void StmtDumper::VisitFloatingLiteral(FloatingLiteral *Node) {
433 DumpExpr(Node);
Daniel Dunbar34a96c82009-12-03 09:13:13 +0000434 OS << " " << Node->getValueAsApproximateDouble();
Chris Lattnercbe4f772007-08-08 22:51:59 +0000435}
Chris Lattner1c20a172007-08-26 03:42:43 +0000436
Chris Lattnercbe4f772007-08-08 22:51:59 +0000437void StmtDumper::VisitStringLiteral(StringLiteral *Str) {
Chris Lattner273a1ea2007-08-09 01:04:32 +0000438 DumpExpr(Str);
439 // FIXME: this doesn't print wstrings right.
Daniel Dunbar34a96c82009-12-03 09:13:13 +0000440 OS << " ";
441 if (Str->isWide())
442 OS << "L";
443 OS << '"';
Benjamin Kramer35b077e2010-08-17 12:54:38 +0000444 OS.write_escaped(Str->getString());
Daniel Dunbar34a96c82009-12-03 09:13:13 +0000445 OS << '"';
Chris Lattnercbe4f772007-08-08 22:51:59 +0000446}
Chris Lattner84ca3762007-08-30 01:00:35 +0000447
Chris Lattnercbe4f772007-08-08 22:51:59 +0000448void StmtDumper::VisitUnaryOperator(UnaryOperator *Node) {
Chris Lattnerdb3b3ff2007-08-09 17:35:30 +0000449 DumpExpr(Node);
Daniel Dunbar34a96c82009-12-03 09:13:13 +0000450 OS << " " << (Node->isPostfix() ? "postfix" : "prefix")
451 << " '" << UnaryOperator::getOpcodeStr(Node->getOpcode()) << "'";
Chris Lattnercbe4f772007-08-08 22:51:59 +0000452}
Peter Collingbournee190dee2011-03-11 19:24:49 +0000453void StmtDumper::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *Node) {
Chris Lattnerdb3b3ff2007-08-09 17:35:30 +0000454 DumpExpr(Node);
Peter Collingbournee190dee2011-03-11 19:24:49 +0000455 switch(Node->getKind()) {
456 case UETT_SizeOf:
457 OS << " sizeof ";
458 break;
459 case UETT_AlignOf:
460 OS << " __alignof ";
461 break;
462 case UETT_VecStep:
463 OS << " vec_step ";
464 break;
465 }
Sebastian Redl6f282892008-11-11 17:56:53 +0000466 if (Node->isArgumentType())
467 DumpType(Node->getArgumentType());
Chris Lattnercbe4f772007-08-08 22:51:59 +0000468}
Chris Lattnerdb3b3ff2007-08-09 17:35:30 +0000469
Chris Lattnercbe4f772007-08-08 22:51:59 +0000470void StmtDumper::VisitMemberExpr(MemberExpr *Node) {
Chris Lattnerdb3b3ff2007-08-09 17:35:30 +0000471 DumpExpr(Node);
Daniel Dunbar34a96c82009-12-03 09:13:13 +0000472 OS << " " << (Node->isArrow() ? "->" : ".")
Benjamin Kramerb11416d2010-04-17 09:33:03 +0000473 << Node->getMemberDecl() << ' '
Daniel Dunbar34a96c82009-12-03 09:13:13 +0000474 << (void*)Node->getMemberDecl();
Chris Lattnercbe4f772007-08-08 22:51:59 +0000475}
Nate Begemance4d7fc2008-04-18 23:10:10 +0000476void StmtDumper::VisitExtVectorElementExpr(ExtVectorElementExpr *Node) {
Chris Lattnerdb3b3ff2007-08-09 17:35:30 +0000477 DumpExpr(Node);
Daniel Dunbar34a96c82009-12-03 09:13:13 +0000478 OS << " " << Node->getAccessor().getNameStart();
Chris Lattnercbe4f772007-08-08 22:51:59 +0000479}
Chris Lattnercbe4f772007-08-08 22:51:59 +0000480void StmtDumper::VisitBinaryOperator(BinaryOperator *Node) {
481 DumpExpr(Node);
Daniel Dunbar34a96c82009-12-03 09:13:13 +0000482 OS << " '" << BinaryOperator::getOpcodeStr(Node->getOpcode()) << "'";
Chris Lattner86928112007-08-25 02:00:02 +0000483}
484void StmtDumper::VisitCompoundAssignOperator(CompoundAssignOperator *Node) {
485 DumpExpr(Node);
Daniel Dunbar34a96c82009-12-03 09:13:13 +0000486 OS << " '" << BinaryOperator::getOpcodeStr(Node->getOpcode())
487 << "' ComputeLHSTy=";
Eli Friedman8b7b1b12009-03-28 01:22:36 +0000488 DumpType(Node->getComputationLHSType());
Daniel Dunbar34a96c82009-12-03 09:13:13 +0000489 OS << " ComputeResultTy=";
Eli Friedman8b7b1b12009-03-28 01:22:36 +0000490 DumpType(Node->getComputationResultType());
Chris Lattnercbe4f772007-08-08 22:51:59 +0000491}
Chris Lattnercbe4f772007-08-08 22:51:59 +0000492
John McCall351762c2011-02-07 10:33:21 +0000493void StmtDumper::VisitBlockExpr(BlockExpr *Node) {
494 DumpExpr(Node);
495
496 IndentLevel++;
497 BlockDecl *block = Node->getBlockDecl();
498 if (block->capturesCXXThis()) {
499 OS << '\n'; Indent(); OS << "(capture this)";
500 }
501 for (BlockDecl::capture_iterator
502 i = block->capture_begin(), e = block->capture_end(); i != e; ++i) {
503 OS << '\n';
504 Indent();
505 OS << "(capture ";
506 if (i->isByRef()) OS << "byref ";
507 if (i->isNested()) OS << "nested ";
508 DumpDeclRef(i->getVariable());
509 if (i->hasCopyExpr()) DumpSubTree(i->getCopyExpr());
510 OS << ")";
511 }
512 IndentLevel--;
513
514 DumpSubTree(block->getBody());
515}
516
Chris Lattnercbe4f772007-08-08 22:51:59 +0000517// GNU extensions.
518
519void StmtDumper::VisitAddrLabelExpr(AddrLabelExpr *Node) {
Chris Lattnerdb3b3ff2007-08-09 17:35:30 +0000520 DumpExpr(Node);
Daniel Dunbar34a96c82009-12-03 09:13:13 +0000521 OS << " " << Node->getLabel()->getName()
522 << " " << (void*)Node->getLabel();
Chris Lattnercbe4f772007-08-08 22:51:59 +0000523}
524
Chris Lattner8f184b12007-08-09 18:03:18 +0000525//===----------------------------------------------------------------------===//
526// C++ Expressions
527//===----------------------------------------------------------------------===//
Chris Lattnercbe4f772007-08-08 22:51:59 +0000528
Douglas Gregore200adc2008-10-27 19:41:14 +0000529void StmtDumper::VisitCXXNamedCastExpr(CXXNamedCastExpr *Node) {
Chris Lattnerdb3b3ff2007-08-09 17:35:30 +0000530 DumpExpr(Node);
Daniel Dunbar34a96c82009-12-03 09:13:13 +0000531 OS << " " << Node->getCastName()
532 << "<" << Node->getTypeAsWritten().getAsString() << ">"
Anders Carlssona70cff62010-04-24 19:06:50 +0000533 << " <" << Node->getCastKindName();
534 DumpBasePath(OS, Node);
535 OS << ">";
Chris Lattnercbe4f772007-08-08 22:51:59 +0000536}
537
538void StmtDumper::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *Node) {
Chris Lattnerdb3b3ff2007-08-09 17:35:30 +0000539 DumpExpr(Node);
Daniel Dunbar34a96c82009-12-03 09:13:13 +0000540 OS << " " << (Node->getValue() ? "true" : "false");
Chris Lattnercbe4f772007-08-08 22:51:59 +0000541}
542
Douglas Gregor8ea1f532008-11-04 14:56:14 +0000543void StmtDumper::VisitCXXThisExpr(CXXThisExpr *Node) {
544 DumpExpr(Node);
Daniel Dunbar34a96c82009-12-03 09:13:13 +0000545 OS << " this";
Douglas Gregor8ea1f532008-11-04 14:56:14 +0000546}
547
Douglas Gregore200adc2008-10-27 19:41:14 +0000548void StmtDumper::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *Node) {
549 DumpExpr(Node);
Daniel Dunbar34a96c82009-12-03 09:13:13 +0000550 OS << " functional cast to " << Node->getTypeAsWritten().getAsString();
Douglas Gregore200adc2008-10-27 19:41:14 +0000551}
552
Anders Carlsson073846832009-08-12 00:21:52 +0000553void StmtDumper::VisitCXXConstructExpr(CXXConstructExpr *Node) {
554 DumpExpr(Node);
John McCalleba90cd2010-02-02 19:03:45 +0000555 CXXConstructorDecl *Ctor = Node->getConstructor();
556 DumpType(Ctor->getType());
Anders Carlsson073846832009-08-12 00:21:52 +0000557 if (Node->isElidable())
Daniel Dunbar34a96c82009-12-03 09:13:13 +0000558 OS << " elidable";
John McCall85370042010-08-07 06:38:55 +0000559 if (Node->requiresZeroInitialization())
560 OS << " zeroing";
Anders Carlsson073846832009-08-12 00:21:52 +0000561}
562
563void StmtDumper::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *Node) {
564 DumpExpr(Node);
Daniel Dunbar34a96c82009-12-03 09:13:13 +0000565 OS << " ";
Anders Carlsson073846832009-08-12 00:21:52 +0000566 DumpCXXTemporary(Node->getTemporary());
567}
568
John McCall5d413782010-12-06 08:20:24 +0000569void StmtDumper::VisitExprWithCleanups(ExprWithCleanups *Node) {
Anders Carlsson073846832009-08-12 00:21:52 +0000570 DumpExpr(Node);
571 ++IndentLevel;
572 for (unsigned i = 0, e = Node->getNumTemporaries(); i != e; ++i) {
Daniel Dunbar34a96c82009-12-03 09:13:13 +0000573 OS << "\n";
Anders Carlsson073846832009-08-12 00:21:52 +0000574 Indent();
575 DumpCXXTemporary(Node->getTemporary(i));
576 }
577 --IndentLevel;
578}
579
580void StmtDumper::DumpCXXTemporary(CXXTemporary *Temporary) {
Daniel Dunbar34a96c82009-12-03 09:13:13 +0000581 OS << "(CXXTemporary " << (void *)Temporary << ")";
Anders Carlsson073846832009-08-12 00:21:52 +0000582}
583
Anders Carlsson76f4a902007-08-21 17:43:55 +0000584//===----------------------------------------------------------------------===//
585// Obj-C Expressions
586//===----------------------------------------------------------------------===//
587
Ted Kremenek36748da2008-02-29 22:04:05 +0000588void StmtDumper::VisitObjCMessageExpr(ObjCMessageExpr* Node) {
589 DumpExpr(Node);
Daniel Dunbar34a96c82009-12-03 09:13:13 +0000590 OS << " selector=" << Node->getSelector().getAsString();
Douglas Gregor9a129192010-04-21 00:45:42 +0000591 switch (Node->getReceiverKind()) {
592 case ObjCMessageExpr::Instance:
593 break;
594
595 case ObjCMessageExpr::Class:
596 OS << " class=";
597 DumpType(Node->getClassReceiver());
598 break;
599
600 case ObjCMessageExpr::SuperInstance:
601 OS << " super (instance)";
602 break;
603
604 case ObjCMessageExpr::SuperClass:
605 OS << " super (class)";
606 break;
607 }
Ted Kremenek36748da2008-02-29 22:04:05 +0000608}
609
Douglas Gregor96c79492010-04-23 22:50:49 +0000610void StmtDumper::VisitObjCAtCatchStmt(ObjCAtCatchStmt *Node) {
611 DumpStmt(Node);
Douglas Gregor46a572b2010-04-26 16:46:50 +0000612 if (VarDecl *CatchParam = Node->getCatchParamDecl()) {
Douglas Gregor96c79492010-04-23 22:50:49 +0000613 OS << " catch parm = ";
614 DumpDeclarator(CatchParam);
615 } else {
616 OS << " catch all";
617 }
618}
619
Anders Carlssonc5a81eb2007-08-22 15:14:15 +0000620void StmtDumper::VisitObjCEncodeExpr(ObjCEncodeExpr *Node) {
621 DumpExpr(Node);
Daniel Dunbar34a96c82009-12-03 09:13:13 +0000622 OS << " ";
Anders Carlssonc5a81eb2007-08-22 15:14:15 +0000623 DumpType(Node->getEncodedType());
Anders Carlssonc5a81eb2007-08-22 15:14:15 +0000624}
625
Fariborz Jahanian4bef4622007-10-16 20:40:23 +0000626void StmtDumper::VisitObjCSelectorExpr(ObjCSelectorExpr *Node) {
627 DumpExpr(Node);
Mike Stump11289f42009-09-09 15:08:12 +0000628
Daniel Dunbar34a96c82009-12-03 09:13:13 +0000629 OS << " " << Node->getSelector().getAsString();
Fariborz Jahanian4bef4622007-10-16 20:40:23 +0000630}
631
Fariborz Jahaniana32aaef2007-10-17 16:58:11 +0000632void StmtDumper::VisitObjCProtocolExpr(ObjCProtocolExpr *Node) {
633 DumpExpr(Node);
Mike Stump11289f42009-09-09 15:08:12 +0000634
Benjamin Kramerb11416d2010-04-17 09:33:03 +0000635 OS << ' ' << Node->getProtocol();
Fariborz Jahaniana32aaef2007-10-17 16:58:11 +0000636}
Daniel Dunbar4b8c6db2008-08-30 05:35:15 +0000637
638void StmtDumper::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *Node) {
639 DumpExpr(Node);
John McCallb7bd14f2010-12-02 01:19:52 +0000640 if (Node->isImplicitProperty()) {
Fariborz Jahanian0f0b3022010-12-22 19:46:35 +0000641 OS << " Kind=MethodRef Getter=\"";
642 if (Node->getImplicitPropertyGetter())
643 OS << Node->getImplicitPropertyGetter()->getSelector().getAsString();
644 else
645 OS << "(null)";
646
647 OS << "\" Setter=\"";
John McCallb7bd14f2010-12-02 01:19:52 +0000648 if (ObjCMethodDecl *Setter = Node->getImplicitPropertySetter())
649 OS << Setter->getSelector().getAsString();
650 else
651 OS << "(null)";
652 OS << "\"";
653 } else {
654 OS << " Kind=PropertyRef Property=\"" << Node->getExplicitProperty() << '"';
655 }
Fariborz Jahanian8a1810f2008-11-22 18:39:36 +0000656
Fariborz Jahanian681c0752010-10-14 16:04:05 +0000657 if (Node->isSuperReceiver())
658 OS << " super";
Douglas Gregor8ea1f532008-11-04 14:56:14 +0000659}
660
Chris Lattnercbe4f772007-08-08 22:51:59 +0000661//===----------------------------------------------------------------------===//
662// Stmt method implementations
663//===----------------------------------------------------------------------===//
664
665/// dump - This does a local dump of the specified AST fragment. It dumps the
666/// specified node and a few nodes underneath it, but not the whole subtree.
667/// This is useful in a debugger.
Chris Lattner11e30d32007-08-30 06:17:34 +0000668void Stmt::dump(SourceManager &SM) const {
Argyrios Kyrtzidisc049f752010-08-09 10:54:31 +0000669 dump(llvm::errs(), SM);
670}
671
672void Stmt::dump(llvm::raw_ostream &OS, SourceManager &SM) const {
673 StmtDumper P(&SM, OS, 4);
Chris Lattnercfb83dd2007-08-30 00:53:54 +0000674 P.DumpSubTree(const_cast<Stmt*>(this));
Argyrios Kyrtzidisc049f752010-08-09 10:54:31 +0000675 OS << "\n";
Chris Lattner779d5d92007-08-30 00:40:08 +0000676}
677
678/// dump - This does a local dump of the specified AST fragment. It dumps the
679/// specified node and a few nodes underneath it, but not the whole subtree.
680/// This is useful in a debugger.
Chris Lattnercbe4f772007-08-08 22:51:59 +0000681void Stmt::dump() const {
Argyrios Kyrtzidisc049f752010-08-09 10:54:31 +0000682 StmtDumper P(0, llvm::errs(), 4);
Chris Lattnercfb83dd2007-08-30 00:53:54 +0000683 P.DumpSubTree(const_cast<Stmt*>(this));
Argyrios Kyrtzidisc049f752010-08-09 10:54:31 +0000684 llvm::errs() << "\n";
Chris Lattner779d5d92007-08-30 00:40:08 +0000685}
686
687/// dumpAll - This does a dump of the specified AST fragment and all subtrees.
Chris Lattner11e30d32007-08-30 06:17:34 +0000688void Stmt::dumpAll(SourceManager &SM) const {
Argyrios Kyrtzidisc049f752010-08-09 10:54:31 +0000689 StmtDumper P(&SM, llvm::errs(), ~0U);
Chris Lattnercfb83dd2007-08-30 00:53:54 +0000690 P.DumpSubTree(const_cast<Stmt*>(this));
Argyrios Kyrtzidisc049f752010-08-09 10:54:31 +0000691 llvm::errs() << "\n";
Chris Lattnercbe4f772007-08-08 22:51:59 +0000692}
693
694/// dumpAll - This does a dump of the specified AST fragment and all subtrees.
695void Stmt::dumpAll() const {
Argyrios Kyrtzidisc049f752010-08-09 10:54:31 +0000696 StmtDumper P(0, llvm::errs(), ~0U);
Chris Lattnercfb83dd2007-08-30 00:53:54 +0000697 P.DumpSubTree(const_cast<Stmt*>(this));
Argyrios Kyrtzidisc049f752010-08-09 10:54:31 +0000698 llvm::errs() << "\n";
Chris Lattnercbe4f772007-08-08 22:51:59 +0000699}