blob: 7fe1524c58c49a68e856027191e5bf10edc287db [file] [log] [blame]
Reid Spencer5f016e22007-07-11 17:01:13 +00001//===--- StmtPrinter.cpp - Printing 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.
Reid Spencer5f016e22007-07-11 17:01:13 +00007//
8//===----------------------------------------------------------------------===//
9//
Chris Lattner6000dac2007-08-08 22:51:59 +000010// This file implements the Stmt::dumpPretty/Stmt::printPretty methods, which
11// pretty print the AST back out to C code.
Reid Spencer5f016e22007-07-11 17:01:13 +000012//
13//===----------------------------------------------------------------------===//
14
15#include "clang/AST/StmtVisitor.h"
Douglas Gregor1a49af92009-01-06 05:10:23 +000016#include "clang/AST/DeclCXX.h"
Ted Kremenek91d1d7a2007-10-17 18:36:42 +000017#include "clang/AST/DeclObjC.h"
Ted Kremenek42a509f2007-08-31 21:30:12 +000018#include "clang/AST/PrettyPrinter.h"
Reid Spencer5f016e22007-07-11 17:01:13 +000019#include "llvm/Support/Compiler.h"
Ted Kremenek51221ec2007-11-26 22:50:46 +000020#include "llvm/Support/Streams.h"
Ted Kremeneka95d3752008-09-13 05:16:45 +000021#include "llvm/Support/Format.h"
Reid Spencer5f016e22007-07-11 17:01:13 +000022using namespace clang;
23
24//===----------------------------------------------------------------------===//
25// StmtPrinter Visitor
26//===----------------------------------------------------------------------===//
27
28namespace {
Chris Lattnerc5598cb2007-08-21 04:04:25 +000029 class VISIBILITY_HIDDEN StmtPrinter : public StmtVisitor<StmtPrinter> {
Ted Kremeneka95d3752008-09-13 05:16:45 +000030 llvm::raw_ostream &OS;
Reid Spencer5f016e22007-07-11 17:01:13 +000031 unsigned IndentLevel;
Ted Kremenek42a509f2007-08-31 21:30:12 +000032 clang::PrinterHelper* Helper;
Douglas Gregord249e1d1f2009-05-29 20:38:28 +000033 PrintingPolicy Policy;
34
Reid Spencer5f016e22007-07-11 17:01:13 +000035 public:
Douglas Gregord249e1d1f2009-05-29 20:38:28 +000036 StmtPrinter(llvm::raw_ostream &os, PrinterHelper* helper,
37 const PrintingPolicy &Policy = PrintingPolicy(),
38 unsigned Indentation = 0)
39 : OS(os), IndentLevel(Indentation), Helper(helper), Policy(Policy) {}
Reid Spencer5f016e22007-07-11 17:01:13 +000040
Douglas Gregord249e1d1f2009-05-29 20:38:28 +000041 void PrintStmt(Stmt *S) {
42 PrintStmt(S, Policy.Indentation);
43 }
44
45 void PrintStmt(Stmt *S, int SubIndent) {
Reid Spencer5f016e22007-07-11 17:01:13 +000046 IndentLevel += SubIndent;
47 if (S && isa<Expr>(S)) {
48 // If this is an expr used in a stmt context, indent and newline it.
49 Indent();
Chris Lattnerc5598cb2007-08-21 04:04:25 +000050 Visit(S);
Reid Spencer5f016e22007-07-11 17:01:13 +000051 OS << ";\n";
52 } else if (S) {
Chris Lattnerc5598cb2007-08-21 04:04:25 +000053 Visit(S);
Reid Spencer5f016e22007-07-11 17:01:13 +000054 } else {
55 Indent() << "<<<NULL STATEMENT>>>\n";
56 }
57 IndentLevel -= SubIndent;
58 }
Eli Friedmandb23b152009-05-30 00:19:54 +000059
60 QualType GetBaseType(QualType T);
61 void PrintBaseType(QualType T, TagDecl* TD);
62 void PrintDeclIdentifier(NamedDecl* ND);
Reid Spencer5f016e22007-07-11 17:01:13 +000063 void PrintRawCompoundStmt(CompoundStmt *S);
64 void PrintRawDecl(Decl *D);
Ted Kremenekecd64c52008-10-06 18:39:36 +000065 void PrintRawDeclStmt(DeclStmt *S);
Mike Stump071e4da2009-02-10 20:16:46 +000066 void PrintFieldDecl(FieldDecl *FD);
Eli Friedmandb23b152009-05-30 00:19:54 +000067 void PrintEnumConstantDecl(EnumConstantDecl *ECD);
Reid Spencer5f016e22007-07-11 17:01:13 +000068 void PrintRawIfStmt(IfStmt *If);
Sebastian Redl8351da02008-12-22 21:35:02 +000069 void PrintRawCXXCatchStmt(CXXCatchStmt *Catch);
Reid Spencer5f016e22007-07-11 17:01:13 +000070
71 void PrintExpr(Expr *E) {
72 if (E)
Chris Lattnerc5598cb2007-08-21 04:04:25 +000073 Visit(E);
Reid Spencer5f016e22007-07-11 17:01:13 +000074 else
75 OS << "<null expr>";
76 }
77
Mike Stump071e4da2009-02-10 20:16:46 +000078 llvm::raw_ostream &Indent(int Delta = 0) {
Douglas Gregord249e1d1f2009-05-29 20:38:28 +000079 for (int i = 0, e = IndentLevel+Delta; i < e; ++i)
80 OS << " ";
Reid Spencer5f016e22007-07-11 17:01:13 +000081 return OS;
82 }
83
Chris Lattner704fe352007-08-30 17:59:59 +000084 bool PrintOffsetOfDesignator(Expr *E);
85 void VisitUnaryOffsetOf(UnaryOperator *Node);
86
Ted Kremenek42a509f2007-08-31 21:30:12 +000087 void Visit(Stmt* S) {
88 if (Helper && Helper->handledStmt(S,OS))
89 return;
90 else StmtVisitor<StmtPrinter>::Visit(S);
91 }
92
Chris Lattnerc5598cb2007-08-21 04:04:25 +000093 void VisitStmt(Stmt *Node);
Douglas Gregorf2cad862008-11-14 12:46:07 +000094#define STMT(CLASS, PARENT) \
Chris Lattnerc5598cb2007-08-21 04:04:25 +000095 void Visit##CLASS(CLASS *Node);
Reid Spencer5f016e22007-07-11 17:01:13 +000096#include "clang/AST/StmtNodes.def"
97 };
98}
99
100//===----------------------------------------------------------------------===//
101// Stmt printing methods.
102//===----------------------------------------------------------------------===//
103
104void StmtPrinter::VisitStmt(Stmt *Node) {
105 Indent() << "<<unknown stmt type>>\n";
106}
107
108/// PrintRawCompoundStmt - Print a compound stmt without indenting the {, and
109/// with no newline after the }.
110void StmtPrinter::PrintRawCompoundStmt(CompoundStmt *Node) {
111 OS << "{\n";
112 for (CompoundStmt::body_iterator I = Node->body_begin(), E = Node->body_end();
113 I != E; ++I)
114 PrintStmt(*I);
115
116 Indent() << "}";
117}
118
Eli Friedmandb23b152009-05-30 00:19:54 +0000119QualType StmtPrinter::GetBaseType(QualType T) {
120 // FIXME: This should be on the Type class!
121 QualType BaseType = T;
122 while (!BaseType->isSpecifierType()) {
123 if (isa<TypedefType>(BaseType))
124 break;
125 else if (const PointerType* PTy = BaseType->getAsPointerType())
126 BaseType = PTy->getPointeeType();
127 else if (const ArrayType* ATy = dyn_cast<ArrayType>(BaseType))
128 BaseType = ATy->getElementType();
129 else if (const FunctionType* FTy = BaseType->getAsFunctionType())
130 BaseType = FTy->getResultType();
131 else
132 assert(0 && "Unknown declarator!");
133 }
134 return BaseType;
135}
136
137void StmtPrinter::PrintBaseType(QualType BaseType, TagDecl* TD) {
138 std::string BaseString;
139 if (TD && TD->isDefinition()) {
140 // FIXME: This is an ugly hack; perhaps we can expose something better
141 // from Type.h?
142 if (BaseType.isConstQualified())
143 OS << "const ";
144 PrintRawDecl(TD);
145 OS << " ";
146 } else {
147 BaseType.getAsStringInternal(BaseString, Policy);
148 OS << BaseString << " ";
149 }
150}
151
152void StmtPrinter::PrintDeclIdentifier(NamedDecl* ND) {
153 std::string Name = ND->getNameAsString();
154
155 QualType Ty;
156 if (TypedefDecl* TDD = dyn_cast<TypedefDecl>(ND)) {
157 Ty = TDD->getUnderlyingType();
158 } else if (ValueDecl* VD = dyn_cast<ValueDecl>(ND)) {
159 Ty = VD->getType();
160 } else {
161 assert(0 && "Unexpected decl");
162 }
163
164 PrintingPolicy SubPolicy(Policy);
165 SubPolicy.SuppressTypeSpecifiers = true;
166 Ty.getAsStringInternal(Name, SubPolicy);
167 OS << Name;
168}
169
Reid Spencer5f016e22007-07-11 17:01:13 +0000170void StmtPrinter::PrintRawDecl(Decl *D) {
171 // FIXME: Need to complete/beautify this... this code simply shows the
172 // nodes are where they need to be.
173 if (TypedefDecl *localType = dyn_cast<TypedefDecl>(D)) {
174 OS << "typedef " << localType->getUnderlyingType().getAsString();
Chris Lattner39f34e92008-11-24 04:00:27 +0000175 OS << " " << localType->getNameAsString();
Reid Spencer5f016e22007-07-11 17:01:13 +0000176 } else if (ValueDecl *VD = dyn_cast<ValueDecl>(D)) {
177 // Emit storage class for vardecls.
178 if (VarDecl *V = dyn_cast<VarDecl>(VD)) {
Daniel Dunbar5466c7b2009-04-14 02:25:56 +0000179 if (V->getStorageClass() != VarDecl::None)
180 OS << VarDecl::getStorageClassSpecifierString(V->getStorageClass())
181 << ' ';
Reid Spencer5f016e22007-07-11 17:01:13 +0000182 }
183
Chris Lattner39f34e92008-11-24 04:00:27 +0000184 std::string Name = VD->getNameAsString();
Douglas Gregord249e1d1f2009-05-29 20:38:28 +0000185 VD->getType().getAsStringInternal(Name, Policy);
Reid Spencer5f016e22007-07-11 17:01:13 +0000186 OS << Name;
187
Chris Lattner24c39902007-07-12 00:36:32 +0000188 // If this is a vardecl with an initializer, emit it.
189 if (VarDecl *V = dyn_cast<VarDecl>(VD)) {
190 if (V->getInit()) {
191 OS << " = ";
192 PrintExpr(V->getInit());
193 }
194 }
Steve Naroff91578f32007-11-17 21:21:01 +0000195 } else if (TagDecl *TD = dyn_cast<TagDecl>(D)) {
196 // print a free standing tag decl (e.g. "struct x;").
197 OS << TD->getKindName();
198 OS << " ";
199 if (const IdentifierInfo *II = TD->getIdentifier())
200 OS << II->getName();
Eli Friedmandb23b152009-05-30 00:19:54 +0000201 if (TD->isDefinition()) {
202 if (RecordDecl *RD = dyn_cast<RecordDecl>(TD)) {
203 OS << "{\n";
204 IndentLevel += 1;
205 // FIXME: The context passed to field_begin/field_end should
206 // never be NULL!
207 ASTContext *Context = 0;
208 for (RecordDecl::field_iterator i = RD->field_begin(*Context);
209 i != RD->field_end(*Context); ++i)
210 PrintFieldDecl(*i);
211 IndentLevel -= 1;
212 Indent() << "}";
213 } else if (EnumDecl *ED = dyn_cast<EnumDecl>(TD)) {
214 OS << "{\n";
215 IndentLevel += 1;
216 // FIXME: The context shouldn't be NULL!
217 ASTContext *Context = 0;
218 for (EnumDecl::enumerator_iterator i = ED->enumerator_begin(*Context);
219 i != ED->enumerator_end(*Context); ++i)
220 PrintEnumConstantDecl(*i);
221 IndentLevel -= 1;
222 Indent() << "}";
Mike Stump071e4da2009-02-10 20:16:46 +0000223 }
224 }
Reid Spencer5f016e22007-07-11 17:01:13 +0000225 } else {
Reid Spencer5f016e22007-07-11 17:01:13 +0000226 assert(0 && "Unexpected decl");
227 }
228}
229
Mike Stump071e4da2009-02-10 20:16:46 +0000230void StmtPrinter::PrintFieldDecl(FieldDecl *FD) {
Eli Friedmandb23b152009-05-30 00:19:54 +0000231 Indent();
232 QualType BaseType = GetBaseType(FD->getType());
233 PrintBaseType(BaseType, 0);
234 PrintDeclIdentifier(FD);
235 if (FD->isBitField()) {
236 OS << " : ";
237 PrintExpr(FD->getBitWidth());
238 }
239 OS << ";\n";
240}
241
242void StmtPrinter::PrintEnumConstantDecl(EnumConstantDecl *ECD) {
243 Indent() << ECD->getNameAsString();
244 if (ECD->getInitExpr()) {
245 OS << " = ";
246 PrintExpr(ECD->getInitExpr());
247 }
248 OS << ",\n";
Mike Stump071e4da2009-02-10 20:16:46 +0000249}
250
Ted Kremenekecd64c52008-10-06 18:39:36 +0000251void StmtPrinter::PrintRawDeclStmt(DeclStmt *S) {
Eli Friedmandb23b152009-05-30 00:19:54 +0000252 DeclStmt::decl_iterator Begin = S->decl_begin(), End = S->decl_end();
253
254 TagDecl* TD = dyn_cast<TagDecl>(*Begin);
255 if (TD)
256 ++Begin;
257
258 if (isa<TypedefDecl>(*Begin))
259 OS << "typedef ";
260 else if (VarDecl *V = dyn_cast<VarDecl>(*Begin)) {
261 switch (V->getStorageClass()) {
262 default: assert(0 && "Unknown storage class!");
263 case VarDecl::None: break;
264 case VarDecl::Auto: OS << "auto "; break;
265 case VarDecl::Register: OS << "register "; break;
266 case VarDecl::Extern: OS << "extern "; break;
267 case VarDecl::Static: OS << "static "; break;
268 case VarDecl::PrivateExtern: OS << "__private_extern__ "; break;
269 }
270 } else if (FunctionDecl *V = dyn_cast<FunctionDecl>(*Begin)) {
271 switch (V->getStorageClass()) {
272 default: assert(0 && "Unknown storage class!");
273 case FunctionDecl::None: break;
274 case FunctionDecl::Extern: OS << "extern "; break;
275 case FunctionDecl::Static: OS << "static "; break;
276 case FunctionDecl::PrivateExtern: OS << "__private_extern__ "; break;
277 }
278 } else {
279 assert(0 && "Unhandled decl");
280 }
281
282 QualType BaseType;
283 if (ValueDecl* VD = dyn_cast<ValueDecl>(*Begin)) {
284 BaseType = VD->getType();
285 } else {
286 BaseType = cast<TypedefDecl>(*Begin)->getUnderlyingType();
287 }
288 BaseType = GetBaseType(BaseType);
289 PrintBaseType(BaseType, TD);
290
Mike Stump071e4da2009-02-10 20:16:46 +0000291 bool isFirst = true;
Eli Friedmandb23b152009-05-30 00:19:54 +0000292 for ( ; Begin != End; ++Begin) {
Ted Kremenekecd64c52008-10-06 18:39:36 +0000293 if (!isFirst) OS << ", ";
294 else isFirst = false;
Eli Friedmandb23b152009-05-30 00:19:54 +0000295
296 PrintDeclIdentifier(cast<NamedDecl>(*Begin));
Ted Kremenekecd64c52008-10-06 18:39:36 +0000297 }
298}
Reid Spencer5f016e22007-07-11 17:01:13 +0000299
300void StmtPrinter::VisitNullStmt(NullStmt *Node) {
301 Indent() << ";\n";
302}
303
304void StmtPrinter::VisitDeclStmt(DeclStmt *Node) {
Eli Friedmandb23b152009-05-30 00:19:54 +0000305 Indent();
306 PrintRawDeclStmt(Node);
307 OS << ";\n";
Reid Spencer5f016e22007-07-11 17:01:13 +0000308}
309
310void StmtPrinter::VisitCompoundStmt(CompoundStmt *Node) {
311 Indent();
312 PrintRawCompoundStmt(Node);
313 OS << "\n";
314}
315
316void StmtPrinter::VisitCaseStmt(CaseStmt *Node) {
317 Indent(-1) << "case ";
318 PrintExpr(Node->getLHS());
319 if (Node->getRHS()) {
320 OS << " ... ";
321 PrintExpr(Node->getRHS());
322 }
323 OS << ":\n";
324
325 PrintStmt(Node->getSubStmt(), 0);
326}
327
328void StmtPrinter::VisitDefaultStmt(DefaultStmt *Node) {
329 Indent(-1) << "default:\n";
330 PrintStmt(Node->getSubStmt(), 0);
331}
332
333void StmtPrinter::VisitLabelStmt(LabelStmt *Node) {
334 Indent(-1) << Node->getName() << ":\n";
335 PrintStmt(Node->getSubStmt(), 0);
336}
337
338void StmtPrinter::PrintRawIfStmt(IfStmt *If) {
Sebastian Redlbfee9b22009-02-07 20:05:48 +0000339 OS << "if (";
Reid Spencer5f016e22007-07-11 17:01:13 +0000340 PrintExpr(If->getCond());
Sebastian Redlbfee9b22009-02-07 20:05:48 +0000341 OS << ')';
Reid Spencer5f016e22007-07-11 17:01:13 +0000342
343 if (CompoundStmt *CS = dyn_cast<CompoundStmt>(If->getThen())) {
344 OS << ' ';
345 PrintRawCompoundStmt(CS);
346 OS << (If->getElse() ? ' ' : '\n');
347 } else {
348 OS << '\n';
349 PrintStmt(If->getThen());
350 if (If->getElse()) Indent();
351 }
352
353 if (Stmt *Else = If->getElse()) {
354 OS << "else";
355
356 if (CompoundStmt *CS = dyn_cast<CompoundStmt>(Else)) {
357 OS << ' ';
358 PrintRawCompoundStmt(CS);
359 OS << '\n';
360 } else if (IfStmt *ElseIf = dyn_cast<IfStmt>(Else)) {
361 OS << ' ';
362 PrintRawIfStmt(ElseIf);
363 } else {
364 OS << '\n';
365 PrintStmt(If->getElse());
366 }
367 }
368}
369
370void StmtPrinter::VisitIfStmt(IfStmt *If) {
371 Indent();
372 PrintRawIfStmt(If);
373}
374
375void StmtPrinter::VisitSwitchStmt(SwitchStmt *Node) {
376 Indent() << "switch (";
377 PrintExpr(Node->getCond());
378 OS << ")";
379
380 // Pretty print compoundstmt bodies (very common).
381 if (CompoundStmt *CS = dyn_cast<CompoundStmt>(Node->getBody())) {
382 OS << " ";
383 PrintRawCompoundStmt(CS);
384 OS << "\n";
385 } else {
386 OS << "\n";
387 PrintStmt(Node->getBody());
388 }
389}
390
Anders Carlssonc1fcb772007-07-22 07:07:56 +0000391void StmtPrinter::VisitSwitchCase(SwitchCase*) {
392 assert(0 && "SwitchCase is an abstract class");
393}
394
Reid Spencer5f016e22007-07-11 17:01:13 +0000395void StmtPrinter::VisitWhileStmt(WhileStmt *Node) {
396 Indent() << "while (";
397 PrintExpr(Node->getCond());
398 OS << ")\n";
399 PrintStmt(Node->getBody());
400}
401
402void StmtPrinter::VisitDoStmt(DoStmt *Node) {
Chris Lattner8bdcc472007-09-15 21:49:37 +0000403 Indent() << "do ";
404 if (CompoundStmt *CS = dyn_cast<CompoundStmt>(Node->getBody())) {
405 PrintRawCompoundStmt(CS);
406 OS << " ";
407 } else {
408 OS << "\n";
409 PrintStmt(Node->getBody());
410 Indent();
411 }
412
Eli Friedmanb3e22962009-05-17 01:05:34 +0000413 OS << "while (";
Reid Spencer5f016e22007-07-11 17:01:13 +0000414 PrintExpr(Node->getCond());
Eli Friedmanb3e22962009-05-17 01:05:34 +0000415 OS << ");\n";
Reid Spencer5f016e22007-07-11 17:01:13 +0000416}
417
418void StmtPrinter::VisitForStmt(ForStmt *Node) {
419 Indent() << "for (";
420 if (Node->getInit()) {
421 if (DeclStmt *DS = dyn_cast<DeclStmt>(Node->getInit()))
Ted Kremenekecd64c52008-10-06 18:39:36 +0000422 PrintRawDeclStmt(DS);
Reid Spencer5f016e22007-07-11 17:01:13 +0000423 else
424 PrintExpr(cast<Expr>(Node->getInit()));
425 }
Chris Lattner8bdcc472007-09-15 21:49:37 +0000426 OS << ";";
427 if (Node->getCond()) {
428 OS << " ";
Reid Spencer5f016e22007-07-11 17:01:13 +0000429 PrintExpr(Node->getCond());
Chris Lattner8bdcc472007-09-15 21:49:37 +0000430 }
431 OS << ";";
432 if (Node->getInc()) {
433 OS << " ";
Reid Spencer5f016e22007-07-11 17:01:13 +0000434 PrintExpr(Node->getInc());
Chris Lattner8bdcc472007-09-15 21:49:37 +0000435 }
436 OS << ") ";
437
438 if (CompoundStmt *CS = dyn_cast<CompoundStmt>(Node->getBody())) {
439 PrintRawCompoundStmt(CS);
440 OS << "\n";
441 } else {
442 OS << "\n";
443 PrintStmt(Node->getBody());
444 }
Reid Spencer5f016e22007-07-11 17:01:13 +0000445}
446
Ted Kremeneka526c5c2008-01-07 19:49:32 +0000447void StmtPrinter::VisitObjCForCollectionStmt(ObjCForCollectionStmt *Node) {
Fariborz Jahanian0196cab2008-01-02 22:54:34 +0000448 Indent() << "for (";
449 if (DeclStmt *DS = dyn_cast<DeclStmt>(Node->getElement()))
Ted Kremenekecd64c52008-10-06 18:39:36 +0000450 PrintRawDeclStmt(DS);
Fariborz Jahanian0196cab2008-01-02 22:54:34 +0000451 else
452 PrintExpr(cast<Expr>(Node->getElement()));
453 OS << " in ";
454 PrintExpr(Node->getCollection());
455 OS << ") ";
456
457 if (CompoundStmt *CS = dyn_cast<CompoundStmt>(Node->getBody())) {
458 PrintRawCompoundStmt(CS);
459 OS << "\n";
460 } else {
461 OS << "\n";
462 PrintStmt(Node->getBody());
463 }
464}
465
Reid Spencer5f016e22007-07-11 17:01:13 +0000466void StmtPrinter::VisitGotoStmt(GotoStmt *Node) {
467 Indent() << "goto " << Node->getLabel()->getName() << ";\n";
468}
469
470void StmtPrinter::VisitIndirectGotoStmt(IndirectGotoStmt *Node) {
471 Indent() << "goto *";
472 PrintExpr(Node->getTarget());
473 OS << ";\n";
474}
475
476void StmtPrinter::VisitContinueStmt(ContinueStmt *Node) {
477 Indent() << "continue;\n";
478}
479
480void StmtPrinter::VisitBreakStmt(BreakStmt *Node) {
481 Indent() << "break;\n";
482}
483
484
485void StmtPrinter::VisitReturnStmt(ReturnStmt *Node) {
486 Indent() << "return";
487 if (Node->getRetValue()) {
488 OS << " ";
489 PrintExpr(Node->getRetValue());
490 }
491 OS << ";\n";
492}
493
Chris Lattnerfe795952007-10-29 04:04:16 +0000494
495void StmtPrinter::VisitAsmStmt(AsmStmt *Node) {
Anders Carlsson39c47b52007-11-23 23:12:25 +0000496 Indent() << "asm ";
497
498 if (Node->isVolatile())
499 OS << "volatile ";
500
501 OS << "(";
Anders Carlsson6a0ef4b2007-11-20 19:21:03 +0000502 VisitStringLiteral(Node->getAsmString());
Anders Carlssonb235fc22007-11-22 01:36:19 +0000503
504 // Outputs
505 if (Node->getNumOutputs() != 0 || Node->getNumInputs() != 0 ||
506 Node->getNumClobbers() != 0)
507 OS << " : ";
508
509 for (unsigned i = 0, e = Node->getNumOutputs(); i != e; ++i) {
510 if (i != 0)
511 OS << ", ";
512
513 if (!Node->getOutputName(i).empty()) {
514 OS << '[';
515 OS << Node->getOutputName(i);
516 OS << "] ";
517 }
518
Chris Lattnerb3277932009-03-10 04:59:06 +0000519 VisitStringLiteral(Node->getOutputConstraintLiteral(i));
Anders Carlssonb235fc22007-11-22 01:36:19 +0000520 OS << " ";
521 Visit(Node->getOutputExpr(i));
522 }
523
524 // Inputs
525 if (Node->getNumInputs() != 0 || Node->getNumClobbers() != 0)
526 OS << " : ";
527
528 for (unsigned i = 0, e = Node->getNumInputs(); i != e; ++i) {
529 if (i != 0)
530 OS << ", ";
531
532 if (!Node->getInputName(i).empty()) {
533 OS << '[';
534 OS << Node->getInputName(i);
535 OS << "] ";
536 }
537
Chris Lattnerb3277932009-03-10 04:59:06 +0000538 VisitStringLiteral(Node->getInputConstraintLiteral(i));
Anders Carlssonb235fc22007-11-22 01:36:19 +0000539 OS << " ";
540 Visit(Node->getInputExpr(i));
541 }
542
543 // Clobbers
544 if (Node->getNumClobbers() != 0)
545 OS << " : ";
546
547 for (unsigned i = 0, e = Node->getNumClobbers(); i != e; ++i) {
548 if (i != 0)
549 OS << ", ";
550
551 VisitStringLiteral(Node->getClobber(i));
552 }
553
Anders Carlsson6a0ef4b2007-11-20 19:21:03 +0000554 OS << ");\n";
Chris Lattnerfe795952007-10-29 04:04:16 +0000555}
556
Ted Kremeneka526c5c2008-01-07 19:49:32 +0000557void StmtPrinter::VisitObjCAtTryStmt(ObjCAtTryStmt *Node) {
Fariborz Jahanian7794cb82007-11-02 18:16:07 +0000558 Indent() << "@try";
559 if (CompoundStmt *TS = dyn_cast<CompoundStmt>(Node->getTryBody())) {
560 PrintRawCompoundStmt(TS);
561 OS << "\n";
562 }
563
Ted Kremeneka526c5c2008-01-07 19:49:32 +0000564 for (ObjCAtCatchStmt *catchStmt =
565 static_cast<ObjCAtCatchStmt *>(Node->getCatchStmts());
Fariborz Jahanian7794cb82007-11-02 18:16:07 +0000566 catchStmt;
567 catchStmt =
Ted Kremeneka526c5c2008-01-07 19:49:32 +0000568 static_cast<ObjCAtCatchStmt *>(catchStmt->getNextCatchStmt())) {
Fariborz Jahanian7794cb82007-11-02 18:16:07 +0000569 Indent() << "@catch(";
Steve Naroff7ba138a2009-03-03 19:52:17 +0000570 if (catchStmt->getCatchParamDecl()) {
571 if (Decl *DS = catchStmt->getCatchParamDecl())
572 PrintRawDecl(DS);
Fariborz Jahanian7794cb82007-11-02 18:16:07 +0000573 }
574 OS << ")";
575 if (CompoundStmt *CS = dyn_cast<CompoundStmt>(catchStmt->getCatchBody()))
576 {
577 PrintRawCompoundStmt(CS);
578 OS << "\n";
579 }
580 }
581
Ted Kremeneka526c5c2008-01-07 19:49:32 +0000582 if (ObjCAtFinallyStmt *FS =static_cast<ObjCAtFinallyStmt *>(
Fariborz Jahanian1e7eab42007-11-07 00:46:42 +0000583 Node->getFinallyStmt())) {
584 Indent() << "@finally";
585 PrintRawCompoundStmt(dyn_cast<CompoundStmt>(FS->getFinallyBody()));
Fariborz Jahanian7794cb82007-11-02 18:16:07 +0000586 OS << "\n";
587 }
Fariborz Jahanianb210bd02007-11-01 21:12:44 +0000588}
589
Ted Kremeneka526c5c2008-01-07 19:49:32 +0000590void StmtPrinter::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *Node) {
Fariborz Jahanianb210bd02007-11-01 21:12:44 +0000591}
592
Ted Kremeneka526c5c2008-01-07 19:49:32 +0000593void StmtPrinter::VisitObjCAtCatchStmt (ObjCAtCatchStmt *Node) {
Fariborz Jahanianb210bd02007-11-01 21:12:44 +0000594 Indent() << "@catch (...) { /* todo */ } \n";
595}
596
Fariborz Jahanian78a677b2008-01-30 17:38:29 +0000597void StmtPrinter::VisitObjCAtThrowStmt(ObjCAtThrowStmt *Node) {
Fariborz Jahanian39f8f152007-11-07 02:00:49 +0000598 Indent() << "@throw";
599 if (Node->getThrowExpr()) {
600 OS << " ";
601 PrintExpr(Node->getThrowExpr());
602 }
603 OS << ";\n";
604}
605
Fariborz Jahanian78a677b2008-01-30 17:38:29 +0000606void StmtPrinter::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *Node) {
Fariborz Jahanianc385c902008-01-29 18:21:32 +0000607 Indent() << "@synchronized (";
608 PrintExpr(Node->getSynchExpr());
609 OS << ")";
Fariborz Jahanian78a677b2008-01-30 17:38:29 +0000610 PrintRawCompoundStmt(Node->getSynchBody());
611 OS << "\n";
Fariborz Jahanianc385c902008-01-29 18:21:32 +0000612}
613
Sebastian Redl8351da02008-12-22 21:35:02 +0000614void StmtPrinter::PrintRawCXXCatchStmt(CXXCatchStmt *Node) {
615 OS << "catch (";
Sebastian Redl4b07b292008-12-22 19:15:10 +0000616 if (Decl *ExDecl = Node->getExceptionDecl())
617 PrintRawDecl(ExDecl);
618 else
619 OS << "...";
620 OS << ") ";
621 PrintRawCompoundStmt(cast<CompoundStmt>(Node->getHandlerBlock()));
Sebastian Redl8351da02008-12-22 21:35:02 +0000622}
623
624void StmtPrinter::VisitCXXCatchStmt(CXXCatchStmt *Node) {
625 Indent();
626 PrintRawCXXCatchStmt(Node);
627 OS << "\n";
628}
629
630void StmtPrinter::VisitCXXTryStmt(CXXTryStmt *Node) {
631 Indent() << "try ";
632 PrintRawCompoundStmt(Node->getTryBlock());
633 for(unsigned i = 0, e = Node->getNumHandlers(); i < e; ++i) {
634 OS << " ";
635 PrintRawCXXCatchStmt(Node->getHandler(i));
636 }
Sebastian Redl4b07b292008-12-22 19:15:10 +0000637 OS << "\n";
638}
639
Reid Spencer5f016e22007-07-11 17:01:13 +0000640//===----------------------------------------------------------------------===//
641// Expr printing methods.
642//===----------------------------------------------------------------------===//
643
644void StmtPrinter::VisitExpr(Expr *Node) {
645 OS << "<<unknown expr type>>";
646}
647
648void StmtPrinter::VisitDeclRefExpr(DeclRefExpr *Node) {
Chris Lattner39f34e92008-11-24 04:00:27 +0000649 OS << Node->getDecl()->getNameAsString();
Reid Spencer5f016e22007-07-11 17:01:13 +0000650}
651
Douglas Gregorbad35182009-03-19 03:51:16 +0000652void StmtPrinter::VisitQualifiedDeclRefExpr(QualifiedDeclRefExpr *Node) {
Douglas Gregor1a49af92009-01-06 05:10:23 +0000653 NamedDecl *D = Node->getDecl();
654
Douglas Gregord249e1d1f2009-05-29 20:38:28 +0000655 Node->getQualifier()->print(OS, Policy);
Douglas Gregor1a49af92009-01-06 05:10:23 +0000656 OS << D->getNameAsString();
657}
658
Douglas Gregor5953d8b2009-03-19 17:26:29 +0000659void StmtPrinter::VisitUnresolvedDeclRefExpr(UnresolvedDeclRefExpr *Node) {
Douglas Gregord249e1d1f2009-05-29 20:38:28 +0000660 Node->getQualifier()->print(OS, Policy);
Douglas Gregor5953d8b2009-03-19 17:26:29 +0000661 OS << Node->getDeclName().getAsString();
662}
663
Steve Naroff7779db42007-11-12 14:29:37 +0000664void StmtPrinter::VisitObjCIvarRefExpr(ObjCIvarRefExpr *Node) {
Fariborz Jahanian232220c2007-11-12 22:29:28 +0000665 if (Node->getBase()) {
666 PrintExpr(Node->getBase());
667 OS << (Node->isArrow() ? "->" : ".");
668 }
Chris Lattner39f34e92008-11-24 04:00:27 +0000669 OS << Node->getDecl()->getNameAsString();
Steve Naroff7779db42007-11-12 14:29:37 +0000670}
671
Steve Naroffae784072008-05-30 00:40:33 +0000672void StmtPrinter::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *Node) {
673 if (Node->getBase()) {
674 PrintExpr(Node->getBase());
675 OS << ".";
676 }
Steve Naroffc77a6362008-12-04 16:24:46 +0000677 OS << Node->getProperty()->getNameAsCString();
Steve Naroffae784072008-05-30 00:40:33 +0000678}
679
Fariborz Jahanian5daf5702008-11-22 18:39:36 +0000680void StmtPrinter::VisitObjCKVCRefExpr(ObjCKVCRefExpr *Node) {
681 if (Node->getBase()) {
682 PrintExpr(Node->getBase());
683 OS << ".";
684 }
685 // FIXME: Setter/Getter names
686}
687
Chris Lattnerd9f69102008-08-10 01:53:14 +0000688void StmtPrinter::VisitPredefinedExpr(PredefinedExpr *Node) {
Anders Carlsson22742662007-07-21 05:21:51 +0000689 switch (Node->getIdentType()) {
690 default:
691 assert(0 && "unknown case");
Chris Lattnerd9f69102008-08-10 01:53:14 +0000692 case PredefinedExpr::Func:
Anders Carlsson22742662007-07-21 05:21:51 +0000693 OS << "__func__";
694 break;
Chris Lattnerd9f69102008-08-10 01:53:14 +0000695 case PredefinedExpr::Function:
Anders Carlsson22742662007-07-21 05:21:51 +0000696 OS << "__FUNCTION__";
697 break;
Chris Lattnerd9f69102008-08-10 01:53:14 +0000698 case PredefinedExpr::PrettyFunction:
Anders Carlsson22742662007-07-21 05:21:51 +0000699 OS << "__PRETTY_FUNCTION__";
700 break;
701 }
702}
703
Reid Spencer5f016e22007-07-11 17:01:13 +0000704void StmtPrinter::VisitCharacterLiteral(CharacterLiteral *Node) {
Chris Lattnerb0a721a2007-07-13 05:18:11 +0000705 unsigned value = Node->getValue();
Chris Lattnerc250aae2008-06-07 22:35:38 +0000706 if (Node->isWide())
707 OS << "L";
Chris Lattner8bf9f072007-07-13 23:58:20 +0000708 switch (value) {
709 case '\\':
710 OS << "'\\\\'";
711 break;
712 case '\'':
713 OS << "'\\''";
714 break;
715 case '\a':
716 // TODO: K&R: the meaning of '\\a' is different in traditional C
717 OS << "'\\a'";
718 break;
719 case '\b':
720 OS << "'\\b'";
721 break;
722 // Nonstandard escape sequence.
723 /*case '\e':
724 OS << "'\\e'";
725 break;*/
726 case '\f':
727 OS << "'\\f'";
728 break;
729 case '\n':
730 OS << "'\\n'";
731 break;
732 case '\r':
733 OS << "'\\r'";
734 break;
735 case '\t':
736 OS << "'\\t'";
737 break;
738 case '\v':
739 OS << "'\\v'";
740 break;
741 default:
Ted Kremenek471733d2008-02-23 00:52:04 +0000742 if (value < 256 && isprint(value)) {
Chris Lattner8bf9f072007-07-13 23:58:20 +0000743 OS << "'" << (char)value << "'";
744 } else if (value < 256) {
Ted Kremeneka95d3752008-09-13 05:16:45 +0000745 OS << "'\\x" << llvm::format("%x", value) << "'";
Chris Lattner8bf9f072007-07-13 23:58:20 +0000746 } else {
747 // FIXME what to really do here?
748 OS << value;
749 }
Chris Lattnerb0a721a2007-07-13 05:18:11 +0000750 }
Reid Spencer5f016e22007-07-11 17:01:13 +0000751}
752
753void StmtPrinter::VisitIntegerLiteral(IntegerLiteral *Node) {
754 bool isSigned = Node->getType()->isSignedIntegerType();
755 OS << Node->getValue().toString(10, isSigned);
756
757 // Emit suffixes. Integer literals are always a builtin integer type.
Chris Lattnerb77792e2008-07-26 22:17:49 +0000758 switch (Node->getType()->getAsBuiltinType()->getKind()) {
Reid Spencer5f016e22007-07-11 17:01:13 +0000759 default: assert(0 && "Unexpected type for integer literal!");
760 case BuiltinType::Int: break; // no suffix.
761 case BuiltinType::UInt: OS << 'U'; break;
762 case BuiltinType::Long: OS << 'L'; break;
763 case BuiltinType::ULong: OS << "UL"; break;
764 case BuiltinType::LongLong: OS << "LL"; break;
765 case BuiltinType::ULongLong: OS << "ULL"; break;
766 }
767}
768void StmtPrinter::VisitFloatingLiteral(FloatingLiteral *Node) {
Chris Lattner86e499d2007-08-01 00:23:58 +0000769 // FIXME: print value more precisely.
Chris Lattnerda8249e2008-06-07 22:13:43 +0000770 OS << Node->getValueAsApproximateDouble();
Reid Spencer5f016e22007-07-11 17:01:13 +0000771}
Chris Lattner5d661452007-08-26 03:42:43 +0000772
773void StmtPrinter::VisitImaginaryLiteral(ImaginaryLiteral *Node) {
774 PrintExpr(Node->getSubExpr());
775 OS << "i";
776}
777
Reid Spencer5f016e22007-07-11 17:01:13 +0000778void StmtPrinter::VisitStringLiteral(StringLiteral *Str) {
779 if (Str->isWide()) OS << 'L';
780 OS << '"';
Anders Carlssonee98ac52007-10-15 02:50:23 +0000781
Reid Spencer5f016e22007-07-11 17:01:13 +0000782 // FIXME: this doesn't print wstrings right.
783 for (unsigned i = 0, e = Str->getByteLength(); i != e; ++i) {
Chris Lattner9a81c872009-01-16 19:25:18 +0000784 unsigned char Char = Str->getStrData()[i];
785
786 switch (Char) {
787 default:
788 if (isprint(Char))
789 OS << (char)Char;
790 else // Output anything hard as an octal escape.
791 OS << '\\'
792 << (char)('0'+ ((Char >> 6) & 7))
793 << (char)('0'+ ((Char >> 3) & 7))
794 << (char)('0'+ ((Char >> 0) & 7));
795 break;
796 // Handle some common non-printable cases to make dumps prettier.
Reid Spencer5f016e22007-07-11 17:01:13 +0000797 case '\\': OS << "\\\\"; break;
798 case '"': OS << "\\\""; break;
799 case '\n': OS << "\\n"; break;
800 case '\t': OS << "\\t"; break;
801 case '\a': OS << "\\a"; break;
802 case '\b': OS << "\\b"; break;
803 }
804 }
805 OS << '"';
806}
807void StmtPrinter::VisitParenExpr(ParenExpr *Node) {
808 OS << "(";
809 PrintExpr(Node->getSubExpr());
810 OS << ")";
811}
812void StmtPrinter::VisitUnaryOperator(UnaryOperator *Node) {
Chris Lattner296bf192007-08-23 21:46:40 +0000813 if (!Node->isPostfix()) {
Reid Spencer5f016e22007-07-11 17:01:13 +0000814 OS << UnaryOperator::getOpcodeStr(Node->getOpcode());
Chris Lattner296bf192007-08-23 21:46:40 +0000815
Sebastian Redl05189992008-11-11 17:56:53 +0000816 // Print a space if this is an "identifier operator" like __real.
Chris Lattner296bf192007-08-23 21:46:40 +0000817 switch (Node->getOpcode()) {
818 default: break;
Chris Lattner296bf192007-08-23 21:46:40 +0000819 case UnaryOperator::Real:
820 case UnaryOperator::Imag:
821 case UnaryOperator::Extension:
822 OS << ' ';
823 break;
824 }
825 }
Reid Spencer5f016e22007-07-11 17:01:13 +0000826 PrintExpr(Node->getSubExpr());
827
828 if (Node->isPostfix())
829 OS << UnaryOperator::getOpcodeStr(Node->getOpcode());
Reid Spencer5f016e22007-07-11 17:01:13 +0000830}
Chris Lattner704fe352007-08-30 17:59:59 +0000831
832bool StmtPrinter::PrintOffsetOfDesignator(Expr *E) {
Eli Friedman35183ac2009-02-27 06:44:11 +0000833 if (isa<UnaryOperator>(E)) {
Chris Lattner704fe352007-08-30 17:59:59 +0000834 // Base case, print the type and comma.
835 OS << E->getType().getAsString() << ", ";
836 return true;
837 } else if (ArraySubscriptExpr *ASE = dyn_cast<ArraySubscriptExpr>(E)) {
838 PrintOffsetOfDesignator(ASE->getLHS());
839 OS << "[";
840 PrintExpr(ASE->getRHS());
841 OS << "]";
842 return false;
843 } else {
844 MemberExpr *ME = cast<MemberExpr>(E);
845 bool IsFirst = PrintOffsetOfDesignator(ME->getBase());
Chris Lattner39f34e92008-11-24 04:00:27 +0000846 OS << (IsFirst ? "" : ".") << ME->getMemberDecl()->getNameAsString();
Chris Lattner704fe352007-08-30 17:59:59 +0000847 return false;
848 }
849}
850
851void StmtPrinter::VisitUnaryOffsetOf(UnaryOperator *Node) {
852 OS << "__builtin_offsetof(";
853 PrintOffsetOfDesignator(Node->getSubExpr());
854 OS << ")";
855}
856
Sebastian Redl05189992008-11-11 17:56:53 +0000857void StmtPrinter::VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *Node) {
858 OS << (Node->isSizeOf() ? "sizeof" : "__alignof");
859 if (Node->isArgumentType())
860 OS << "(" << Node->getArgumentType().getAsString() << ")";
861 else {
862 OS << " ";
863 PrintExpr(Node->getArgumentExpr());
864 }
Reid Spencer5f016e22007-07-11 17:01:13 +0000865}
866void StmtPrinter::VisitArraySubscriptExpr(ArraySubscriptExpr *Node) {
Ted Kremenek23245122007-08-20 16:18:38 +0000867 PrintExpr(Node->getLHS());
Reid Spencer5f016e22007-07-11 17:01:13 +0000868 OS << "[";
Ted Kremenek23245122007-08-20 16:18:38 +0000869 PrintExpr(Node->getRHS());
Reid Spencer5f016e22007-07-11 17:01:13 +0000870 OS << "]";
871}
872
873void StmtPrinter::VisitCallExpr(CallExpr *Call) {
874 PrintExpr(Call->getCallee());
875 OS << "(";
876 for (unsigned i = 0, e = Call->getNumArgs(); i != e; ++i) {
Chris Lattner04421082008-04-08 04:40:51 +0000877 if (isa<CXXDefaultArgExpr>(Call->getArg(i))) {
878 // Don't print any defaulted arguments
879 break;
880 }
881
Reid Spencer5f016e22007-07-11 17:01:13 +0000882 if (i) OS << ", ";
883 PrintExpr(Call->getArg(i));
884 }
885 OS << ")";
886}
887void StmtPrinter::VisitMemberExpr(MemberExpr *Node) {
Douglas Gregorb3eef682009-01-08 22:45:41 +0000888 // FIXME: Suppress printing implicit bases (like "this")
889 PrintExpr(Node->getBase());
890 OS << (Node->isArrow() ? "->" : ".");
891 // FIXME: Suppress printing references to unnamed objects
892 // representing anonymous unions/structs
Douglas Gregor86f19402008-12-20 23:49:58 +0000893 OS << Node->getMemberDecl()->getNameAsString();
Reid Spencer5f016e22007-07-11 17:01:13 +0000894}
Nate Begeman213541a2008-04-18 23:10:10 +0000895void StmtPrinter::VisitExtVectorElementExpr(ExtVectorElementExpr *Node) {
Steve Naroff31a45842007-07-28 23:10:27 +0000896 PrintExpr(Node->getBase());
897 OS << ".";
898 OS << Node->getAccessor().getName();
899}
Argyrios Kyrtzidis0835a3c2008-08-18 23:01:59 +0000900void StmtPrinter::VisitCastExpr(CastExpr *) {
901 assert(0 && "CastExpr is an abstract class");
902}
Douglas Gregor49badde2008-10-27 19:41:14 +0000903void StmtPrinter::VisitExplicitCastExpr(ExplicitCastExpr *) {
904 assert(0 && "ExplicitCastExpr is an abstract class");
905}
Douglas Gregor6eec8e82008-10-28 15:36:24 +0000906void StmtPrinter::VisitCStyleCastExpr(CStyleCastExpr *Node) {
Chris Lattner26dc7b32007-07-15 23:54:50 +0000907 OS << "(" << Node->getType().getAsString() << ")";
Reid Spencer5f016e22007-07-11 17:01:13 +0000908 PrintExpr(Node->getSubExpr());
909}
Steve Naroffaff1edd2007-07-19 21:32:11 +0000910void StmtPrinter::VisitCompoundLiteralExpr(CompoundLiteralExpr *Node) {
911 OS << "(" << Node->getType().getAsString() << ")";
912 PrintExpr(Node->getInitializer());
913}
Steve Naroff49b45262007-07-13 16:58:59 +0000914void StmtPrinter::VisitImplicitCastExpr(ImplicitCastExpr *Node) {
Steve Naroff90045e82007-07-13 23:32:42 +0000915 // No need to print anything, simply forward to the sub expression.
916 PrintExpr(Node->getSubExpr());
Steve Naroff49b45262007-07-13 16:58:59 +0000917}
Reid Spencer5f016e22007-07-11 17:01:13 +0000918void StmtPrinter::VisitBinaryOperator(BinaryOperator *Node) {
919 PrintExpr(Node->getLHS());
920 OS << " " << BinaryOperator::getOpcodeStr(Node->getOpcode()) << " ";
921 PrintExpr(Node->getRHS());
922}
Chris Lattnereb14fe82007-08-25 02:00:02 +0000923void StmtPrinter::VisitCompoundAssignOperator(CompoundAssignOperator *Node) {
924 PrintExpr(Node->getLHS());
925 OS << " " << BinaryOperator::getOpcodeStr(Node->getOpcode()) << " ";
926 PrintExpr(Node->getRHS());
927}
Reid Spencer5f016e22007-07-11 17:01:13 +0000928void StmtPrinter::VisitConditionalOperator(ConditionalOperator *Node) {
929 PrintExpr(Node->getCond());
Ted Kremenek8e911c42007-11-26 18:27:54 +0000930
931 if (Node->getLHS()) {
932 OS << " ? ";
933 PrintExpr(Node->getLHS());
934 OS << " : ";
935 }
Douglas Gregor4fe0c8e2009-05-30 00:08:05 +0000936 else { // Handle GCC extension where LHS can be NULL.
Ted Kremenek8e911c42007-11-26 18:27:54 +0000937 OS << " ?: ";
938 }
939
Reid Spencer5f016e22007-07-11 17:01:13 +0000940 PrintExpr(Node->getRHS());
941}
942
943// GNU extensions.
944
Chris Lattner6481a572007-08-03 17:31:20 +0000945void StmtPrinter::VisitAddrLabelExpr(AddrLabelExpr *Node) {
Reid Spencer5f016e22007-07-11 17:01:13 +0000946 OS << "&&" << Node->getLabel()->getName();
Reid Spencer5f016e22007-07-11 17:01:13 +0000947}
948
Chris Lattnerab18c4c2007-07-24 16:58:17 +0000949void StmtPrinter::VisitStmtExpr(StmtExpr *E) {
950 OS << "(";
951 PrintRawCompoundStmt(E->getSubStmt());
952 OS << ")";
953}
954
Steve Naroffd34e9152007-08-01 22:05:33 +0000955void StmtPrinter::VisitTypesCompatibleExpr(TypesCompatibleExpr *Node) {
956 OS << "__builtin_types_compatible_p(";
957 OS << Node->getArgType1().getAsString() << ",";
958 OS << Node->getArgType2().getAsString() << ")";
959}
960
Steve Naroffd04fdd52007-08-03 21:21:27 +0000961void StmtPrinter::VisitChooseExpr(ChooseExpr *Node) {
962 OS << "__builtin_choose_expr(";
963 PrintExpr(Node->getCond());
Chris Lattner94f05e32007-08-04 00:20:15 +0000964 OS << ", ";
Steve Naroffd04fdd52007-08-03 21:21:27 +0000965 PrintExpr(Node->getLHS());
Chris Lattner94f05e32007-08-04 00:20:15 +0000966 OS << ", ";
Steve Naroffd04fdd52007-08-03 21:21:27 +0000967 PrintExpr(Node->getRHS());
968 OS << ")";
969}
Chris Lattnerab18c4c2007-07-24 16:58:17 +0000970
Douglas Gregor2d8b2732008-11-29 04:51:27 +0000971void StmtPrinter::VisitGNUNullExpr(GNUNullExpr *) {
972 OS << "__null";
973}
974
Eli Friedmand38617c2008-05-14 19:38:39 +0000975void StmtPrinter::VisitShuffleVectorExpr(ShuffleVectorExpr *Node) {
976 OS << "__builtin_shufflevector(";
977 for (unsigned i = 0, e = Node->getNumSubExprs(); i != e; ++i) {
978 if (i) OS << ", ";
979 PrintExpr(Node->getExpr(i));
980 }
981 OS << ")";
982}
983
Anders Carlsson66b5a8a2007-08-31 04:56:16 +0000984void StmtPrinter::VisitInitListExpr(InitListExpr* Node) {
985 OS << "{ ";
986 for (unsigned i = 0, e = Node->getNumInits(); i != e; ++i) {
987 if (i) OS << ", ";
Douglas Gregor4c678342009-01-28 21:54:33 +0000988 if (Node->getInit(i))
989 PrintExpr(Node->getInit(i));
990 else
991 OS << "0";
Anders Carlsson66b5a8a2007-08-31 04:56:16 +0000992 }
993 OS << " }";
994}
995
Douglas Gregor05c13a32009-01-22 00:58:24 +0000996void StmtPrinter::VisitDesignatedInitExpr(DesignatedInitExpr *Node) {
Douglas Gregor4c678342009-01-28 21:54:33 +0000997 for (DesignatedInitExpr::designators_iterator D = Node->designators_begin(),
998 DEnd = Node->designators_end();
999 D != DEnd; ++D) {
1000 if (D->isFieldDesignator()) {
1001 if (D->getDotLoc().isInvalid())
1002 OS << D->getFieldName()->getName() << ":";
1003 else
1004 OS << "." << D->getFieldName()->getName();
1005 } else {
1006 OS << "[";
1007 if (D->isArrayDesignator()) {
1008 PrintExpr(Node->getArrayIndex(*D));
1009 } else {
1010 PrintExpr(Node->getArrayRangeStart(*D));
1011 OS << " ... ";
1012 PrintExpr(Node->getArrayRangeEnd(*D));
1013 }
1014 OS << "]";
1015 }
1016 }
1017
1018 OS << " = ";
1019 PrintExpr(Node->getInit());
Douglas Gregor05c13a32009-01-22 00:58:24 +00001020}
1021
Douglas Gregor3498bdb2009-01-29 17:44:32 +00001022void StmtPrinter::VisitImplicitValueInitExpr(ImplicitValueInitExpr *Node) {
Douglas Gregor4fe0c8e2009-05-30 00:08:05 +00001023 if (Policy.CPlusPlus)
1024 OS << "/*implicit*/" << Node->getType().getAsString(Policy) << "()";
1025 else {
1026 OS << "/*implicit*/(" << Node->getType().getAsString(Policy) << ")";
1027 if (Node->getType()->isRecordType())
1028 OS << "{}";
1029 else
1030 OS << 0;
1031 }
Douglas Gregor3498bdb2009-01-29 17:44:32 +00001032}
1033
Anders Carlsson7c50aca2007-10-15 20:28:48 +00001034void StmtPrinter::VisitVAArgExpr(VAArgExpr *Node) {
1035 OS << "va_arg(";
1036 PrintExpr(Node->getSubExpr());
1037 OS << ", ";
1038 OS << Node->getType().getAsString();
1039 OS << ")";
1040}
1041
Reid Spencer5f016e22007-07-11 17:01:13 +00001042// C++
Douglas Gregorb4609802008-11-14 16:09:21 +00001043void StmtPrinter::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *Node) {
1044 const char *OpStrings[NUM_OVERLOADED_OPERATORS] = {
1045 "",
1046#define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \
1047 Spelling,
1048#include "clang/Basic/OperatorKinds.def"
1049 };
1050
1051 OverloadedOperatorKind Kind = Node->getOperator();
1052 if (Kind == OO_PlusPlus || Kind == OO_MinusMinus) {
1053 if (Node->getNumArgs() == 1) {
1054 OS << OpStrings[Kind] << ' ';
1055 PrintExpr(Node->getArg(0));
1056 } else {
1057 PrintExpr(Node->getArg(0));
1058 OS << ' ' << OpStrings[Kind];
1059 }
1060 } else if (Kind == OO_Call) {
1061 PrintExpr(Node->getArg(0));
1062 OS << '(';
1063 for (unsigned ArgIdx = 1; ArgIdx < Node->getNumArgs(); ++ArgIdx) {
1064 if (ArgIdx > 1)
1065 OS << ", ";
1066 if (!isa<CXXDefaultArgExpr>(Node->getArg(ArgIdx)))
1067 PrintExpr(Node->getArg(ArgIdx));
1068 }
1069 OS << ')';
1070 } else if (Kind == OO_Subscript) {
1071 PrintExpr(Node->getArg(0));
1072 OS << '[';
1073 PrintExpr(Node->getArg(1));
1074 OS << ']';
1075 } else if (Node->getNumArgs() == 1) {
1076 OS << OpStrings[Kind] << ' ';
1077 PrintExpr(Node->getArg(0));
1078 } else if (Node->getNumArgs() == 2) {
1079 PrintExpr(Node->getArg(0));
1080 OS << ' ' << OpStrings[Kind] << ' ';
1081 PrintExpr(Node->getArg(1));
1082 } else {
1083 assert(false && "unknown overloaded operator");
1084 }
1085}
Reid Spencer5f016e22007-07-11 17:01:13 +00001086
Douglas Gregor88a35142008-12-22 05:46:06 +00001087void StmtPrinter::VisitCXXMemberCallExpr(CXXMemberCallExpr *Node) {
1088 VisitCallExpr(cast<CallExpr>(Node));
1089}
1090
Douglas Gregor49badde2008-10-27 19:41:14 +00001091void StmtPrinter::VisitCXXNamedCastExpr(CXXNamedCastExpr *Node) {
1092 OS << Node->getCastName() << '<';
1093 OS << Node->getTypeAsWritten().getAsString() << ">(";
Reid Spencer5f016e22007-07-11 17:01:13 +00001094 PrintExpr(Node->getSubExpr());
1095 OS << ")";
1096}
1097
Douglas Gregor49badde2008-10-27 19:41:14 +00001098void StmtPrinter::VisitCXXStaticCastExpr(CXXStaticCastExpr *Node) {
1099 VisitCXXNamedCastExpr(Node);
1100}
1101
1102void StmtPrinter::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *Node) {
1103 VisitCXXNamedCastExpr(Node);
1104}
1105
1106void StmtPrinter::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *Node) {
1107 VisitCXXNamedCastExpr(Node);
1108}
1109
1110void StmtPrinter::VisitCXXConstCastExpr(CXXConstCastExpr *Node) {
1111 VisitCXXNamedCastExpr(Node);
1112}
1113
Sebastian Redlc42e1182008-11-11 11:37:55 +00001114void StmtPrinter::VisitCXXTypeidExpr(CXXTypeidExpr *Node) {
1115 OS << "typeid(";
1116 if (Node->isTypeOperand()) {
1117 OS << Node->getTypeOperand().getAsString();
1118 } else {
1119 PrintExpr(Node->getExprOperand());
1120 }
1121 OS << ")";
1122}
1123
Reid Spencer5f016e22007-07-11 17:01:13 +00001124void StmtPrinter::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *Node) {
1125 OS << (Node->getValue() ? "true" : "false");
1126}
1127
Sebastian Redl6e8ed162009-05-10 18:38:11 +00001128void StmtPrinter::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *Node) {
1129 OS << "nullptr";
1130}
1131
Douglas Gregor796da182008-11-04 14:32:21 +00001132void StmtPrinter::VisitCXXThisExpr(CXXThisExpr *Node) {
1133 OS << "this";
1134}
1135
Chris Lattner50dd2892008-02-26 00:51:44 +00001136void StmtPrinter::VisitCXXThrowExpr(CXXThrowExpr *Node) {
1137 if (Node->getSubExpr() == 0)
1138 OS << "throw";
1139 else {
1140 OS << "throw ";
1141 PrintExpr(Node->getSubExpr());
1142 }
1143}
1144
Chris Lattner04421082008-04-08 04:40:51 +00001145void StmtPrinter::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *Node) {
1146 // Nothing to print: we picked up the default argument
1147}
1148
Argyrios Kyrtzidis987a14b2008-08-22 15:38:55 +00001149void StmtPrinter::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *Node) {
1150 OS << Node->getType().getAsString();
1151 OS << "(";
1152 PrintExpr(Node->getSubExpr());
1153 OS << ")";
1154}
1155
Douglas Gregor506ae412009-01-16 18:33:17 +00001156void StmtPrinter::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *Node) {
1157 OS << Node->getType().getAsString();
1158 OS << "(";
1159 for (CXXTemporaryObjectExpr::arg_iterator Arg = Node->arg_begin(),
1160 ArgEnd = Node->arg_end();
1161 Arg != ArgEnd; ++Arg) {
1162 if (Arg != Node->arg_begin())
1163 OS << ", ";
1164 PrintExpr(*Arg);
1165 }
1166 OS << ")";
1167}
1168
Argyrios Kyrtzidis987a14b2008-08-22 15:38:55 +00001169void StmtPrinter::VisitCXXZeroInitValueExpr(CXXZeroInitValueExpr *Node) {
1170 OS << Node->getType().getAsString() << "()";
1171}
1172
Argyrios Kyrtzidis9e922b12008-09-09 23:47:53 +00001173void
1174StmtPrinter::VisitCXXConditionDeclExpr(CXXConditionDeclExpr *E) {
1175 PrintRawDecl(E->getVarDecl());
1176}
1177
Sebastian Redl4c5d3202008-11-21 19:14:01 +00001178void StmtPrinter::VisitCXXNewExpr(CXXNewExpr *E) {
1179 if (E->isGlobalNew())
1180 OS << "::";
1181 OS << "new ";
1182 unsigned NumPlace = E->getNumPlacementArgs();
1183 if (NumPlace > 0) {
1184 OS << "(";
1185 PrintExpr(E->getPlacementArg(0));
1186 for (unsigned i = 1; i < NumPlace; ++i) {
1187 OS << ", ";
1188 PrintExpr(E->getPlacementArg(i));
1189 }
1190 OS << ") ";
1191 }
1192 if (E->isParenTypeId())
1193 OS << "(";
Sebastian Redl6fec6482008-12-02 22:08:59 +00001194 std::string TypeS;
1195 if (Expr *Size = E->getArraySize()) {
1196 llvm::raw_string_ostream s(TypeS);
Douglas Gregord249e1d1f2009-05-29 20:38:28 +00001197 Size->printPretty(s, Helper, Policy);
Sebastian Redl6fec6482008-12-02 22:08:59 +00001198 s.flush();
1199 TypeS = "[" + TypeS + "]";
1200 }
Douglas Gregord249e1d1f2009-05-29 20:38:28 +00001201 E->getAllocatedType().getAsStringInternal(TypeS, Policy);
Sebastian Redl6fec6482008-12-02 22:08:59 +00001202 OS << TypeS;
Sebastian Redl4c5d3202008-11-21 19:14:01 +00001203 if (E->isParenTypeId())
1204 OS << ")";
1205
1206 if (E->hasInitializer()) {
1207 OS << "(";
1208 unsigned NumCons = E->getNumConstructorArgs();
1209 if (NumCons > 0) {
1210 PrintExpr(E->getConstructorArg(0));
1211 for (unsigned i = 1; i < NumCons; ++i) {
1212 OS << ", ";
1213 PrintExpr(E->getConstructorArg(i));
1214 }
1215 }
1216 OS << ")";
1217 }
1218}
1219
1220void StmtPrinter::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
1221 if (E->isGlobalDelete())
1222 OS << "::";
1223 OS << "delete ";
1224 if (E->isArrayForm())
1225 OS << "[] ";
1226 PrintExpr(E->getArgument());
1227}
1228
Douglas Gregor17330012009-02-04 15:01:18 +00001229void StmtPrinter::VisitUnresolvedFunctionNameExpr(UnresolvedFunctionNameExpr *E) {
1230 OS << E->getName().getAsString();
Douglas Gregor5c37de72008-12-06 00:22:45 +00001231}
1232
Anders Carlssone349bea2009-04-23 02:32:43 +00001233void StmtPrinter::VisitCXXConstructExpr(CXXConstructExpr *E) {
1234 // Nothing to print.
1235}
1236
Anders Carlsson2d44e8a2009-05-01 22:18:43 +00001237void StmtPrinter::VisitCXXExprWithTemporaries(CXXExprWithTemporaries *E) {
Anders Carlsson02bbfa32009-04-24 22:47:04 +00001238 // Just forward to the sub expression.
1239 PrintExpr(E->getSubExpr());
1240}
1241
Douglas Gregord81e6ca2009-05-20 18:46:25 +00001242void
1243StmtPrinter::VisitCXXUnresolvedConstructExpr(
1244 CXXUnresolvedConstructExpr *Node) {
1245 OS << Node->getTypeAsWritten().getAsString();
1246 OS << "(";
1247 for (CXXUnresolvedConstructExpr::arg_iterator Arg = Node->arg_begin(),
1248 ArgEnd = Node->arg_end();
1249 Arg != ArgEnd; ++Arg) {
1250 if (Arg != Node->arg_begin())
1251 OS << ", ";
1252 PrintExpr(*Arg);
1253 }
1254 OS << ")";
1255}
1256
Douglas Gregor1c0ca592009-05-22 21:13:27 +00001257void StmtPrinter::VisitCXXUnresolvedMemberExpr(CXXUnresolvedMemberExpr *Node) {
1258 PrintExpr(Node->getBase());
1259 OS << (Node->isArrow() ? "->" : ".");
1260 OS << Node->getMember().getAsString();
1261}
1262
Sebastian Redl64b45f72009-01-05 20:52:13 +00001263static const char *getTypeTraitName(UnaryTypeTrait UTT) {
1264 switch (UTT) {
1265 default: assert(false && "Unknown type trait");
1266 case UTT_HasNothrowAssign: return "__has_nothrow_assign";
1267 case UTT_HasNothrowCopy: return "__has_nothrow_copy";
1268 case UTT_HasNothrowConstructor: return "__has_nothrow_constructor";
1269 case UTT_HasTrivialAssign: return "__has_trivial_assign";
1270 case UTT_HasTrivialCopy: return "__has_trivial_copy";
1271 case UTT_HasTrivialConstructor: return "__has_trivial_constructor";
1272 case UTT_HasTrivialDestructor: return "__has_trivial_destructor";
1273 case UTT_HasVirtualDestructor: return "__has_virtual_destructor";
1274 case UTT_IsAbstract: return "__is_abstract";
1275 case UTT_IsClass: return "__is_class";
1276 case UTT_IsEmpty: return "__is_empty";
1277 case UTT_IsEnum: return "__is_enum";
1278 case UTT_IsPOD: return "__is_pod";
1279 case UTT_IsPolymorphic: return "__is_polymorphic";
1280 case UTT_IsUnion: return "__is_union";
1281 }
1282}
1283
1284void StmtPrinter::VisitUnaryTypeTraitExpr(UnaryTypeTraitExpr *E) {
1285 OS << getTypeTraitName(E->getTrait()) << "("
1286 << E->getQueriedType().getAsString() << ")";
1287}
1288
Anders Carlsson55085182007-08-21 17:43:55 +00001289// Obj-C
1290
1291void StmtPrinter::VisitObjCStringLiteral(ObjCStringLiteral *Node) {
1292 OS << "@";
1293 VisitStringLiteral(Node->getString());
1294}
Reid Spencer5f016e22007-07-11 17:01:13 +00001295
Anders Carlssonf9bcf012007-08-22 15:14:15 +00001296void StmtPrinter::VisitObjCEncodeExpr(ObjCEncodeExpr *Node) {
Chris Lattner39f34e92008-11-24 04:00:27 +00001297 OS << "@encode(" << Node->getEncodedType().getAsString() << ')';
Anders Carlssonf9bcf012007-08-22 15:14:15 +00001298}
1299
Fariborz Jahanianb62f6812007-10-16 20:40:23 +00001300void StmtPrinter::VisitObjCSelectorExpr(ObjCSelectorExpr *Node) {
Chris Lattner39f34e92008-11-24 04:00:27 +00001301 OS << "@selector(" << Node->getSelector().getAsString() << ')';
Fariborz Jahanianb62f6812007-10-16 20:40:23 +00001302}
1303
Fariborz Jahanian390d50a2007-10-17 16:58:11 +00001304void StmtPrinter::VisitObjCProtocolExpr(ObjCProtocolExpr *Node) {
Chris Lattner39f34e92008-11-24 04:00:27 +00001305 OS << "@protocol(" << Node->getProtocol()->getNameAsString() << ')';
Fariborz Jahanian390d50a2007-10-17 16:58:11 +00001306}
1307
Steve Naroff563477d2007-09-18 23:55:05 +00001308void StmtPrinter::VisitObjCMessageExpr(ObjCMessageExpr *Mess) {
1309 OS << "[";
Steve Naroff6a8a9a42007-10-02 20:01:56 +00001310 Expr *receiver = Mess->getReceiver();
1311 if (receiver) PrintExpr(receiver);
1312 else OS << Mess->getClassName()->getName();
Ted Kremenekc29efd82008-05-02 17:32:38 +00001313 OS << ' ';
Ted Kremenek97b7f262008-04-16 04:30:16 +00001314 Selector selector = Mess->getSelector();
Steve Naroff6a8a9a42007-10-02 20:01:56 +00001315 if (selector.isUnarySelector()) {
Ted Kremenekc29efd82008-05-02 17:32:38 +00001316 OS << selector.getIdentifierInfoForSlot(0)->getName();
Steve Naroff6a8a9a42007-10-02 20:01:56 +00001317 } else {
1318 for (unsigned i = 0, e = Mess->getNumArgs(); i != e; ++i) {
Ted Kremenekc29efd82008-05-02 17:32:38 +00001319 if (i < selector.getNumArgs()) {
1320 if (i > 0) OS << ' ';
1321 if (selector.getIdentifierInfoForSlot(i))
Chris Lattner39f34e92008-11-24 04:00:27 +00001322 OS << selector.getIdentifierInfoForSlot(i)->getName() << ':';
Ted Kremenekc29efd82008-05-02 17:32:38 +00001323 else
1324 OS << ":";
1325 }
1326 else OS << ", "; // Handle variadic methods.
1327
Steve Naroff6a8a9a42007-10-02 20:01:56 +00001328 PrintExpr(Mess->getArg(i));
1329 }
Steve Naroff563477d2007-09-18 23:55:05 +00001330 }
1331 OS << "]";
1332}
1333
Douglas Gregorcd9b46e2008-11-04 14:56:14 +00001334void StmtPrinter::VisitObjCSuperExpr(ObjCSuperExpr *) {
1335 OS << "super";
1336}
1337
Steve Naroff4eb206b2008-09-03 18:15:37 +00001338void StmtPrinter::VisitBlockExpr(BlockExpr *Node) {
Steve Naroff56ee6892008-10-08 17:01:13 +00001339 BlockDecl *BD = Node->getBlockDecl();
Steve Naroff4eb206b2008-09-03 18:15:37 +00001340 OS << "^";
1341
1342 const FunctionType *AFT = Node->getFunctionType();
1343
Douglas Gregor72564e72009-02-26 23:50:07 +00001344 if (isa<FunctionNoProtoType>(AFT)) {
Steve Naroff4eb206b2008-09-03 18:15:37 +00001345 OS << "()";
Douglas Gregor72564e72009-02-26 23:50:07 +00001346 } else if (!BD->param_empty() || cast<FunctionProtoType>(AFT)->isVariadic()) {
Steve Naroff4eb206b2008-09-03 18:15:37 +00001347 OS << '(';
1348 std::string ParamStr;
Steve Naroff56ee6892008-10-08 17:01:13 +00001349 for (BlockDecl::param_iterator AI = BD->param_begin(),
1350 E = BD->param_end(); AI != E; ++AI) {
1351 if (AI != BD->param_begin()) OS << ", ";
Chris Lattner39f34e92008-11-24 04:00:27 +00001352 ParamStr = (*AI)->getNameAsString();
Douglas Gregord249e1d1f2009-05-29 20:38:28 +00001353 (*AI)->getType().getAsStringInternal(ParamStr, Policy);
Steve Naroff4eb206b2008-09-03 18:15:37 +00001354 OS << ParamStr;
1355 }
1356
Douglas Gregor72564e72009-02-26 23:50:07 +00001357 const FunctionProtoType *FT = cast<FunctionProtoType>(AFT);
Steve Naroff4eb206b2008-09-03 18:15:37 +00001358 if (FT->isVariadic()) {
Steve Naroff56ee6892008-10-08 17:01:13 +00001359 if (!BD->param_empty()) OS << ", ";
Steve Naroff4eb206b2008-09-03 18:15:37 +00001360 OS << "...";
1361 }
1362 OS << ')';
1363 }
1364}
1365
Steve Naroff4eb206b2008-09-03 18:15:37 +00001366void StmtPrinter::VisitBlockDeclRefExpr(BlockDeclRefExpr *Node) {
Chris Lattner39f34e92008-11-24 04:00:27 +00001367 OS << Node->getDecl()->getNameAsString();
Steve Naroff4eb206b2008-09-03 18:15:37 +00001368}
Reid Spencer5f016e22007-07-11 17:01:13 +00001369//===----------------------------------------------------------------------===//
1370// Stmt method implementations
1371//===----------------------------------------------------------------------===//
1372
Chris Lattner6000dac2007-08-08 22:51:59 +00001373void Stmt::dumpPretty() const {
Douglas Gregord249e1d1f2009-05-29 20:38:28 +00001374 printPretty(llvm::errs(), 0, PrintingPolicy());
Reid Spencer5f016e22007-07-11 17:01:13 +00001375}
1376
Mike Stump071e4da2009-02-10 20:16:46 +00001377void Stmt::printPretty(llvm::raw_ostream &OS, PrinterHelper* Helper,
Douglas Gregord249e1d1f2009-05-29 20:38:28 +00001378 const PrintingPolicy &Policy,
1379 unsigned Indentation) const {
Reid Spencer5f016e22007-07-11 17:01:13 +00001380 if (this == 0) {
1381 OS << "<NULL>";
1382 return;
1383 }
1384
Douglas Gregor4fe0c8e2009-05-30 00:08:05 +00001385 if (Policy.Dump) {
1386 dump();
1387 return;
1388 }
1389
Douglas Gregord249e1d1f2009-05-29 20:38:28 +00001390 StmtPrinter P(OS, Helper, Policy, Indentation);
Chris Lattnerc5598cb2007-08-21 04:04:25 +00001391 P.Visit(const_cast<Stmt*>(this));
Reid Spencer5f016e22007-07-11 17:01:13 +00001392}
Ted Kremenek42a509f2007-08-31 21:30:12 +00001393
1394//===----------------------------------------------------------------------===//
1395// PrinterHelper
1396//===----------------------------------------------------------------------===//
1397
1398// Implement virtual destructor.
Gabor Greif84675832007-09-11 15:32:40 +00001399PrinterHelper::~PrinterHelper() {}