StmtPrinter.cpp revision 4765fa05b5652fcc4356371c2f481d0ea9a1b007
1//===--- StmtPrinter.cpp - Printing implementation for Stmt ASTs ----------===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file implements the Stmt::dumpPretty/Stmt::printPretty methods, which
11// pretty print the AST back out to C code.
12//
13//===----------------------------------------------------------------------===//
14
15#include "clang/AST/StmtVisitor.h"
16#include "clang/AST/DeclCXX.h"
17#include "clang/AST/DeclObjC.h"
18#include "clang/AST/PrettyPrinter.h"
19#include "llvm/Support/Format.h"
20#include "clang/AST/Expr.h"
21#include "clang/AST/ExprCXX.h"
22using namespace clang;
23
24//===----------------------------------------------------------------------===//
25// StmtPrinter Visitor
26//===----------------------------------------------------------------------===//
27
28namespace  {
29  class StmtPrinter : public StmtVisitor<StmtPrinter> {
30    llvm::raw_ostream &OS;
31    ASTContext &Context;
32    unsigned IndentLevel;
33    clang::PrinterHelper* Helper;
34    PrintingPolicy Policy;
35
36  public:
37    StmtPrinter(llvm::raw_ostream &os, ASTContext &C, PrinterHelper* helper,
38                const PrintingPolicy &Policy,
39                unsigned Indentation = 0)
40      : OS(os), Context(C), IndentLevel(Indentation), Helper(helper),
41        Policy(Policy) {}
42
43    void PrintStmt(Stmt *S) {
44      PrintStmt(S, Policy.Indentation);
45    }
46
47    void PrintStmt(Stmt *S, int SubIndent) {
48      IndentLevel += SubIndent;
49      if (S && isa<Expr>(S)) {
50        // If this is an expr used in a stmt context, indent and newline it.
51        Indent();
52        Visit(S);
53        OS << ";\n";
54      } else if (S) {
55        Visit(S);
56      } else {
57        Indent() << "<<<NULL STATEMENT>>>\n";
58      }
59      IndentLevel -= SubIndent;
60    }
61
62    void PrintRawCompoundStmt(CompoundStmt *S);
63    void PrintRawDecl(Decl *D);
64    void PrintRawDeclStmt(DeclStmt *S);
65    void PrintRawIfStmt(IfStmt *If);
66    void PrintRawCXXCatchStmt(CXXCatchStmt *Catch);
67
68    void PrintExpr(Expr *E) {
69      if (E)
70        Visit(E);
71      else
72        OS << "<null expr>";
73    }
74
75    llvm::raw_ostream &Indent(int Delta = 0) {
76      for (int i = 0, e = IndentLevel+Delta; i < e; ++i)
77        OS << "  ";
78      return OS;
79    }
80
81    void Visit(Stmt* S) {
82      if (Helper && Helper->handledStmt(S,OS))
83          return;
84      else StmtVisitor<StmtPrinter>::Visit(S);
85    }
86
87    void VisitStmt(Stmt *Node) LLVM_ATTRIBUTE_UNUSED {
88      Indent() << "<<unknown stmt type>>\n";
89    }
90    void VisitExpr(Expr *Node) LLVM_ATTRIBUTE_UNUSED {
91      OS << "<<unknown expr type>>";
92    }
93    void VisitCXXNamedCastExpr(CXXNamedCastExpr *Node);
94
95#define ABSTRACT_STMT(CLASS)
96#define STMT(CLASS, PARENT) \
97    void Visit##CLASS(CLASS *Node);
98#include "clang/AST/StmtNodes.inc"
99  };
100}
101
102//===----------------------------------------------------------------------===//
103//  Stmt printing methods.
104//===----------------------------------------------------------------------===//
105
106/// PrintRawCompoundStmt - Print a compound stmt without indenting the {, and
107/// with no newline after the }.
108void StmtPrinter::PrintRawCompoundStmt(CompoundStmt *Node) {
109  OS << "{\n";
110  for (CompoundStmt::body_iterator I = Node->body_begin(), E = Node->body_end();
111       I != E; ++I)
112    PrintStmt(*I);
113
114  Indent() << "}";
115}
116
117void StmtPrinter::PrintRawDecl(Decl *D) {
118  D->print(OS, Policy, IndentLevel);
119}
120
121void StmtPrinter::PrintRawDeclStmt(DeclStmt *S) {
122  DeclStmt::decl_iterator Begin = S->decl_begin(), End = S->decl_end();
123  llvm::SmallVector<Decl*, 2> Decls;
124  for ( ; Begin != End; ++Begin)
125    Decls.push_back(*Begin);
126
127  Decl::printGroup(Decls.data(), Decls.size(), OS, Policy, IndentLevel);
128}
129
130void StmtPrinter::VisitNullStmt(NullStmt *Node) {
131  Indent() << ";\n";
132}
133
134void StmtPrinter::VisitDeclStmt(DeclStmt *Node) {
135  Indent();
136  PrintRawDeclStmt(Node);
137  OS << ";\n";
138}
139
140void StmtPrinter::VisitCompoundStmt(CompoundStmt *Node) {
141  Indent();
142  PrintRawCompoundStmt(Node);
143  OS << "\n";
144}
145
146void StmtPrinter::VisitCaseStmt(CaseStmt *Node) {
147  Indent(-1) << "case ";
148  PrintExpr(Node->getLHS());
149  if (Node->getRHS()) {
150    OS << " ... ";
151    PrintExpr(Node->getRHS());
152  }
153  OS << ":\n";
154
155  PrintStmt(Node->getSubStmt(), 0);
156}
157
158void StmtPrinter::VisitDefaultStmt(DefaultStmt *Node) {
159  Indent(-1) << "default:\n";
160  PrintStmt(Node->getSubStmt(), 0);
161}
162
163void StmtPrinter::VisitLabelStmt(LabelStmt *Node) {
164  Indent(-1) << Node->getName() << ":\n";
165  PrintStmt(Node->getSubStmt(), 0);
166}
167
168void StmtPrinter::PrintRawIfStmt(IfStmt *If) {
169  OS << "if (";
170  PrintExpr(If->getCond());
171  OS << ')';
172
173  if (CompoundStmt *CS = dyn_cast<CompoundStmt>(If->getThen())) {
174    OS << ' ';
175    PrintRawCompoundStmt(CS);
176    OS << (If->getElse() ? ' ' : '\n');
177  } else {
178    OS << '\n';
179    PrintStmt(If->getThen());
180    if (If->getElse()) Indent();
181  }
182
183  if (Stmt *Else = If->getElse()) {
184    OS << "else";
185
186    if (CompoundStmt *CS = dyn_cast<CompoundStmt>(Else)) {
187      OS << ' ';
188      PrintRawCompoundStmt(CS);
189      OS << '\n';
190    } else if (IfStmt *ElseIf = dyn_cast<IfStmt>(Else)) {
191      OS << ' ';
192      PrintRawIfStmt(ElseIf);
193    } else {
194      OS << '\n';
195      PrintStmt(If->getElse());
196    }
197  }
198}
199
200void StmtPrinter::VisitIfStmt(IfStmt *If) {
201  Indent();
202  PrintRawIfStmt(If);
203}
204
205void StmtPrinter::VisitSwitchStmt(SwitchStmt *Node) {
206  Indent() << "switch (";
207  PrintExpr(Node->getCond());
208  OS << ")";
209
210  // Pretty print compoundstmt bodies (very common).
211  if (CompoundStmt *CS = dyn_cast<CompoundStmt>(Node->getBody())) {
212    OS << " ";
213    PrintRawCompoundStmt(CS);
214    OS << "\n";
215  } else {
216    OS << "\n";
217    PrintStmt(Node->getBody());
218  }
219}
220
221void StmtPrinter::VisitSwitchCase(SwitchCase*) {
222  assert(0 && "SwitchCase is an abstract class");
223}
224
225void StmtPrinter::VisitWhileStmt(WhileStmt *Node) {
226  Indent() << "while (";
227  PrintExpr(Node->getCond());
228  OS << ")\n";
229  PrintStmt(Node->getBody());
230}
231
232void StmtPrinter::VisitDoStmt(DoStmt *Node) {
233  Indent() << "do ";
234  if (CompoundStmt *CS = dyn_cast<CompoundStmt>(Node->getBody())) {
235    PrintRawCompoundStmt(CS);
236    OS << " ";
237  } else {
238    OS << "\n";
239    PrintStmt(Node->getBody());
240    Indent();
241  }
242
243  OS << "while (";
244  PrintExpr(Node->getCond());
245  OS << ");\n";
246}
247
248void StmtPrinter::VisitForStmt(ForStmt *Node) {
249  Indent() << "for (";
250  if (Node->getInit()) {
251    if (DeclStmt *DS = dyn_cast<DeclStmt>(Node->getInit()))
252      PrintRawDeclStmt(DS);
253    else
254      PrintExpr(cast<Expr>(Node->getInit()));
255  }
256  OS << ";";
257  if (Node->getCond()) {
258    OS << " ";
259    PrintExpr(Node->getCond());
260  }
261  OS << ";";
262  if (Node->getInc()) {
263    OS << " ";
264    PrintExpr(Node->getInc());
265  }
266  OS << ") ";
267
268  if (CompoundStmt *CS = dyn_cast<CompoundStmt>(Node->getBody())) {
269    PrintRawCompoundStmt(CS);
270    OS << "\n";
271  } else {
272    OS << "\n";
273    PrintStmt(Node->getBody());
274  }
275}
276
277void StmtPrinter::VisitObjCForCollectionStmt(ObjCForCollectionStmt *Node) {
278  Indent() << "for (";
279  if (DeclStmt *DS = dyn_cast<DeclStmt>(Node->getElement()))
280    PrintRawDeclStmt(DS);
281  else
282    PrintExpr(cast<Expr>(Node->getElement()));
283  OS << " in ";
284  PrintExpr(Node->getCollection());
285  OS << ") ";
286
287  if (CompoundStmt *CS = dyn_cast<CompoundStmt>(Node->getBody())) {
288    PrintRawCompoundStmt(CS);
289    OS << "\n";
290  } else {
291    OS << "\n";
292    PrintStmt(Node->getBody());
293  }
294}
295
296void StmtPrinter::VisitGotoStmt(GotoStmt *Node) {
297  Indent() << "goto " << Node->getLabel()->getName() << ";\n";
298}
299
300void StmtPrinter::VisitIndirectGotoStmt(IndirectGotoStmt *Node) {
301  Indent() << "goto *";
302  PrintExpr(Node->getTarget());
303  OS << ";\n";
304}
305
306void StmtPrinter::VisitContinueStmt(ContinueStmt *Node) {
307  Indent() << "continue;\n";
308}
309
310void StmtPrinter::VisitBreakStmt(BreakStmt *Node) {
311  Indent() << "break;\n";
312}
313
314
315void StmtPrinter::VisitReturnStmt(ReturnStmt *Node) {
316  Indent() << "return";
317  if (Node->getRetValue()) {
318    OS << " ";
319    PrintExpr(Node->getRetValue());
320  }
321  OS << ";\n";
322}
323
324
325void StmtPrinter::VisitAsmStmt(AsmStmt *Node) {
326  Indent() << "asm ";
327
328  if (Node->isVolatile())
329    OS << "volatile ";
330
331  OS << "(";
332  VisitStringLiteral(Node->getAsmString());
333
334  // Outputs
335  if (Node->getNumOutputs() != 0 || Node->getNumInputs() != 0 ||
336      Node->getNumClobbers() != 0)
337    OS << " : ";
338
339  for (unsigned i = 0, e = Node->getNumOutputs(); i != e; ++i) {
340    if (i != 0)
341      OS << ", ";
342
343    if (!Node->getOutputName(i).empty()) {
344      OS << '[';
345      OS << Node->getOutputName(i);
346      OS << "] ";
347    }
348
349    VisitStringLiteral(Node->getOutputConstraintLiteral(i));
350    OS << " ";
351    Visit(Node->getOutputExpr(i));
352  }
353
354  // Inputs
355  if (Node->getNumInputs() != 0 || Node->getNumClobbers() != 0)
356    OS << " : ";
357
358  for (unsigned i = 0, e = Node->getNumInputs(); i != e; ++i) {
359    if (i != 0)
360      OS << ", ";
361
362    if (!Node->getInputName(i).empty()) {
363      OS << '[';
364      OS << Node->getInputName(i);
365      OS << "] ";
366    }
367
368    VisitStringLiteral(Node->getInputConstraintLiteral(i));
369    OS << " ";
370    Visit(Node->getInputExpr(i));
371  }
372
373  // Clobbers
374  if (Node->getNumClobbers() != 0)
375    OS << " : ";
376
377  for (unsigned i = 0, e = Node->getNumClobbers(); i != e; ++i) {
378    if (i != 0)
379      OS << ", ";
380
381    VisitStringLiteral(Node->getClobber(i));
382  }
383
384  OS << ");\n";
385}
386
387void StmtPrinter::VisitObjCAtTryStmt(ObjCAtTryStmt *Node) {
388  Indent() << "@try";
389  if (CompoundStmt *TS = dyn_cast<CompoundStmt>(Node->getTryBody())) {
390    PrintRawCompoundStmt(TS);
391    OS << "\n";
392  }
393
394  for (unsigned I = 0, N = Node->getNumCatchStmts(); I != N; ++I) {
395    ObjCAtCatchStmt *catchStmt = Node->getCatchStmt(I);
396    Indent() << "@catch(";
397    if (catchStmt->getCatchParamDecl()) {
398      if (Decl *DS = catchStmt->getCatchParamDecl())
399        PrintRawDecl(DS);
400    }
401    OS << ")";
402    if (CompoundStmt *CS = dyn_cast<CompoundStmt>(catchStmt->getCatchBody())) {
403      PrintRawCompoundStmt(CS);
404      OS << "\n";
405    }
406  }
407
408  if (ObjCAtFinallyStmt *FS = static_cast<ObjCAtFinallyStmt *>(
409        Node->getFinallyStmt())) {
410    Indent() << "@finally";
411    PrintRawCompoundStmt(dyn_cast<CompoundStmt>(FS->getFinallyBody()));
412    OS << "\n";
413  }
414}
415
416void StmtPrinter::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *Node) {
417}
418
419void StmtPrinter::VisitObjCAtCatchStmt (ObjCAtCatchStmt *Node) {
420  Indent() << "@catch (...) { /* todo */ } \n";
421}
422
423void StmtPrinter::VisitObjCAtThrowStmt(ObjCAtThrowStmt *Node) {
424  Indent() << "@throw";
425  if (Node->getThrowExpr()) {
426    OS << " ";
427    PrintExpr(Node->getThrowExpr());
428  }
429  OS << ";\n";
430}
431
432void StmtPrinter::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *Node) {
433  Indent() << "@synchronized (";
434  PrintExpr(Node->getSynchExpr());
435  OS << ")";
436  PrintRawCompoundStmt(Node->getSynchBody());
437  OS << "\n";
438}
439
440void StmtPrinter::PrintRawCXXCatchStmt(CXXCatchStmt *Node) {
441  OS << "catch (";
442  if (Decl *ExDecl = Node->getExceptionDecl())
443    PrintRawDecl(ExDecl);
444  else
445    OS << "...";
446  OS << ") ";
447  PrintRawCompoundStmt(cast<CompoundStmt>(Node->getHandlerBlock()));
448}
449
450void StmtPrinter::VisitCXXCatchStmt(CXXCatchStmt *Node) {
451  Indent();
452  PrintRawCXXCatchStmt(Node);
453  OS << "\n";
454}
455
456void StmtPrinter::VisitCXXTryStmt(CXXTryStmt *Node) {
457  Indent() << "try ";
458  PrintRawCompoundStmt(Node->getTryBlock());
459  for (unsigned i = 0, e = Node->getNumHandlers(); i < e; ++i) {
460    OS << " ";
461    PrintRawCXXCatchStmt(Node->getHandler(i));
462  }
463  OS << "\n";
464}
465
466//===----------------------------------------------------------------------===//
467//  Expr printing methods.
468//===----------------------------------------------------------------------===//
469
470void StmtPrinter::VisitDeclRefExpr(DeclRefExpr *Node) {
471  if (NestedNameSpecifier *Qualifier = Node->getQualifier())
472    Qualifier->print(OS, Policy);
473  OS << Node->getNameInfo();
474  if (Node->hasExplicitTemplateArgs())
475    OS << TemplateSpecializationType::PrintTemplateArgumentList(
476                                                    Node->getTemplateArgs(),
477                                                    Node->getNumTemplateArgs(),
478                                                    Policy);
479}
480
481void StmtPrinter::VisitDependentScopeDeclRefExpr(
482                                           DependentScopeDeclRefExpr *Node) {
483  Node->getQualifier()->print(OS, Policy);
484  OS << Node->getNameInfo();
485  if (Node->hasExplicitTemplateArgs())
486    OS << TemplateSpecializationType::PrintTemplateArgumentList(
487                                                   Node->getTemplateArgs(),
488                                                   Node->getNumTemplateArgs(),
489                                                   Policy);
490}
491
492void StmtPrinter::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *Node) {
493  if (Node->getQualifier())
494    Node->getQualifier()->print(OS, Policy);
495  OS << Node->getNameInfo();
496  if (Node->hasExplicitTemplateArgs())
497    OS << TemplateSpecializationType::PrintTemplateArgumentList(
498                                                   Node->getTemplateArgs(),
499                                                   Node->getNumTemplateArgs(),
500                                                   Policy);
501}
502
503void StmtPrinter::VisitObjCIvarRefExpr(ObjCIvarRefExpr *Node) {
504  if (Node->getBase()) {
505    PrintExpr(Node->getBase());
506    OS << (Node->isArrow() ? "->" : ".");
507  }
508  OS << Node->getDecl();
509}
510
511void StmtPrinter::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *Node) {
512  if (Node->isSuperReceiver())
513    OS << "super.";
514  else if (Node->getBase()) {
515    PrintExpr(Node->getBase());
516    OS << ".";
517  }
518
519  if (Node->isImplicitProperty())
520    OS << Node->getImplicitPropertyGetter()->getSelector().getAsString();
521  else
522    OS << Node->getExplicitProperty()->getName();
523}
524
525void StmtPrinter::VisitPredefinedExpr(PredefinedExpr *Node) {
526  switch (Node->getIdentType()) {
527    default:
528      assert(0 && "unknown case");
529    case PredefinedExpr::Func:
530      OS << "__func__";
531      break;
532    case PredefinedExpr::Function:
533      OS << "__FUNCTION__";
534      break;
535    case PredefinedExpr::PrettyFunction:
536      OS << "__PRETTY_FUNCTION__";
537      break;
538  }
539}
540
541void StmtPrinter::VisitCharacterLiteral(CharacterLiteral *Node) {
542  unsigned value = Node->getValue();
543  if (Node->isWide())
544    OS << "L";
545  switch (value) {
546  case '\\':
547    OS << "'\\\\'";
548    break;
549  case '\'':
550    OS << "'\\''";
551    break;
552  case '\a':
553    // TODO: K&R: the meaning of '\\a' is different in traditional C
554    OS << "'\\a'";
555    break;
556  case '\b':
557    OS << "'\\b'";
558    break;
559  // Nonstandard escape sequence.
560  /*case '\e':
561    OS << "'\\e'";
562    break;*/
563  case '\f':
564    OS << "'\\f'";
565    break;
566  case '\n':
567    OS << "'\\n'";
568    break;
569  case '\r':
570    OS << "'\\r'";
571    break;
572  case '\t':
573    OS << "'\\t'";
574    break;
575  case '\v':
576    OS << "'\\v'";
577    break;
578  default:
579    if (value < 256 && isprint(value)) {
580      OS << "'" << (char)value << "'";
581    } else if (value < 256) {
582      OS << "'\\x" << llvm::format("%x", value) << "'";
583    } else {
584      // FIXME what to really do here?
585      OS << value;
586    }
587  }
588}
589
590void StmtPrinter::VisitIntegerLiteral(IntegerLiteral *Node) {
591  bool isSigned = Node->getType()->isSignedIntegerType();
592  OS << Node->getValue().toString(10, isSigned);
593
594  // Emit suffixes.  Integer literals are always a builtin integer type.
595  switch (Node->getType()->getAs<BuiltinType>()->getKind()) {
596  default: assert(0 && "Unexpected type for integer literal!");
597  case BuiltinType::Int:       break; // no suffix.
598  case BuiltinType::UInt:      OS << 'U'; break;
599  case BuiltinType::Long:      OS << 'L'; break;
600  case BuiltinType::ULong:     OS << "UL"; break;
601  case BuiltinType::LongLong:  OS << "LL"; break;
602  case BuiltinType::ULongLong: OS << "ULL"; break;
603  }
604}
605void StmtPrinter::VisitFloatingLiteral(FloatingLiteral *Node) {
606  // FIXME: print value more precisely.
607  OS << Node->getValueAsApproximateDouble();
608}
609
610void StmtPrinter::VisitImaginaryLiteral(ImaginaryLiteral *Node) {
611  PrintExpr(Node->getSubExpr());
612  OS << "i";
613}
614
615void StmtPrinter::VisitStringLiteral(StringLiteral *Str) {
616  if (Str->isWide()) OS << 'L';
617  OS << '"';
618
619  // FIXME: this doesn't print wstrings right.
620  llvm::StringRef StrData = Str->getString();
621  for (llvm::StringRef::iterator I = StrData.begin(), E = StrData.end();
622                                                             I != E; ++I) {
623    unsigned char Char = *I;
624
625    switch (Char) {
626    default:
627      if (isprint(Char))
628        OS << (char)Char;
629      else  // Output anything hard as an octal escape.
630        OS << '\\'
631        << (char)('0'+ ((Char >> 6) & 7))
632        << (char)('0'+ ((Char >> 3) & 7))
633        << (char)('0'+ ((Char >> 0) & 7));
634      break;
635    // Handle some common non-printable cases to make dumps prettier.
636    case '\\': OS << "\\\\"; break;
637    case '"': OS << "\\\""; break;
638    case '\n': OS << "\\n"; break;
639    case '\t': OS << "\\t"; break;
640    case '\a': OS << "\\a"; break;
641    case '\b': OS << "\\b"; break;
642    }
643  }
644  OS << '"';
645}
646void StmtPrinter::VisitParenExpr(ParenExpr *Node) {
647  OS << "(";
648  PrintExpr(Node->getSubExpr());
649  OS << ")";
650}
651void StmtPrinter::VisitUnaryOperator(UnaryOperator *Node) {
652  if (!Node->isPostfix()) {
653    OS << UnaryOperator::getOpcodeStr(Node->getOpcode());
654
655    // Print a space if this is an "identifier operator" like __real, or if
656    // it might be concatenated incorrectly like '+'.
657    switch (Node->getOpcode()) {
658    default: break;
659    case UO_Real:
660    case UO_Imag:
661    case UO_Extension:
662      OS << ' ';
663      break;
664    case UO_Plus:
665    case UO_Minus:
666      if (isa<UnaryOperator>(Node->getSubExpr()))
667        OS << ' ';
668      break;
669    }
670  }
671  PrintExpr(Node->getSubExpr());
672
673  if (Node->isPostfix())
674    OS << UnaryOperator::getOpcodeStr(Node->getOpcode());
675}
676
677void StmtPrinter::VisitOffsetOfExpr(OffsetOfExpr *Node) {
678  OS << "__builtin_offsetof(";
679  OS << Node->getTypeSourceInfo()->getType().getAsString(Policy) << ", ";
680  bool PrintedSomething = false;
681  for (unsigned i = 0, n = Node->getNumComponents(); i < n; ++i) {
682    OffsetOfExpr::OffsetOfNode ON = Node->getComponent(i);
683    if (ON.getKind() == OffsetOfExpr::OffsetOfNode::Array) {
684      // Array node
685      OS << "[";
686      PrintExpr(Node->getIndexExpr(ON.getArrayExprIndex()));
687      OS << "]";
688      PrintedSomething = true;
689      continue;
690    }
691
692    // Skip implicit base indirections.
693    if (ON.getKind() == OffsetOfExpr::OffsetOfNode::Base)
694      continue;
695
696    // Field or identifier node.
697    IdentifierInfo *Id = ON.getFieldName();
698    if (!Id)
699      continue;
700
701    if (PrintedSomething)
702      OS << ".";
703    else
704      PrintedSomething = true;
705    OS << Id->getName();
706  }
707  OS << ")";
708}
709
710void StmtPrinter::VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *Node) {
711  OS << (Node->isSizeOf() ? "sizeof" : "__alignof");
712  if (Node->isArgumentType())
713    OS << "(" << Node->getArgumentType().getAsString(Policy) << ")";
714  else {
715    OS << " ";
716    PrintExpr(Node->getArgumentExpr());
717  }
718}
719void StmtPrinter::VisitArraySubscriptExpr(ArraySubscriptExpr *Node) {
720  PrintExpr(Node->getLHS());
721  OS << "[";
722  PrintExpr(Node->getRHS());
723  OS << "]";
724}
725
726void StmtPrinter::VisitCallExpr(CallExpr *Call) {
727  PrintExpr(Call->getCallee());
728  OS << "(";
729  for (unsigned i = 0, e = Call->getNumArgs(); i != e; ++i) {
730    if (isa<CXXDefaultArgExpr>(Call->getArg(i))) {
731      // Don't print any defaulted arguments
732      break;
733    }
734
735    if (i) OS << ", ";
736    PrintExpr(Call->getArg(i));
737  }
738  OS << ")";
739}
740void StmtPrinter::VisitMemberExpr(MemberExpr *Node) {
741  // FIXME: Suppress printing implicit bases (like "this")
742  PrintExpr(Node->getBase());
743  if (FieldDecl *FD = dyn_cast<FieldDecl>(Node->getMemberDecl()))
744    if (FD->isAnonymousStructOrUnion())
745      return;
746  OS << (Node->isArrow() ? "->" : ".");
747  if (NestedNameSpecifier *Qualifier = Node->getQualifier())
748    Qualifier->print(OS, Policy);
749
750  OS << Node->getMemberNameInfo();
751
752  if (Node->hasExplicitTemplateArgs())
753    OS << TemplateSpecializationType::PrintTemplateArgumentList(
754                                                    Node->getTemplateArgs(),
755                                                    Node->getNumTemplateArgs(),
756                                                                Policy);
757}
758void StmtPrinter::VisitObjCIsaExpr(ObjCIsaExpr *Node) {
759  PrintExpr(Node->getBase());
760  OS << (Node->isArrow() ? "->isa" : ".isa");
761}
762
763void StmtPrinter::VisitExtVectorElementExpr(ExtVectorElementExpr *Node) {
764  PrintExpr(Node->getBase());
765  OS << ".";
766  OS << Node->getAccessor().getName();
767}
768void StmtPrinter::VisitCStyleCastExpr(CStyleCastExpr *Node) {
769  OS << "(" << Node->getType().getAsString(Policy) << ")";
770  PrintExpr(Node->getSubExpr());
771}
772void StmtPrinter::VisitCompoundLiteralExpr(CompoundLiteralExpr *Node) {
773  OS << "(" << Node->getType().getAsString(Policy) << ")";
774  PrintExpr(Node->getInitializer());
775}
776void StmtPrinter::VisitImplicitCastExpr(ImplicitCastExpr *Node) {
777  // No need to print anything, simply forward to the sub expression.
778  PrintExpr(Node->getSubExpr());
779}
780void StmtPrinter::VisitBinaryOperator(BinaryOperator *Node) {
781  PrintExpr(Node->getLHS());
782  OS << " " << BinaryOperator::getOpcodeStr(Node->getOpcode()) << " ";
783  PrintExpr(Node->getRHS());
784}
785void StmtPrinter::VisitCompoundAssignOperator(CompoundAssignOperator *Node) {
786  PrintExpr(Node->getLHS());
787  OS << " " << BinaryOperator::getOpcodeStr(Node->getOpcode()) << " ";
788  PrintExpr(Node->getRHS());
789}
790void StmtPrinter::VisitConditionalOperator(ConditionalOperator *Node) {
791  PrintExpr(Node->getCond());
792
793  if (Node->getLHS()) {
794    OS << " ? ";
795    PrintExpr(Node->getLHS());
796    OS << " : ";
797  }
798  else { // Handle GCC extension where LHS can be NULL.
799    OS << " ?: ";
800  }
801
802  PrintExpr(Node->getRHS());
803}
804
805// GNU extensions.
806
807void StmtPrinter::VisitAddrLabelExpr(AddrLabelExpr *Node) {
808  OS << "&&" << Node->getLabel()->getName();
809}
810
811void StmtPrinter::VisitStmtExpr(StmtExpr *E) {
812  OS << "(";
813  PrintRawCompoundStmt(E->getSubStmt());
814  OS << ")";
815}
816
817void StmtPrinter::VisitTypesCompatibleExpr(TypesCompatibleExpr *Node) {
818  OS << "__builtin_types_compatible_p(";
819  OS << Node->getArgType1().getAsString(Policy) << ",";
820  OS << Node->getArgType2().getAsString(Policy) << ")";
821}
822
823void StmtPrinter::VisitChooseExpr(ChooseExpr *Node) {
824  OS << "__builtin_choose_expr(";
825  PrintExpr(Node->getCond());
826  OS << ", ";
827  PrintExpr(Node->getLHS());
828  OS << ", ";
829  PrintExpr(Node->getRHS());
830  OS << ")";
831}
832
833void StmtPrinter::VisitGNUNullExpr(GNUNullExpr *) {
834  OS << "__null";
835}
836
837void StmtPrinter::VisitShuffleVectorExpr(ShuffleVectorExpr *Node) {
838  OS << "__builtin_shufflevector(";
839  for (unsigned i = 0, e = Node->getNumSubExprs(); i != e; ++i) {
840    if (i) OS << ", ";
841    PrintExpr(Node->getExpr(i));
842  }
843  OS << ")";
844}
845
846void StmtPrinter::VisitInitListExpr(InitListExpr* Node) {
847  if (Node->getSyntacticForm()) {
848    Visit(Node->getSyntacticForm());
849    return;
850  }
851
852  OS << "{ ";
853  for (unsigned i = 0, e = Node->getNumInits(); i != e; ++i) {
854    if (i) OS << ", ";
855    if (Node->getInit(i))
856      PrintExpr(Node->getInit(i));
857    else
858      OS << "0";
859  }
860  OS << " }";
861}
862
863void StmtPrinter::VisitParenListExpr(ParenListExpr* Node) {
864  OS << "( ";
865  for (unsigned i = 0, e = Node->getNumExprs(); i != e; ++i) {
866    if (i) OS << ", ";
867    PrintExpr(Node->getExpr(i));
868  }
869  OS << " )";
870}
871
872void StmtPrinter::VisitDesignatedInitExpr(DesignatedInitExpr *Node) {
873  for (DesignatedInitExpr::designators_iterator D = Node->designators_begin(),
874                      DEnd = Node->designators_end();
875       D != DEnd; ++D) {
876    if (D->isFieldDesignator()) {
877      if (D->getDotLoc().isInvalid())
878        OS << D->getFieldName()->getName() << ":";
879      else
880        OS << "." << D->getFieldName()->getName();
881    } else {
882      OS << "[";
883      if (D->isArrayDesignator()) {
884        PrintExpr(Node->getArrayIndex(*D));
885      } else {
886        PrintExpr(Node->getArrayRangeStart(*D));
887        OS << " ... ";
888        PrintExpr(Node->getArrayRangeEnd(*D));
889      }
890      OS << "]";
891    }
892  }
893
894  OS << " = ";
895  PrintExpr(Node->getInit());
896}
897
898void StmtPrinter::VisitImplicitValueInitExpr(ImplicitValueInitExpr *Node) {
899  if (Policy.LangOpts.CPlusPlus)
900    OS << "/*implicit*/" << Node->getType().getAsString(Policy) << "()";
901  else {
902    OS << "/*implicit*/(" << Node->getType().getAsString(Policy) << ")";
903    if (Node->getType()->isRecordType())
904      OS << "{}";
905    else
906      OS << 0;
907  }
908}
909
910void StmtPrinter::VisitVAArgExpr(VAArgExpr *Node) {
911  OS << "__builtin_va_arg(";
912  PrintExpr(Node->getSubExpr());
913  OS << ", ";
914  OS << Node->getType().getAsString(Policy);
915  OS << ")";
916}
917
918// C++
919void StmtPrinter::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *Node) {
920  const char *OpStrings[NUM_OVERLOADED_OPERATORS] = {
921    "",
922#define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \
923    Spelling,
924#include "clang/Basic/OperatorKinds.def"
925  };
926
927  OverloadedOperatorKind Kind = Node->getOperator();
928  if (Kind == OO_PlusPlus || Kind == OO_MinusMinus) {
929    if (Node->getNumArgs() == 1) {
930      OS << OpStrings[Kind] << ' ';
931      PrintExpr(Node->getArg(0));
932    } else {
933      PrintExpr(Node->getArg(0));
934      OS << ' ' << OpStrings[Kind];
935    }
936  } else if (Kind == OO_Call) {
937    PrintExpr(Node->getArg(0));
938    OS << '(';
939    for (unsigned ArgIdx = 1; ArgIdx < Node->getNumArgs(); ++ArgIdx) {
940      if (ArgIdx > 1)
941        OS << ", ";
942      if (!isa<CXXDefaultArgExpr>(Node->getArg(ArgIdx)))
943        PrintExpr(Node->getArg(ArgIdx));
944    }
945    OS << ')';
946  } else if (Kind == OO_Subscript) {
947    PrintExpr(Node->getArg(0));
948    OS << '[';
949    PrintExpr(Node->getArg(1));
950    OS << ']';
951  } else if (Node->getNumArgs() == 1) {
952    OS << OpStrings[Kind] << ' ';
953    PrintExpr(Node->getArg(0));
954  } else if (Node->getNumArgs() == 2) {
955    PrintExpr(Node->getArg(0));
956    OS << ' ' << OpStrings[Kind] << ' ';
957    PrintExpr(Node->getArg(1));
958  } else {
959    assert(false && "unknown overloaded operator");
960  }
961}
962
963void StmtPrinter::VisitCXXMemberCallExpr(CXXMemberCallExpr *Node) {
964  VisitCallExpr(cast<CallExpr>(Node));
965}
966
967void StmtPrinter::VisitCXXNamedCastExpr(CXXNamedCastExpr *Node) {
968  OS << Node->getCastName() << '<';
969  OS << Node->getTypeAsWritten().getAsString(Policy) << ">(";
970  PrintExpr(Node->getSubExpr());
971  OS << ")";
972}
973
974void StmtPrinter::VisitCXXStaticCastExpr(CXXStaticCastExpr *Node) {
975  VisitCXXNamedCastExpr(Node);
976}
977
978void StmtPrinter::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *Node) {
979  VisitCXXNamedCastExpr(Node);
980}
981
982void StmtPrinter::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *Node) {
983  VisitCXXNamedCastExpr(Node);
984}
985
986void StmtPrinter::VisitCXXConstCastExpr(CXXConstCastExpr *Node) {
987  VisitCXXNamedCastExpr(Node);
988}
989
990void StmtPrinter::VisitCXXTypeidExpr(CXXTypeidExpr *Node) {
991  OS << "typeid(";
992  if (Node->isTypeOperand()) {
993    OS << Node->getTypeOperand().getAsString(Policy);
994  } else {
995    PrintExpr(Node->getExprOperand());
996  }
997  OS << ")";
998}
999
1000void StmtPrinter::VisitCXXUuidofExpr(CXXUuidofExpr *Node) {
1001  OS << "__uuidof(";
1002  if (Node->isTypeOperand()) {
1003    OS << Node->getTypeOperand().getAsString(Policy);
1004  } else {
1005    PrintExpr(Node->getExprOperand());
1006  }
1007  OS << ")";
1008}
1009
1010void StmtPrinter::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *Node) {
1011  OS << (Node->getValue() ? "true" : "false");
1012}
1013
1014void StmtPrinter::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *Node) {
1015  OS << "nullptr";
1016}
1017
1018void StmtPrinter::VisitCXXThisExpr(CXXThisExpr *Node) {
1019  OS << "this";
1020}
1021
1022void StmtPrinter::VisitCXXThrowExpr(CXXThrowExpr *Node) {
1023  if (Node->getSubExpr() == 0)
1024    OS << "throw";
1025  else {
1026    OS << "throw ";
1027    PrintExpr(Node->getSubExpr());
1028  }
1029}
1030
1031void StmtPrinter::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *Node) {
1032  // Nothing to print: we picked up the default argument
1033}
1034
1035void StmtPrinter::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *Node) {
1036  OS << Node->getType().getAsString(Policy);
1037  OS << "(";
1038  PrintExpr(Node->getSubExpr());
1039  OS << ")";
1040}
1041
1042void StmtPrinter::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *Node) {
1043  PrintExpr(Node->getSubExpr());
1044}
1045
1046void StmtPrinter::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *Node) {
1047  OS << Node->getType().getAsString(Policy);
1048  OS << "(";
1049  for (CXXTemporaryObjectExpr::arg_iterator Arg = Node->arg_begin(),
1050                                         ArgEnd = Node->arg_end();
1051       Arg != ArgEnd; ++Arg) {
1052    if (Arg != Node->arg_begin())
1053      OS << ", ";
1054    PrintExpr(*Arg);
1055  }
1056  OS << ")";
1057}
1058
1059void StmtPrinter::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *Node) {
1060  if (TypeSourceInfo *TSInfo = Node->getTypeSourceInfo())
1061    OS << TSInfo->getType().getAsString(Policy) << "()";
1062  else
1063    OS << Node->getType().getAsString(Policy) << "()";
1064}
1065
1066void StmtPrinter::VisitCXXNewExpr(CXXNewExpr *E) {
1067  if (E->isGlobalNew())
1068    OS << "::";
1069  OS << "new ";
1070  unsigned NumPlace = E->getNumPlacementArgs();
1071  if (NumPlace > 0) {
1072    OS << "(";
1073    PrintExpr(E->getPlacementArg(0));
1074    for (unsigned i = 1; i < NumPlace; ++i) {
1075      OS << ", ";
1076      PrintExpr(E->getPlacementArg(i));
1077    }
1078    OS << ") ";
1079  }
1080  if (E->isParenTypeId())
1081    OS << "(";
1082  std::string TypeS;
1083  if (Expr *Size = E->getArraySize()) {
1084    llvm::raw_string_ostream s(TypeS);
1085    Size->printPretty(s, Context, Helper, Policy);
1086    s.flush();
1087    TypeS = "[" + TypeS + "]";
1088  }
1089  E->getAllocatedType().getAsStringInternal(TypeS, Policy);
1090  OS << TypeS;
1091  if (E->isParenTypeId())
1092    OS << ")";
1093
1094  if (E->hasInitializer()) {
1095    OS << "(";
1096    unsigned NumCons = E->getNumConstructorArgs();
1097    if (NumCons > 0) {
1098      PrintExpr(E->getConstructorArg(0));
1099      for (unsigned i = 1; i < NumCons; ++i) {
1100        OS << ", ";
1101        PrintExpr(E->getConstructorArg(i));
1102      }
1103    }
1104    OS << ")";
1105  }
1106}
1107
1108void StmtPrinter::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
1109  if (E->isGlobalDelete())
1110    OS << "::";
1111  OS << "delete ";
1112  if (E->isArrayForm())
1113    OS << "[] ";
1114  PrintExpr(E->getArgument());
1115}
1116
1117void StmtPrinter::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
1118  PrintExpr(E->getBase());
1119  if (E->isArrow())
1120    OS << "->";
1121  else
1122    OS << '.';
1123  if (E->getQualifier())
1124    E->getQualifier()->print(OS, Policy);
1125
1126  std::string TypeS;
1127  if (IdentifierInfo *II = E->getDestroyedTypeIdentifier())
1128    OS << II->getName();
1129  else
1130    E->getDestroyedType().getAsStringInternal(TypeS, Policy);
1131  OS << TypeS;
1132}
1133
1134void StmtPrinter::VisitCXXConstructExpr(CXXConstructExpr *E) {
1135  // FIXME. For now we just print a trivial constructor call expression,
1136  // constructing its first argument object.
1137  if (E->getNumArgs() == 1) {
1138    CXXConstructorDecl *CD = E->getConstructor();
1139    if (CD->isTrivial())
1140      PrintExpr(E->getArg(0));
1141  }
1142  // Nothing to print.
1143}
1144
1145void StmtPrinter::VisitExprWithCleanups(ExprWithCleanups *E) {
1146  // Just forward to the sub expression.
1147  PrintExpr(E->getSubExpr());
1148}
1149
1150void
1151StmtPrinter::VisitCXXUnresolvedConstructExpr(
1152                                           CXXUnresolvedConstructExpr *Node) {
1153  OS << Node->getTypeAsWritten().getAsString(Policy);
1154  OS << "(";
1155  for (CXXUnresolvedConstructExpr::arg_iterator Arg = Node->arg_begin(),
1156                                             ArgEnd = Node->arg_end();
1157       Arg != ArgEnd; ++Arg) {
1158    if (Arg != Node->arg_begin())
1159      OS << ", ";
1160    PrintExpr(*Arg);
1161  }
1162  OS << ")";
1163}
1164
1165void StmtPrinter::VisitCXXDependentScopeMemberExpr(
1166                                         CXXDependentScopeMemberExpr *Node) {
1167  if (!Node->isImplicitAccess()) {
1168    PrintExpr(Node->getBase());
1169    OS << (Node->isArrow() ? "->" : ".");
1170  }
1171  if (NestedNameSpecifier *Qualifier = Node->getQualifier())
1172    Qualifier->print(OS, Policy);
1173  else if (Node->hasExplicitTemplateArgs())
1174    // FIXME: Track use of "template" keyword explicitly?
1175    OS << "template ";
1176
1177  OS << Node->getMemberNameInfo();
1178
1179  if (Node->hasExplicitTemplateArgs()) {
1180    OS << TemplateSpecializationType::PrintTemplateArgumentList(
1181                                                    Node->getTemplateArgs(),
1182                                                    Node->getNumTemplateArgs(),
1183                                                    Policy);
1184  }
1185}
1186
1187void StmtPrinter::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *Node) {
1188  if (!Node->isImplicitAccess()) {
1189    PrintExpr(Node->getBase());
1190    OS << (Node->isArrow() ? "->" : ".");
1191  }
1192  if (NestedNameSpecifier *Qualifier = Node->getQualifier())
1193    Qualifier->print(OS, Policy);
1194
1195  // FIXME: this might originally have been written with 'template'
1196
1197  OS << Node->getMemberNameInfo();
1198
1199  if (Node->hasExplicitTemplateArgs()) {
1200    OS << TemplateSpecializationType::PrintTemplateArgumentList(
1201                                                    Node->getTemplateArgs(),
1202                                                    Node->getNumTemplateArgs(),
1203                                                    Policy);
1204  }
1205}
1206
1207static const char *getTypeTraitName(UnaryTypeTrait UTT) {
1208  switch (UTT) {
1209  default: assert(false && "Unknown type trait");
1210  case UTT_HasNothrowAssign:      return "__has_nothrow_assign";
1211  case UTT_HasNothrowCopy:        return "__has_nothrow_copy";
1212  case UTT_HasNothrowConstructor: return "__has_nothrow_constructor";
1213  case UTT_HasTrivialAssign:      return "__has_trivial_assign";
1214  case UTT_HasTrivialCopy:        return "__has_trivial_copy";
1215  case UTT_HasTrivialConstructor: return "__has_trivial_constructor";
1216  case UTT_HasTrivialDestructor:  return "__has_trivial_destructor";
1217  case UTT_HasVirtualDestructor:  return "__has_virtual_destructor";
1218  case UTT_IsAbstract:            return "__is_abstract";
1219  case UTT_IsClass:               return "__is_class";
1220  case UTT_IsEmpty:               return "__is_empty";
1221  case UTT_IsEnum:                return "__is_enum";
1222  case UTT_IsPOD:                 return "__is_pod";
1223  case UTT_IsPolymorphic:         return "__is_polymorphic";
1224  case UTT_IsUnion:               return "__is_union";
1225  }
1226}
1227
1228void StmtPrinter::VisitUnaryTypeTraitExpr(UnaryTypeTraitExpr *E) {
1229  OS << getTypeTraitName(E->getTrait()) << "("
1230     << E->getQueriedType().getAsString(Policy) << ")";
1231}
1232
1233void StmtPrinter::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
1234  OS << "noexcept(";
1235  PrintExpr(E->getOperand());
1236  OS << ")";
1237}
1238
1239// Obj-C
1240
1241void StmtPrinter::VisitObjCStringLiteral(ObjCStringLiteral *Node) {
1242  OS << "@";
1243  VisitStringLiteral(Node->getString());
1244}
1245
1246void StmtPrinter::VisitObjCEncodeExpr(ObjCEncodeExpr *Node) {
1247  OS << "@encode(" << Node->getEncodedType().getAsString(Policy) << ')';
1248}
1249
1250void StmtPrinter::VisitObjCSelectorExpr(ObjCSelectorExpr *Node) {
1251  OS << "@selector(" << Node->getSelector().getAsString() << ')';
1252}
1253
1254void StmtPrinter::VisitObjCProtocolExpr(ObjCProtocolExpr *Node) {
1255  OS << "@protocol(" << Node->getProtocol() << ')';
1256}
1257
1258void StmtPrinter::VisitObjCMessageExpr(ObjCMessageExpr *Mess) {
1259  OS << "[";
1260  switch (Mess->getReceiverKind()) {
1261  case ObjCMessageExpr::Instance:
1262    PrintExpr(Mess->getInstanceReceiver());
1263    break;
1264
1265  case ObjCMessageExpr::Class:
1266    OS << Mess->getClassReceiver().getAsString(Policy);
1267    break;
1268
1269  case ObjCMessageExpr::SuperInstance:
1270  case ObjCMessageExpr::SuperClass:
1271    OS << "Super";
1272    break;
1273  }
1274
1275  OS << ' ';
1276  Selector selector = Mess->getSelector();
1277  if (selector.isUnarySelector()) {
1278    OS << selector.getIdentifierInfoForSlot(0)->getName();
1279  } else {
1280    for (unsigned i = 0, e = Mess->getNumArgs(); i != e; ++i) {
1281      if (i < selector.getNumArgs()) {
1282        if (i > 0) OS << ' ';
1283        if (selector.getIdentifierInfoForSlot(i))
1284          OS << selector.getIdentifierInfoForSlot(i)->getName() << ':';
1285        else
1286           OS << ":";
1287      }
1288      else OS << ", "; // Handle variadic methods.
1289
1290      PrintExpr(Mess->getArg(i));
1291    }
1292  }
1293  OS << "]";
1294}
1295
1296
1297void StmtPrinter::VisitBlockExpr(BlockExpr *Node) {
1298  BlockDecl *BD = Node->getBlockDecl();
1299  OS << "^";
1300
1301  const FunctionType *AFT = Node->getFunctionType();
1302
1303  if (isa<FunctionNoProtoType>(AFT)) {
1304    OS << "()";
1305  } else if (!BD->param_empty() || cast<FunctionProtoType>(AFT)->isVariadic()) {
1306    OS << '(';
1307    std::string ParamStr;
1308    for (BlockDecl::param_iterator AI = BD->param_begin(),
1309         E = BD->param_end(); AI != E; ++AI) {
1310      if (AI != BD->param_begin()) OS << ", ";
1311      ParamStr = (*AI)->getNameAsString();
1312      (*AI)->getType().getAsStringInternal(ParamStr, Policy);
1313      OS << ParamStr;
1314    }
1315
1316    const FunctionProtoType *FT = cast<FunctionProtoType>(AFT);
1317    if (FT->isVariadic()) {
1318      if (!BD->param_empty()) OS << ", ";
1319      OS << "...";
1320    }
1321    OS << ')';
1322  }
1323}
1324
1325void StmtPrinter::VisitBlockDeclRefExpr(BlockDeclRefExpr *Node) {
1326  OS << Node->getDecl();
1327}
1328
1329void StmtPrinter::VisitOpaqueValueExpr(OpaqueValueExpr *Node) {}
1330
1331//===----------------------------------------------------------------------===//
1332// Stmt method implementations
1333//===----------------------------------------------------------------------===//
1334
1335void Stmt::dumpPretty(ASTContext& Context) const {
1336  printPretty(llvm::errs(), Context, 0,
1337              PrintingPolicy(Context.getLangOptions()));
1338}
1339
1340void Stmt::printPretty(llvm::raw_ostream &OS, ASTContext& Context,
1341                       PrinterHelper* Helper,
1342                       const PrintingPolicy &Policy,
1343                       unsigned Indentation) const {
1344  if (this == 0) {
1345    OS << "<NULL>";
1346    return;
1347  }
1348
1349  if (Policy.Dump && &Context) {
1350    dump(OS, Context.getSourceManager());
1351    return;
1352  }
1353
1354  StmtPrinter P(OS, Context, Helper, Policy, Indentation);
1355  P.Visit(const_cast<Stmt*>(this));
1356}
1357
1358//===----------------------------------------------------------------------===//
1359// PrinterHelper
1360//===----------------------------------------------------------------------===//
1361
1362// Implement virtual destructor.
1363PrinterHelper::~PrinterHelper() {}
1364