StmtPrinter.cpp revision 251662
1193326Sed//===--- StmtPrinter.cpp - Printing implementation for Stmt ASTs ----------===//
2193326Sed//
3193326Sed//                     The LLVM Compiler Infrastructure
4193326Sed//
5193326Sed// This file is distributed under the University of Illinois Open Source
6193326Sed// License. See LICENSE.TXT for details.
7193326Sed//
8193326Sed//===----------------------------------------------------------------------===//
9193326Sed//
10193326Sed// This file implements the Stmt::dumpPretty/Stmt::printPretty methods, which
11193326Sed// pretty print the AST back out to C code.
12193326Sed//
13193326Sed//===----------------------------------------------------------------------===//
14193326Sed
15239462Sdim#include "clang/AST/ASTContext.h"
16249423Sdim#include "clang/AST/Attr.h"
17193326Sed#include "clang/AST/DeclCXX.h"
18193326Sed#include "clang/AST/DeclObjC.h"
19218893Sdim#include "clang/AST/DeclTemplate.h"
20207619Srdivacky#include "clang/AST/Expr.h"
21218893Sdim#include "clang/AST/ExprCXX.h"
22249423Sdim#include "clang/AST/PrettyPrinter.h"
23249423Sdim#include "clang/AST/StmtVisitor.h"
24249423Sdim#include "clang/Basic/CharInfo.h"
25234353Sdim#include "llvm/ADT/SmallString.h"
26249423Sdim#include "llvm/Support/Format.h"
27193326Sedusing namespace clang;
28193326Sed
29193326Sed//===----------------------------------------------------------------------===//
30193326Sed// StmtPrinter Visitor
31193326Sed//===----------------------------------------------------------------------===//
32193326Sed
33193326Sednamespace  {
34199990Srdivacky  class StmtPrinter : public StmtVisitor<StmtPrinter> {
35226633Sdim    raw_ostream &OS;
36193326Sed    unsigned IndentLevel;
37193326Sed    clang::PrinterHelper* Helper;
38193326Sed    PrintingPolicy Policy;
39193326Sed
40193326Sed  public:
41239462Sdim    StmtPrinter(raw_ostream &os, PrinterHelper* helper,
42195341Sed                const PrintingPolicy &Policy,
43193326Sed                unsigned Indentation = 0)
44239462Sdim      : OS(os), IndentLevel(Indentation), Helper(helper), Policy(Policy) {}
45198092Srdivacky
46193326Sed    void PrintStmt(Stmt *S) {
47193326Sed      PrintStmt(S, Policy.Indentation);
48193326Sed    }
49193326Sed
50193326Sed    void PrintStmt(Stmt *S, int SubIndent) {
51193326Sed      IndentLevel += SubIndent;
52193326Sed      if (S && isa<Expr>(S)) {
53193326Sed        // If this is an expr used in a stmt context, indent and newline it.
54193326Sed        Indent();
55193326Sed        Visit(S);
56193326Sed        OS << ";\n";
57193326Sed      } else if (S) {
58193326Sed        Visit(S);
59193326Sed      } else {
60193326Sed        Indent() << "<<<NULL STATEMENT>>>\n";
61193326Sed      }
62193326Sed      IndentLevel -= SubIndent;
63193326Sed    }
64193326Sed
65193326Sed    void PrintRawCompoundStmt(CompoundStmt *S);
66193326Sed    void PrintRawDecl(Decl *D);
67243830Sdim    void PrintRawDeclStmt(const DeclStmt *S);
68193326Sed    void PrintRawIfStmt(IfStmt *If);
69193326Sed    void PrintRawCXXCatchStmt(CXXCatchStmt *Catch);
70218893Sdim    void PrintCallArgs(CallExpr *E);
71221345Sdim    void PrintRawSEHExceptHandler(SEHExceptStmt *S);
72221345Sdim    void PrintRawSEHFinallyStmt(SEHFinallyStmt *S);
73198092Srdivacky
74193326Sed    void PrintExpr(Expr *E) {
75193326Sed      if (E)
76193326Sed        Visit(E);
77193326Sed      else
78193326Sed        OS << "<null expr>";
79193326Sed    }
80198092Srdivacky
81226633Sdim    raw_ostream &Indent(int Delta = 0) {
82193326Sed      for (int i = 0, e = IndentLevel+Delta; i < e; ++i)
83193326Sed        OS << "  ";
84193326Sed      return OS;
85193326Sed    }
86198092Srdivacky
87198092Srdivacky    void Visit(Stmt* S) {
88193326Sed      if (Helper && Helper->handledStmt(S,OS))
89193326Sed          return;
90193326Sed      else StmtVisitor<StmtPrinter>::Visit(S);
91193326Sed    }
92212904Sdim
93218893Sdim    void VisitStmt(Stmt *Node) LLVM_ATTRIBUTE_UNUSED {
94212904Sdim      Indent() << "<<unknown stmt type>>\n";
95212904Sdim    }
96218893Sdim    void VisitExpr(Expr *Node) LLVM_ATTRIBUTE_UNUSED {
97212904Sdim      OS << "<<unknown expr type>>";
98212904Sdim    }
99212904Sdim    void VisitCXXNamedCastExpr(CXXNamedCastExpr *Node);
100198092Srdivacky
101212904Sdim#define ABSTRACT_STMT(CLASS)
102193326Sed#define STMT(CLASS, PARENT) \
103193326Sed    void Visit##CLASS(CLASS *Node);
104208600Srdivacky#include "clang/AST/StmtNodes.inc"
105193326Sed  };
106193326Sed}
107193326Sed
108193326Sed//===----------------------------------------------------------------------===//
109193326Sed//  Stmt printing methods.
110193326Sed//===----------------------------------------------------------------------===//
111193326Sed
112193326Sed/// PrintRawCompoundStmt - Print a compound stmt without indenting the {, and
113193326Sed/// with no newline after the }.
114193326Sedvoid StmtPrinter::PrintRawCompoundStmt(CompoundStmt *Node) {
115193326Sed  OS << "{\n";
116193326Sed  for (CompoundStmt::body_iterator I = Node->body_begin(), E = Node->body_end();
117193326Sed       I != E; ++I)
118193326Sed    PrintStmt(*I);
119198092Srdivacky
120193326Sed  Indent() << "}";
121193326Sed}
122193326Sed
123193326Sedvoid StmtPrinter::PrintRawDecl(Decl *D) {
124195341Sed  D->print(OS, Policy, IndentLevel);
125193326Sed}
126193326Sed
127243830Sdimvoid StmtPrinter::PrintRawDeclStmt(const DeclStmt *S) {
128243830Sdim  DeclStmt::const_decl_iterator Begin = S->decl_begin(), End = S->decl_end();
129226633Sdim  SmallVector<Decl*, 2> Decls;
130198092Srdivacky  for ( ; Begin != End; ++Begin)
131193326Sed    Decls.push_back(*Begin);
132193326Sed
133195341Sed  Decl::printGroup(Decls.data(), Decls.size(), OS, Policy, IndentLevel);
134193326Sed}
135193326Sed
136193326Sedvoid StmtPrinter::VisitNullStmt(NullStmt *Node) {
137193326Sed  Indent() << ";\n";
138193326Sed}
139193326Sed
140193326Sedvoid StmtPrinter::VisitDeclStmt(DeclStmt *Node) {
141193326Sed  Indent();
142193326Sed  PrintRawDeclStmt(Node);
143193326Sed  OS << ";\n";
144193326Sed}
145193326Sed
146193326Sedvoid StmtPrinter::VisitCompoundStmt(CompoundStmt *Node) {
147193326Sed  Indent();
148193326Sed  PrintRawCompoundStmt(Node);
149193326Sed  OS << "\n";
150193326Sed}
151193326Sed
152193326Sedvoid StmtPrinter::VisitCaseStmt(CaseStmt *Node) {
153193326Sed  Indent(-1) << "case ";
154193326Sed  PrintExpr(Node->getLHS());
155193326Sed  if (Node->getRHS()) {
156193326Sed    OS << " ... ";
157193326Sed    PrintExpr(Node->getRHS());
158193326Sed  }
159193326Sed  OS << ":\n";
160198092Srdivacky
161193326Sed  PrintStmt(Node->getSubStmt(), 0);
162193326Sed}
163193326Sed
164193326Sedvoid StmtPrinter::VisitDefaultStmt(DefaultStmt *Node) {
165193326Sed  Indent(-1) << "default:\n";
166193326Sed  PrintStmt(Node->getSubStmt(), 0);
167193326Sed}
168193326Sed
169193326Sedvoid StmtPrinter::VisitLabelStmt(LabelStmt *Node) {
170193326Sed  Indent(-1) << Node->getName() << ":\n";
171193326Sed  PrintStmt(Node->getSubStmt(), 0);
172193326Sed}
173193326Sed
174234982Sdimvoid StmtPrinter::VisitAttributedStmt(AttributedStmt *Node) {
175234982Sdim  OS << "[[";
176234982Sdim  bool first = true;
177239462Sdim  for (ArrayRef<const Attr*>::iterator it = Node->getAttrs().begin(),
178239462Sdim                                       end = Node->getAttrs().end();
179239462Sdim                                       it != end; ++it) {
180234982Sdim    if (!first) {
181234982Sdim      OS << ", ";
182234982Sdim      first = false;
183234982Sdim    }
184234982Sdim    // TODO: check this
185239462Sdim    (*it)->printPretty(OS, Policy);
186234982Sdim  }
187234982Sdim  OS << "]] ";
188234982Sdim  PrintStmt(Node->getSubStmt(), 0);
189234982Sdim}
190234982Sdim
191193326Sedvoid StmtPrinter::PrintRawIfStmt(IfStmt *If) {
192193326Sed  OS << "if (";
193243830Sdim  if (const DeclStmt *DS = If->getConditionVariableDeclStmt())
194243830Sdim    PrintRawDeclStmt(DS);
195243830Sdim  else
196243830Sdim    PrintExpr(If->getCond());
197193326Sed  OS << ')';
198198092Srdivacky
199193326Sed  if (CompoundStmt *CS = dyn_cast<CompoundStmt>(If->getThen())) {
200193326Sed    OS << ' ';
201193326Sed    PrintRawCompoundStmt(CS);
202193326Sed    OS << (If->getElse() ? ' ' : '\n');
203193326Sed  } else {
204193326Sed    OS << '\n';
205193326Sed    PrintStmt(If->getThen());
206193326Sed    if (If->getElse()) Indent();
207193326Sed  }
208198092Srdivacky
209193326Sed  if (Stmt *Else = If->getElse()) {
210193326Sed    OS << "else";
211198092Srdivacky
212193326Sed    if (CompoundStmt *CS = dyn_cast<CompoundStmt>(Else)) {
213193326Sed      OS << ' ';
214193326Sed      PrintRawCompoundStmt(CS);
215193326Sed      OS << '\n';
216193326Sed    } else if (IfStmt *ElseIf = dyn_cast<IfStmt>(Else)) {
217193326Sed      OS << ' ';
218193326Sed      PrintRawIfStmt(ElseIf);
219193326Sed    } else {
220193326Sed      OS << '\n';
221193326Sed      PrintStmt(If->getElse());
222193326Sed    }
223193326Sed  }
224193326Sed}
225193326Sed
226193326Sedvoid StmtPrinter::VisitIfStmt(IfStmt *If) {
227193326Sed  Indent();
228193326Sed  PrintRawIfStmt(If);
229193326Sed}
230193326Sed
231193326Sedvoid StmtPrinter::VisitSwitchStmt(SwitchStmt *Node) {
232193326Sed  Indent() << "switch (";
233243830Sdim  if (const DeclStmt *DS = Node->getConditionVariableDeclStmt())
234243830Sdim    PrintRawDeclStmt(DS);
235243830Sdim  else
236243830Sdim    PrintExpr(Node->getCond());
237193326Sed  OS << ")";
238198092Srdivacky
239193326Sed  // Pretty print compoundstmt bodies (very common).
240193326Sed  if (CompoundStmt *CS = dyn_cast<CompoundStmt>(Node->getBody())) {
241193326Sed    OS << " ";
242193326Sed    PrintRawCompoundStmt(CS);
243193326Sed    OS << "\n";
244193326Sed  } else {
245193326Sed    OS << "\n";
246193326Sed    PrintStmt(Node->getBody());
247193326Sed  }
248193326Sed}
249193326Sed
250193326Sedvoid StmtPrinter::VisitWhileStmt(WhileStmt *Node) {
251193326Sed  Indent() << "while (";
252243830Sdim  if (const DeclStmt *DS = Node->getConditionVariableDeclStmt())
253243830Sdim    PrintRawDeclStmt(DS);
254243830Sdim  else
255243830Sdim    PrintExpr(Node->getCond());
256193326Sed  OS << ")\n";
257193326Sed  PrintStmt(Node->getBody());
258193326Sed}
259193326Sed
260193326Sedvoid StmtPrinter::VisitDoStmt(DoStmt *Node) {
261193326Sed  Indent() << "do ";
262193326Sed  if (CompoundStmt *CS = dyn_cast<CompoundStmt>(Node->getBody())) {
263193326Sed    PrintRawCompoundStmt(CS);
264193326Sed    OS << " ";
265193326Sed  } else {
266193326Sed    OS << "\n";
267193326Sed    PrintStmt(Node->getBody());
268193326Sed    Indent();
269193326Sed  }
270198092Srdivacky
271193326Sed  OS << "while (";
272193326Sed  PrintExpr(Node->getCond());
273193326Sed  OS << ");\n";
274193326Sed}
275193326Sed
276193326Sedvoid StmtPrinter::VisitForStmt(ForStmt *Node) {
277193326Sed  Indent() << "for (";
278193326Sed  if (Node->getInit()) {
279193326Sed    if (DeclStmt *DS = dyn_cast<DeclStmt>(Node->getInit()))
280193326Sed      PrintRawDeclStmt(DS);
281193326Sed    else
282193326Sed      PrintExpr(cast<Expr>(Node->getInit()));
283193326Sed  }
284193326Sed  OS << ";";
285193326Sed  if (Node->getCond()) {
286193326Sed    OS << " ";
287193326Sed    PrintExpr(Node->getCond());
288193326Sed  }
289193326Sed  OS << ";";
290193326Sed  if (Node->getInc()) {
291193326Sed    OS << " ";
292193326Sed    PrintExpr(Node->getInc());
293193326Sed  }
294193326Sed  OS << ") ";
295198092Srdivacky
296193326Sed  if (CompoundStmt *CS = dyn_cast<CompoundStmt>(Node->getBody())) {
297193326Sed    PrintRawCompoundStmt(CS);
298193326Sed    OS << "\n";
299193326Sed  } else {
300193326Sed    OS << "\n";
301193326Sed    PrintStmt(Node->getBody());
302193326Sed  }
303193326Sed}
304193326Sed
305193326Sedvoid StmtPrinter::VisitObjCForCollectionStmt(ObjCForCollectionStmt *Node) {
306193326Sed  Indent() << "for (";
307193326Sed  if (DeclStmt *DS = dyn_cast<DeclStmt>(Node->getElement()))
308193326Sed    PrintRawDeclStmt(DS);
309193326Sed  else
310193326Sed    PrintExpr(cast<Expr>(Node->getElement()));
311193326Sed  OS << " in ";
312193326Sed  PrintExpr(Node->getCollection());
313193326Sed  OS << ") ";
314198092Srdivacky
315193326Sed  if (CompoundStmt *CS = dyn_cast<CompoundStmt>(Node->getBody())) {
316193326Sed    PrintRawCompoundStmt(CS);
317193326Sed    OS << "\n";
318193326Sed  } else {
319193326Sed    OS << "\n";
320193326Sed    PrintStmt(Node->getBody());
321193326Sed  }
322193326Sed}
323193326Sed
324221345Sdimvoid StmtPrinter::VisitCXXForRangeStmt(CXXForRangeStmt *Node) {
325221345Sdim  Indent() << "for (";
326221345Sdim  PrintingPolicy SubPolicy(Policy);
327221345Sdim  SubPolicy.SuppressInitializers = true;
328221345Sdim  Node->getLoopVariable()->print(OS, SubPolicy, IndentLevel);
329221345Sdim  OS << " : ";
330221345Sdim  PrintExpr(Node->getRangeInit());
331221345Sdim  OS << ") {\n";
332221345Sdim  PrintStmt(Node->getBody());
333221345Sdim  Indent() << "}\n";
334221345Sdim}
335221345Sdim
336234353Sdimvoid StmtPrinter::VisitMSDependentExistsStmt(MSDependentExistsStmt *Node) {
337234353Sdim  Indent();
338234353Sdim  if (Node->isIfExists())
339234353Sdim    OS << "__if_exists (";
340234353Sdim  else
341234353Sdim    OS << "__if_not_exists (";
342234353Sdim
343234353Sdim  if (NestedNameSpecifier *Qualifier
344234353Sdim        = Node->getQualifierLoc().getNestedNameSpecifier())
345234353Sdim    Qualifier->print(OS, Policy);
346234353Sdim
347234353Sdim  OS << Node->getNameInfo() << ") ";
348234353Sdim
349234353Sdim  PrintRawCompoundStmt(Node->getSubStmt());
350234353Sdim}
351234353Sdim
352193326Sedvoid StmtPrinter::VisitGotoStmt(GotoStmt *Node) {
353193326Sed  Indent() << "goto " << Node->getLabel()->getName() << ";\n";
354193326Sed}
355193326Sed
356193326Sedvoid StmtPrinter::VisitIndirectGotoStmt(IndirectGotoStmt *Node) {
357193326Sed  Indent() << "goto *";
358193326Sed  PrintExpr(Node->getTarget());
359193326Sed  OS << ";\n";
360193326Sed}
361193326Sed
362193326Sedvoid StmtPrinter::VisitContinueStmt(ContinueStmt *Node) {
363193326Sed  Indent() << "continue;\n";
364193326Sed}
365193326Sed
366193326Sedvoid StmtPrinter::VisitBreakStmt(BreakStmt *Node) {
367193326Sed  Indent() << "break;\n";
368193326Sed}
369193326Sed
370193326Sed
371193326Sedvoid StmtPrinter::VisitReturnStmt(ReturnStmt *Node) {
372193326Sed  Indent() << "return";
373193326Sed  if (Node->getRetValue()) {
374193326Sed    OS << " ";
375193326Sed    PrintExpr(Node->getRetValue());
376193326Sed  }
377193326Sed  OS << ";\n";
378193326Sed}
379193326Sed
380193326Sed
381243830Sdimvoid StmtPrinter::VisitGCCAsmStmt(GCCAsmStmt *Node) {
382193326Sed  Indent() << "asm ";
383198092Srdivacky
384193326Sed  if (Node->isVolatile())
385193326Sed    OS << "volatile ";
386198092Srdivacky
387193326Sed  OS << "(";
388193326Sed  VisitStringLiteral(Node->getAsmString());
389198092Srdivacky
390193326Sed  // Outputs
391193326Sed  if (Node->getNumOutputs() != 0 || Node->getNumInputs() != 0 ||
392193326Sed      Node->getNumClobbers() != 0)
393193326Sed    OS << " : ";
394198092Srdivacky
395193326Sed  for (unsigned i = 0, e = Node->getNumOutputs(); i != e; ++i) {
396193326Sed    if (i != 0)
397193326Sed      OS << ", ";
398198092Srdivacky
399193326Sed    if (!Node->getOutputName(i).empty()) {
400193326Sed      OS << '[';
401193326Sed      OS << Node->getOutputName(i);
402193326Sed      OS << "] ";
403193326Sed    }
404198092Srdivacky
405193326Sed    VisitStringLiteral(Node->getOutputConstraintLiteral(i));
406193326Sed    OS << " ";
407193326Sed    Visit(Node->getOutputExpr(i));
408193326Sed  }
409198092Srdivacky
410193326Sed  // Inputs
411193326Sed  if (Node->getNumInputs() != 0 || Node->getNumClobbers() != 0)
412193326Sed    OS << " : ";
413198092Srdivacky
414193326Sed  for (unsigned i = 0, e = Node->getNumInputs(); i != e; ++i) {
415193326Sed    if (i != 0)
416193326Sed      OS << ", ";
417198092Srdivacky
418193326Sed    if (!Node->getInputName(i).empty()) {
419193326Sed      OS << '[';
420193326Sed      OS << Node->getInputName(i);
421193326Sed      OS << "] ";
422193326Sed    }
423198092Srdivacky
424193326Sed    VisitStringLiteral(Node->getInputConstraintLiteral(i));
425193326Sed    OS << " ";
426193326Sed    Visit(Node->getInputExpr(i));
427193326Sed  }
428198092Srdivacky
429193326Sed  // Clobbers
430193326Sed  if (Node->getNumClobbers() != 0)
431193326Sed    OS << " : ";
432198092Srdivacky
433193326Sed  for (unsigned i = 0, e = Node->getNumClobbers(); i != e; ++i) {
434193326Sed    if (i != 0)
435193326Sed      OS << ", ";
436198092Srdivacky
437243830Sdim    VisitStringLiteral(Node->getClobberStringLiteral(i));
438193326Sed  }
439198092Srdivacky
440193326Sed  OS << ");\n";
441193326Sed}
442193326Sed
443239462Sdimvoid StmtPrinter::VisitMSAsmStmt(MSAsmStmt *Node) {
444239462Sdim  // FIXME: Implement MS style inline asm statement printer.
445239462Sdim  Indent() << "__asm ";
446239462Sdim  if (Node->hasBraces())
447239462Sdim    OS << "{\n";
448251662Sdim  OS << Node->getAsmString() << "\n";
449239462Sdim  if (Node->hasBraces())
450239462Sdim    Indent() << "}\n";
451239462Sdim}
452239462Sdim
453251662Sdimvoid StmtPrinter::VisitCapturedStmt(CapturedStmt *Node) {
454251662Sdim  PrintStmt(Node->getCapturedDecl()->getBody());
455251662Sdim}
456251662Sdim
457193326Sedvoid StmtPrinter::VisitObjCAtTryStmt(ObjCAtTryStmt *Node) {
458193326Sed  Indent() << "@try";
459193326Sed  if (CompoundStmt *TS = dyn_cast<CompoundStmt>(Node->getTryBody())) {
460193326Sed    PrintRawCompoundStmt(TS);
461193326Sed    OS << "\n";
462193326Sed  }
463198092Srdivacky
464207619Srdivacky  for (unsigned I = 0, N = Node->getNumCatchStmts(); I != N; ++I) {
465207619Srdivacky    ObjCAtCatchStmt *catchStmt = Node->getCatchStmt(I);
466193326Sed    Indent() << "@catch(";
467193326Sed    if (catchStmt->getCatchParamDecl()) {
468193326Sed      if (Decl *DS = catchStmt->getCatchParamDecl())
469193326Sed        PrintRawDecl(DS);
470193326Sed    }
471193326Sed    OS << ")";
472198092Srdivacky    if (CompoundStmt *CS = dyn_cast<CompoundStmt>(catchStmt->getCatchBody())) {
473198092Srdivacky      PrintRawCompoundStmt(CS);
474198092Srdivacky      OS << "\n";
475198092Srdivacky    }
476193326Sed  }
477198092Srdivacky
478198092Srdivacky  if (ObjCAtFinallyStmt *FS = static_cast<ObjCAtFinallyStmt *>(
479198092Srdivacky        Node->getFinallyStmt())) {
480193326Sed    Indent() << "@finally";
481193326Sed    PrintRawCompoundStmt(dyn_cast<CompoundStmt>(FS->getFinallyBody()));
482193326Sed    OS << "\n";
483198092Srdivacky  }
484193326Sed}
485193326Sed
486193326Sedvoid StmtPrinter::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *Node) {
487193326Sed}
488193326Sed
489193326Sedvoid StmtPrinter::VisitObjCAtCatchStmt (ObjCAtCatchStmt *Node) {
490193326Sed  Indent() << "@catch (...) { /* todo */ } \n";
491193326Sed}
492193326Sed
493193326Sedvoid StmtPrinter::VisitObjCAtThrowStmt(ObjCAtThrowStmt *Node) {
494193326Sed  Indent() << "@throw";
495193326Sed  if (Node->getThrowExpr()) {
496193326Sed    OS << " ";
497193326Sed    PrintExpr(Node->getThrowExpr());
498193326Sed  }
499193326Sed  OS << ";\n";
500193326Sed}
501193326Sed
502193326Sedvoid StmtPrinter::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *Node) {
503193326Sed  Indent() << "@synchronized (";
504193326Sed  PrintExpr(Node->getSynchExpr());
505193326Sed  OS << ")";
506193326Sed  PrintRawCompoundStmt(Node->getSynchBody());
507193326Sed  OS << "\n";
508193326Sed}
509193326Sed
510224145Sdimvoid StmtPrinter::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *Node) {
511224145Sdim  Indent() << "@autoreleasepool";
512224145Sdim  PrintRawCompoundStmt(dyn_cast<CompoundStmt>(Node->getSubStmt()));
513224145Sdim  OS << "\n";
514224145Sdim}
515224145Sdim
516193326Sedvoid StmtPrinter::PrintRawCXXCatchStmt(CXXCatchStmt *Node) {
517193326Sed  OS << "catch (";
518193326Sed  if (Decl *ExDecl = Node->getExceptionDecl())
519193326Sed    PrintRawDecl(ExDecl);
520193326Sed  else
521193326Sed    OS << "...";
522193326Sed  OS << ") ";
523193326Sed  PrintRawCompoundStmt(cast<CompoundStmt>(Node->getHandlerBlock()));
524193326Sed}
525193326Sed
526193326Sedvoid StmtPrinter::VisitCXXCatchStmt(CXXCatchStmt *Node) {
527193326Sed  Indent();
528193326Sed  PrintRawCXXCatchStmt(Node);
529193326Sed  OS << "\n";
530193326Sed}
531193326Sed
532193326Sedvoid StmtPrinter::VisitCXXTryStmt(CXXTryStmt *Node) {
533193326Sed  Indent() << "try ";
534193326Sed  PrintRawCompoundStmt(Node->getTryBlock());
535198092Srdivacky  for (unsigned i = 0, e = Node->getNumHandlers(); i < e; ++i) {
536193326Sed    OS << " ";
537193326Sed    PrintRawCXXCatchStmt(Node->getHandler(i));
538193326Sed  }
539193326Sed  OS << "\n";
540193326Sed}
541193326Sed
542221345Sdimvoid StmtPrinter::VisitSEHTryStmt(SEHTryStmt *Node) {
543221345Sdim  Indent() << (Node->getIsCXXTry() ? "try " : "__try ");
544221345Sdim  PrintRawCompoundStmt(Node->getTryBlock());
545221345Sdim  SEHExceptStmt *E = Node->getExceptHandler();
546221345Sdim  SEHFinallyStmt *F = Node->getFinallyHandler();
547221345Sdim  if(E)
548221345Sdim    PrintRawSEHExceptHandler(E);
549221345Sdim  else {
550221345Sdim    assert(F && "Must have a finally block...");
551221345Sdim    PrintRawSEHFinallyStmt(F);
552221345Sdim  }
553221345Sdim  OS << "\n";
554221345Sdim}
555221345Sdim
556221345Sdimvoid StmtPrinter::PrintRawSEHFinallyStmt(SEHFinallyStmt *Node) {
557221345Sdim  OS << "__finally ";
558221345Sdim  PrintRawCompoundStmt(Node->getBlock());
559221345Sdim  OS << "\n";
560221345Sdim}
561221345Sdim
562221345Sdimvoid StmtPrinter::PrintRawSEHExceptHandler(SEHExceptStmt *Node) {
563221345Sdim  OS << "__except (";
564221345Sdim  VisitExpr(Node->getFilterExpr());
565221345Sdim  OS << ")\n";
566221345Sdim  PrintRawCompoundStmt(Node->getBlock());
567221345Sdim  OS << "\n";
568221345Sdim}
569221345Sdim
570221345Sdimvoid StmtPrinter::VisitSEHExceptStmt(SEHExceptStmt *Node) {
571221345Sdim  Indent();
572221345Sdim  PrintRawSEHExceptHandler(Node);
573221345Sdim  OS << "\n";
574221345Sdim}
575221345Sdim
576221345Sdimvoid StmtPrinter::VisitSEHFinallyStmt(SEHFinallyStmt *Node) {
577221345Sdim  Indent();
578221345Sdim  PrintRawSEHFinallyStmt(Node);
579221345Sdim  OS << "\n";
580221345Sdim}
581221345Sdim
582193326Sed//===----------------------------------------------------------------------===//
583193326Sed//  Expr printing methods.
584193326Sed//===----------------------------------------------------------------------===//
585193326Sed
586193326Sedvoid StmtPrinter::VisitDeclRefExpr(DeclRefExpr *Node) {
587198893Srdivacky  if (NestedNameSpecifier *Qualifier = Node->getQualifier())
588198893Srdivacky    Qualifier->print(OS, Policy);
589234353Sdim  if (Node->hasTemplateKeyword())
590234353Sdim    OS << "template ";
591212904Sdim  OS << Node->getNameInfo();
592212904Sdim  if (Node->hasExplicitTemplateArgs())
593249423Sdim    TemplateSpecializationType::PrintTemplateArgumentList(
594249423Sdim        OS, Node->getTemplateArgs(), Node->getNumTemplateArgs(), Policy);
595193326Sed}
596193326Sed
597199990Srdivackyvoid StmtPrinter::VisitDependentScopeDeclRefExpr(
598199990Srdivacky                                           DependentScopeDeclRefExpr *Node) {
599218893Sdim  if (NestedNameSpecifier *Qualifier = Node->getQualifier())
600218893Sdim    Qualifier->print(OS, Policy);
601234353Sdim  if (Node->hasTemplateKeyword())
602234353Sdim    OS << "template ";
603212904Sdim  OS << Node->getNameInfo();
604199990Srdivacky  if (Node->hasExplicitTemplateArgs())
605249423Sdim    TemplateSpecializationType::PrintTemplateArgumentList(
606249423Sdim        OS, Node->getTemplateArgs(), Node->getNumTemplateArgs(), Policy);
607193326Sed}
608193326Sed
609199990Srdivackyvoid StmtPrinter::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *Node) {
610195341Sed  if (Node->getQualifier())
611195341Sed    Node->getQualifier()->print(OS, Policy);
612234353Sdim  if (Node->hasTemplateKeyword())
613234353Sdim    OS << "template ";
614212904Sdim  OS << Node->getNameInfo();
615199990Srdivacky  if (Node->hasExplicitTemplateArgs())
616249423Sdim    TemplateSpecializationType::PrintTemplateArgumentList(
617249423Sdim        OS, Node->getTemplateArgs(), Node->getNumTemplateArgs(), Policy);
618195341Sed}
619195341Sed
620193326Sedvoid StmtPrinter::VisitObjCIvarRefExpr(ObjCIvarRefExpr *Node) {
621193326Sed  if (Node->getBase()) {
622193326Sed    PrintExpr(Node->getBase());
623193326Sed    OS << (Node->isArrow() ? "->" : ".");
624193326Sed  }
625226633Sdim  OS << *Node->getDecl();
626193326Sed}
627193326Sed
628193326Sedvoid StmtPrinter::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *Node) {
629218893Sdim  if (Node->isSuperReceiver())
630218893Sdim    OS << "super.";
631218893Sdim  else if (Node->getBase()) {
632193326Sed    PrintExpr(Node->getBase());
633193326Sed    OS << ".";
634193326Sed  }
635193326Sed
636218893Sdim  if (Node->isImplicitProperty())
637218893Sdim    OS << Node->getImplicitPropertyGetter()->getSelector().getAsString();
638218893Sdim  else
639218893Sdim    OS << Node->getExplicitProperty()->getName();
640193326Sed}
641193326Sed
642234353Sdimvoid StmtPrinter::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *Node) {
643234353Sdim
644234353Sdim  PrintExpr(Node->getBaseExpr());
645234353Sdim  OS << "[";
646234353Sdim  PrintExpr(Node->getKeyExpr());
647234353Sdim  OS << "]";
648234353Sdim}
649234353Sdim
650193326Sedvoid StmtPrinter::VisitPredefinedExpr(PredefinedExpr *Node) {
651193326Sed  switch (Node->getIdentType()) {
652193326Sed    default:
653226633Sdim      llvm_unreachable("unknown case");
654193326Sed    case PredefinedExpr::Func:
655193326Sed      OS << "__func__";
656193326Sed      break;
657193326Sed    case PredefinedExpr::Function:
658193326Sed      OS << "__FUNCTION__";
659193326Sed      break;
660239462Sdim    case PredefinedExpr::LFunction:
661239462Sdim      OS << "L__FUNCTION__";
662239462Sdim      break;
663193326Sed    case PredefinedExpr::PrettyFunction:
664193326Sed      OS << "__PRETTY_FUNCTION__";
665193326Sed      break;
666193326Sed  }
667193326Sed}
668193326Sed
669193326Sedvoid StmtPrinter::VisitCharacterLiteral(CharacterLiteral *Node) {
670193326Sed  unsigned value = Node->getValue();
671226633Sdim
672226633Sdim  switch (Node->getKind()) {
673226633Sdim  case CharacterLiteral::Ascii: break; // no prefix.
674226633Sdim  case CharacterLiteral::Wide:  OS << 'L'; break;
675226633Sdim  case CharacterLiteral::UTF16: OS << 'u'; break;
676226633Sdim  case CharacterLiteral::UTF32: OS << 'U'; break;
677226633Sdim  }
678226633Sdim
679193326Sed  switch (value) {
680193326Sed  case '\\':
681193326Sed    OS << "'\\\\'";
682193326Sed    break;
683193326Sed  case '\'':
684193326Sed    OS << "'\\''";
685193326Sed    break;
686193326Sed  case '\a':
687193326Sed    // TODO: K&R: the meaning of '\\a' is different in traditional C
688193326Sed    OS << "'\\a'";
689193326Sed    break;
690193326Sed  case '\b':
691193326Sed    OS << "'\\b'";
692193326Sed    break;
693193326Sed  // Nonstandard escape sequence.
694193326Sed  /*case '\e':
695193326Sed    OS << "'\\e'";
696193326Sed    break;*/
697193326Sed  case '\f':
698193326Sed    OS << "'\\f'";
699193326Sed    break;
700193326Sed  case '\n':
701193326Sed    OS << "'\\n'";
702193326Sed    break;
703193326Sed  case '\r':
704193326Sed    OS << "'\\r'";
705193326Sed    break;
706193326Sed  case '\t':
707193326Sed    OS << "'\\t'";
708193326Sed    break;
709193326Sed  case '\v':
710193326Sed    OS << "'\\v'";
711193326Sed    break;
712193326Sed  default:
713249423Sdim    if (value < 256 && isPrintable((unsigned char)value))
714193326Sed      OS << "'" << (char)value << "'";
715249423Sdim    else if (value < 256)
716249423Sdim      OS << "'\\x" << llvm::format("%02x", value) << "'";
717249423Sdim    else if (value <= 0xFFFF)
718249423Sdim      OS << "'\\u" << llvm::format("%04x", value) << "'";
719249423Sdim    else
720249423Sdim      OS << "'\\U" << llvm::format("%08x", value) << "'";
721193326Sed  }
722193326Sed}
723193326Sed
724193326Sedvoid StmtPrinter::VisitIntegerLiteral(IntegerLiteral *Node) {
725193326Sed  bool isSigned = Node->getType()->isSignedIntegerType();
726193326Sed  OS << Node->getValue().toString(10, isSigned);
727198092Srdivacky
728193326Sed  // Emit suffixes.  Integer literals are always a builtin integer type.
729198092Srdivacky  switch (Node->getType()->getAs<BuiltinType>()->getKind()) {
730226633Sdim  default: llvm_unreachable("Unexpected type for integer literal!");
731234353Sdim  // FIXME: The Short and UShort cases are to handle cases where a short
732234353Sdim  // integeral literal is formed during template instantiation.  They should
733234353Sdim  // be removed when template instantiation no longer needs integer literals.
734234353Sdim  case BuiltinType::Short:
735234353Sdim  case BuiltinType::UShort:
736193326Sed  case BuiltinType::Int:       break; // no suffix.
737193326Sed  case BuiltinType::UInt:      OS << 'U'; break;
738193326Sed  case BuiltinType::Long:      OS << 'L'; break;
739193326Sed  case BuiltinType::ULong:     OS << "UL"; break;
740193326Sed  case BuiltinType::LongLong:  OS << "LL"; break;
741193326Sed  case BuiltinType::ULongLong: OS << "ULL"; break;
742234353Sdim  case BuiltinType::Int128:    OS << "i128"; break;
743234353Sdim  case BuiltinType::UInt128:   OS << "Ui128"; break;
744193326Sed  }
745193326Sed}
746243830Sdim
747243830Sdimstatic void PrintFloatingLiteral(raw_ostream &OS, FloatingLiteral *Node,
748243830Sdim                                 bool PrintSuffix) {
749234353Sdim  SmallString<16> Str;
750226633Sdim  Node->getValue().toString(Str);
751226633Sdim  OS << Str;
752243830Sdim  if (Str.find_first_not_of("-0123456789") == StringRef::npos)
753243830Sdim    OS << '.'; // Trailing dot in order to separate from ints.
754243830Sdim
755243830Sdim  if (!PrintSuffix)
756243830Sdim    return;
757243830Sdim
758243830Sdim  // Emit suffixes.  Float literals are always a builtin float type.
759243830Sdim  switch (Node->getType()->getAs<BuiltinType>()->getKind()) {
760243830Sdim  default: llvm_unreachable("Unexpected type for float literal!");
761243830Sdim  case BuiltinType::Half:       break; // FIXME: suffix?
762243830Sdim  case BuiltinType::Double:     break; // no suffix.
763243830Sdim  case BuiltinType::Float:      OS << 'F'; break;
764243830Sdim  case BuiltinType::LongDouble: OS << 'L'; break;
765243830Sdim  }
766193326Sed}
767193326Sed
768243830Sdimvoid StmtPrinter::VisitFloatingLiteral(FloatingLiteral *Node) {
769243830Sdim  PrintFloatingLiteral(OS, Node, /*PrintSuffix=*/true);
770243830Sdim}
771243830Sdim
772193326Sedvoid StmtPrinter::VisitImaginaryLiteral(ImaginaryLiteral *Node) {
773193326Sed  PrintExpr(Node->getSubExpr());
774193326Sed  OS << "i";
775193326Sed}
776193326Sed
777193326Sedvoid StmtPrinter::VisitStringLiteral(StringLiteral *Str) {
778239462Sdim  Str->outputString(OS);
779193326Sed}
780193326Sedvoid StmtPrinter::VisitParenExpr(ParenExpr *Node) {
781193326Sed  OS << "(";
782193326Sed  PrintExpr(Node->getSubExpr());
783193326Sed  OS << ")";
784193326Sed}
785193326Sedvoid StmtPrinter::VisitUnaryOperator(UnaryOperator *Node) {
786193326Sed  if (!Node->isPostfix()) {
787193326Sed    OS << UnaryOperator::getOpcodeStr(Node->getOpcode());
788198092Srdivacky
789194613Sed    // Print a space if this is an "identifier operator" like __real, or if
790194613Sed    // it might be concatenated incorrectly like '+'.
791193326Sed    switch (Node->getOpcode()) {
792193326Sed    default: break;
793212904Sdim    case UO_Real:
794212904Sdim    case UO_Imag:
795212904Sdim    case UO_Extension:
796193326Sed      OS << ' ';
797193326Sed      break;
798212904Sdim    case UO_Plus:
799212904Sdim    case UO_Minus:
800194613Sed      if (isa<UnaryOperator>(Node->getSubExpr()))
801194613Sed        OS << ' ';
802194613Sed      break;
803193326Sed    }
804193326Sed  }
805193326Sed  PrintExpr(Node->getSubExpr());
806198092Srdivacky
807193326Sed  if (Node->isPostfix())
808193326Sed    OS << UnaryOperator::getOpcodeStr(Node->getOpcode());
809193326Sed}
810193326Sed
811207619Srdivackyvoid StmtPrinter::VisitOffsetOfExpr(OffsetOfExpr *Node) {
812207619Srdivacky  OS << "__builtin_offsetof(";
813249423Sdim  Node->getTypeSourceInfo()->getType().print(OS, Policy);
814249423Sdim  OS << ", ";
815207619Srdivacky  bool PrintedSomething = false;
816207619Srdivacky  for (unsigned i = 0, n = Node->getNumComponents(); i < n; ++i) {
817207619Srdivacky    OffsetOfExpr::OffsetOfNode ON = Node->getComponent(i);
818207619Srdivacky    if (ON.getKind() == OffsetOfExpr::OffsetOfNode::Array) {
819207619Srdivacky      // Array node
820207619Srdivacky      OS << "[";
821207619Srdivacky      PrintExpr(Node->getIndexExpr(ON.getArrayExprIndex()));
822207619Srdivacky      OS << "]";
823207619Srdivacky      PrintedSomething = true;
824207619Srdivacky      continue;
825207619Srdivacky    }
826207619Srdivacky
827207619Srdivacky    // Skip implicit base indirections.
828207619Srdivacky    if (ON.getKind() == OffsetOfExpr::OffsetOfNode::Base)
829207619Srdivacky      continue;
830207619Srdivacky
831207619Srdivacky    // Field or identifier node.
832207619Srdivacky    IdentifierInfo *Id = ON.getFieldName();
833207619Srdivacky    if (!Id)
834207619Srdivacky      continue;
835207619Srdivacky
836207619Srdivacky    if (PrintedSomething)
837207619Srdivacky      OS << ".";
838207619Srdivacky    else
839207619Srdivacky      PrintedSomething = true;
840207619Srdivacky    OS << Id->getName();
841207619Srdivacky  }
842207619Srdivacky  OS << ")";
843207619Srdivacky}
844207619Srdivacky
845221345Sdimvoid StmtPrinter::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *Node){
846221345Sdim  switch(Node->getKind()) {
847221345Sdim  case UETT_SizeOf:
848221345Sdim    OS << "sizeof";
849221345Sdim    break;
850221345Sdim  case UETT_AlignOf:
851239462Sdim    if (Policy.LangOpts.CPlusPlus)
852239462Sdim      OS << "alignof";
853239462Sdim    else if (Policy.LangOpts.C11)
854239462Sdim      OS << "_Alignof";
855239462Sdim    else
856239462Sdim      OS << "__alignof";
857221345Sdim    break;
858221345Sdim  case UETT_VecStep:
859221345Sdim    OS << "vec_step";
860221345Sdim    break;
861221345Sdim  }
862249423Sdim  if (Node->isArgumentType()) {
863249423Sdim    OS << '(';
864249423Sdim    Node->getArgumentType().print(OS, Policy);
865249423Sdim    OS << ')';
866249423Sdim  } else {
867193326Sed    OS << " ";
868193326Sed    PrintExpr(Node->getArgumentExpr());
869193326Sed  }
870193326Sed}
871221345Sdim
872221345Sdimvoid StmtPrinter::VisitGenericSelectionExpr(GenericSelectionExpr *Node) {
873221345Sdim  OS << "_Generic(";
874221345Sdim  PrintExpr(Node->getControllingExpr());
875221345Sdim  for (unsigned i = 0; i != Node->getNumAssocs(); ++i) {
876221345Sdim    OS << ", ";
877221345Sdim    QualType T = Node->getAssocType(i);
878221345Sdim    if (T.isNull())
879221345Sdim      OS << "default";
880221345Sdim    else
881249423Sdim      T.print(OS, Policy);
882221345Sdim    OS << ": ";
883221345Sdim    PrintExpr(Node->getAssocExpr(i));
884221345Sdim  }
885221345Sdim  OS << ")";
886221345Sdim}
887221345Sdim
888193326Sedvoid StmtPrinter::VisitArraySubscriptExpr(ArraySubscriptExpr *Node) {
889193326Sed  PrintExpr(Node->getLHS());
890193326Sed  OS << "[";
891193326Sed  PrintExpr(Node->getRHS());
892193326Sed  OS << "]";
893193326Sed}
894193326Sed
895218893Sdimvoid StmtPrinter::PrintCallArgs(CallExpr *Call) {
896193326Sed  for (unsigned i = 0, e = Call->getNumArgs(); i != e; ++i) {
897193326Sed    if (isa<CXXDefaultArgExpr>(Call->getArg(i))) {
898193326Sed      // Don't print any defaulted arguments
899193326Sed      break;
900193326Sed    }
901193326Sed
902193326Sed    if (i) OS << ", ";
903193326Sed    PrintExpr(Call->getArg(i));
904193326Sed  }
905218893Sdim}
906218893Sdim
907218893Sdimvoid StmtPrinter::VisitCallExpr(CallExpr *Call) {
908218893Sdim  PrintExpr(Call->getCallee());
909218893Sdim  OS << "(";
910218893Sdim  PrintCallArgs(Call);
911193326Sed  OS << ")";
912193326Sed}
913193326Sedvoid StmtPrinter::VisitMemberExpr(MemberExpr *Node) {
914193326Sed  // FIXME: Suppress printing implicit bases (like "this")
915193326Sed  PrintExpr(Node->getBase());
916249423Sdim
917249423Sdim  MemberExpr *ParentMember = dyn_cast<MemberExpr>(Node->getBase());
918249423Sdim  FieldDecl  *ParentDecl   = ParentMember
919249423Sdim    ? dyn_cast<FieldDecl>(ParentMember->getMemberDecl()) : NULL;
920249423Sdim
921249423Sdim  if (!ParentDecl || !ParentDecl->isAnonymousStructOrUnion())
922249423Sdim    OS << (Node->isArrow() ? "->" : ".");
923249423Sdim
924202379Srdivacky  if (FieldDecl *FD = dyn_cast<FieldDecl>(Node->getMemberDecl()))
925202379Srdivacky    if (FD->isAnonymousStructOrUnion())
926202379Srdivacky      return;
927249423Sdim
928198092Srdivacky  if (NestedNameSpecifier *Qualifier = Node->getQualifier())
929198092Srdivacky    Qualifier->print(OS, Policy);
930234353Sdim  if (Node->hasTemplateKeyword())
931234353Sdim    OS << "template ";
932212904Sdim  OS << Node->getMemberNameInfo();
933212904Sdim  if (Node->hasExplicitTemplateArgs())
934249423Sdim    TemplateSpecializationType::PrintTemplateArgumentList(
935249423Sdim        OS, Node->getTemplateArgs(), Node->getNumTemplateArgs(), Policy);
936193326Sed}
937198092Srdivackyvoid StmtPrinter::VisitObjCIsaExpr(ObjCIsaExpr *Node) {
938198092Srdivacky  PrintExpr(Node->getBase());
939198092Srdivacky  OS << (Node->isArrow() ? "->isa" : ".isa");
940198092Srdivacky}
941198092Srdivacky
942193326Sedvoid StmtPrinter::VisitExtVectorElementExpr(ExtVectorElementExpr *Node) {
943193326Sed  PrintExpr(Node->getBase());
944193326Sed  OS << ".";
945193326Sed  OS << Node->getAccessor().getName();
946193326Sed}
947193326Sedvoid StmtPrinter::VisitCStyleCastExpr(CStyleCastExpr *Node) {
948249423Sdim  OS << '(';
949249423Sdim  Node->getTypeAsWritten().print(OS, Policy);
950249423Sdim  OS << ')';
951193326Sed  PrintExpr(Node->getSubExpr());
952193326Sed}
953193326Sedvoid StmtPrinter::VisitCompoundLiteralExpr(CompoundLiteralExpr *Node) {
954249423Sdim  OS << '(';
955249423Sdim  Node->getType().print(OS, Policy);
956249423Sdim  OS << ')';
957193326Sed  PrintExpr(Node->getInitializer());
958193326Sed}
959193326Sedvoid StmtPrinter::VisitImplicitCastExpr(ImplicitCastExpr *Node) {
960193326Sed  // No need to print anything, simply forward to the sub expression.
961193326Sed  PrintExpr(Node->getSubExpr());
962193326Sed}
963193326Sedvoid StmtPrinter::VisitBinaryOperator(BinaryOperator *Node) {
964193326Sed  PrintExpr(Node->getLHS());
965193326Sed  OS << " " << BinaryOperator::getOpcodeStr(Node->getOpcode()) << " ";
966193326Sed  PrintExpr(Node->getRHS());
967193326Sed}
968193326Sedvoid StmtPrinter::VisitCompoundAssignOperator(CompoundAssignOperator *Node) {
969193326Sed  PrintExpr(Node->getLHS());
970193326Sed  OS << " " << BinaryOperator::getOpcodeStr(Node->getOpcode()) << " ";
971193326Sed  PrintExpr(Node->getRHS());
972193326Sed}
973193326Sedvoid StmtPrinter::VisitConditionalOperator(ConditionalOperator *Node) {
974193326Sed  PrintExpr(Node->getCond());
975218893Sdim  OS << " ? ";
976218893Sdim  PrintExpr(Node->getLHS());
977218893Sdim  OS << " : ";
978193326Sed  PrintExpr(Node->getRHS());
979193326Sed}
980193326Sed
981193326Sed// GNU extensions.
982193326Sed
983218893Sdimvoid
984218893SdimStmtPrinter::VisitBinaryConditionalOperator(BinaryConditionalOperator *Node) {
985218893Sdim  PrintExpr(Node->getCommon());
986218893Sdim  OS << " ?: ";
987218893Sdim  PrintExpr(Node->getFalseExpr());
988218893Sdim}
989193326Sedvoid StmtPrinter::VisitAddrLabelExpr(AddrLabelExpr *Node) {
990193326Sed  OS << "&&" << Node->getLabel()->getName();
991193326Sed}
992193326Sed
993193326Sedvoid StmtPrinter::VisitStmtExpr(StmtExpr *E) {
994193326Sed  OS << "(";
995193326Sed  PrintRawCompoundStmt(E->getSubStmt());
996193326Sed  OS << ")";
997193326Sed}
998193326Sed
999193326Sedvoid StmtPrinter::VisitChooseExpr(ChooseExpr *Node) {
1000193326Sed  OS << "__builtin_choose_expr(";
1001193326Sed  PrintExpr(Node->getCond());
1002193326Sed  OS << ", ";
1003193326Sed  PrintExpr(Node->getLHS());
1004193326Sed  OS << ", ";
1005193326Sed  PrintExpr(Node->getRHS());
1006193326Sed  OS << ")";
1007193326Sed}
1008193326Sed
1009193326Sedvoid StmtPrinter::VisitGNUNullExpr(GNUNullExpr *) {
1010193326Sed  OS << "__null";
1011193326Sed}
1012193326Sed
1013193326Sedvoid StmtPrinter::VisitShuffleVectorExpr(ShuffleVectorExpr *Node) {
1014193326Sed  OS << "__builtin_shufflevector(";
1015193326Sed  for (unsigned i = 0, e = Node->getNumSubExprs(); i != e; ++i) {
1016193326Sed    if (i) OS << ", ";
1017193326Sed    PrintExpr(Node->getExpr(i));
1018193326Sed  }
1019193326Sed  OS << ")";
1020193326Sed}
1021193326Sed
1022193326Sedvoid StmtPrinter::VisitInitListExpr(InitListExpr* Node) {
1023193326Sed  if (Node->getSyntacticForm()) {
1024193326Sed    Visit(Node->getSyntacticForm());
1025193326Sed    return;
1026193326Sed  }
1027193326Sed
1028193326Sed  OS << "{ ";
1029193326Sed  for (unsigned i = 0, e = Node->getNumInits(); i != e; ++i) {
1030193326Sed    if (i) OS << ", ";
1031193326Sed    if (Node->getInit(i))
1032193326Sed      PrintExpr(Node->getInit(i));
1033193326Sed    else
1034193326Sed      OS << "0";
1035193326Sed  }
1036193326Sed  OS << " }";
1037193326Sed}
1038193326Sed
1039198092Srdivackyvoid StmtPrinter::VisitParenListExpr(ParenListExpr* Node) {
1040198092Srdivacky  OS << "( ";
1041198092Srdivacky  for (unsigned i = 0, e = Node->getNumExprs(); i != e; ++i) {
1042198092Srdivacky    if (i) OS << ", ";
1043198092Srdivacky    PrintExpr(Node->getExpr(i));
1044198092Srdivacky  }
1045198092Srdivacky  OS << " )";
1046198092Srdivacky}
1047198092Srdivacky
1048193326Sedvoid StmtPrinter::VisitDesignatedInitExpr(DesignatedInitExpr *Node) {
1049193326Sed  for (DesignatedInitExpr::designators_iterator D = Node->designators_begin(),
1050193326Sed                      DEnd = Node->designators_end();
1051193326Sed       D != DEnd; ++D) {
1052193326Sed    if (D->isFieldDesignator()) {
1053193326Sed      if (D->getDotLoc().isInvalid())
1054193326Sed        OS << D->getFieldName()->getName() << ":";
1055193326Sed      else
1056193326Sed        OS << "." << D->getFieldName()->getName();
1057193326Sed    } else {
1058193326Sed      OS << "[";
1059193326Sed      if (D->isArrayDesignator()) {
1060193326Sed        PrintExpr(Node->getArrayIndex(*D));
1061193326Sed      } else {
1062193326Sed        PrintExpr(Node->getArrayRangeStart(*D));
1063193326Sed        OS << " ... ";
1064198092Srdivacky        PrintExpr(Node->getArrayRangeEnd(*D));
1065193326Sed      }
1066193326Sed      OS << "]";
1067193326Sed    }
1068193326Sed  }
1069193326Sed
1070193326Sed  OS << " = ";
1071193326Sed  PrintExpr(Node->getInit());
1072193326Sed}
1073193326Sed
1074193326Sedvoid StmtPrinter::VisitImplicitValueInitExpr(ImplicitValueInitExpr *Node) {
1075249423Sdim  if (Policy.LangOpts.CPlusPlus) {
1076249423Sdim    OS << "/*implicit*/";
1077249423Sdim    Node->getType().print(OS, Policy);
1078249423Sdim    OS << "()";
1079249423Sdim  } else {
1080249423Sdim    OS << "/*implicit*/(";
1081249423Sdim    Node->getType().print(OS, Policy);
1082249423Sdim    OS << ')';
1083193326Sed    if (Node->getType()->isRecordType())
1084193326Sed      OS << "{}";
1085193326Sed    else
1086193326Sed      OS << 0;
1087193326Sed  }
1088193326Sed}
1089193326Sed
1090193326Sedvoid StmtPrinter::VisitVAArgExpr(VAArgExpr *Node) {
1091193326Sed  OS << "__builtin_va_arg(";
1092193326Sed  PrintExpr(Node->getSubExpr());
1093193326Sed  OS << ", ";
1094249423Sdim  Node->getType().print(OS, Policy);
1095193326Sed  OS << ")";
1096193326Sed}
1097193326Sed
1098234353Sdimvoid StmtPrinter::VisitPseudoObjectExpr(PseudoObjectExpr *Node) {
1099234353Sdim  PrintExpr(Node->getSyntacticForm());
1100234353Sdim}
1101234353Sdim
1102226633Sdimvoid StmtPrinter::VisitAtomicExpr(AtomicExpr *Node) {
1103226633Sdim  const char *Name = 0;
1104226633Sdim  switch (Node->getOp()) {
1105234353Sdim#define BUILTIN(ID, TYPE, ATTRS)
1106234353Sdim#define ATOMIC_BUILTIN(ID, TYPE, ATTRS) \
1107234353Sdim  case AtomicExpr::AO ## ID: \
1108234353Sdim    Name = #ID "("; \
1109234353Sdim    break;
1110234353Sdim#include "clang/Basic/Builtins.def"
1111226633Sdim  }
1112226633Sdim  OS << Name;
1113234353Sdim
1114234353Sdim  // AtomicExpr stores its subexpressions in a permuted order.
1115226633Sdim  PrintExpr(Node->getPtr());
1116234353Sdim  if (Node->getOp() != AtomicExpr::AO__c11_atomic_load &&
1117234353Sdim      Node->getOp() != AtomicExpr::AO__atomic_load_n) {
1118251662Sdim    OS << ", ";
1119226633Sdim    PrintExpr(Node->getVal1());
1120226633Sdim  }
1121234353Sdim  if (Node->getOp() == AtomicExpr::AO__atomic_exchange ||
1122234353Sdim      Node->isCmpXChg()) {
1123251662Sdim    OS << ", ";
1124226633Sdim    PrintExpr(Node->getVal2());
1125226633Sdim  }
1126234353Sdim  if (Node->getOp() == AtomicExpr::AO__atomic_compare_exchange ||
1127234353Sdim      Node->getOp() == AtomicExpr::AO__atomic_compare_exchange_n) {
1128251662Sdim    OS << ", ";
1129234353Sdim    PrintExpr(Node->getWeak());
1130251662Sdim  }
1131251662Sdim  if (Node->getOp() != AtomicExpr::AO__c11_atomic_init) {
1132234353Sdim    OS << ", ";
1133251662Sdim    PrintExpr(Node->getOrder());
1134234353Sdim  }
1135226633Sdim  if (Node->isCmpXChg()) {
1136226633Sdim    OS << ", ";
1137226633Sdim    PrintExpr(Node->getOrderFail());
1138226633Sdim  }
1139226633Sdim  OS << ")";
1140226633Sdim}
1141226633Sdim
1142193326Sed// C++
1143193326Sedvoid StmtPrinter::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *Node) {
1144193326Sed  const char *OpStrings[NUM_OVERLOADED_OPERATORS] = {
1145193326Sed    "",
1146193326Sed#define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \
1147193326Sed    Spelling,
1148193326Sed#include "clang/Basic/OperatorKinds.def"
1149193326Sed  };
1150193326Sed
1151193326Sed  OverloadedOperatorKind Kind = Node->getOperator();
1152193326Sed  if (Kind == OO_PlusPlus || Kind == OO_MinusMinus) {
1153193326Sed    if (Node->getNumArgs() == 1) {
1154193326Sed      OS << OpStrings[Kind] << ' ';
1155193326Sed      PrintExpr(Node->getArg(0));
1156193326Sed    } else {
1157193326Sed      PrintExpr(Node->getArg(0));
1158193326Sed      OS << ' ' << OpStrings[Kind];
1159193326Sed    }
1160243830Sdim  } else if (Kind == OO_Arrow) {
1161243830Sdim    PrintExpr(Node->getArg(0));
1162193326Sed  } else if (Kind == OO_Call) {
1163193326Sed    PrintExpr(Node->getArg(0));
1164193326Sed    OS << '(';
1165193326Sed    for (unsigned ArgIdx = 1; ArgIdx < Node->getNumArgs(); ++ArgIdx) {
1166193326Sed      if (ArgIdx > 1)
1167193326Sed        OS << ", ";
1168193326Sed      if (!isa<CXXDefaultArgExpr>(Node->getArg(ArgIdx)))
1169193326Sed        PrintExpr(Node->getArg(ArgIdx));
1170193326Sed    }
1171193326Sed    OS << ')';
1172193326Sed  } else if (Kind == OO_Subscript) {
1173193326Sed    PrintExpr(Node->getArg(0));
1174193326Sed    OS << '[';
1175193326Sed    PrintExpr(Node->getArg(1));
1176193326Sed    OS << ']';
1177193326Sed  } else if (Node->getNumArgs() == 1) {
1178193326Sed    OS << OpStrings[Kind] << ' ';
1179193326Sed    PrintExpr(Node->getArg(0));
1180193326Sed  } else if (Node->getNumArgs() == 2) {
1181193326Sed    PrintExpr(Node->getArg(0));
1182193326Sed    OS << ' ' << OpStrings[Kind] << ' ';
1183193326Sed    PrintExpr(Node->getArg(1));
1184193326Sed  } else {
1185226633Sdim    llvm_unreachable("unknown overloaded operator");
1186193326Sed  }
1187193326Sed}
1188193326Sed
1189193326Sedvoid StmtPrinter::VisitCXXMemberCallExpr(CXXMemberCallExpr *Node) {
1190193326Sed  VisitCallExpr(cast<CallExpr>(Node));
1191193326Sed}
1192193326Sed
1193218893Sdimvoid StmtPrinter::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *Node) {
1194218893Sdim  PrintExpr(Node->getCallee());
1195218893Sdim  OS << "<<<";
1196218893Sdim  PrintCallArgs(Node->getConfig());
1197218893Sdim  OS << ">>>(";
1198218893Sdim  PrintCallArgs(Node);
1199218893Sdim  OS << ")";
1200218893Sdim}
1201218893Sdim
1202193326Sedvoid StmtPrinter::VisitCXXNamedCastExpr(CXXNamedCastExpr *Node) {
1203193326Sed  OS << Node->getCastName() << '<';
1204249423Sdim  Node->getTypeAsWritten().print(OS, Policy);
1205249423Sdim  OS << ">(";
1206193326Sed  PrintExpr(Node->getSubExpr());
1207193326Sed  OS << ")";
1208193326Sed}
1209193326Sed
1210193326Sedvoid StmtPrinter::VisitCXXStaticCastExpr(CXXStaticCastExpr *Node) {
1211193326Sed  VisitCXXNamedCastExpr(Node);
1212193326Sed}
1213193326Sed
1214193326Sedvoid StmtPrinter::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *Node) {
1215193326Sed  VisitCXXNamedCastExpr(Node);
1216193326Sed}
1217193326Sed
1218193326Sedvoid StmtPrinter::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *Node) {
1219193326Sed  VisitCXXNamedCastExpr(Node);
1220193326Sed}
1221193326Sed
1222193326Sedvoid StmtPrinter::VisitCXXConstCastExpr(CXXConstCastExpr *Node) {
1223193326Sed  VisitCXXNamedCastExpr(Node);
1224193326Sed}
1225193326Sed
1226193326Sedvoid StmtPrinter::VisitCXXTypeidExpr(CXXTypeidExpr *Node) {
1227193326Sed  OS << "typeid(";
1228193326Sed  if (Node->isTypeOperand()) {
1229249423Sdim    Node->getTypeOperand().print(OS, Policy);
1230193326Sed  } else {
1231193326Sed    PrintExpr(Node->getExprOperand());
1232193326Sed  }
1233193326Sed  OS << ")";
1234193326Sed}
1235193326Sed
1236218893Sdimvoid StmtPrinter::VisitCXXUuidofExpr(CXXUuidofExpr *Node) {
1237218893Sdim  OS << "__uuidof(";
1238218893Sdim  if (Node->isTypeOperand()) {
1239249423Sdim    Node->getTypeOperand().print(OS, Policy);
1240218893Sdim  } else {
1241218893Sdim    PrintExpr(Node->getExprOperand());
1242218893Sdim  }
1243218893Sdim  OS << ")";
1244218893Sdim}
1245218893Sdim
1246251662Sdimvoid StmtPrinter::VisitMSPropertyRefExpr(MSPropertyRefExpr *Node) {
1247251662Sdim  PrintExpr(Node->getBaseExpr());
1248251662Sdim  if (Node->isArrow())
1249251662Sdim    OS << "->";
1250251662Sdim  else
1251251662Sdim    OS << ".";
1252251662Sdim  if (NestedNameSpecifier *Qualifier =
1253251662Sdim      Node->getQualifierLoc().getNestedNameSpecifier())
1254251662Sdim    Qualifier->print(OS, Policy);
1255251662Sdim  OS << Node->getPropertyDecl()->getDeclName();
1256251662Sdim}
1257251662Sdim
1258234353Sdimvoid StmtPrinter::VisitUserDefinedLiteral(UserDefinedLiteral *Node) {
1259234353Sdim  switch (Node->getLiteralOperatorKind()) {
1260234353Sdim  case UserDefinedLiteral::LOK_Raw:
1261234353Sdim    OS << cast<StringLiteral>(Node->getArg(0)->IgnoreImpCasts())->getString();
1262234353Sdim    break;
1263234353Sdim  case UserDefinedLiteral::LOK_Template: {
1264234353Sdim    DeclRefExpr *DRE = cast<DeclRefExpr>(Node->getCallee()->IgnoreImpCasts());
1265234353Sdim    const TemplateArgumentList *Args =
1266234353Sdim      cast<FunctionDecl>(DRE->getDecl())->getTemplateSpecializationArgs();
1267234353Sdim    assert(Args);
1268234353Sdim    const TemplateArgument &Pack = Args->get(0);
1269234353Sdim    for (TemplateArgument::pack_iterator I = Pack.pack_begin(),
1270234353Sdim                                         E = Pack.pack_end(); I != E; ++I) {
1271239462Sdim      char C = (char)I->getAsIntegral().getZExtValue();
1272234353Sdim      OS << C;
1273234353Sdim    }
1274234353Sdim    break;
1275234353Sdim  }
1276234353Sdim  case UserDefinedLiteral::LOK_Integer: {
1277234353Sdim    // Print integer literal without suffix.
1278234353Sdim    IntegerLiteral *Int = cast<IntegerLiteral>(Node->getCookedLiteral());
1279234353Sdim    OS << Int->getValue().toString(10, /*isSigned*/false);
1280234353Sdim    break;
1281234353Sdim  }
1282243830Sdim  case UserDefinedLiteral::LOK_Floating: {
1283243830Sdim    // Print floating literal without suffix.
1284243830Sdim    FloatingLiteral *Float = cast<FloatingLiteral>(Node->getCookedLiteral());
1285243830Sdim    PrintFloatingLiteral(OS, Float, /*PrintSuffix=*/false);
1286243830Sdim    break;
1287243830Sdim  }
1288234353Sdim  case UserDefinedLiteral::LOK_String:
1289234353Sdim  case UserDefinedLiteral::LOK_Character:
1290234353Sdim    PrintExpr(Node->getCookedLiteral());
1291234353Sdim    break;
1292234353Sdim  }
1293234353Sdim  OS << Node->getUDSuffix()->getName();
1294234353Sdim}
1295234353Sdim
1296193326Sedvoid StmtPrinter::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *Node) {
1297193326Sed  OS << (Node->getValue() ? "true" : "false");
1298193326Sed}
1299193326Sed
1300193326Sedvoid StmtPrinter::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *Node) {
1301193326Sed  OS << "nullptr";
1302193326Sed}
1303193326Sed
1304193326Sedvoid StmtPrinter::VisitCXXThisExpr(CXXThisExpr *Node) {
1305193326Sed  OS << "this";
1306193326Sed}
1307193326Sed
1308193326Sedvoid StmtPrinter::VisitCXXThrowExpr(CXXThrowExpr *Node) {
1309193326Sed  if (Node->getSubExpr() == 0)
1310193326Sed    OS << "throw";
1311193326Sed  else {
1312193326Sed    OS << "throw ";
1313193326Sed    PrintExpr(Node->getSubExpr());
1314193326Sed  }
1315193326Sed}
1316193326Sed
1317193326Sedvoid StmtPrinter::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *Node) {
1318251662Sdim  // Nothing to print: we picked up the default argument.
1319193326Sed}
1320193326Sed
1321251662Sdimvoid StmtPrinter::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *Node) {
1322251662Sdim  // Nothing to print: we picked up the default initializer.
1323251662Sdim}
1324251662Sdim
1325193326Sedvoid StmtPrinter::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *Node) {
1326249423Sdim  Node->getType().print(OS, Policy);
1327193326Sed  OS << "(";
1328193326Sed  PrintExpr(Node->getSubExpr());
1329193326Sed  OS << ")";
1330193326Sed}
1331193326Sed
1332193326Sedvoid StmtPrinter::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *Node) {
1333193326Sed  PrintExpr(Node->getSubExpr());
1334193326Sed}
1335193326Sed
1336193326Sedvoid StmtPrinter::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *Node) {
1337249423Sdim  Node->getType().print(OS, Policy);
1338193326Sed  OS << "(";
1339193326Sed  for (CXXTemporaryObjectExpr::arg_iterator Arg = Node->arg_begin(),
1340198092Srdivacky                                         ArgEnd = Node->arg_end();
1341193326Sed       Arg != ArgEnd; ++Arg) {
1342193326Sed    if (Arg != Node->arg_begin())
1343193326Sed      OS << ", ";
1344193326Sed    PrintExpr(*Arg);
1345193326Sed  }
1346193326Sed  OS << ")";
1347193326Sed}
1348193326Sed
1349234353Sdimvoid StmtPrinter::VisitLambdaExpr(LambdaExpr *Node) {
1350234353Sdim  OS << '[';
1351234353Sdim  bool NeedComma = false;
1352234353Sdim  switch (Node->getCaptureDefault()) {
1353234353Sdim  case LCD_None:
1354234353Sdim    break;
1355234353Sdim
1356234353Sdim  case LCD_ByCopy:
1357234353Sdim    OS << '=';
1358234353Sdim    NeedComma = true;
1359234353Sdim    break;
1360234353Sdim
1361234353Sdim  case LCD_ByRef:
1362234353Sdim    OS << '&';
1363234353Sdim    NeedComma = true;
1364234353Sdim    break;
1365234353Sdim  }
1366234353Sdim  for (LambdaExpr::capture_iterator C = Node->explicit_capture_begin(),
1367234353Sdim                                 CEnd = Node->explicit_capture_end();
1368234353Sdim       C != CEnd;
1369234353Sdim       ++C) {
1370234353Sdim    if (NeedComma)
1371234353Sdim      OS << ", ";
1372234353Sdim    NeedComma = true;
1373234353Sdim
1374234353Sdim    switch (C->getCaptureKind()) {
1375234353Sdim    case LCK_This:
1376234353Sdim      OS << "this";
1377234353Sdim      break;
1378234353Sdim
1379234353Sdim    case LCK_ByRef:
1380234353Sdim      if (Node->getCaptureDefault() != LCD_ByRef)
1381234353Sdim        OS << '&';
1382234353Sdim      OS << C->getCapturedVar()->getName();
1383234353Sdim      break;
1384234353Sdim
1385234353Sdim    case LCK_ByCopy:
1386234353Sdim      if (Node->getCaptureDefault() != LCD_ByCopy)
1387234353Sdim        OS << '=';
1388234353Sdim      OS << C->getCapturedVar()->getName();
1389234353Sdim      break;
1390234353Sdim    }
1391234353Sdim  }
1392234353Sdim  OS << ']';
1393234353Sdim
1394234353Sdim  if (Node->hasExplicitParameters()) {
1395234353Sdim    OS << " (";
1396234353Sdim    CXXMethodDecl *Method = Node->getCallOperator();
1397234353Sdim    NeedComma = false;
1398234353Sdim    for (CXXMethodDecl::param_iterator P = Method->param_begin(),
1399234353Sdim                                    PEnd = Method->param_end();
1400234353Sdim         P != PEnd; ++P) {
1401234353Sdim      if (NeedComma) {
1402234353Sdim        OS << ", ";
1403234353Sdim      } else {
1404234353Sdim        NeedComma = true;
1405234353Sdim      }
1406234353Sdim      std::string ParamStr = (*P)->getNameAsString();
1407249423Sdim      (*P)->getOriginalType().print(OS, Policy, ParamStr);
1408234353Sdim    }
1409234353Sdim    if (Method->isVariadic()) {
1410234353Sdim      if (NeedComma)
1411234353Sdim        OS << ", ";
1412234353Sdim      OS << "...";
1413234353Sdim    }
1414234353Sdim    OS << ')';
1415234353Sdim
1416234353Sdim    if (Node->isMutable())
1417234353Sdim      OS << " mutable";
1418234353Sdim
1419234353Sdim    const FunctionProtoType *Proto
1420234353Sdim      = Method->getType()->getAs<FunctionProtoType>();
1421249423Sdim    Proto->printExceptionSpecification(OS, Policy);
1422234353Sdim
1423234353Sdim    // FIXME: Attributes
1424234353Sdim
1425234353Sdim    // Print the trailing return type if it was specified in the source.
1426249423Sdim    if (Node->hasExplicitResultType()) {
1427249423Sdim      OS << " -> ";
1428249423Sdim      Proto->getResultType().print(OS, Policy);
1429249423Sdim    }
1430234353Sdim  }
1431234353Sdim
1432234353Sdim  // Print the body.
1433234353Sdim  CompoundStmt *Body = Node->getBody();
1434234353Sdim  OS << ' ';
1435234353Sdim  PrintStmt(Body);
1436234353Sdim}
1437234353Sdim
1438210299Sedvoid StmtPrinter::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *Node) {
1439218893Sdim  if (TypeSourceInfo *TSInfo = Node->getTypeSourceInfo())
1440249423Sdim    TSInfo->getType().print(OS, Policy);
1441218893Sdim  else
1442249423Sdim    Node->getType().print(OS, Policy);
1443249423Sdim  OS << "()";
1444193326Sed}
1445193326Sed
1446193326Sedvoid StmtPrinter::VisitCXXNewExpr(CXXNewExpr *E) {
1447193326Sed  if (E->isGlobalNew())
1448193326Sed    OS << "::";
1449193326Sed  OS << "new ";
1450193326Sed  unsigned NumPlace = E->getNumPlacementArgs();
1451243830Sdim  if (NumPlace > 0 && !isa<CXXDefaultArgExpr>(E->getPlacementArg(0))) {
1452193326Sed    OS << "(";
1453193326Sed    PrintExpr(E->getPlacementArg(0));
1454193326Sed    for (unsigned i = 1; i < NumPlace; ++i) {
1455243830Sdim      if (isa<CXXDefaultArgExpr>(E->getPlacementArg(i)))
1456243830Sdim        break;
1457193326Sed      OS << ", ";
1458193326Sed      PrintExpr(E->getPlacementArg(i));
1459193326Sed    }
1460193326Sed    OS << ") ";
1461193326Sed  }
1462193326Sed  if (E->isParenTypeId())
1463193326Sed    OS << "(";
1464193326Sed  std::string TypeS;
1465193326Sed  if (Expr *Size = E->getArraySize()) {
1466193326Sed    llvm::raw_string_ostream s(TypeS);
1467249423Sdim    s << '[';
1468239462Sdim    Size->printPretty(s, Helper, Policy);
1469249423Sdim    s << ']';
1470193326Sed  }
1471249423Sdim  E->getAllocatedType().print(OS, Policy, TypeS);
1472193326Sed  if (E->isParenTypeId())
1473193326Sed    OS << ")";
1474193326Sed
1475234353Sdim  CXXNewExpr::InitializationStyle InitStyle = E->getInitializationStyle();
1476234353Sdim  if (InitStyle) {
1477234353Sdim    if (InitStyle == CXXNewExpr::CallInit)
1478234353Sdim      OS << "(";
1479234353Sdim    PrintExpr(E->getInitializer());
1480234353Sdim    if (InitStyle == CXXNewExpr::CallInit)
1481234353Sdim      OS << ")";
1482193326Sed  }
1483193326Sed}
1484193326Sed
1485193326Sedvoid StmtPrinter::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
1486193326Sed  if (E->isGlobalDelete())
1487193326Sed    OS << "::";
1488193326Sed  OS << "delete ";
1489193326Sed  if (E->isArrayForm())
1490193326Sed    OS << "[] ";
1491193326Sed  PrintExpr(E->getArgument());
1492193326Sed}
1493193326Sed
1494198092Srdivackyvoid StmtPrinter::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
1495198092Srdivacky  PrintExpr(E->getBase());
1496198092Srdivacky  if (E->isArrow())
1497198092Srdivacky    OS << "->";
1498198092Srdivacky  else
1499198092Srdivacky    OS << '.';
1500198092Srdivacky  if (E->getQualifier())
1501198092Srdivacky    E->getQualifier()->print(OS, Policy);
1502243830Sdim  OS << "~";
1503198092Srdivacky
1504204643Srdivacky  if (IdentifierInfo *II = E->getDestroyedTypeIdentifier())
1505204643Srdivacky    OS << II->getName();
1506204643Srdivacky  else
1507249423Sdim    E->getDestroyedType().print(OS, Policy);
1508198092Srdivacky}
1509198092Srdivacky
1510193326Sedvoid StmtPrinter::VisitCXXConstructExpr(CXXConstructExpr *E) {
1511249423Sdim  if (E->isListInitialization())
1512249423Sdim    OS << "{ ";
1513249423Sdim
1514218893Sdim  for (unsigned i = 0, e = E->getNumArgs(); i != e; ++i) {
1515218893Sdim    if (isa<CXXDefaultArgExpr>(E->getArg(i))) {
1516218893Sdim      // Don't print any defaulted arguments
1517218893Sdim      break;
1518218893Sdim    }
1519218893Sdim
1520218893Sdim    if (i) OS << ", ";
1521218893Sdim    PrintExpr(E->getArg(i));
1522202379Srdivacky  }
1523249423Sdim
1524249423Sdim  if (E->isListInitialization())
1525249423Sdim    OS << " }";
1526193326Sed}
1527193326Sed
1528218893Sdimvoid StmtPrinter::VisitExprWithCleanups(ExprWithCleanups *E) {
1529193326Sed  // Just forward to the sub expression.
1530193326Sed  PrintExpr(E->getSubExpr());
1531193326Sed}
1532193326Sed
1533198092Srdivackyvoid
1534193326SedStmtPrinter::VisitCXXUnresolvedConstructExpr(
1535193326Sed                                           CXXUnresolvedConstructExpr *Node) {
1536249423Sdim  Node->getTypeAsWritten().print(OS, Policy);
1537193326Sed  OS << "(";
1538193326Sed  for (CXXUnresolvedConstructExpr::arg_iterator Arg = Node->arg_begin(),
1539198092Srdivacky                                             ArgEnd = Node->arg_end();
1540193326Sed       Arg != ArgEnd; ++Arg) {
1541193326Sed    if (Arg != Node->arg_begin())
1542193326Sed      OS << ", ";
1543193326Sed    PrintExpr(*Arg);
1544193326Sed  }
1545193326Sed  OS << ")";
1546193326Sed}
1547193326Sed
1548199990Srdivackyvoid StmtPrinter::VisitCXXDependentScopeMemberExpr(
1549199990Srdivacky                                         CXXDependentScopeMemberExpr *Node) {
1550200583Srdivacky  if (!Node->isImplicitAccess()) {
1551200583Srdivacky    PrintExpr(Node->getBase());
1552200583Srdivacky    OS << (Node->isArrow() ? "->" : ".");
1553200583Srdivacky  }
1554198092Srdivacky  if (NestedNameSpecifier *Qualifier = Node->getQualifier())
1555198092Srdivacky    Qualifier->print(OS, Policy);
1556234353Sdim  if (Node->hasTemplateKeyword())
1557198092Srdivacky    OS << "template ";
1558212904Sdim  OS << Node->getMemberNameInfo();
1559249423Sdim  if (Node->hasExplicitTemplateArgs())
1560249423Sdim    TemplateSpecializationType::PrintTemplateArgumentList(
1561249423Sdim        OS, Node->getTemplateArgs(), Node->getNumTemplateArgs(), Policy);
1562193326Sed}
1563193326Sed
1564199990Srdivackyvoid StmtPrinter::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *Node) {
1565200583Srdivacky  if (!Node->isImplicitAccess()) {
1566200583Srdivacky    PrintExpr(Node->getBase());
1567200583Srdivacky    OS << (Node->isArrow() ? "->" : ".");
1568200583Srdivacky  }
1569199990Srdivacky  if (NestedNameSpecifier *Qualifier = Node->getQualifier())
1570199990Srdivacky    Qualifier->print(OS, Policy);
1571234353Sdim  if (Node->hasTemplateKeyword())
1572234353Sdim    OS << "template ";
1573212904Sdim  OS << Node->getMemberNameInfo();
1574249423Sdim  if (Node->hasExplicitTemplateArgs())
1575249423Sdim    TemplateSpecializationType::PrintTemplateArgumentList(
1576249423Sdim        OS, Node->getTemplateArgs(), Node->getNumTemplateArgs(), Policy);
1577199990Srdivacky}
1578199990Srdivacky
1579193326Sedstatic const char *getTypeTraitName(UnaryTypeTrait UTT) {
1580193326Sed  switch (UTT) {
1581193326Sed  case UTT_HasNothrowAssign:      return "__has_nothrow_assign";
1582249423Sdim  case UTT_HasNothrowMoveAssign:  return "__has_nothrow_move_assign";
1583193326Sed  case UTT_HasNothrowConstructor: return "__has_nothrow_constructor";
1584221345Sdim  case UTT_HasNothrowCopy:          return "__has_nothrow_copy";
1585193326Sed  case UTT_HasTrivialAssign:      return "__has_trivial_assign";
1586249423Sdim  case UTT_HasTrivialMoveAssign:      return "__has_trivial_move_assign";
1587249423Sdim  case UTT_HasTrivialMoveConstructor: return "__has_trivial_move_constructor";
1588223017Sdim  case UTT_HasTrivialDefaultConstructor: return "__has_trivial_constructor";
1589221345Sdim  case UTT_HasTrivialCopy:          return "__has_trivial_copy";
1590193326Sed  case UTT_HasTrivialDestructor:  return "__has_trivial_destructor";
1591193326Sed  case UTT_HasVirtualDestructor:  return "__has_virtual_destructor";
1592193326Sed  case UTT_IsAbstract:            return "__is_abstract";
1593221345Sdim  case UTT_IsArithmetic:            return "__is_arithmetic";
1594221345Sdim  case UTT_IsArray:                 return "__is_array";
1595193326Sed  case UTT_IsClass:               return "__is_class";
1596221345Sdim  case UTT_IsCompleteType:          return "__is_complete_type";
1597221345Sdim  case UTT_IsCompound:              return "__is_compound";
1598221345Sdim  case UTT_IsConst:                 return "__is_const";
1599193326Sed  case UTT_IsEmpty:               return "__is_empty";
1600193326Sed  case UTT_IsEnum:                return "__is_enum";
1601234353Sdim  case UTT_IsFinal:                 return "__is_final";
1602221345Sdim  case UTT_IsFloatingPoint:         return "__is_floating_point";
1603221345Sdim  case UTT_IsFunction:              return "__is_function";
1604221345Sdim  case UTT_IsFundamental:           return "__is_fundamental";
1605221345Sdim  case UTT_IsIntegral:              return "__is_integral";
1606243830Sdim  case UTT_IsInterfaceClass:        return "__is_interface_class";
1607221345Sdim  case UTT_IsLiteral:               return "__is_literal";
1608221345Sdim  case UTT_IsLvalueReference:       return "__is_lvalue_reference";
1609221345Sdim  case UTT_IsMemberFunctionPointer: return "__is_member_function_pointer";
1610221345Sdim  case UTT_IsMemberObjectPointer:   return "__is_member_object_pointer";
1611221345Sdim  case UTT_IsMemberPointer:         return "__is_member_pointer";
1612221345Sdim  case UTT_IsObject:                return "__is_object";
1613193326Sed  case UTT_IsPOD:                 return "__is_pod";
1614221345Sdim  case UTT_IsPointer:               return "__is_pointer";
1615193326Sed  case UTT_IsPolymorphic:         return "__is_polymorphic";
1616221345Sdim  case UTT_IsReference:             return "__is_reference";
1617221345Sdim  case UTT_IsRvalueReference:       return "__is_rvalue_reference";
1618221345Sdim  case UTT_IsScalar:                return "__is_scalar";
1619221345Sdim  case UTT_IsSigned:                return "__is_signed";
1620221345Sdim  case UTT_IsStandardLayout:        return "__is_standard_layout";
1621221345Sdim  case UTT_IsTrivial:               return "__is_trivial";
1622223017Sdim  case UTT_IsTriviallyCopyable:     return "__is_trivially_copyable";
1623193326Sed  case UTT_IsUnion:               return "__is_union";
1624221345Sdim  case UTT_IsUnsigned:              return "__is_unsigned";
1625221345Sdim  case UTT_IsVoid:                  return "__is_void";
1626221345Sdim  case UTT_IsVolatile:              return "__is_volatile";
1627193326Sed  }
1628221345Sdim  llvm_unreachable("Type trait not covered by switch statement");
1629193326Sed}
1630193326Sed
1631218893Sdimstatic const char *getTypeTraitName(BinaryTypeTrait BTT) {
1632218893Sdim  switch (BTT) {
1633234353Sdim  case BTT_IsBaseOf:              return "__is_base_of";
1634234353Sdim  case BTT_IsConvertible:         return "__is_convertible";
1635234353Sdim  case BTT_IsSame:                return "__is_same";
1636234353Sdim  case BTT_TypeCompatible:        return "__builtin_types_compatible_p";
1637234353Sdim  case BTT_IsConvertibleTo:       return "__is_convertible_to";
1638234353Sdim  case BTT_IsTriviallyAssignable: return "__is_trivially_assignable";
1639218893Sdim  }
1640221345Sdim  llvm_unreachable("Binary type trait not covered by switch");
1641218893Sdim}
1642218893Sdim
1643234353Sdimstatic const char *getTypeTraitName(TypeTrait TT) {
1644234353Sdim  switch (TT) {
1645234353Sdim  case clang::TT_IsTriviallyConstructible:return "__is_trivially_constructible";
1646234353Sdim  }
1647234353Sdim  llvm_unreachable("Type trait not covered by switch");
1648234353Sdim}
1649234353Sdim
1650221345Sdimstatic const char *getTypeTraitName(ArrayTypeTrait ATT) {
1651221345Sdim  switch (ATT) {
1652221345Sdim  case ATT_ArrayRank:        return "__array_rank";
1653221345Sdim  case ATT_ArrayExtent:      return "__array_extent";
1654221345Sdim  }
1655221345Sdim  llvm_unreachable("Array type trait not covered by switch");
1656221345Sdim}
1657221345Sdim
1658221345Sdimstatic const char *getExpressionTraitName(ExpressionTrait ET) {
1659221345Sdim  switch (ET) {
1660221345Sdim  case ET_IsLValueExpr:      return "__is_lvalue_expr";
1661221345Sdim  case ET_IsRValueExpr:      return "__is_rvalue_expr";
1662221345Sdim  }
1663221345Sdim  llvm_unreachable("Expression type trait not covered by switch");
1664221345Sdim}
1665221345Sdim
1666193326Sedvoid StmtPrinter::VisitUnaryTypeTraitExpr(UnaryTypeTraitExpr *E) {
1667249423Sdim  OS << getTypeTraitName(E->getTrait()) << '(';
1668249423Sdim  E->getQueriedType().print(OS, Policy);
1669249423Sdim  OS << ')';
1670193326Sed}
1671193326Sed
1672218893Sdimvoid StmtPrinter::VisitBinaryTypeTraitExpr(BinaryTypeTraitExpr *E) {
1673249423Sdim  OS << getTypeTraitName(E->getTrait()) << '(';
1674249423Sdim  E->getLhsType().print(OS, Policy);
1675249423Sdim  OS << ',';
1676249423Sdim  E->getRhsType().print(OS, Policy);
1677249423Sdim  OS << ')';
1678218893Sdim}
1679218893Sdim
1680234353Sdimvoid StmtPrinter::VisitTypeTraitExpr(TypeTraitExpr *E) {
1681234353Sdim  OS << getTypeTraitName(E->getTrait()) << "(";
1682234353Sdim  for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) {
1683234353Sdim    if (I > 0)
1684234353Sdim      OS << ", ";
1685249423Sdim    E->getArg(I)->getType().print(OS, Policy);
1686234353Sdim  }
1687234353Sdim  OS << ")";
1688234353Sdim}
1689234353Sdim
1690221345Sdimvoid StmtPrinter::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
1691249423Sdim  OS << getTypeTraitName(E->getTrait()) << '(';
1692249423Sdim  E->getQueriedType().print(OS, Policy);
1693249423Sdim  OS << ')';
1694221345Sdim}
1695221345Sdim
1696221345Sdimvoid StmtPrinter::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
1697249423Sdim  OS << getExpressionTraitName(E->getTrait()) << '(';
1698249423Sdim  PrintExpr(E->getQueriedExpression());
1699249423Sdim  OS << ')';
1700221345Sdim}
1701221345Sdim
1702218893Sdimvoid StmtPrinter::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
1703218893Sdim  OS << "noexcept(";
1704218893Sdim  PrintExpr(E->getOperand());
1705218893Sdim  OS << ")";
1706218893Sdim}
1707218893Sdim
1708218893Sdimvoid StmtPrinter::VisitPackExpansionExpr(PackExpansionExpr *E) {
1709218893Sdim  PrintExpr(E->getPattern());
1710218893Sdim  OS << "...";
1711218893Sdim}
1712218893Sdim
1713218893Sdimvoid StmtPrinter::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
1714234353Sdim  OS << "sizeof...(" << *E->getPack() << ")";
1715218893Sdim}
1716218893Sdim
1717218893Sdimvoid StmtPrinter::VisitSubstNonTypeTemplateParmPackExpr(
1718218893Sdim                                       SubstNonTypeTemplateParmPackExpr *Node) {
1719234353Sdim  OS << *Node->getParameterPack();
1720218893Sdim}
1721218893Sdim
1722224145Sdimvoid StmtPrinter::VisitSubstNonTypeTemplateParmExpr(
1723224145Sdim                                       SubstNonTypeTemplateParmExpr *Node) {
1724224145Sdim  Visit(Node->getReplacement());
1725224145Sdim}
1726224145Sdim
1727243830Sdimvoid StmtPrinter::VisitFunctionParmPackExpr(FunctionParmPackExpr *E) {
1728243830Sdim  OS << *E->getParameterPack();
1729243830Sdim}
1730243830Sdim
1731224145Sdimvoid StmtPrinter::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *Node){
1732224145Sdim  PrintExpr(Node->GetTemporaryExpr());
1733224145Sdim}
1734224145Sdim
1735198092Srdivacky// Obj-C
1736193326Sed
1737193326Sedvoid StmtPrinter::VisitObjCStringLiteral(ObjCStringLiteral *Node) {
1738193326Sed  OS << "@";
1739193326Sed  VisitStringLiteral(Node->getString());
1740193326Sed}
1741193326Sed
1742239462Sdimvoid StmtPrinter::VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
1743234353Sdim  OS << "@";
1744239462Sdim  Visit(E->getSubExpr());
1745234353Sdim}
1746234353Sdim
1747234353Sdimvoid StmtPrinter::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
1748234353Sdim  OS << "@[ ";
1749234353Sdim  StmtRange ch = E->children();
1750234353Sdim  if (ch.first != ch.second) {
1751234353Sdim    while (1) {
1752234353Sdim      Visit(*ch.first);
1753234353Sdim      ++ch.first;
1754234353Sdim      if (ch.first == ch.second) break;
1755234353Sdim      OS << ", ";
1756234353Sdim    }
1757234353Sdim  }
1758234353Sdim  OS << " ]";
1759234353Sdim}
1760234353Sdim
1761234353Sdimvoid StmtPrinter::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
1762234353Sdim  OS << "@{ ";
1763234353Sdim  for (unsigned I = 0, N = E->getNumElements(); I != N; ++I) {
1764234353Sdim    if (I > 0)
1765234353Sdim      OS << ", ";
1766234353Sdim
1767234353Sdim    ObjCDictionaryElement Element = E->getKeyValueElement(I);
1768234353Sdim    Visit(Element.Key);
1769234353Sdim    OS << " : ";
1770234353Sdim    Visit(Element.Value);
1771234353Sdim    if (Element.isPackExpansion())
1772234353Sdim      OS << "...";
1773234353Sdim  }
1774234353Sdim  OS << " }";
1775234353Sdim}
1776234353Sdim
1777193326Sedvoid StmtPrinter::VisitObjCEncodeExpr(ObjCEncodeExpr *Node) {
1778249423Sdim  OS << "@encode(";
1779249423Sdim  Node->getEncodedType().print(OS, Policy);
1780249423Sdim  OS << ')';
1781193326Sed}
1782193326Sed
1783193326Sedvoid StmtPrinter::VisitObjCSelectorExpr(ObjCSelectorExpr *Node) {
1784193326Sed  OS << "@selector(" << Node->getSelector().getAsString() << ')';
1785193326Sed}
1786193326Sed
1787193326Sedvoid StmtPrinter::VisitObjCProtocolExpr(ObjCProtocolExpr *Node) {
1788226633Sdim  OS << "@protocol(" << *Node->getProtocol() << ')';
1789193326Sed}
1790193326Sed
1791193326Sedvoid StmtPrinter::VisitObjCMessageExpr(ObjCMessageExpr *Mess) {
1792193326Sed  OS << "[";
1793207619Srdivacky  switch (Mess->getReceiverKind()) {
1794207619Srdivacky  case ObjCMessageExpr::Instance:
1795207619Srdivacky    PrintExpr(Mess->getInstanceReceiver());
1796207619Srdivacky    break;
1797207619Srdivacky
1798207619Srdivacky  case ObjCMessageExpr::Class:
1799249423Sdim    Mess->getClassReceiver().print(OS, Policy);
1800207619Srdivacky    break;
1801207619Srdivacky
1802207619Srdivacky  case ObjCMessageExpr::SuperInstance:
1803207619Srdivacky  case ObjCMessageExpr::SuperClass:
1804207619Srdivacky    OS << "Super";
1805207619Srdivacky    break;
1806207619Srdivacky  }
1807207619Srdivacky
1808193326Sed  OS << ' ';
1809193326Sed  Selector selector = Mess->getSelector();
1810193326Sed  if (selector.isUnarySelector()) {
1811218893Sdim    OS << selector.getNameForSlot(0);
1812193326Sed  } else {
1813193326Sed    for (unsigned i = 0, e = Mess->getNumArgs(); i != e; ++i) {
1814193326Sed      if (i < selector.getNumArgs()) {
1815193326Sed        if (i > 0) OS << ' ';
1816193326Sed        if (selector.getIdentifierInfoForSlot(i))
1817193326Sed          OS << selector.getIdentifierInfoForSlot(i)->getName() << ':';
1818193326Sed        else
1819193326Sed           OS << ":";
1820193326Sed      }
1821193326Sed      else OS << ", "; // Handle variadic methods.
1822198092Srdivacky
1823193326Sed      PrintExpr(Mess->getArg(i));
1824193326Sed    }
1825193326Sed  }
1826193326Sed  OS << "]";
1827193326Sed}
1828193326Sed
1829234353Sdimvoid StmtPrinter::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *Node) {
1830234353Sdim  OS << (Node->getValue() ? "__objc_yes" : "__objc_no");
1831234353Sdim}
1832234353Sdim
1833224145Sdimvoid
1834224145SdimStmtPrinter::VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
1835224145Sdim  PrintExpr(E->getSubExpr());
1836224145Sdim}
1837193326Sed
1838224145Sdimvoid
1839224145SdimStmtPrinter::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
1840249423Sdim  OS << '(' << E->getBridgeKindName();
1841249423Sdim  E->getType().print(OS, Policy);
1842249423Sdim  OS << ')';
1843224145Sdim  PrintExpr(E->getSubExpr());
1844224145Sdim}
1845224145Sdim
1846193326Sedvoid StmtPrinter::VisitBlockExpr(BlockExpr *Node) {
1847193326Sed  BlockDecl *BD = Node->getBlockDecl();
1848193326Sed  OS << "^";
1849198092Srdivacky
1850193326Sed  const FunctionType *AFT = Node->getFunctionType();
1851198092Srdivacky
1852193326Sed  if (isa<FunctionNoProtoType>(AFT)) {
1853193326Sed    OS << "()";
1854193326Sed  } else if (!BD->param_empty() || cast<FunctionProtoType>(AFT)->isVariadic()) {
1855193326Sed    OS << '(';
1856193326Sed    for (BlockDecl::param_iterator AI = BD->param_begin(),
1857193326Sed         E = BD->param_end(); AI != E; ++AI) {
1858193326Sed      if (AI != BD->param_begin()) OS << ", ";
1859249423Sdim      std::string ParamStr = (*AI)->getNameAsString();
1860249423Sdim      (*AI)->getType().print(OS, Policy, ParamStr);
1861193326Sed    }
1862198092Srdivacky
1863193326Sed    const FunctionProtoType *FT = cast<FunctionProtoType>(AFT);
1864193326Sed    if (FT->isVariadic()) {
1865193326Sed      if (!BD->param_empty()) OS << ", ";
1866193326Sed      OS << "...";
1867193326Sed    }
1868193326Sed    OS << ')';
1869193326Sed  }
1870249423Sdim  OS << "{ }";
1871193326Sed}
1872193326Sed
1873234353Sdimvoid StmtPrinter::VisitOpaqueValueExpr(OpaqueValueExpr *Node) {
1874234353Sdim  PrintExpr(Node->getSourceExpr());
1875193326Sed}
1876218893Sdim
1877223017Sdimvoid StmtPrinter::VisitAsTypeExpr(AsTypeExpr *Node) {
1878223017Sdim  OS << "__builtin_astype(";
1879223017Sdim  PrintExpr(Node->getSrcExpr());
1880249423Sdim  OS << ", ";
1881249423Sdim  Node->getType().print(OS, Policy);
1882223017Sdim  OS << ")";
1883223017Sdim}
1884223017Sdim
1885193326Sed//===----------------------------------------------------------------------===//
1886193326Sed// Stmt method implementations
1887193326Sed//===----------------------------------------------------------------------===//
1888193326Sed
1889239462Sdimvoid Stmt::dumpPretty(ASTContext &Context) const {
1890239462Sdim  printPretty(llvm::errs(), 0, PrintingPolicy(Context.getLangOpts()));
1891193326Sed}
1892193326Sed
1893239462Sdimvoid Stmt::printPretty(raw_ostream &OS,
1894239462Sdim                       PrinterHelper *Helper,
1895193326Sed                       const PrintingPolicy &Policy,
1896193326Sed                       unsigned Indentation) const {
1897193326Sed  if (this == 0) {
1898193326Sed    OS << "<NULL>";
1899193326Sed    return;
1900193326Sed  }
1901193326Sed
1902239462Sdim  StmtPrinter P(OS, Helper, Policy, Indentation);
1903193326Sed  P.Visit(const_cast<Stmt*>(this));
1904193326Sed}
1905193326Sed
1906193326Sed//===----------------------------------------------------------------------===//
1907193326Sed// PrinterHelper
1908193326Sed//===----------------------------------------------------------------------===//
1909193326Sed
1910193326Sed// Implement virtual destructor.
1911193326SedPrinterHelper::~PrinterHelper() {}
1912