clang  3.7.0
StmtPrinter.cpp
Go to the documentation of this file.
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/ASTContext.h"
16 #include "clang/AST/Attr.h"
17 #include "clang/AST/DeclCXX.h"
18 #include "clang/AST/DeclObjC.h"
19 #include "clang/AST/DeclTemplate.h"
20 #include "clang/AST/Expr.h"
21 #include "clang/AST/ExprCXX.h"
23 #include "clang/AST/StmtVisitor.h"
24 #include "clang/Basic/CharInfo.h"
25 #include "llvm/ADT/SmallString.h"
26 #include "llvm/Support/Format.h"
27 using namespace clang;
28 
29 //===----------------------------------------------------------------------===//
30 // StmtPrinter Visitor
31 //===----------------------------------------------------------------------===//
32 
33 namespace {
34  class StmtPrinter : public StmtVisitor<StmtPrinter> {
35  raw_ostream &OS;
36  unsigned IndentLevel;
37  clang::PrinterHelper* Helper;
38  PrintingPolicy Policy;
39 
40  public:
41  StmtPrinter(raw_ostream &os, PrinterHelper* helper,
42  const PrintingPolicy &Policy,
43  unsigned Indentation = 0)
44  : OS(os), IndentLevel(Indentation), Helper(helper), Policy(Policy) {}
45 
46  void PrintStmt(Stmt *S) {
47  PrintStmt(S, Policy.Indentation);
48  }
49 
50  void PrintStmt(Stmt *S, int SubIndent) {
51  IndentLevel += SubIndent;
52  if (S && isa<Expr>(S)) {
53  // If this is an expr used in a stmt context, indent and newline it.
54  Indent();
55  Visit(S);
56  OS << ";\n";
57  } else if (S) {
58  Visit(S);
59  } else {
60  Indent() << "<<<NULL STATEMENT>>>\n";
61  }
62  IndentLevel -= SubIndent;
63  }
64 
65  void PrintRawCompoundStmt(CompoundStmt *S);
66  void PrintRawDecl(Decl *D);
67  void PrintRawDeclStmt(const DeclStmt *S);
68  void PrintRawIfStmt(IfStmt *If);
69  void PrintRawCXXCatchStmt(CXXCatchStmt *Catch);
70  void PrintCallArgs(CallExpr *E);
71  void PrintRawSEHExceptHandler(SEHExceptStmt *S);
72  void PrintRawSEHFinallyStmt(SEHFinallyStmt *S);
73  void PrintOMPExecutableDirective(OMPExecutableDirective *S);
74 
75  void PrintExpr(Expr *E) {
76  if (E)
77  Visit(E);
78  else
79  OS << "<null expr>";
80  }
81 
82  raw_ostream &Indent(int Delta = 0) {
83  for (int i = 0, e = IndentLevel+Delta; i < e; ++i)
84  OS << " ";
85  return OS;
86  }
87 
88  void Visit(Stmt* S) {
89  if (Helper && Helper->handledStmt(S,OS))
90  return;
92  }
93 
94  void VisitStmt(Stmt *Node) LLVM_ATTRIBUTE_UNUSED {
95  Indent() << "<<unknown stmt type>>\n";
96  }
97  void VisitExpr(Expr *Node) LLVM_ATTRIBUTE_UNUSED {
98  OS << "<<unknown expr type>>";
99  }
100  void VisitCXXNamedCastExpr(CXXNamedCastExpr *Node);
101 
102 #define ABSTRACT_STMT(CLASS)
103 #define STMT(CLASS, PARENT) \
104  void Visit##CLASS(CLASS *Node);
105 #include "clang/AST/StmtNodes.inc"
106  };
107 }
108 
109 //===----------------------------------------------------------------------===//
110 // Stmt printing methods.
111 //===----------------------------------------------------------------------===//
112 
113 /// PrintRawCompoundStmt - Print a compound stmt without indenting the {, and
114 /// with no newline after the }.
115 void StmtPrinter::PrintRawCompoundStmt(CompoundStmt *Node) {
116  OS << "{\n";
117  for (auto *I : Node->body())
118  PrintStmt(I);
119 
120  Indent() << "}";
121 }
122 
123 void StmtPrinter::PrintRawDecl(Decl *D) {
124  D->print(OS, Policy, IndentLevel);
125 }
126 
127 void StmtPrinter::PrintRawDeclStmt(const DeclStmt *S) {
128  SmallVector<Decl*, 2> Decls(S->decls());
129  Decl::printGroup(Decls.data(), Decls.size(), OS, Policy, IndentLevel);
130 }
131 
132 void StmtPrinter::VisitNullStmt(NullStmt *Node) {
133  Indent() << ";\n";
134 }
135 
136 void StmtPrinter::VisitDeclStmt(DeclStmt *Node) {
137  Indent();
138  PrintRawDeclStmt(Node);
139  OS << ";\n";
140 }
141 
142 void StmtPrinter::VisitCompoundStmt(CompoundStmt *Node) {
143  Indent();
144  PrintRawCompoundStmt(Node);
145  OS << "\n";
146 }
147 
148 void StmtPrinter::VisitCaseStmt(CaseStmt *Node) {
149  Indent(-1) << "case ";
150  PrintExpr(Node->getLHS());
151  if (Node->getRHS()) {
152  OS << " ... ";
153  PrintExpr(Node->getRHS());
154  }
155  OS << ":\n";
156 
157  PrintStmt(Node->getSubStmt(), 0);
158 }
159 
160 void StmtPrinter::VisitDefaultStmt(DefaultStmt *Node) {
161  Indent(-1) << "default:\n";
162  PrintStmt(Node->getSubStmt(), 0);
163 }
164 
165 void StmtPrinter::VisitLabelStmt(LabelStmt *Node) {
166  Indent(-1) << Node->getName() << ":\n";
167  PrintStmt(Node->getSubStmt(), 0);
168 }
169 
170 void StmtPrinter::VisitAttributedStmt(AttributedStmt *Node) {
171  for (const auto *Attr : Node->getAttrs()) {
172  Attr->printPretty(OS, Policy);
173  }
174 
175  PrintStmt(Node->getSubStmt(), 0);
176 }
177 
178 void StmtPrinter::PrintRawIfStmt(IfStmt *If) {
179  OS << "if (";
180  if (const DeclStmt *DS = If->getConditionVariableDeclStmt())
181  PrintRawDeclStmt(DS);
182  else
183  PrintExpr(If->getCond());
184  OS << ')';
185 
186  if (CompoundStmt *CS = dyn_cast<CompoundStmt>(If->getThen())) {
187  OS << ' ';
188  PrintRawCompoundStmt(CS);
189  OS << (If->getElse() ? ' ' : '\n');
190  } else {
191  OS << '\n';
192  PrintStmt(If->getThen());
193  if (If->getElse()) Indent();
194  }
195 
196  if (Stmt *Else = If->getElse()) {
197  OS << "else";
198 
199  if (CompoundStmt *CS = dyn_cast<CompoundStmt>(Else)) {
200  OS << ' ';
201  PrintRawCompoundStmt(CS);
202  OS << '\n';
203  } else if (IfStmt *ElseIf = dyn_cast<IfStmt>(Else)) {
204  OS << ' ';
205  PrintRawIfStmt(ElseIf);
206  } else {
207  OS << '\n';
208  PrintStmt(If->getElse());
209  }
210  }
211 }
212 
213 void StmtPrinter::VisitIfStmt(IfStmt *If) {
214  Indent();
215  PrintRawIfStmt(If);
216 }
217 
218 void StmtPrinter::VisitSwitchStmt(SwitchStmt *Node) {
219  Indent() << "switch (";
220  if (const DeclStmt *DS = Node->getConditionVariableDeclStmt())
221  PrintRawDeclStmt(DS);
222  else
223  PrintExpr(Node->getCond());
224  OS << ")";
225 
226  // Pretty print compoundstmt bodies (very common).
227  if (CompoundStmt *CS = dyn_cast<CompoundStmt>(Node->getBody())) {
228  OS << " ";
229  PrintRawCompoundStmt(CS);
230  OS << "\n";
231  } else {
232  OS << "\n";
233  PrintStmt(Node->getBody());
234  }
235 }
236 
237 void StmtPrinter::VisitWhileStmt(WhileStmt *Node) {
238  Indent() << "while (";
239  if (const DeclStmt *DS = Node->getConditionVariableDeclStmt())
240  PrintRawDeclStmt(DS);
241  else
242  PrintExpr(Node->getCond());
243  OS << ")\n";
244  PrintStmt(Node->getBody());
245 }
246 
247 void StmtPrinter::VisitDoStmt(DoStmt *Node) {
248  Indent() << "do ";
249  if (CompoundStmt *CS = dyn_cast<CompoundStmt>(Node->getBody())) {
250  PrintRawCompoundStmt(CS);
251  OS << " ";
252  } else {
253  OS << "\n";
254  PrintStmt(Node->getBody());
255  Indent();
256  }
257 
258  OS << "while (";
259  PrintExpr(Node->getCond());
260  OS << ");\n";
261 }
262 
263 void StmtPrinter::VisitForStmt(ForStmt *Node) {
264  Indent() << "for (";
265  if (Node->getInit()) {
266  if (DeclStmt *DS = dyn_cast<DeclStmt>(Node->getInit()))
267  PrintRawDeclStmt(DS);
268  else
269  PrintExpr(cast<Expr>(Node->getInit()));
270  }
271  OS << ";";
272  if (Node->getCond()) {
273  OS << " ";
274  PrintExpr(Node->getCond());
275  }
276  OS << ";";
277  if (Node->getInc()) {
278  OS << " ";
279  PrintExpr(Node->getInc());
280  }
281  OS << ") ";
282 
283  if (CompoundStmt *CS = dyn_cast<CompoundStmt>(Node->getBody())) {
284  PrintRawCompoundStmt(CS);
285  OS << "\n";
286  } else {
287  OS << "\n";
288  PrintStmt(Node->getBody());
289  }
290 }
291 
292 void StmtPrinter::VisitObjCForCollectionStmt(ObjCForCollectionStmt *Node) {
293  Indent() << "for (";
294  if (DeclStmt *DS = dyn_cast<DeclStmt>(Node->getElement()))
295  PrintRawDeclStmt(DS);
296  else
297  PrintExpr(cast<Expr>(Node->getElement()));
298  OS << " in ";
299  PrintExpr(Node->getCollection());
300  OS << ") ";
301 
302  if (CompoundStmt *CS = dyn_cast<CompoundStmt>(Node->getBody())) {
303  PrintRawCompoundStmt(CS);
304  OS << "\n";
305  } else {
306  OS << "\n";
307  PrintStmt(Node->getBody());
308  }
309 }
310 
311 void StmtPrinter::VisitCXXForRangeStmt(CXXForRangeStmt *Node) {
312  Indent() << "for (";
313  PrintingPolicy SubPolicy(Policy);
314  SubPolicy.SuppressInitializers = true;
315  Node->getLoopVariable()->print(OS, SubPolicy, IndentLevel);
316  OS << " : ";
317  PrintExpr(Node->getRangeInit());
318  OS << ") {\n";
319  PrintStmt(Node->getBody());
320  Indent() << "}";
321  if (Policy.IncludeNewlines) OS << "\n";
322 }
323 
324 void StmtPrinter::VisitMSDependentExistsStmt(MSDependentExistsStmt *Node) {
325  Indent();
326  if (Node->isIfExists())
327  OS << "__if_exists (";
328  else
329  OS << "__if_not_exists (";
330 
331  if (NestedNameSpecifier *Qualifier
333  Qualifier->print(OS, Policy);
334 
335  OS << Node->getNameInfo() << ") ";
336 
337  PrintRawCompoundStmt(Node->getSubStmt());
338 }
339 
340 void StmtPrinter::VisitGotoStmt(GotoStmt *Node) {
341  Indent() << "goto " << Node->getLabel()->getName() << ";";
342  if (Policy.IncludeNewlines) OS << "\n";
343 }
344 
345 void StmtPrinter::VisitIndirectGotoStmt(IndirectGotoStmt *Node) {
346  Indent() << "goto *";
347  PrintExpr(Node->getTarget());
348  OS << ";";
349  if (Policy.IncludeNewlines) OS << "\n";
350 }
351 
352 void StmtPrinter::VisitContinueStmt(ContinueStmt *Node) {
353  Indent() << "continue;";
354  if (Policy.IncludeNewlines) OS << "\n";
355 }
356 
357 void StmtPrinter::VisitBreakStmt(BreakStmt *Node) {
358  Indent() << "break;";
359  if (Policy.IncludeNewlines) OS << "\n";
360 }
361 
362 
363 void StmtPrinter::VisitReturnStmt(ReturnStmt *Node) {
364  Indent() << "return";
365  if (Node->getRetValue()) {
366  OS << " ";
367  PrintExpr(Node->getRetValue());
368  }
369  OS << ";";
370  if (Policy.IncludeNewlines) OS << "\n";
371 }
372 
373 
374 void StmtPrinter::VisitGCCAsmStmt(GCCAsmStmt *Node) {
375  Indent() << "asm ";
376 
377  if (Node->isVolatile())
378  OS << "volatile ";
379 
380  OS << "(";
381  VisitStringLiteral(Node->getAsmString());
382 
383  // Outputs
384  if (Node->getNumOutputs() != 0 || Node->getNumInputs() != 0 ||
385  Node->getNumClobbers() != 0)
386  OS << " : ";
387 
388  for (unsigned i = 0, e = Node->getNumOutputs(); i != e; ++i) {
389  if (i != 0)
390  OS << ", ";
391 
392  if (!Node->getOutputName(i).empty()) {
393  OS << '[';
394  OS << Node->getOutputName(i);
395  OS << "] ";
396  }
397 
398  VisitStringLiteral(Node->getOutputConstraintLiteral(i));
399  OS << " (";
400  Visit(Node->getOutputExpr(i));
401  OS << ")";
402  }
403 
404  // Inputs
405  if (Node->getNumInputs() != 0 || Node->getNumClobbers() != 0)
406  OS << " : ";
407 
408  for (unsigned i = 0, e = Node->getNumInputs(); i != e; ++i) {
409  if (i != 0)
410  OS << ", ";
411 
412  if (!Node->getInputName(i).empty()) {
413  OS << '[';
414  OS << Node->getInputName(i);
415  OS << "] ";
416  }
417 
418  VisitStringLiteral(Node->getInputConstraintLiteral(i));
419  OS << " (";
420  Visit(Node->getInputExpr(i));
421  OS << ")";
422  }
423 
424  // Clobbers
425  if (Node->getNumClobbers() != 0)
426  OS << " : ";
427 
428  for (unsigned i = 0, e = Node->getNumClobbers(); i != e; ++i) {
429  if (i != 0)
430  OS << ", ";
431 
432  VisitStringLiteral(Node->getClobberStringLiteral(i));
433  }
434 
435  OS << ");";
436  if (Policy.IncludeNewlines) OS << "\n";
437 }
438 
439 void StmtPrinter::VisitMSAsmStmt(MSAsmStmt *Node) {
440  // FIXME: Implement MS style inline asm statement printer.
441  Indent() << "__asm ";
442  if (Node->hasBraces())
443  OS << "{\n";
444  OS << Node->getAsmString() << "\n";
445  if (Node->hasBraces())
446  Indent() << "}\n";
447 }
448 
449 void StmtPrinter::VisitCapturedStmt(CapturedStmt *Node) {
450  PrintStmt(Node->getCapturedDecl()->getBody());
451 }
452 
453 void StmtPrinter::VisitObjCAtTryStmt(ObjCAtTryStmt *Node) {
454  Indent() << "@try";
455  if (CompoundStmt *TS = dyn_cast<CompoundStmt>(Node->getTryBody())) {
456  PrintRawCompoundStmt(TS);
457  OS << "\n";
458  }
459 
460  for (unsigned I = 0, N = Node->getNumCatchStmts(); I != N; ++I) {
462  Indent() << "@catch(";
463  if (catchStmt->getCatchParamDecl()) {
464  if (Decl *DS = catchStmt->getCatchParamDecl())
465  PrintRawDecl(DS);
466  }
467  OS << ")";
468  if (CompoundStmt *CS = dyn_cast<CompoundStmt>(catchStmt->getCatchBody())) {
469  PrintRawCompoundStmt(CS);
470  OS << "\n";
471  }
472  }
473 
474  if (ObjCAtFinallyStmt *FS = static_cast<ObjCAtFinallyStmt *>(
475  Node->getFinallyStmt())) {
476  Indent() << "@finally";
477  PrintRawCompoundStmt(dyn_cast<CompoundStmt>(FS->getFinallyBody()));
478  OS << "\n";
479  }
480 }
481 
482 void StmtPrinter::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *Node) {
483 }
484 
485 void StmtPrinter::VisitObjCAtCatchStmt (ObjCAtCatchStmt *Node) {
486  Indent() << "@catch (...) { /* todo */ } \n";
487 }
488 
489 void StmtPrinter::VisitObjCAtThrowStmt(ObjCAtThrowStmt *Node) {
490  Indent() << "@throw";
491  if (Node->getThrowExpr()) {
492  OS << " ";
493  PrintExpr(Node->getThrowExpr());
494  }
495  OS << ";\n";
496 }
497 
498 void StmtPrinter::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *Node) {
499  Indent() << "@synchronized (";
500  PrintExpr(Node->getSynchExpr());
501  OS << ")";
502  PrintRawCompoundStmt(Node->getSynchBody());
503  OS << "\n";
504 }
505 
506 void StmtPrinter::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *Node) {
507  Indent() << "@autoreleasepool";
508  PrintRawCompoundStmt(dyn_cast<CompoundStmt>(Node->getSubStmt()));
509  OS << "\n";
510 }
511 
512 void StmtPrinter::PrintRawCXXCatchStmt(CXXCatchStmt *Node) {
513  OS << "catch (";
514  if (Decl *ExDecl = Node->getExceptionDecl())
515  PrintRawDecl(ExDecl);
516  else
517  OS << "...";
518  OS << ") ";
519  PrintRawCompoundStmt(cast<CompoundStmt>(Node->getHandlerBlock()));
520 }
521 
522 void StmtPrinter::VisitCXXCatchStmt(CXXCatchStmt *Node) {
523  Indent();
524  PrintRawCXXCatchStmt(Node);
525  OS << "\n";
526 }
527 
528 void StmtPrinter::VisitCXXTryStmt(CXXTryStmt *Node) {
529  Indent() << "try ";
530  PrintRawCompoundStmt(Node->getTryBlock());
531  for (unsigned i = 0, e = Node->getNumHandlers(); i < e; ++i) {
532  OS << " ";
533  PrintRawCXXCatchStmt(Node->getHandler(i));
534  }
535  OS << "\n";
536 }
537 
538 void StmtPrinter::VisitSEHTryStmt(SEHTryStmt *Node) {
539  Indent() << (Node->getIsCXXTry() ? "try " : "__try ");
540  PrintRawCompoundStmt(Node->getTryBlock());
541  SEHExceptStmt *E = Node->getExceptHandler();
542  SEHFinallyStmt *F = Node->getFinallyHandler();
543  if(E)
544  PrintRawSEHExceptHandler(E);
545  else {
546  assert(F && "Must have a finally block...");
547  PrintRawSEHFinallyStmt(F);
548  }
549  OS << "\n";
550 }
551 
552 void StmtPrinter::PrintRawSEHFinallyStmt(SEHFinallyStmt *Node) {
553  OS << "__finally ";
554  PrintRawCompoundStmt(Node->getBlock());
555  OS << "\n";
556 }
557 
558 void StmtPrinter::PrintRawSEHExceptHandler(SEHExceptStmt *Node) {
559  OS << "__except (";
560  VisitExpr(Node->getFilterExpr());
561  OS << ")\n";
562  PrintRawCompoundStmt(Node->getBlock());
563  OS << "\n";
564 }
565 
566 void StmtPrinter::VisitSEHExceptStmt(SEHExceptStmt *Node) {
567  Indent();
568  PrintRawSEHExceptHandler(Node);
569  OS << "\n";
570 }
571 
572 void StmtPrinter::VisitSEHFinallyStmt(SEHFinallyStmt *Node) {
573  Indent();
574  PrintRawSEHFinallyStmt(Node);
575  OS << "\n";
576 }
577 
578 void StmtPrinter::VisitSEHLeaveStmt(SEHLeaveStmt *Node) {
579  Indent() << "__leave;";
580  if (Policy.IncludeNewlines) OS << "\n";
581 }
582 
583 //===----------------------------------------------------------------------===//
584 // OpenMP clauses printing methods
585 //===----------------------------------------------------------------------===//
586 
587 namespace {
588 class OMPClausePrinter : public OMPClauseVisitor<OMPClausePrinter> {
589  raw_ostream &OS;
590  const PrintingPolicy &Policy;
591  /// \brief Process clauses with list of variables.
592  template <typename T>
593  void VisitOMPClauseList(T *Node, char StartSym);
594 public:
595  OMPClausePrinter(raw_ostream &OS, const PrintingPolicy &Policy)
596  : OS(OS), Policy(Policy) { }
597 #define OPENMP_CLAUSE(Name, Class) \
598  void Visit##Class(Class *S);
599 #include "clang/Basic/OpenMPKinds.def"
600 };
601 
602 void OMPClausePrinter::VisitOMPIfClause(OMPIfClause *Node) {
603  OS << "if(";
604  Node->getCondition()->printPretty(OS, nullptr, Policy, 0);
605  OS << ")";
606 }
607 
608 void OMPClausePrinter::VisitOMPFinalClause(OMPFinalClause *Node) {
609  OS << "final(";
610  Node->getCondition()->printPretty(OS, nullptr, Policy, 0);
611  OS << ")";
612 }
613 
614 void OMPClausePrinter::VisitOMPNumThreadsClause(OMPNumThreadsClause *Node) {
615  OS << "num_threads(";
616  Node->getNumThreads()->printPretty(OS, nullptr, Policy, 0);
617  OS << ")";
618 }
619 
620 void OMPClausePrinter::VisitOMPSafelenClause(OMPSafelenClause *Node) {
621  OS << "safelen(";
622  Node->getSafelen()->printPretty(OS, nullptr, Policy, 0);
623  OS << ")";
624 }
625 
626 void OMPClausePrinter::VisitOMPCollapseClause(OMPCollapseClause *Node) {
627  OS << "collapse(";
628  Node->getNumForLoops()->printPretty(OS, nullptr, Policy, 0);
629  OS << ")";
630 }
631 
632 void OMPClausePrinter::VisitOMPDefaultClause(OMPDefaultClause *Node) {
633  OS << "default("
634  << getOpenMPSimpleClauseTypeName(OMPC_default, Node->getDefaultKind())
635  << ")";
636 }
637 
638 void OMPClausePrinter::VisitOMPProcBindClause(OMPProcBindClause *Node) {
639  OS << "proc_bind("
640  << getOpenMPSimpleClauseTypeName(OMPC_proc_bind, Node->getProcBindKind())
641  << ")";
642 }
643 
644 void OMPClausePrinter::VisitOMPScheduleClause(OMPScheduleClause *Node) {
645  OS << "schedule("
646  << getOpenMPSimpleClauseTypeName(OMPC_schedule, Node->getScheduleKind());
647  if (Node->getChunkSize()) {
648  OS << ", ";
649  Node->getChunkSize()->printPretty(OS, nullptr, Policy);
650  }
651  OS << ")";
652 }
653 
654 void OMPClausePrinter::VisitOMPOrderedClause(OMPOrderedClause *) {
655  OS << "ordered";
656 }
657 
658 void OMPClausePrinter::VisitOMPNowaitClause(OMPNowaitClause *) {
659  OS << "nowait";
660 }
661 
662 void OMPClausePrinter::VisitOMPUntiedClause(OMPUntiedClause *) {
663  OS << "untied";
664 }
665 
666 void OMPClausePrinter::VisitOMPMergeableClause(OMPMergeableClause *) {
667  OS << "mergeable";
668 }
669 
670 void OMPClausePrinter::VisitOMPReadClause(OMPReadClause *) { OS << "read"; }
671 
672 void OMPClausePrinter::VisitOMPWriteClause(OMPWriteClause *) { OS << "write"; }
673 
674 void OMPClausePrinter::VisitOMPUpdateClause(OMPUpdateClause *) {
675  OS << "update";
676 }
677 
678 void OMPClausePrinter::VisitOMPCaptureClause(OMPCaptureClause *) {
679  OS << "capture";
680 }
681 
682 void OMPClausePrinter::VisitOMPSeqCstClause(OMPSeqCstClause *) {
683  OS << "seq_cst";
684 }
685 
686 template<typename T>
687 void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) {
688  for (typename T::varlist_iterator I = Node->varlist_begin(),
689  E = Node->varlist_end();
690  I != E; ++I) {
691  assert(*I && "Expected non-null Stmt");
692  if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(*I)) {
693  OS << (I == Node->varlist_begin() ? StartSym : ',');
694  cast<NamedDecl>(DRE->getDecl())->printQualifiedName(OS);
695  } else {
696  OS << (I == Node->varlist_begin() ? StartSym : ',');
697  (*I)->printPretty(OS, nullptr, Policy, 0);
698  }
699  }
700 }
701 
702 void OMPClausePrinter::VisitOMPPrivateClause(OMPPrivateClause *Node) {
703  if (!Node->varlist_empty()) {
704  OS << "private";
705  VisitOMPClauseList(Node, '(');
706  OS << ")";
707  }
708 }
709 
710 void OMPClausePrinter::VisitOMPFirstprivateClause(OMPFirstprivateClause *Node) {
711  if (!Node->varlist_empty()) {
712  OS << "firstprivate";
713  VisitOMPClauseList(Node, '(');
714  OS << ")";
715  }
716 }
717 
718 void OMPClausePrinter::VisitOMPLastprivateClause(OMPLastprivateClause *Node) {
719  if (!Node->varlist_empty()) {
720  OS << "lastprivate";
721  VisitOMPClauseList(Node, '(');
722  OS << ")";
723  }
724 }
725 
726 void OMPClausePrinter::VisitOMPSharedClause(OMPSharedClause *Node) {
727  if (!Node->varlist_empty()) {
728  OS << "shared";
729  VisitOMPClauseList(Node, '(');
730  OS << ")";
731  }
732 }
733 
734 void OMPClausePrinter::VisitOMPReductionClause(OMPReductionClause *Node) {
735  if (!Node->varlist_empty()) {
736  OS << "reduction(";
737  NestedNameSpecifier *QualifierLoc =
741  if (QualifierLoc == nullptr && OOK != OO_None) {
742  // Print reduction identifier in C format
743  OS << getOperatorSpelling(OOK);
744  } else {
745  // Use C++ format
746  if (QualifierLoc != nullptr)
747  QualifierLoc->print(OS, Policy);
748  OS << Node->getNameInfo();
749  }
750  OS << ":";
751  VisitOMPClauseList(Node, ' ');
752  OS << ")";
753  }
754 }
755 
756 void OMPClausePrinter::VisitOMPLinearClause(OMPLinearClause *Node) {
757  if (!Node->varlist_empty()) {
758  OS << "linear";
759  VisitOMPClauseList(Node, '(');
760  if (Node->getStep() != nullptr) {
761  OS << ": ";
762  Node->getStep()->printPretty(OS, nullptr, Policy, 0);
763  }
764  OS << ")";
765  }
766 }
767 
768 void OMPClausePrinter::VisitOMPAlignedClause(OMPAlignedClause *Node) {
769  if (!Node->varlist_empty()) {
770  OS << "aligned";
771  VisitOMPClauseList(Node, '(');
772  if (Node->getAlignment() != nullptr) {
773  OS << ": ";
774  Node->getAlignment()->printPretty(OS, nullptr, Policy, 0);
775  }
776  OS << ")";
777  }
778 }
779 
780 void OMPClausePrinter::VisitOMPCopyinClause(OMPCopyinClause *Node) {
781  if (!Node->varlist_empty()) {
782  OS << "copyin";
783  VisitOMPClauseList(Node, '(');
784  OS << ")";
785  }
786 }
787 
788 void OMPClausePrinter::VisitOMPCopyprivateClause(OMPCopyprivateClause *Node) {
789  if (!Node->varlist_empty()) {
790  OS << "copyprivate";
791  VisitOMPClauseList(Node, '(');
792  OS << ")";
793  }
794 }
795 
796 void OMPClausePrinter::VisitOMPFlushClause(OMPFlushClause *Node) {
797  if (!Node->varlist_empty()) {
798  VisitOMPClauseList(Node, '(');
799  OS << ")";
800  }
801 }
802 
803 void OMPClausePrinter::VisitOMPDependClause(OMPDependClause *Node) {
804  if (!Node->varlist_empty()) {
805  OS << "depend(";
806  OS << getOpenMPSimpleClauseTypeName(Node->getClauseKind(),
807  Node->getDependencyKind())
808  << " :";
809  VisitOMPClauseList(Node, ' ');
810  OS << ")";
811  }
812 }
813 }
814 
815 //===----------------------------------------------------------------------===//
816 // OpenMP directives printing methods
817 //===----------------------------------------------------------------------===//
818 
819 void StmtPrinter::PrintOMPExecutableDirective(OMPExecutableDirective *S) {
820  OMPClausePrinter Printer(OS, Policy);
821  ArrayRef<OMPClause *> Clauses = S->clauses();
822  for (ArrayRef<OMPClause *>::iterator I = Clauses.begin(), E = Clauses.end();
823  I != E; ++I)
824  if (*I && !(*I)->isImplicit()) {
825  Printer.Visit(*I);
826  OS << ' ';
827  }
828  OS << "\n";
829  if (S->hasAssociatedStmt() && S->getAssociatedStmt()) {
830  assert(isa<CapturedStmt>(S->getAssociatedStmt()) &&
831  "Expected captured statement!");
832  Stmt *CS = cast<CapturedStmt>(S->getAssociatedStmt())->getCapturedStmt();
833  PrintStmt(CS);
834  }
835 }
836 
837 void StmtPrinter::VisitOMPParallelDirective(OMPParallelDirective *Node) {
838  Indent() << "#pragma omp parallel ";
839  PrintOMPExecutableDirective(Node);
840 }
841 
842 void StmtPrinter::VisitOMPSimdDirective(OMPSimdDirective *Node) {
843  Indent() << "#pragma omp simd ";
844  PrintOMPExecutableDirective(Node);
845 }
846 
847 void StmtPrinter::VisitOMPForDirective(OMPForDirective *Node) {
848  Indent() << "#pragma omp for ";
849  PrintOMPExecutableDirective(Node);
850 }
851 
852 void StmtPrinter::VisitOMPForSimdDirective(OMPForSimdDirective *Node) {
853  Indent() << "#pragma omp for simd ";
854  PrintOMPExecutableDirective(Node);
855 }
856 
857 void StmtPrinter::VisitOMPSectionsDirective(OMPSectionsDirective *Node) {
858  Indent() << "#pragma omp sections ";
859  PrintOMPExecutableDirective(Node);
860 }
861 
862 void StmtPrinter::VisitOMPSectionDirective(OMPSectionDirective *Node) {
863  Indent() << "#pragma omp section";
864  PrintOMPExecutableDirective(Node);
865 }
866 
867 void StmtPrinter::VisitOMPSingleDirective(OMPSingleDirective *Node) {
868  Indent() << "#pragma omp single ";
869  PrintOMPExecutableDirective(Node);
870 }
871 
872 void StmtPrinter::VisitOMPMasterDirective(OMPMasterDirective *Node) {
873  Indent() << "#pragma omp master";
874  PrintOMPExecutableDirective(Node);
875 }
876 
877 void StmtPrinter::VisitOMPCriticalDirective(OMPCriticalDirective *Node) {
878  Indent() << "#pragma omp critical";
879  if (Node->getDirectiveName().getName()) {
880  OS << " (";
881  Node->getDirectiveName().printName(OS);
882  OS << ")";
883  }
884  PrintOMPExecutableDirective(Node);
885 }
886 
887 void StmtPrinter::VisitOMPParallelForDirective(OMPParallelForDirective *Node) {
888  Indent() << "#pragma omp parallel for ";
889  PrintOMPExecutableDirective(Node);
890 }
891 
892 void StmtPrinter::VisitOMPParallelForSimdDirective(
894  Indent() << "#pragma omp parallel for simd ";
895  PrintOMPExecutableDirective(Node);
896 }
897 
898 void StmtPrinter::VisitOMPParallelSectionsDirective(
900  Indent() << "#pragma omp parallel sections ";
901  PrintOMPExecutableDirective(Node);
902 }
903 
904 void StmtPrinter::VisitOMPTaskDirective(OMPTaskDirective *Node) {
905  Indent() << "#pragma omp task ";
906  PrintOMPExecutableDirective(Node);
907 }
908 
909 void StmtPrinter::VisitOMPTaskyieldDirective(OMPTaskyieldDirective *Node) {
910  Indent() << "#pragma omp taskyield";
911  PrintOMPExecutableDirective(Node);
912 }
913 
914 void StmtPrinter::VisitOMPBarrierDirective(OMPBarrierDirective *Node) {
915  Indent() << "#pragma omp barrier";
916  PrintOMPExecutableDirective(Node);
917 }
918 
919 void StmtPrinter::VisitOMPTaskwaitDirective(OMPTaskwaitDirective *Node) {
920  Indent() << "#pragma omp taskwait";
921  PrintOMPExecutableDirective(Node);
922 }
923 
924 void StmtPrinter::VisitOMPTaskgroupDirective(OMPTaskgroupDirective *Node) {
925  Indent() << "#pragma omp taskgroup";
926  PrintOMPExecutableDirective(Node);
927 }
928 
929 void StmtPrinter::VisitOMPFlushDirective(OMPFlushDirective *Node) {
930  Indent() << "#pragma omp flush ";
931  PrintOMPExecutableDirective(Node);
932 }
933 
934 void StmtPrinter::VisitOMPOrderedDirective(OMPOrderedDirective *Node) {
935  Indent() << "#pragma omp ordered";
936  PrintOMPExecutableDirective(Node);
937 }
938 
939 void StmtPrinter::VisitOMPAtomicDirective(OMPAtomicDirective *Node) {
940  Indent() << "#pragma omp atomic ";
941  PrintOMPExecutableDirective(Node);
942 }
943 
944 void StmtPrinter::VisitOMPTargetDirective(OMPTargetDirective *Node) {
945  Indent() << "#pragma omp target ";
946  PrintOMPExecutableDirective(Node);
947 }
948 
949 void StmtPrinter::VisitOMPTeamsDirective(OMPTeamsDirective *Node) {
950  Indent() << "#pragma omp teams ";
951  PrintOMPExecutableDirective(Node);
952 }
953 
954 void StmtPrinter::VisitOMPCancellationPointDirective(
956  Indent() << "#pragma omp cancellation point "
958  PrintOMPExecutableDirective(Node);
959 }
960 
961 void StmtPrinter::VisitOMPCancelDirective(OMPCancelDirective *Node) {
962  Indent() << "#pragma omp cancel "
964  PrintOMPExecutableDirective(Node);
965 }
966 //===----------------------------------------------------------------------===//
967 // Expr printing methods.
968 //===----------------------------------------------------------------------===//
969 
970 void StmtPrinter::VisitDeclRefExpr(DeclRefExpr *Node) {
971  if (NestedNameSpecifier *Qualifier = Node->getQualifier())
972  Qualifier->print(OS, Policy);
973  if (Node->hasTemplateKeyword())
974  OS << "template ";
975  OS << Node->getNameInfo();
976  if (Node->hasExplicitTemplateArgs())
978  OS, Node->getTemplateArgs(), Node->getNumTemplateArgs(), Policy);
979 }
980 
981 void StmtPrinter::VisitDependentScopeDeclRefExpr(
983  if (NestedNameSpecifier *Qualifier = Node->getQualifier())
984  Qualifier->print(OS, Policy);
985  if (Node->hasTemplateKeyword())
986  OS << "template ";
987  OS << Node->getNameInfo();
988  if (Node->hasExplicitTemplateArgs())
990  OS, Node->getTemplateArgs(), Node->getNumTemplateArgs(), Policy);
991 }
992 
993 void StmtPrinter::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *Node) {
994  if (Node->getQualifier())
995  Node->getQualifier()->print(OS, Policy);
996  if (Node->hasTemplateKeyword())
997  OS << "template ";
998  OS << Node->getNameInfo();
999  if (Node->hasExplicitTemplateArgs())
1001  OS, Node->getTemplateArgs(), Node->getNumTemplateArgs(), Policy);
1002 }
1003 
1004 void StmtPrinter::VisitObjCIvarRefExpr(ObjCIvarRefExpr *Node) {
1005  if (Node->getBase()) {
1006  PrintExpr(Node->getBase());
1007  OS << (Node->isArrow() ? "->" : ".");
1008  }
1009  OS << *Node->getDecl();
1010 }
1011 
1012 void StmtPrinter::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *Node) {
1013  if (Node->isSuperReceiver())
1014  OS << "super.";
1015  else if (Node->isObjectReceiver() && Node->getBase()) {
1016  PrintExpr(Node->getBase());
1017  OS << ".";
1018  } else if (Node->isClassReceiver() && Node->getClassReceiver()) {
1019  OS << Node->getClassReceiver()->getName() << ".";
1020  }
1021 
1022  if (Node->isImplicitProperty())
1024  else
1025  OS << Node->getExplicitProperty()->getName();
1026 }
1027 
1028 void StmtPrinter::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *Node) {
1029 
1030  PrintExpr(Node->getBaseExpr());
1031  OS << "[";
1032  PrintExpr(Node->getKeyExpr());
1033  OS << "]";
1034 }
1035 
1036 void StmtPrinter::VisitPredefinedExpr(PredefinedExpr *Node) {
1038 }
1039 
1040 void StmtPrinter::VisitCharacterLiteral(CharacterLiteral *Node) {
1041  unsigned value = Node->getValue();
1042 
1043  switch (Node->getKind()) {
1044  case CharacterLiteral::Ascii: break; // no prefix.
1045  case CharacterLiteral::Wide: OS << 'L'; break;
1046  case CharacterLiteral::UTF16: OS << 'u'; break;
1047  case CharacterLiteral::UTF32: OS << 'U'; break;
1048  }
1049 
1050  switch (value) {
1051  case '\\':
1052  OS << "'\\\\'";
1053  break;
1054  case '\'':
1055  OS << "'\\''";
1056  break;
1057  case '\a':
1058  // TODO: K&R: the meaning of '\\a' is different in traditional C
1059  OS << "'\\a'";
1060  break;
1061  case '\b':
1062  OS << "'\\b'";
1063  break;
1064  // Nonstandard escape sequence.
1065  /*case '\e':
1066  OS << "'\\e'";
1067  break;*/
1068  case '\f':
1069  OS << "'\\f'";
1070  break;
1071  case '\n':
1072  OS << "'\\n'";
1073  break;
1074  case '\r':
1075  OS << "'\\r'";
1076  break;
1077  case '\t':
1078  OS << "'\\t'";
1079  break;
1080  case '\v':
1081  OS << "'\\v'";
1082  break;
1083  default:
1084  if (value < 256 && isPrintable((unsigned char)value))
1085  OS << "'" << (char)value << "'";
1086  else if (value < 256)
1087  OS << "'\\x" << llvm::format("%02x", value) << "'";
1088  else if (value <= 0xFFFF)
1089  OS << "'\\u" << llvm::format("%04x", value) << "'";
1090  else
1091  OS << "'\\U" << llvm::format("%08x", value) << "'";
1092  }
1093 }
1094 
1095 void StmtPrinter::VisitIntegerLiteral(IntegerLiteral *Node) {
1096  bool isSigned = Node->getType()->isSignedIntegerType();
1097  OS << Node->getValue().toString(10, isSigned);
1098 
1099  // Emit suffixes. Integer literals are always a builtin integer type.
1100  switch (Node->getType()->getAs<BuiltinType>()->getKind()) {
1101  default: llvm_unreachable("Unexpected type for integer literal!");
1102  case BuiltinType::Char_S:
1103  case BuiltinType::Char_U: OS << "i8"; break;
1104  case BuiltinType::UChar: OS << "Ui8"; break;
1105  case BuiltinType::Short: OS << "i16"; break;
1106  case BuiltinType::UShort: OS << "Ui16"; break;
1107  case BuiltinType::Int: break; // no suffix.
1108  case BuiltinType::UInt: OS << 'U'; break;
1109  case BuiltinType::Long: OS << 'L'; break;
1110  case BuiltinType::ULong: OS << "UL"; break;
1111  case BuiltinType::LongLong: OS << "LL"; break;
1112  case BuiltinType::ULongLong: OS << "ULL"; break;
1113  case BuiltinType::Int128: OS << "i128"; break;
1114  case BuiltinType::UInt128: OS << "Ui128"; break;
1115  }
1116 }
1117 
1118 static void PrintFloatingLiteral(raw_ostream &OS, FloatingLiteral *Node,
1119  bool PrintSuffix) {
1120  SmallString<16> Str;
1121  Node->getValue().toString(Str);
1122  OS << Str;
1123  if (Str.find_first_not_of("-0123456789") == StringRef::npos)
1124  OS << '.'; // Trailing dot in order to separate from ints.
1125 
1126  if (!PrintSuffix)
1127  return;
1128 
1129  // Emit suffixes. Float literals are always a builtin float type.
1130  switch (Node->getType()->getAs<BuiltinType>()->getKind()) {
1131  default: llvm_unreachable("Unexpected type for float literal!");
1132  case BuiltinType::Half: break; // FIXME: suffix?
1133  case BuiltinType::Double: break; // no suffix.
1134  case BuiltinType::Float: OS << 'F'; break;
1135  case BuiltinType::LongDouble: OS << 'L'; break;
1136  }
1137 }
1138 
1139 void StmtPrinter::VisitFloatingLiteral(FloatingLiteral *Node) {
1140  PrintFloatingLiteral(OS, Node, /*PrintSuffix=*/true);
1141 }
1142 
1143 void StmtPrinter::VisitImaginaryLiteral(ImaginaryLiteral *Node) {
1144  PrintExpr(Node->getSubExpr());
1145  OS << "i";
1146 }
1147 
1148 void StmtPrinter::VisitStringLiteral(StringLiteral *Str) {
1149  Str->outputString(OS);
1150 }
1151 void StmtPrinter::VisitParenExpr(ParenExpr *Node) {
1152  OS << "(";
1153  PrintExpr(Node->getSubExpr());
1154  OS << ")";
1155 }
1156 void StmtPrinter::VisitUnaryOperator(UnaryOperator *Node) {
1157  if (!Node->isPostfix()) {
1158  OS << UnaryOperator::getOpcodeStr(Node->getOpcode());
1159 
1160  // Print a space if this is an "identifier operator" like __real, or if
1161  // it might be concatenated incorrectly like '+'.
1162  switch (Node->getOpcode()) {
1163  default: break;
1164  case UO_Real:
1165  case UO_Imag:
1166  case UO_Extension:
1167  OS << ' ';
1168  break;
1169  case UO_Plus:
1170  case UO_Minus:
1171  if (isa<UnaryOperator>(Node->getSubExpr()))
1172  OS << ' ';
1173  break;
1174  }
1175  }
1176  PrintExpr(Node->getSubExpr());
1177 
1178  if (Node->isPostfix())
1179  OS << UnaryOperator::getOpcodeStr(Node->getOpcode());
1180 }
1181 
1182 void StmtPrinter::VisitOffsetOfExpr(OffsetOfExpr *Node) {
1183  OS << "__builtin_offsetof(";
1184  Node->getTypeSourceInfo()->getType().print(OS, Policy);
1185  OS << ", ";
1186  bool PrintedSomething = false;
1187  for (unsigned i = 0, n = Node->getNumComponents(); i < n; ++i) {
1190  // Array node
1191  OS << "[";
1192  PrintExpr(Node->getIndexExpr(ON.getArrayExprIndex()));
1193  OS << "]";
1194  PrintedSomething = true;
1195  continue;
1196  }
1197 
1198  // Skip implicit base indirections.
1200  continue;
1201 
1202  // Field or identifier node.
1203  IdentifierInfo *Id = ON.getFieldName();
1204  if (!Id)
1205  continue;
1206 
1207  if (PrintedSomething)
1208  OS << ".";
1209  else
1210  PrintedSomething = true;
1211  OS << Id->getName();
1212  }
1213  OS << ")";
1214 }
1215 
1216 void StmtPrinter::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *Node){
1217  switch(Node->getKind()) {
1218  case UETT_SizeOf:
1219  OS << "sizeof";
1220  break;
1221  case UETT_AlignOf:
1222  if (Policy.LangOpts.CPlusPlus)
1223  OS << "alignof";
1224  else if (Policy.LangOpts.C11)
1225  OS << "_Alignof";
1226  else
1227  OS << "__alignof";
1228  break;
1229  case UETT_VecStep:
1230  OS << "vec_step";
1231  break;
1233  OS << "__builtin_omp_required_simd_align";
1234  break;
1235  }
1236  if (Node->isArgumentType()) {
1237  OS << '(';
1238  Node->getArgumentType().print(OS, Policy);
1239  OS << ')';
1240  } else {
1241  OS << " ";
1242  PrintExpr(Node->getArgumentExpr());
1243  }
1244 }
1245 
1246 void StmtPrinter::VisitGenericSelectionExpr(GenericSelectionExpr *Node) {
1247  OS << "_Generic(";
1248  PrintExpr(Node->getControllingExpr());
1249  for (unsigned i = 0; i != Node->getNumAssocs(); ++i) {
1250  OS << ", ";
1251  QualType T = Node->getAssocType(i);
1252  if (T.isNull())
1253  OS << "default";
1254  else
1255  T.print(OS, Policy);
1256  OS << ": ";
1257  PrintExpr(Node->getAssocExpr(i));
1258  }
1259  OS << ")";
1260 }
1261 
1262 void StmtPrinter::VisitArraySubscriptExpr(ArraySubscriptExpr *Node) {
1263  PrintExpr(Node->getLHS());
1264  OS << "[";
1265  PrintExpr(Node->getRHS());
1266  OS << "]";
1267 }
1268 
1269 void StmtPrinter::PrintCallArgs(CallExpr *Call) {
1270  for (unsigned i = 0, e = Call->getNumArgs(); i != e; ++i) {
1271  if (isa<CXXDefaultArgExpr>(Call->getArg(i))) {
1272  // Don't print any defaulted arguments
1273  break;
1274  }
1275 
1276  if (i) OS << ", ";
1277  PrintExpr(Call->getArg(i));
1278  }
1279 }
1280 
1281 void StmtPrinter::VisitCallExpr(CallExpr *Call) {
1282  PrintExpr(Call->getCallee());
1283  OS << "(";
1284  PrintCallArgs(Call);
1285  OS << ")";
1286 }
1287 void StmtPrinter::VisitMemberExpr(MemberExpr *Node) {
1288  // FIXME: Suppress printing implicit bases (like "this")
1289  PrintExpr(Node->getBase());
1290 
1291  MemberExpr *ParentMember = dyn_cast<MemberExpr>(Node->getBase());
1292  FieldDecl *ParentDecl = ParentMember
1293  ? dyn_cast<FieldDecl>(ParentMember->getMemberDecl()) : nullptr;
1294 
1295  if (!ParentDecl || !ParentDecl->isAnonymousStructOrUnion())
1296  OS << (Node->isArrow() ? "->" : ".");
1297 
1298  if (FieldDecl *FD = dyn_cast<FieldDecl>(Node->getMemberDecl()))
1299  if (FD->isAnonymousStructOrUnion())
1300  return;
1301 
1302  if (NestedNameSpecifier *Qualifier = Node->getQualifier())
1303  Qualifier->print(OS, Policy);
1304  if (Node->hasTemplateKeyword())
1305  OS << "template ";
1306  OS << Node->getMemberNameInfo();
1307  if (Node->hasExplicitTemplateArgs())
1309  OS, Node->getTemplateArgs(), Node->getNumTemplateArgs(), Policy);
1310 }
1311 void StmtPrinter::VisitObjCIsaExpr(ObjCIsaExpr *Node) {
1312  PrintExpr(Node->getBase());
1313  OS << (Node->isArrow() ? "->isa" : ".isa");
1314 }
1315 
1316 void StmtPrinter::VisitExtVectorElementExpr(ExtVectorElementExpr *Node) {
1317  PrintExpr(Node->getBase());
1318  OS << ".";
1319  OS << Node->getAccessor().getName();
1320 }
1321 void StmtPrinter::VisitCStyleCastExpr(CStyleCastExpr *Node) {
1322  OS << '(';
1323  Node->getTypeAsWritten().print(OS, Policy);
1324  OS << ')';
1325  PrintExpr(Node->getSubExpr());
1326 }
1327 void StmtPrinter::VisitCompoundLiteralExpr(CompoundLiteralExpr *Node) {
1328  OS << '(';
1329  Node->getType().print(OS, Policy);
1330  OS << ')';
1331  PrintExpr(Node->getInitializer());
1332 }
1333 void StmtPrinter::VisitImplicitCastExpr(ImplicitCastExpr *Node) {
1334  // No need to print anything, simply forward to the subexpression.
1335  PrintExpr(Node->getSubExpr());
1336 }
1337 void StmtPrinter::VisitBinaryOperator(BinaryOperator *Node) {
1338  PrintExpr(Node->getLHS());
1339  OS << " " << BinaryOperator::getOpcodeStr(Node->getOpcode()) << " ";
1340  PrintExpr(Node->getRHS());
1341 }
1342 void StmtPrinter::VisitCompoundAssignOperator(CompoundAssignOperator *Node) {
1343  PrintExpr(Node->getLHS());
1344  OS << " " << BinaryOperator::getOpcodeStr(Node->getOpcode()) << " ";
1345  PrintExpr(Node->getRHS());
1346 }
1347 void StmtPrinter::VisitConditionalOperator(ConditionalOperator *Node) {
1348  PrintExpr(Node->getCond());
1349  OS << " ? ";
1350  PrintExpr(Node->getLHS());
1351  OS << " : ";
1352  PrintExpr(Node->getRHS());
1353 }
1354 
1355 // GNU extensions.
1356 
1357 void
1358 StmtPrinter::VisitBinaryConditionalOperator(BinaryConditionalOperator *Node) {
1359  PrintExpr(Node->getCommon());
1360  OS << " ?: ";
1361  PrintExpr(Node->getFalseExpr());
1362 }
1363 void StmtPrinter::VisitAddrLabelExpr(AddrLabelExpr *Node) {
1364  OS << "&&" << Node->getLabel()->getName();
1365 }
1366 
1367 void StmtPrinter::VisitStmtExpr(StmtExpr *E) {
1368  OS << "(";
1369  PrintRawCompoundStmt(E->getSubStmt());
1370  OS << ")";
1371 }
1372 
1373 void StmtPrinter::VisitChooseExpr(ChooseExpr *Node) {
1374  OS << "__builtin_choose_expr(";
1375  PrintExpr(Node->getCond());
1376  OS << ", ";
1377  PrintExpr(Node->getLHS());
1378  OS << ", ";
1379  PrintExpr(Node->getRHS());
1380  OS << ")";
1381 }
1382 
1383 void StmtPrinter::VisitGNUNullExpr(GNUNullExpr *) {
1384  OS << "__null";
1385 }
1386 
1387 void StmtPrinter::VisitShuffleVectorExpr(ShuffleVectorExpr *Node) {
1388  OS << "__builtin_shufflevector(";
1389  for (unsigned i = 0, e = Node->getNumSubExprs(); i != e; ++i) {
1390  if (i) OS << ", ";
1391  PrintExpr(Node->getExpr(i));
1392  }
1393  OS << ")";
1394 }
1395 
1396 void StmtPrinter::VisitConvertVectorExpr(ConvertVectorExpr *Node) {
1397  OS << "__builtin_convertvector(";
1398  PrintExpr(Node->getSrcExpr());
1399  OS << ", ";
1400  Node->getType().print(OS, Policy);
1401  OS << ")";
1402 }
1403 
1404 void StmtPrinter::VisitInitListExpr(InitListExpr* Node) {
1405  if (Node->getSyntacticForm()) {
1406  Visit(Node->getSyntacticForm());
1407  return;
1408  }
1409 
1410  OS << "{";
1411  for (unsigned i = 0, e = Node->getNumInits(); i != e; ++i) {
1412  if (i) OS << ", ";
1413  if (Node->getInit(i))
1414  PrintExpr(Node->getInit(i));
1415  else
1416  OS << "{}";
1417  }
1418  OS << "}";
1419 }
1420 
1421 void StmtPrinter::VisitParenListExpr(ParenListExpr* Node) {
1422  OS << "(";
1423  for (unsigned i = 0, e = Node->getNumExprs(); i != e; ++i) {
1424  if (i) OS << ", ";
1425  PrintExpr(Node->getExpr(i));
1426  }
1427  OS << ")";
1428 }
1429 
1430 void StmtPrinter::VisitDesignatedInitExpr(DesignatedInitExpr *Node) {
1431  bool NeedsEquals = true;
1433  DEnd = Node->designators_end();
1434  D != DEnd; ++D) {
1435  if (D->isFieldDesignator()) {
1436  if (D->getDotLoc().isInvalid()) {
1437  if (IdentifierInfo *II = D->getFieldName()) {
1438  OS << II->getName() << ":";
1439  NeedsEquals = false;
1440  }
1441  } else {
1442  OS << "." << D->getFieldName()->getName();
1443  }
1444  } else {
1445  OS << "[";
1446  if (D->isArrayDesignator()) {
1447  PrintExpr(Node->getArrayIndex(*D));
1448  } else {
1449  PrintExpr(Node->getArrayRangeStart(*D));
1450  OS << " ... ";
1451  PrintExpr(Node->getArrayRangeEnd(*D));
1452  }
1453  OS << "]";
1454  }
1455  }
1456 
1457  if (NeedsEquals)
1458  OS << " = ";
1459  else
1460  OS << " ";
1461  PrintExpr(Node->getInit());
1462 }
1463 
1464 void StmtPrinter::VisitDesignatedInitUpdateExpr(
1465  DesignatedInitUpdateExpr *Node) {
1466  OS << "{";
1467  OS << "/*base*/";
1468  PrintExpr(Node->getBase());
1469  OS << ", ";
1470 
1471  OS << "/*updater*/";
1472  PrintExpr(Node->getUpdater());
1473  OS << "}";
1474 }
1475 
1476 void StmtPrinter::VisitNoInitExpr(NoInitExpr *Node) {
1477  OS << "/*no init*/";
1478 }
1479 
1480 void StmtPrinter::VisitImplicitValueInitExpr(ImplicitValueInitExpr *Node) {
1481  if (Policy.LangOpts.CPlusPlus) {
1482  OS << "/*implicit*/";
1483  Node->getType().print(OS, Policy);
1484  OS << "()";
1485  } else {
1486  OS << "/*implicit*/(";
1487  Node->getType().print(OS, Policy);
1488  OS << ')';
1489  if (Node->getType()->isRecordType())
1490  OS << "{}";
1491  else
1492  OS << 0;
1493  }
1494 }
1495 
1496 void StmtPrinter::VisitVAArgExpr(VAArgExpr *Node) {
1497  OS << "__builtin_va_arg(";
1498  PrintExpr(Node->getSubExpr());
1499  OS << ", ";
1500  Node->getType().print(OS, Policy);
1501  OS << ")";
1502 }
1503 
1504 void StmtPrinter::VisitPseudoObjectExpr(PseudoObjectExpr *Node) {
1505  PrintExpr(Node->getSyntacticForm());
1506 }
1507 
1508 void StmtPrinter::VisitAtomicExpr(AtomicExpr *Node) {
1509  const char *Name = nullptr;
1510  switch (Node->getOp()) {
1511 #define BUILTIN(ID, TYPE, ATTRS)
1512 #define ATOMIC_BUILTIN(ID, TYPE, ATTRS) \
1513  case AtomicExpr::AO ## ID: \
1514  Name = #ID "("; \
1515  break;
1516 #include "clang/Basic/Builtins.def"
1517  }
1518  OS << Name;
1519 
1520  // AtomicExpr stores its subexpressions in a permuted order.
1521  PrintExpr(Node->getPtr());
1522  if (Node->getOp() != AtomicExpr::AO__c11_atomic_load &&
1523  Node->getOp() != AtomicExpr::AO__atomic_load_n) {
1524  OS << ", ";
1525  PrintExpr(Node->getVal1());
1526  }
1527  if (Node->getOp() == AtomicExpr::AO__atomic_exchange ||
1528  Node->isCmpXChg()) {
1529  OS << ", ";
1530  PrintExpr(Node->getVal2());
1531  }
1532  if (Node->getOp() == AtomicExpr::AO__atomic_compare_exchange ||
1533  Node->getOp() == AtomicExpr::AO__atomic_compare_exchange_n) {
1534  OS << ", ";
1535  PrintExpr(Node->getWeak());
1536  }
1537  if (Node->getOp() != AtomicExpr::AO__c11_atomic_init) {
1538  OS << ", ";
1539  PrintExpr(Node->getOrder());
1540  }
1541  if (Node->isCmpXChg()) {
1542  OS << ", ";
1543  PrintExpr(Node->getOrderFail());
1544  }
1545  OS << ")";
1546 }
1547 
1548 // C++
1549 void StmtPrinter::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *Node) {
1550  const char *OpStrings[NUM_OVERLOADED_OPERATORS] = {
1551  "",
1552 #define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \
1553  Spelling,
1554 #include "clang/Basic/OperatorKinds.def"
1555  };
1556 
1558  if (Kind == OO_PlusPlus || Kind == OO_MinusMinus) {
1559  if (Node->getNumArgs() == 1) {
1560  OS << OpStrings[Kind] << ' ';
1561  PrintExpr(Node->getArg(0));
1562  } else {
1563  PrintExpr(Node->getArg(0));
1564  OS << ' ' << OpStrings[Kind];
1565  }
1566  } else if (Kind == OO_Arrow) {
1567  PrintExpr(Node->getArg(0));
1568  } else if (Kind == OO_Call) {
1569  PrintExpr(Node->getArg(0));
1570  OS << '(';
1571  for (unsigned ArgIdx = 1; ArgIdx < Node->getNumArgs(); ++ArgIdx) {
1572  if (ArgIdx > 1)
1573  OS << ", ";
1574  if (!isa<CXXDefaultArgExpr>(Node->getArg(ArgIdx)))
1575  PrintExpr(Node->getArg(ArgIdx));
1576  }
1577  OS << ')';
1578  } else if (Kind == OO_Subscript) {
1579  PrintExpr(Node->getArg(0));
1580  OS << '[';
1581  PrintExpr(Node->getArg(1));
1582  OS << ']';
1583  } else if (Node->getNumArgs() == 1) {
1584  OS << OpStrings[Kind] << ' ';
1585  PrintExpr(Node->getArg(0));
1586  } else if (Node->getNumArgs() == 2) {
1587  PrintExpr(Node->getArg(0));
1588  OS << ' ' << OpStrings[Kind] << ' ';
1589  PrintExpr(Node->getArg(1));
1590  } else {
1591  llvm_unreachable("unknown overloaded operator");
1592  }
1593 }
1594 
1595 void StmtPrinter::VisitCXXMemberCallExpr(CXXMemberCallExpr *Node) {
1596  // If we have a conversion operator call only print the argument.
1597  CXXMethodDecl *MD = Node->getMethodDecl();
1598  if (MD && isa<CXXConversionDecl>(MD)) {
1599  PrintExpr(Node->getImplicitObjectArgument());
1600  return;
1601  }
1602  VisitCallExpr(cast<CallExpr>(Node));
1603 }
1604 
1605 void StmtPrinter::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *Node) {
1606  PrintExpr(Node->getCallee());
1607  OS << "<<<";
1608  PrintCallArgs(Node->getConfig());
1609  OS << ">>>(";
1610  PrintCallArgs(Node);
1611  OS << ")";
1612 }
1613 
1614 void StmtPrinter::VisitCXXNamedCastExpr(CXXNamedCastExpr *Node) {
1615  OS << Node->getCastName() << '<';
1616  Node->getTypeAsWritten().print(OS, Policy);
1617  OS << ">(";
1618  PrintExpr(Node->getSubExpr());
1619  OS << ")";
1620 }
1621 
1622 void StmtPrinter::VisitCXXStaticCastExpr(CXXStaticCastExpr *Node) {
1623  VisitCXXNamedCastExpr(Node);
1624 }
1625 
1626 void StmtPrinter::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *Node) {
1627  VisitCXXNamedCastExpr(Node);
1628 }
1629 
1630 void StmtPrinter::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *Node) {
1631  VisitCXXNamedCastExpr(Node);
1632 }
1633 
1634 void StmtPrinter::VisitCXXConstCastExpr(CXXConstCastExpr *Node) {
1635  VisitCXXNamedCastExpr(Node);
1636 }
1637 
1638 void StmtPrinter::VisitCXXTypeidExpr(CXXTypeidExpr *Node) {
1639  OS << "typeid(";
1640  if (Node->isTypeOperand()) {
1641  Node->getTypeOperandSourceInfo()->getType().print(OS, Policy);
1642  } else {
1643  PrintExpr(Node->getExprOperand());
1644  }
1645  OS << ")";
1646 }
1647 
1648 void StmtPrinter::VisitCXXUuidofExpr(CXXUuidofExpr *Node) {
1649  OS << "__uuidof(";
1650  if (Node->isTypeOperand()) {
1651  Node->getTypeOperandSourceInfo()->getType().print(OS, Policy);
1652  } else {
1653  PrintExpr(Node->getExprOperand());
1654  }
1655  OS << ")";
1656 }
1657 
1658 void StmtPrinter::VisitMSPropertyRefExpr(MSPropertyRefExpr *Node) {
1659  PrintExpr(Node->getBaseExpr());
1660  if (Node->isArrow())
1661  OS << "->";
1662  else
1663  OS << ".";
1664  if (NestedNameSpecifier *Qualifier =
1666  Qualifier->print(OS, Policy);
1667  OS << Node->getPropertyDecl()->getDeclName();
1668 }
1669 
1670 void StmtPrinter::VisitUserDefinedLiteral(UserDefinedLiteral *Node) {
1671  switch (Node->getLiteralOperatorKind()) {
1673  OS << cast<StringLiteral>(Node->getArg(0)->IgnoreImpCasts())->getString();
1674  break;
1676  DeclRefExpr *DRE = cast<DeclRefExpr>(Node->getCallee()->IgnoreImpCasts());
1677  const TemplateArgumentList *Args =
1678  cast<FunctionDecl>(DRE->getDecl())->getTemplateSpecializationArgs();
1679  assert(Args);
1680 
1681  if (Args->size() != 1) {
1682  OS << "operator \"\" " << Node->getUDSuffix()->getName();
1684  OS, Args->data(), Args->size(), Policy);
1685  OS << "()";
1686  return;
1687  }
1688 
1689  const TemplateArgument &Pack = Args->get(0);
1690  for (const auto &P : Pack.pack_elements()) {
1691  char C = (char)P.getAsIntegral().getZExtValue();
1692  OS << C;
1693  }
1694  break;
1695  }
1697  // Print integer literal without suffix.
1698  IntegerLiteral *Int = cast<IntegerLiteral>(Node->getCookedLiteral());
1699  OS << Int->getValue().toString(10, /*isSigned*/false);
1700  break;
1701  }
1703  // Print floating literal without suffix.
1704  FloatingLiteral *Float = cast<FloatingLiteral>(Node->getCookedLiteral());
1705  PrintFloatingLiteral(OS, Float, /*PrintSuffix=*/false);
1706  break;
1707  }
1710  PrintExpr(Node->getCookedLiteral());
1711  break;
1712  }
1713  OS << Node->getUDSuffix()->getName();
1714 }
1715 
1716 void StmtPrinter::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *Node) {
1717  OS << (Node->getValue() ? "true" : "false");
1718 }
1719 
1720 void StmtPrinter::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *Node) {
1721  OS << "nullptr";
1722 }
1723 
1724 void StmtPrinter::VisitCXXThisExpr(CXXThisExpr *Node) {
1725  OS << "this";
1726 }
1727 
1728 void StmtPrinter::VisitCXXThrowExpr(CXXThrowExpr *Node) {
1729  if (!Node->getSubExpr())
1730  OS << "throw";
1731  else {
1732  OS << "throw ";
1733  PrintExpr(Node->getSubExpr());
1734  }
1735 }
1736 
1737 void StmtPrinter::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *Node) {
1738  // Nothing to print: we picked up the default argument.
1739 }
1740 
1741 void StmtPrinter::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *Node) {
1742  // Nothing to print: we picked up the default initializer.
1743 }
1744 
1745 void StmtPrinter::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *Node) {
1746  Node->getType().print(OS, Policy);
1747  // If there are no parens, this is list-initialization, and the braces are
1748  // part of the syntax of the inner construct.
1749  if (Node->getLParenLoc().isValid())
1750  OS << "(";
1751  PrintExpr(Node->getSubExpr());
1752  if (Node->getLParenLoc().isValid())
1753  OS << ")";
1754 }
1755 
1756 void StmtPrinter::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *Node) {
1757  PrintExpr(Node->getSubExpr());
1758 }
1759 
1760 void StmtPrinter::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *Node) {
1761  Node->getType().print(OS, Policy);
1762  if (Node->isStdInitListInitialization())
1763  /* Nothing to do; braces are part of creating the std::initializer_list. */;
1764  else if (Node->isListInitialization())
1765  OS << "{";
1766  else
1767  OS << "(";
1769  ArgEnd = Node->arg_end();
1770  Arg != ArgEnd; ++Arg) {
1771  if (Arg->isDefaultArgument())
1772  break;
1773  if (Arg != Node->arg_begin())
1774  OS << ", ";
1775  PrintExpr(*Arg);
1776  }
1777  if (Node->isStdInitListInitialization())
1778  /* See above. */;
1779  else if (Node->isListInitialization())
1780  OS << "}";
1781  else
1782  OS << ")";
1783 }
1784 
1785 void StmtPrinter::VisitLambdaExpr(LambdaExpr *Node) {
1786  OS << '[';
1787  bool NeedComma = false;
1788  switch (Node->getCaptureDefault()) {
1789  case LCD_None:
1790  break;
1791 
1792  case LCD_ByCopy:
1793  OS << '=';
1794  NeedComma = true;
1795  break;
1796 
1797  case LCD_ByRef:
1798  OS << '&';
1799  NeedComma = true;
1800  break;
1801  }
1803  CEnd = Node->explicit_capture_end();
1804  C != CEnd;
1805  ++C) {
1806  if (NeedComma)
1807  OS << ", ";
1808  NeedComma = true;
1809 
1810  switch (C->getCaptureKind()) {
1811  case LCK_This:
1812  OS << "this";
1813  break;
1814 
1815  case LCK_ByRef:
1816  if (Node->getCaptureDefault() != LCD_ByRef || Node->isInitCapture(C))
1817  OS << '&';
1818  OS << C->getCapturedVar()->getName();
1819  break;
1820 
1821  case LCK_ByCopy:
1822  OS << C->getCapturedVar()->getName();
1823  break;
1824  case LCK_VLAType:
1825  llvm_unreachable("VLA type in explicit captures.");
1826  }
1827 
1828  if (Node->isInitCapture(C))
1829  PrintExpr(C->getCapturedVar()->getInit());
1830  }
1831  OS << ']';
1832 
1833  if (Node->hasExplicitParameters()) {
1834  OS << " (";
1835  CXXMethodDecl *Method = Node->getCallOperator();
1836  NeedComma = false;
1837  for (auto P : Method->params()) {
1838  if (NeedComma) {
1839  OS << ", ";
1840  } else {
1841  NeedComma = true;
1842  }
1843  std::string ParamStr = P->getNameAsString();
1844  P->getOriginalType().print(OS, Policy, ParamStr);
1845  }
1846  if (Method->isVariadic()) {
1847  if (NeedComma)
1848  OS << ", ";
1849  OS << "...";
1850  }
1851  OS << ')';
1852 
1853  if (Node->isMutable())
1854  OS << " mutable";
1855 
1856  const FunctionProtoType *Proto
1857  = Method->getType()->getAs<FunctionProtoType>();
1858  Proto->printExceptionSpecification(OS, Policy);
1859 
1860  // FIXME: Attributes
1861 
1862  // Print the trailing return type if it was specified in the source.
1863  if (Node->hasExplicitResultType()) {
1864  OS << " -> ";
1865  Proto->getReturnType().print(OS, Policy);
1866  }
1867  }
1868 
1869  // Print the body.
1870  CompoundStmt *Body = Node->getBody();
1871  OS << ' ';
1872  PrintStmt(Body);
1873 }
1874 
1875 void StmtPrinter::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *Node) {
1876  if (TypeSourceInfo *TSInfo = Node->getTypeSourceInfo())
1877  TSInfo->getType().print(OS, Policy);
1878  else
1879  Node->getType().print(OS, Policy);
1880  OS << "()";
1881 }
1882 
1883 void StmtPrinter::VisitCXXNewExpr(CXXNewExpr *E) {
1884  if (E->isGlobalNew())
1885  OS << "::";
1886  OS << "new ";
1887  unsigned NumPlace = E->getNumPlacementArgs();
1888  if (NumPlace > 0 && !isa<CXXDefaultArgExpr>(E->getPlacementArg(0))) {
1889  OS << "(";
1890  PrintExpr(E->getPlacementArg(0));
1891  for (unsigned i = 1; i < NumPlace; ++i) {
1892  if (isa<CXXDefaultArgExpr>(E->getPlacementArg(i)))
1893  break;
1894  OS << ", ";
1895  PrintExpr(E->getPlacementArg(i));
1896  }
1897  OS << ") ";
1898  }
1899  if (E->isParenTypeId())
1900  OS << "(";
1901  std::string TypeS;
1902  if (Expr *Size = E->getArraySize()) {
1903  llvm::raw_string_ostream s(TypeS);
1904  s << '[';
1905  Size->printPretty(s, Helper, Policy);
1906  s << ']';
1907  }
1908  E->getAllocatedType().print(OS, Policy, TypeS);
1909  if (E->isParenTypeId())
1910  OS << ")";
1911 
1913  if (InitStyle) {
1914  if (InitStyle == CXXNewExpr::CallInit)
1915  OS << "(";
1916  PrintExpr(E->getInitializer());
1917  if (InitStyle == CXXNewExpr::CallInit)
1918  OS << ")";
1919  }
1920 }
1921 
1922 void StmtPrinter::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
1923  if (E->isGlobalDelete())
1924  OS << "::";
1925  OS << "delete ";
1926  if (E->isArrayForm())
1927  OS << "[] ";
1928  PrintExpr(E->getArgument());
1929 }
1930 
1931 void StmtPrinter::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
1932  PrintExpr(E->getBase());
1933  if (E->isArrow())
1934  OS << "->";
1935  else
1936  OS << '.';
1937  if (E->getQualifier())
1938  E->getQualifier()->print(OS, Policy);
1939  OS << "~";
1940 
1942  OS << II->getName();
1943  else
1944  E->getDestroyedType().print(OS, Policy);
1945 }
1946 
1947 void StmtPrinter::VisitCXXConstructExpr(CXXConstructExpr *E) {
1949  OS << "{";
1950 
1951  for (unsigned i = 0, e = E->getNumArgs(); i != e; ++i) {
1952  if (isa<CXXDefaultArgExpr>(E->getArg(i))) {
1953  // Don't print any defaulted arguments
1954  break;
1955  }
1956 
1957  if (i) OS << ", ";
1958  PrintExpr(E->getArg(i));
1959  }
1960 
1962  OS << "}";
1963 }
1964 
1965 void StmtPrinter::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E) {
1966  PrintExpr(E->getSubExpr());
1967 }
1968 
1969 void StmtPrinter::VisitExprWithCleanups(ExprWithCleanups *E) {
1970  // Just forward to the subexpression.
1971  PrintExpr(E->getSubExpr());
1972 }
1973 
1974 void
1975 StmtPrinter::VisitCXXUnresolvedConstructExpr(
1977  Node->getTypeAsWritten().print(OS, Policy);
1978  OS << "(";
1980  ArgEnd = Node->arg_end();
1981  Arg != ArgEnd; ++Arg) {
1982  if (Arg != Node->arg_begin())
1983  OS << ", ";
1984  PrintExpr(*Arg);
1985  }
1986  OS << ")";
1987 }
1988 
1989 void StmtPrinter::VisitCXXDependentScopeMemberExpr(
1991  if (!Node->isImplicitAccess()) {
1992  PrintExpr(Node->getBase());
1993  OS << (Node->isArrow() ? "->" : ".");
1994  }
1995  if (NestedNameSpecifier *Qualifier = Node->getQualifier())
1996  Qualifier->print(OS, Policy);
1997  if (Node->hasTemplateKeyword())
1998  OS << "template ";
1999  OS << Node->getMemberNameInfo();
2000  if (Node->hasExplicitTemplateArgs())
2002  OS, Node->getTemplateArgs(), Node->getNumTemplateArgs(), Policy);
2003 }
2004 
2005 void StmtPrinter::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *Node) {
2006  if (!Node->isImplicitAccess()) {
2007  PrintExpr(Node->getBase());
2008  OS << (Node->isArrow() ? "->" : ".");
2009  }
2010  if (NestedNameSpecifier *Qualifier = Node->getQualifier())
2011  Qualifier->print(OS, Policy);
2012  if (Node->hasTemplateKeyword())
2013  OS << "template ";
2014  OS << Node->getMemberNameInfo();
2015  if (Node->hasExplicitTemplateArgs())
2017  OS, Node->getTemplateArgs(), Node->getNumTemplateArgs(), Policy);
2018 }
2019 
2020 static const char *getTypeTraitName(TypeTrait TT) {
2021  switch (TT) {
2022 #define TYPE_TRAIT_1(Spelling, Name, Key) \
2023 case clang::UTT_##Name: return #Spelling;
2024 #define TYPE_TRAIT_2(Spelling, Name, Key) \
2025 case clang::BTT_##Name: return #Spelling;
2026 #define TYPE_TRAIT_N(Spelling, Name, Key) \
2027  case clang::TT_##Name: return #Spelling;
2028 #include "clang/Basic/TokenKinds.def"
2029  }
2030  llvm_unreachable("Type trait not covered by switch");
2031 }
2032 
2033 static const char *getTypeTraitName(ArrayTypeTrait ATT) {
2034  switch (ATT) {
2035  case ATT_ArrayRank: return "__array_rank";
2036  case ATT_ArrayExtent: return "__array_extent";
2037  }
2038  llvm_unreachable("Array type trait not covered by switch");
2039 }
2040 
2041 static const char *getExpressionTraitName(ExpressionTrait ET) {
2042  switch (ET) {
2043  case ET_IsLValueExpr: return "__is_lvalue_expr";
2044  case ET_IsRValueExpr: return "__is_rvalue_expr";
2045  }
2046  llvm_unreachable("Expression type trait not covered by switch");
2047 }
2048 
2049 void StmtPrinter::VisitTypeTraitExpr(TypeTraitExpr *E) {
2050  OS << getTypeTraitName(E->getTrait()) << "(";
2051  for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) {
2052  if (I > 0)
2053  OS << ", ";
2054  E->getArg(I)->getType().print(OS, Policy);
2055  }
2056  OS << ")";
2057 }
2058 
2059 void StmtPrinter::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
2060  OS << getTypeTraitName(E->getTrait()) << '(';
2061  E->getQueriedType().print(OS, Policy);
2062  OS << ')';
2063 }
2064 
2065 void StmtPrinter::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
2066  OS << getExpressionTraitName(E->getTrait()) << '(';
2067  PrintExpr(E->getQueriedExpression());
2068  OS << ')';
2069 }
2070 
2071 void StmtPrinter::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
2072  OS << "noexcept(";
2073  PrintExpr(E->getOperand());
2074  OS << ")";
2075 }
2076 
2077 void StmtPrinter::VisitPackExpansionExpr(PackExpansionExpr *E) {
2078  PrintExpr(E->getPattern());
2079  OS << "...";
2080 }
2081 
2082 void StmtPrinter::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
2083  OS << "sizeof...(" << *E->getPack() << ")";
2084 }
2085 
2086 void StmtPrinter::VisitSubstNonTypeTemplateParmPackExpr(
2088  OS << *Node->getParameterPack();
2089 }
2090 
2091 void StmtPrinter::VisitSubstNonTypeTemplateParmExpr(
2093  Visit(Node->getReplacement());
2094 }
2095 
2096 void StmtPrinter::VisitFunctionParmPackExpr(FunctionParmPackExpr *E) {
2097  OS << *E->getParameterPack();
2098 }
2099 
2100 void StmtPrinter::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *Node){
2101  PrintExpr(Node->GetTemporaryExpr());
2102 }
2103 
2104 void StmtPrinter::VisitCXXFoldExpr(CXXFoldExpr *E) {
2105  OS << "(";
2106  if (E->getLHS()) {
2107  PrintExpr(E->getLHS());
2108  OS << " " << BinaryOperator::getOpcodeStr(E->getOperator()) << " ";
2109  }
2110  OS << "...";
2111  if (E->getRHS()) {
2112  OS << " " << BinaryOperator::getOpcodeStr(E->getOperator()) << " ";
2113  PrintExpr(E->getRHS());
2114  }
2115  OS << ")";
2116 }
2117 
2118 // Obj-C
2119 
2120 void StmtPrinter::VisitObjCStringLiteral(ObjCStringLiteral *Node) {
2121  OS << "@";
2122  VisitStringLiteral(Node->getString());
2123 }
2124 
2125 void StmtPrinter::VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
2126  OS << "@";
2127  Visit(E->getSubExpr());
2128 }
2129 
2130 void StmtPrinter::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
2131  OS << "@[ ";
2132  StmtRange ch = E->children();
2133  if (ch.first != ch.second) {
2134  while (1) {
2135  Visit(*ch.first);
2136  ++ch.first;
2137  if (ch.first == ch.second) break;
2138  OS << ", ";
2139  }
2140  }
2141  OS << " ]";
2142 }
2143 
2144 void StmtPrinter::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
2145  OS << "@{ ";
2146  for (unsigned I = 0, N = E->getNumElements(); I != N; ++I) {
2147  if (I > 0)
2148  OS << ", ";
2149 
2150  ObjCDictionaryElement Element = E->getKeyValueElement(I);
2151  Visit(Element.Key);
2152  OS << " : ";
2153  Visit(Element.Value);
2154  if (Element.isPackExpansion())
2155  OS << "...";
2156  }
2157  OS << " }";
2158 }
2159 
2160 void StmtPrinter::VisitObjCEncodeExpr(ObjCEncodeExpr *Node) {
2161  OS << "@encode(";
2162  Node->getEncodedType().print(OS, Policy);
2163  OS << ')';
2164 }
2165 
2166 void StmtPrinter::VisitObjCSelectorExpr(ObjCSelectorExpr *Node) {
2167  OS << "@selector(";
2168  Node->getSelector().print(OS);
2169  OS << ')';
2170 }
2171 
2172 void StmtPrinter::VisitObjCProtocolExpr(ObjCProtocolExpr *Node) {
2173  OS << "@protocol(" << *Node->getProtocol() << ')';
2174 }
2175 
2176 void StmtPrinter::VisitObjCMessageExpr(ObjCMessageExpr *Mess) {
2177  OS << "[";
2178  switch (Mess->getReceiverKind()) {
2180  PrintExpr(Mess->getInstanceReceiver());
2181  break;
2182 
2184  Mess->getClassReceiver().print(OS, Policy);
2185  break;
2186 
2189  OS << "Super";
2190  break;
2191  }
2192 
2193  OS << ' ';
2194  Selector selector = Mess->getSelector();
2195  if (selector.isUnarySelector()) {
2196  OS << selector.getNameForSlot(0);
2197  } else {
2198  for (unsigned i = 0, e = Mess->getNumArgs(); i != e; ++i) {
2199  if (i < selector.getNumArgs()) {
2200  if (i > 0) OS << ' ';
2201  if (selector.getIdentifierInfoForSlot(i))
2202  OS << selector.getIdentifierInfoForSlot(i)->getName() << ':';
2203  else
2204  OS << ":";
2205  }
2206  else OS << ", "; // Handle variadic methods.
2207 
2208  PrintExpr(Mess->getArg(i));
2209  }
2210  }
2211  OS << "]";
2212 }
2213 
2214 void StmtPrinter::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *Node) {
2215  OS << (Node->getValue() ? "__objc_yes" : "__objc_no");
2216 }
2217 
2218 void
2219 StmtPrinter::VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
2220  PrintExpr(E->getSubExpr());
2221 }
2222 
2223 void
2224 StmtPrinter::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
2225  OS << '(' << E->getBridgeKindName();
2226  E->getType().print(OS, Policy);
2227  OS << ')';
2228  PrintExpr(E->getSubExpr());
2229 }
2230 
2231 void StmtPrinter::VisitBlockExpr(BlockExpr *Node) {
2232  BlockDecl *BD = Node->getBlockDecl();
2233  OS << "^";
2234 
2235  const FunctionType *AFT = Node->getFunctionType();
2236 
2237  if (isa<FunctionNoProtoType>(AFT)) {
2238  OS << "()";
2239  } else if (!BD->param_empty() || cast<FunctionProtoType>(AFT)->isVariadic()) {
2240  OS << '(';
2241  for (BlockDecl::param_iterator AI = BD->param_begin(),
2242  E = BD->param_end(); AI != E; ++AI) {
2243  if (AI != BD->param_begin()) OS << ", ";
2244  std::string ParamStr = (*AI)->getNameAsString();
2245  (*AI)->getType().print(OS, Policy, ParamStr);
2246  }
2247 
2248  const FunctionProtoType *FT = cast<FunctionProtoType>(AFT);
2249  if (FT->isVariadic()) {
2250  if (!BD->param_empty()) OS << ", ";
2251  OS << "...";
2252  }
2253  OS << ')';
2254  }
2255  OS << "{ }";
2256 }
2257 
2258 void StmtPrinter::VisitOpaqueValueExpr(OpaqueValueExpr *Node) {
2259  PrintExpr(Node->getSourceExpr());
2260 }
2261 
2262 void StmtPrinter::VisitTypoExpr(TypoExpr *Node) {
2263  // TODO: Print something reasonable for a TypoExpr, if necessary.
2264  assert(false && "Cannot print TypoExpr nodes");
2265 }
2266 
2267 void StmtPrinter::VisitAsTypeExpr(AsTypeExpr *Node) {
2268  OS << "__builtin_astype(";
2269  PrintExpr(Node->getSrcExpr());
2270  OS << ", ";
2271  Node->getType().print(OS, Policy);
2272  OS << ")";
2273 }
2274 
2275 //===----------------------------------------------------------------------===//
2276 // Stmt method implementations
2277 //===----------------------------------------------------------------------===//
2278 
2279 void Stmt::dumpPretty(const ASTContext &Context) const {
2280  printPretty(llvm::errs(), nullptr, PrintingPolicy(Context.getLangOpts()));
2281 }
2282 
2283 void Stmt::printPretty(raw_ostream &OS,
2284  PrinterHelper *Helper,
2285  const PrintingPolicy &Policy,
2286  unsigned Indentation) const {
2287  StmtPrinter P(OS, Helper, Policy, Indentation);
2288  P.Visit(const_cast<Stmt*>(this));
2289 }
2290 
2291 //===----------------------------------------------------------------------===//
2292 // PrinterHelper
2293 //===----------------------------------------------------------------------===//
2294 
2295 // Implement virtual destructor.
Expr * getInc()
Definition: Stmt.h:1178
A call to an overloaded operator written using operator syntax.
Definition: ExprCXX.h:54
The receiver is the instance of the superclass object.
Definition: ExprObjC.h:1006
Represents a single C99 designator.
Definition: Expr.h:4035
Raw form: operator "" X (const char *)
Definition: ExprCXX.h:387
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
Definition: Expr.h:2411
Defines the clang::ASTContext interface.
unsigned getNumInits() const
Definition: Expr.h:3789
This represents '#pragma omp master' directive.
Definition: StmtOpenMP.h:989
operator "" X (long double)
Definition: ExprCXX.h:390
unsigned getNumTemplateArgs() const
Retrieve the number of template arguments provided as part of this template-id.
Definition: Expr.h:1137
const Expr * getBase() const
Definition: ExprObjC.h:504
The null pointer literal (C++11 [lex.nullptr])
Definition: ExprCXX.h:466
This represents '#pragma omp task' directive.
Definition: StmtOpenMP.h:1295
CapturedDecl * getCapturedDecl()
Retrieve the outlined function declaration.
Definition: Stmt.h:2104
bool isVariadic() const
Definition: Type.h:3228
unsigned getNumOutputs() const
Definition: Stmt.h:1447
The receiver is an object instance.
Definition: ExprObjC.h:1002
bool hasExplicitResultType() const
Whether this lambda had its result type explicitly specified.
Definition: ExprCXX.h:1564
StringRef getName() const
Definition: Decl.h:168
Expr * getSyntacticForm()
Definition: Expr.h:4756
Smart pointer class that efficiently represents Objective-C method names.
llvm::iterator_range< pack_iterator > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
Definition: TemplateBase.h:331
This represents clause 'copyin' in the '#pragma omp ...' directives.
bool hasTemplateKeyword() const
Determines whether the name in this declaration reference was preceded by the template keyword...
Definition: Expr.h:1092
const ObjCAtFinallyStmt * getFinallyStmt() const
Retrieve the @finally statement, if any.
Definition: StmtObjC.h:224
bool hasExplicitTemplateArgs() const
Determines whether this expression had explicit template arguments.
Definition: ExprCXX.h:2443
ArrayRef< OMPClause * > clauses()
Definition: StmtOpenMP.h:203
bool getValue() const
Definition: ExprCXX.h:446
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
Definition: Expr.h:2216
Expr * getCond()
Definition: Stmt.h:1066
Expr * getExpr(unsigned Index)
getExpr - Return the Expr at the specified index.
Definition: Expr.h:3479
DeclarationNameInfo getMemberNameInfo() const
Retrieve the member declaration name info.
Definition: Expr.h:2541
QualType getClassReceiver() const
Returns the type of a class message send, or NULL if the message is not a class message.
Definition: ExprObjC.h:1171
A type trait used in the implementation of various C++11 and Library TR1 trait templates.
Definition: ExprCXX.h:2083
CompoundStmt * getSubStmt()
Definition: Expr.h:3412
CharacterKind getKind() const
Definition: Expr.h:1342
CXXCatchStmt * getHandler(unsigned i)
Definition: StmtCXX.h:104
bool isArgumentType() const
Definition: Expr.h:2013
Expr * getInit() const
Retrieve the initializer value.
Definition: Expr.h:4225
bool isGlobalDelete() const
Definition: ExprCXX.h:1852
Expr * GetTemporaryExpr() const
Retrieve the temporary-generating subexpression whose value will be materialized into a glvalue...
Definition: ExprCXX.h:3787
This represents '#pragma omp for simd' directive.
Definition: StmtOpenMP.h:765
OpenMPProcBindClauseKind getProcBindKind() const
Returns kind of the clause.
Definition: OpenMPClause.h:546
TypeSourceInfo * getTypeSourceInfo() const
Definition: Expr.h:1918
NestedNameSpecifier * getQualifier() const
If the member name was qualified, retrieves the nested-name-specifier that precedes the member name...
Definition: Expr.h:2430
bool isRecordType() const
Definition: Type.h:5289
arg_iterator arg_begin()
Definition: ExprCXX.h:1189
param_iterator param_end()
Definition: Decl.h:3525
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
Definition: ExprCXX.h:2500
This represents 'if' clause in the '#pragma omp ...' directive.
Definition: OpenMPClause.h:154
Defines the C++ template declaration subclasses.
Represents an attribute applied to a statement.
Definition: Stmt.h:833
TypeSourceInfo * getArg(unsigned I) const
Retrieve the Ith argument.
Definition: ExprCXX.h:2135
Represents Objective-C's @throw statement.
Definition: StmtObjC.h:313
const char * getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind, unsigned Type)
InitListExpr * getSyntacticForm() const
Definition: Expr.h:3891
Represents a call to a C++ constructor.
Definition: ExprCXX.h:1075
bool hasExplicitTemplateArgs() const
Determines whether this lookup had explicit template arguments.
Definition: ExprCXX.h:2695
TypeSourceInfo * getTypeSourceInfo() const
Definition: ExprCXX.h:1604
An Embarcadero array type trait, as used in the implementation of __array_rank and __array_extent...
Definition: ExprCXX.h:2182
A container of type source information.
Definition: Decl.h:60
This represents 'update' clause in the '#pragma omp atomic' directive.
Definition: OpenMPClause.h:866
static void printGroup(Decl **Begin, unsigned NumDecls, raw_ostream &Out, const PrintingPolicy &Policy, unsigned Indentation=0)
const Stmt * getElse() const
Definition: Stmt.h:918
This represents '#pragma omp parallel for' directive.
Definition: StmtOpenMP.h:1102
Describes the capture of a variable or of this, or of a C++1y init-capture.
Definition: LambdaCapture.h:26
Represents a prvalue temporary that is written into memory so that a reference can bind to it...
Definition: ExprCXX.h:3746
unsigned getNumTemplateArgs() const
Definition: ExprCXX.h:2462
Expr * getVal1() const
Definition: Expr.h:4872
Expr * getAlignment()
Returns alignment.
bool hasExplicitTemplateArgs() const
Determines whether the member name was followed by an explicit template argument list.
Definition: Expr.h:2490
CompoundStmt * getBlock() const
Definition: Stmt.h:1895
IdentType getIdentType() const
Definition: Expr.h:1201
Expr * getIndexExpr(unsigned Idx)
Definition: Expr.h:1939
ObjCDictionaryElement getKeyValueElement(unsigned Index) const
Definition: ExprObjC.h:316
Stmt * getSubStmt()
Definition: Stmt.h:763
This represents 'read' clause in the '#pragma omp atomic' directive.
Definition: OpenMPClause.h:808
Expr * getOperand() const
Definition: ExprCXX.h:3359
This represents clause 'private' in the '#pragma omp ...' directives.
Definition: OpenMPClause.h:956
This represents 'num_threads' clause in the '#pragma omp ...' directive.
Definition: OpenMPClause.h:261
const Expr * getCallee() const
Definition: Expr.h:2188
const FunctionProtoType * getFunctionType() const
getFunctionType - Return the underlying function type for this block.
Definition: Expr.cpp:1987
void printPretty(raw_ostream &OS, const PrintingPolicy &Policy) const
bool hasExplicitParameters() const
Determine whether this lambda has an explicit parameter list vs. an implicit (empty) parameter list...
Definition: ExprCXX.h:1561
bool hasTemplateKeyword() const
Determines whether the member name was preceded by the template keyword.
Definition: ExprCXX.h:3114
Implicit construction of a std::initializer_list<T> object from an array temporary within list-initia...
Definition: ExprCXX.h:492
UnaryExprOrTypeTrait getKind() const
Definition: Expr.h:2008
bool varlist_empty() const
Definition: OpenMPClause.h:117
An implicit indirection through a C++ base class, when the field found is in a base class...
Definition: Expr.h:1800
This represents implicit clause 'flush' for the '#pragma omp flush' directive. This clause does not e...
Describes how types, statements, expressions, and declarations should be printed. ...
Definition: PrettyPrinter.h:35
unsigned getValue() const
Definition: Expr.h:1349
A C++ throw-expression (C++ [except.throw]).
Definition: ExprCXX.h:808
ParmVarDecl - Represents a parameter to a function.
Definition: Decl.h:1334
Defines the clang::Expr interface and subclasses for C++ expressions.
bool isArrow() const
Definition: ExprObjC.h:1397
Expr * getArrayIndex(const Designator &D) const
Definition: Expr.cpp:3991
ArrayTypeTrait getTrait() const
Definition: ExprCXX.h:2225
bool getIsCXXTry() const
Definition: Stmt.h:1934
This represents 'safelen' clause in the '#pragma omp ...' directive.
Definition: OpenMPClause.h:319
A C++ static_cast expression (C++ [expr.static.cast]).
Definition: ExprCXX.h:238
Expr * IgnoreImpCasts() LLVM_READONLY
Definition: Expr.h:2803
Represents a C99 designated initializer expression.
Definition: Expr.h:3961
Expr * getNumThreads() const
Returns number of threads.
Definition: OpenMPClause.h:297
DeclarationName getName() const
getName - Returns the embedded declaration name.
Stmt * getBody()
Definition: Stmt.h:1114
ObjCProtocolDecl * getProtocol() const
Definition: ExprObjC.h:450
CompoundStmt * getSubStmt() const
Retrieve the compound statement that will be included in the program only if the existence of the sym...
Definition: StmtCXX.h:274
An element in an Objective-C dictionary literal.
Definition: ExprObjC.h:207
This represents '#pragma omp parallel' directive.
Definition: StmtOpenMP.h:219
unsigned getNumInputs() const
Definition: Stmt.h:1469
IdentifierInfo * getIdentifierInfoForSlot(unsigned argIndex) const
Retrieve the identifier at a given position in the selector.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:89
ObjCInterfaceDecl * getClassReceiver() const
Definition: ExprObjC.h:691
LambdaCaptureDefault getCaptureDefault() const
Determine the default capture kind for this lambda.
Definition: ExprCXX.h:1446
unsigned getNumAssocs() const
Definition: Expr.h:4473
child_range children()
Definition: ExprObjC.h:197
This represents clause 'lastprivate' in the '#pragma omp ...' directives.
Expr * getBase()
Retrieve the base object of this member expressions, e.g., the x in x.m.
Definition: ExprCXX.h:3268
Represents a place-holder for an object not to be initialized by anything.
Definition: Expr.h:4279
StringLiteral * getString()
Definition: ExprObjC.h:40
Expr * getImplicitObjectArgument() const
Retrieves the implicit object argument for the member call.
Definition: ExprCXX.cpp:530
const TemplateArgumentLoc * getTemplateArgs() const
Retrieve the template arguments provided as part of this template-id.
Definition: Expr.h:2524
IdentifierInfo * getFieldName() const
For a field or identifier offsetof node, returns the name of the field.
Definition: Expr.cpp:1333
CXXMethodDecl * getCallOperator() const
Retrieve the function call operator associated with this lambda expression.
Definition: ExprCXX.cpp:1090
Expr * getOrder() const
Definition: Expr.h:4869
Expr * getPlacementArg(unsigned i)
Definition: ExprCXX.h:1726
DeclarationNameInfo getNameInfo() const
Retrieve the name of the entity we're testing for, along with location information.
Definition: StmtCXX.h:270
Represents a C++ member access expression for which lookup produced a set of overloaded functions...
Definition: ExprCXX.h:3209
const DeclarationNameInfo & getNameInfo() const
Gets the full name info.
Definition: ExprCXX.h:2401
IdentifierInfo & getAccessor() const
Definition: Expr.h:4565
QualType getQueriedType() const
Definition: ExprCXX.h:2227
Expr * getSubExpr()
Definition: Expr.h:2713
This represents '#pragma omp barrier' directive.
Definition: StmtOpenMP.h:1395
const DeclarationNameInfo & getNameInfo() const
Gets the name info for specified reduction identifier.
Represents a reference to a non-type template parameter pack that has been substituted with a non-tem...
Definition: ExprCXX.h:3613
This represents '#pragma omp critical' directive.
Definition: StmtOpenMP.h:1036
OpenMPDirectiveKind getCancelRegion() const
Get cancellation region for the current cancellation point.
Definition: StmtOpenMP.h:1986
Expr * getFilterExpr() const
Definition: Stmt.h:1855
Expr * getLHS() const
Definition: Expr.h:2964
const VarDecl * getCatchParamDecl() const
Definition: StmtObjC.h:94
Represents Objective-C's @catch statement.
Definition: StmtObjC.h:74
const CompoundStmt * getSynchBody() const
Definition: StmtObjC.h:282
This represents clause 'copyprivate' in the '#pragma omp ...' directives.
Describes an C or C++ initializer list.
Definition: Expr.h:3759
Expr * getRHS() const
Definition: ExprCXX.h:3873
Expr * getArraySize()
Definition: ExprCXX.h:1714
Expr * getVal2() const
Definition: Expr.h:4882
const LangOptions & getLangOpts() const
Definition: ASTContext.h:533
IdentifierInfo * getDestroyedTypeIdentifier() const
In a dependent pseudo-destructor expression for which we do not have full type information on the des...
Definition: ExprCXX.h:2041
Capturing by copy (a.k.a., by value)
Definition: Lambda.h:36
DeclarationNameInfo getNameInfo() const
Definition: Expr.h:998
QualType getReturnType() const
Definition: Type.h:2952
bool isSuperReceiver() const
Definition: ExprObjC.h:695
Stmt * getHandlerBlock() const
Definition: StmtCXX.h:52
Expr * getInitializer()
The initializer of this new-expression.
Definition: ExprCXX.h:1751
Expr * getExprOperand() const
Definition: ExprCXX.h:589
Stmt * getBody()
Definition: Stmt.h:1179
const DeclarationNameInfo & getMemberNameInfo() const
Retrieve the full name info for the member that this expression refers to.
Definition: ExprCXX.h:3295
OpenMPScheduleClauseKind getScheduleKind() const
Get kind of the clause.
Definition: OpenMPClause.h:646
const Expr * getSubExpr() const
Definition: Expr.h:3690
A builtin binary operation expression such as "x + y" or "x <= y".
Definition: Expr.h:2918
Selector getSelector() const
Definition: Expr.cpp:3718
InitializationStyle getInitializationStyle() const
The kind of initializer this new-expression has.
Definition: ExprCXX.h:1744
Stmt * getInit()
Definition: Stmt.h:1158
Expr * getOutputExpr(unsigned i)
Definition: Stmt.cpp:395
static bool isPostfix(Opcode Op)
isPostfix - Return true if this is a postfix operation, like x++.
Definition: Expr.h:1707
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies this declaration.
Definition: ExprCXX.h:2666
This represents '#pragma omp cancellation point' directive.
Definition: StmtOpenMP.h:1885
This represents 'default' clause in the '#pragma omp ...' directive.
Definition: OpenMPClause.h:426
bool isVariadic() const
Whether this function is variadic.
Definition: Decl.cpp:2362
QualType getTypeAsWritten() const
Definition: Expr.h:2849
const DeclStmt * getConditionVariableDeclStmt() const
Definition: Stmt.h:981
Expr * getBaseExpr() const
Definition: ExprCXX.h:666
New-expression has a C++98 paren-delimited initializer.
Definition: ExprCXX.h:1665
const Stmt * getCatchBody() const
Definition: StmtObjC.h:90
This represents 'final' clause in the '#pragma omp ...' directive.
Definition: OpenMPClause.h:207
This represents 'mergeable' clause in the '#pragma omp ...' directive.
Definition: OpenMPClause.h:779
Expr * getCond()
Definition: Stmt.h:1177
This represents '#pragma omp teams' directive.
Definition: StmtOpenMP.h:1828
Expr * getLHS() const
Definition: Expr.h:3233
StringRef getBridgeKindName() const
Retrieve the kind of bridge being performed as a string.
Definition: Expr.cpp:3761
This represents clause 'reduction' in the '#pragma omp ...' directives.
Represents binding an expression to a temporary.
Definition: ExprCXX.h:1032
const ObjCAtCatchStmt * getCatchStmt(unsigned I) const
Retrieve a @catch statement.
Definition: StmtObjC.h:206
StringLiteral * getClobberStringLiteral(unsigned i)
Definition: Stmt.h:1714
CompoundStmt * getBody() const
Retrieve the body of the lambda.
Definition: ExprCXX.cpp:1101
ArrayTypeTrait
Names for the array type traits.
Definition: TypeTraits.h:86
Expr * Key
The key for the dictionary element.
Definition: ExprObjC.h:209
void print(llvm::raw_ostream &OS) const
Prints the full selector name (e.g. "foo:bar:").
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
Definition: ExprCXX.h:1343
Represents a C++ member access expression where the actual member referenced could not be resolved be...
Definition: ExprCXX.h:2954
const Expr * getBase() const
Definition: ExprObjC.h:677
bool isArrow() const
Determine whether this pseudo-destructor expression was written using an '->' (otherwise, it used a '.').
Definition: ExprCXX.h:2004
A default argument (C++ [dcl.fct.default]).
Definition: ExprCXX.h:862
QualType getType() const
Definition: Decl.h:538
ExpressionTrait getTrait() const
Definition: ExprCXX.h:2286
NestedNameSpecifier * getQualifier() const
If the name was qualified, retrieves the nested-name-specifier that precedes the name. Otherwise, returns NULL.
Definition: Expr.h:1013
Represents the this expression in C++.
Definition: ExprCXX.h:770
MSPropertyDecl * getPropertyDecl() const
Definition: ExprCXX.h:667
ObjCIvarDecl * getDecl()
Definition: ExprObjC.h:500
OpenMPDefaultClauseKind getDefaultKind() const
Returns kind of the clause.
Definition: OpenMPClause.h:475
TypeTrait
Names for traits that operate specifically on types.
Definition: TypeTraits.h:21
Expr * getRHS() const
Definition: Expr.h:3234
AnnotatingParser & P
QualType getTypeAsWritten() const
Retrieve the type that is being constructed, as specified in the source code.
Definition: ExprCXX.h:2883
OpenMPDependClauseKind getDependencyKind() const
Get dependency type.
OpenMPDirectiveKind getCancelRegion() const
Get cancellation region for the current cancellation point.
Definition: StmtOpenMP.h:1929
Expr * getLHS() const
Definition: Expr.h:3611
llvm::APInt getValue() const
Definition: Expr.h:1262
Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
Definition: ExprCXX.h:1940
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the member name.
Definition: ExprCXX.h:3054
const TemplateArgumentLoc * getTemplateArgs() const
Retrieve the template arguments provided as part of this template-id.
Definition: Expr.h:1128
StringRef getAsmString() const
Definition: Stmt.h:1764
CXXMethodDecl * getMethodDecl() const
Retrieves the declaration of the called method.
Definition: ExprCXX.cpp:542
This represents '#pragma omp taskgroup' directive.
Definition: StmtOpenMP.h:1483
unsigned getNumArgs() const
Determine the number of arguments to this type trait.
Definition: ExprCXX.h:2132
const Expr * getControllingExpr() const
Definition: Expr.h:4496
This represents clause 'aligned' in the '#pragma omp ...' directives.
bool isCmpXChg() const
Definition: Expr.h:4902
Expr * getQueriedExpression() const
Definition: ExprCXX.h:2288
NestedNameSpecifierLoc getQualifierLoc() const
Definition: ExprCXX.h:670
ASTContext * Context
arg_iterator arg_end()
Definition: ExprCXX.h:1190
VAArgExpr, used for the builtin function __builtin_va_arg.
Definition: Expr.h:3670
Expr * getCond() const
Definition: Expr.h:3222
bool isPackExpansion() const
Determines whether this dictionary element is a pack expansion.
Definition: ExprObjC.h:222
bool isUnarySelector() const
This represents implicit clause 'depend' for the '#pragma omp task' directive.
designators_iterator designators_begin()
Definition: Expr.h:4165
unsigned getNumExprs() const
Definition: Expr.h:4386
unsigned getArrayExprIndex() const
For an array element node, returns the index into the array of expressions.
Definition: Expr.h:1849
This represents 'proc_bind' clause in the '#pragma omp ...' directive.
Definition: OpenMPClause.h:496
bool isMutable() const
Determine whether the lambda is mutable, meaning that any captures values can be modified.
Definition: ExprCXX.cpp:1108
This represents 'capture' clause in the '#pragma omp atomic' directive.
Definition: OpenMPClause.h:896
StringRef getName() const
Return the actual identifier string.
const Expr * getExpr(unsigned Init) const
Definition: Expr.h:4388
void outputString(raw_ostream &OS) const
Definition: Expr.cpp:869
unsigned getNumTemplateArgs() const
Retrieve the number of template arguments provided as part of this template-id.
Definition: ExprCXX.h:3162
bool hasBraces() const
Definition: Stmt.h:1758
unsigned getNumArgs() const
static void PrintFloatingLiteral(raw_ostream &OS, FloatingLiteral *Node, bool PrintSuffix)
bool isListInitialization() const
Whether this constructor call was written as list-initialization.
Definition: ExprCXX.h:1153
Expr * getCondition() const
Returns condition.
Definition: OpenMPClause.h:243
Represents a C++ functional cast expression that builds a temporary object.
Definition: ExprCXX.h:1295
A C++ const_cast expression (C++ [expr.const.cast]).
Definition: ExprCXX.h:340
const DeclarationNameInfo & getNameInfo() const
Retrieve the name that this expression refers to.
Definition: ExprCXX.h:2650
bool hasExplicitTemplateArgs() const
Determines whether this member expression actually had a C++ template argument list explicitly specif...
Definition: ExprCXX.h:3118
bool hasTemplateKeyword() const
Determines whether the name was preceded by the template keyword.
Definition: ExprCXX.h:2440
Stmt * getBody() const override
Definition: Decl.h:3640
ObjCMethodDecl * getImplicitPropertyGetter() const
Definition: ExprObjC.h:633
Stmt * getBody()
Definition: Stmt.h:1069
Expr * getArrayRangeStart(const Designator &D) const
Definition: Expr.cpp:3997
Expr * getRHS()
Definition: Stmt.h:718
Represents Objective-C's @synchronized statement.
Definition: StmtObjC.h:262
ObjCSelectorExpr used for @selector in Objective-C.
Definition: ExprObjC.h:396
bool isImplicitAccess() const
True if this is an implicit access, i.e., one in which the member being accessed was not written in t...
Definition: ExprCXX.cpp:1357
Represents an expression that computes the length of a parameter pack.
Definition: ExprCXX.h:3473
This represents 'ordered' clause in the '#pragma omp ...' directive.
Definition: OpenMPClause.h:691
Selector getSelector() const
Definition: ExprObjC.h:408
NonTypeTemplateParmDecl * getParameterPack() const
Retrieve the non-type template parameter pack being substituted.
Definition: ExprCXX.h:3639
QualType getAllocatedType() const
Definition: ExprCXX.h:1682
StringRef getInputName(unsigned i) const
Definition: Stmt.h:1672
void print(raw_ostream &OS, const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine()) const
Definition: Type.h:907
Expr * getSubExpr() const
Definition: Expr.h:1699
This represents '#pragma omp for' directive.
Definition: StmtOpenMP.h:701
Expr * getLHS() const
Definition: ExprCXX.h:3872
Represents a folding of a pack over an operator.
Definition: ExprCXX.h:3849
Expr * getSrcExpr() const
getSrcExpr - Return the Expr to be converted.
Definition: Expr.h:3528
An expression that sends a message to the given Objective-C object or class.
Definition: ExprObjC.h:858
unsigned getNumComponents() const
Definition: Expr.h:1935
const DeclStmt * getConditionVariableDeclStmt() const
Definition: Stmt.h:910
Expr * getCond() const
Definition: Expr.h:3609
A member reference to an MSPropertyDecl.
Definition: ExprCXX.h:621
DeclarationName getDeclName() const
Definition: Decl.h:189
Represents a reference to a non-type template parameter that has been substituted with a template arg...
Definition: ExprCXX.h:3558
This represents '#pragma omp cancel' directive.
Definition: StmtOpenMP.h:1943
This represents 'collapse' clause in the '#pragma omp ...' directive.
Definition: OpenMPClause.h:374
This represents clause 'firstprivate' in the '#pragma omp ...' directives.
ValueDecl * getDecl()
Definition: Expr.h:994
NestedNameSpecifier * getQualifier() const
If the member name was qualified, retrieves the nested-name-specifier that precedes the member name...
Definition: ExprCXX.h:1998
NestedNameSpecifierLoc getQualifierLoc() const
Gets the nested name specifier.
AtomicOp getOp() const
Definition: Expr.h:4893
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
Definition: ExprObjC.h:1286
This represents '#pragma omp flush' directive.
Definition: StmtOpenMP.h:1534
bool param_empty() const
Definition: Decl.h:3522
This represents '#pragma omp parallel for simd' directive.
Definition: StmtOpenMP.h:1169
InitListExpr * getUpdater() const
Definition: Expr.h:4332
This represents 'seq_cst' clause in the '#pragma omp atomic' directive.
Definition: OpenMPClause.h:926
This represents 'untied' clause in the '#pragma omp ...' directive.
Definition: OpenMPClause.h:749
unsigned getNumSubExprs() const
Definition: Expr.h:3473
param_iterator param_begin()
Definition: Decl.h:3524
LabelDecl * getLabel() const
Definition: Stmt.h:1226
unsigned getNumTemplateArgs() const
Definition: ExprCXX.h:2731
Expr * getBase() const
Definition: ExprObjC.h:1395
Expr * getArgument()
Definition: ExprCXX.h:1866
const TemplateArgumentLoc * getTemplateArgs() const
Retrieve the template arguments provided as part of this template-id.
Definition: ExprCXX.h:3156
bool isArrayForm() const
Definition: ExprCXX.h:1853
A C++ dynamic_cast expression (C++ [expr.dynamic.cast]).
Definition: ExprCXX.h:269
const StringLiteral * getAsmString() const
Definition: Stmt.h:1577
Kind
This captures a statement into a function. For example, the following pragma annotated compound state...
Definition: Stmt.h:1989
operator "" X (const CharT *, size_t)
Definition: ExprCXX.h:391
Expr * getArrayRangeEnd(const Designator &D) const
Definition: Expr.cpp:4004
bool getValue() const
Definition: ExprObjC.h:71
Raw form: operator "" X<cs...> ()
Definition: ExprCXX.h:388
Expr * getNumForLoops() const
Return the number of associated for-loops.
Definition: OpenMPClause.h:409
This represents '#pragma omp single' directive.
Definition: StmtOpenMP.h:934
body_range body()
Definition: Stmt.h:585
TemplateArgumentLoc const * getTemplateArgs() const
Definition: ExprCXX.h:2458
Expr * getSourceExpr() const
Definition: Expr.h:869
Expr * getPtr() const
Definition: Expr.h:4866
This is a basic class for representing single OpenMP executable directive.
Definition: StmtOpenMP.h:33
bool isValid() const
Return true if this is a valid SourceLocation object.
OverloadedOperatorKind getCXXOverloadedOperator() const
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies this name, if any.
Definition: StmtCXX.h:266
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)"...
Definition: ExprCXX.h:1623
Expr * getLHS()
Definition: Stmt.h:717
static const char * getExpressionTraitName(ExpressionTrait ET)
A call to a literal operator (C++11 [over.literal]) written as a user-defined literal (C++11 [lit...
Definition: ExprCXX.h:372
Expr * getCondition() const
Returns condition.
Definition: OpenMPClause.h:190
This represents 'schedule' clause in the '#pragma omp ...' directive.
Definition: OpenMPClause.h:566
StringRef getNameForSlot(unsigned argIndex) const
Retrieve the name at a given position in the selector.
unsigned getNumTemplateArgs() const
Retrieve the number of template arguments provided as part of this template-id.
Definition: Expr.h:2533
CompoundStmt * getBlock() const
Definition: Stmt.h:1859
This represents clause 'shared' in the '#pragma omp ...' directives.
const Expr * getCond() const
Definition: Stmt.h:985
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:1717
Expr * getSrcExpr() const
getSrcExpr - Return the Expr to be converted.
Definition: Expr.h:4665
void VisitStmt(Stmt *S)
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
This represents '#pragma omp taskwait' directive.
Definition: StmtOpenMP.h:1439
const DeclarationNameInfo & getMemberNameInfo() const
Retrieve the name of the member that this expression refers to.
Definition: ExprCXX.h:3080
bool isImplicitAccess() const
True if this is an implicit access, i.e. one in which the member being accessed was not written in th...
Definition: ExprCXX.cpp:1303
NamedDecl * getPack() const
Retrieve the parameter pack.
Definition: ExprCXX.h:3533
bool isInitCapture(const LambdaCapture *Capture) const
Determine whether one of this lambda's captures is an init-capture.
Definition: ExprCXX.cpp:1030
LiteralOperatorKind getLiteralOperatorKind() const
Returns the kind of literal operator invocation which this expression represents. ...
Definition: ExprCXX.cpp:731
capture_iterator explicit_capture_end() const
Retrieve an iterator pointing past the end of the sequence of explicit lambda captures.
Definition: ExprCXX.cpp:1051
QualType getAssocType(unsigned i) const
Definition: Expr.h:4489
ParmVarDecl * getParameterPack() const
Get the parameter pack which this expression refers to.
Definition: ExprCXX.h:3699
SEHExceptStmt * getExceptHandler() const
Returns 0 if not defined.
Definition: Stmt.cpp:1038
This represents '#pragma omp target' directive.
Definition: StmtOpenMP.h:1771
Expr * getInputExpr(unsigned i)
Definition: Stmt.cpp:406
static const char * getTypeTraitName(TypeTrait TT)
TypeTrait getTrait() const
Determine which type trait this expression uses.
Definition: ExprCXX.h:2122
Expr * getRangeInit()
Definition: Stmt.cpp:863
StringRef getOutputName(unsigned i) const
Definition: Stmt.h:1644
bool isArrow() const
Determine whether this member expression used the '->' operator; otherwise, it used the '...
Definition: ExprCXX.h:3285
Expr * getSubExpr()
Definition: ExprObjC.h:106
An expression trait intrinsic.
Definition: ExprCXX.h:2252
TypeSourceInfo * getTypeOperandSourceInfo() const
Retrieve source information for the type operand.
Definition: ExprCXX.h:579
This represents '#pragma omp ordered' directive.
Definition: StmtOpenMP.h:1589
const Expr * getBase() const
Definition: Expr.h:4561
const BlockDecl * getBlockDecl() const
Definition: Expr.h:4616
bool isObjectReceiver() const
Definition: ExprObjC.h:694
bool isParenTypeId() const
Definition: ExprCXX.h:1735
QualType getType() const
Return the type wrapped by this type source info.
Definition: Decl.h:68
Opcode getOpcode() const
Definition: Expr.h:1696
Representation of a Microsoft __if_exists or __if_not_exists statement with a dependent name...
Definition: StmtCXX.h:234
const OffsetOfNode & getComponent(unsigned Idx) const
Definition: Expr.h:1925
A qualified reference to a name whose declaration cannot yet be resolved.
Definition: ExprCXX.h:2609
Expr * Value
The value of the dictionary element.
Definition: ExprObjC.h:212
Represents a C11 generic selection.
Definition: Expr.h:4446
const char * getCastName() const
Definition: ExprCXX.cpp:571
Expr * getInstanceReceiver()
Returns the object expression (receiver) for an instance message, or null for a message that is not a...
Definition: ExprObjC.h:1152
param_range params()
Definition: Decl.h:1951
bool isArrow() const
Definition: Expr.h:2548
AddrLabelExpr - The GNU address of label extension, representing &&label.
Definition: Expr.h:3357
An Objective-C "bridged" cast expression, which casts between Objective-C pointers and C pointers...
Definition: ExprObjC.h:1506
ast_type_traits::DynTypedNode Node
QualType getType() const
Definition: Expr.h:125
Represents a reference to a function parameter pack that has been substituted but not yet expanded...
Definition: ExprCXX.h:3673
Represents a template argument.
Definition: TemplateBase.h:39
Expr * getCommon() const
getCommon - Return the common expression, written to the left of the condition. The opaque value will...
Definition: Expr.h:3298
void print(raw_ostream &OS, const PrintingPolicy &Policy) const
Print this nested name specifier to the given output stream.
const Expr * getSubExpr() const
Definition: ExprCXX.h:828
bool isImplicitProperty() const
Definition: ExprObjC.h:625
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXCatchStmt > catchStmt
Matches catch statements.
Definition: ASTMatchers.h:1331
const Expr * getAssocExpr(unsigned i) const
Definition: Expr.h:4479
StringRef getOpcodeStr() const
Definition: Expr.h:2980
[C99 6.4.2.2] - A predefined identifier such as func.
Definition: Expr.h:1174
Represents a delete expression for memory deallocation and destructor calls, e.g. "delete[] pArray"...
Definition: ExprCXX.h:1819
TypeSourceInfo * getTypeOperandSourceInfo() const
Retrieve source information for the type operand.
Definition: ExprCXX.h:714
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
Definition: OperatorKinds.h:22
TemplateArgumentLoc const * getTemplateArgs() const
Definition: ExprCXX.h:2727
static LLVM_READONLY bool isPrintable(unsigned char c)
Definition: CharInfo.h:140
const Stmt * getBody() const
Definition: Stmt.h:986
This represents '#pragma omp section' directive.
Definition: StmtOpenMP.h:885
SourceLocation getLParenLoc() const
Definition: ExprCXX.h:1267
bool isClassReceiver() const
Definition: ExprObjC.h:696
designators_iterator designators_end()
Definition: Expr.h:4166
A C++ reinterpret_cast expression (C++ [expr.reinterpret.cast]).
Definition: ExprCXX.h:306
This represents '#pragma omp simd' directive.
Definition: StmtOpenMP.h:636
const Expr * getSynchExpr() const
Definition: StmtObjC.h:290
unsigned getNumHandlers() const
Definition: StmtCXX.h:103
Kind getKind() const
Determine what kind of offsetof node this is.
Definition: Expr.h:1843
const StringLiteral * getOutputConstraintLiteral(unsigned i) const
Definition: Stmt.h:1653
Represents a C++11 pack expansion that produces a sequence of expressions.
Definition: ExprCXX.h:3392
unsigned getNumPlacementArgs() const
Definition: ExprCXX.h:1721
This represents clause 'linear' in the '#pragma omp ...' directives.
DeclarationNameInfo getDirectiveName() const
Return name of the directive.
Definition: StmtOpenMP.h:1086
Selector getSelector() const
Definition: DeclObjC.h:328
bool isTypeOperand() const
Definition: ExprCXX.h:707
void printName(raw_ostream &OS) const
printName - Print the human-readable name to a stream.
const Expr * getRetValue() const
Definition: Stmt.cpp:1013
unsigned getNumArgs() const
Definition: Expr.h:2205
unsigned getNumArgs() const
Definition: ExprCXX.h:1198
This represents '#pragma omp atomic' directive.
Definition: StmtOpenMP.h:1637
Expr * getBaseExpr() const
Definition: ExprObjC.h:809
llvm::APFloat getValue() const
Definition: Expr.h:1377
const Stmt * getThen() const
Definition: Stmt.h:916
Represents a C++11 noexcept expression (C++ [expr.unary.noexcept]).
Definition: ExprCXX.h:3337
Capturing variable-length array type.
Definition: Lambda.h:38
Not an overloaded operator.
Definition: OperatorKinds.h:23
Expr * getSafelen() const
Return safe iteration space distance.
Definition: OpenMPClause.h:353
Expr * getRHS() const
Definition: Expr.h:3613
void print(raw_ostream &Out, unsigned Indentation=0, bool PrintInstantiation=false) const
Expr * getBase() const
Retrieve the base object of this member expressions, e.g., the x in x.m.
Definition: ExprCXX.h:3038
const T * getAs() const
Definition: Type.h:5555
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
Definition: Expr.h:2066
const Stmt * getSubStmt() const
Definition: StmtObjC.h:356
capture_iterator explicit_capture_begin() const
Retrieve an iterator pointing to the first explicit lambda capture.
Definition: ExprCXX.cpp:1047
Represents Objective-C's collection statement.
Definition: StmtObjC.h:24
static StringRef getIdentTypeName(IdentType IT)
Definition: Expr.cpp:453
const char * getOperatorSpelling(OverloadedOperatorKind Operator)
Retrieve the spelling of the given overloaded operator, without the preceding "operator" keyword...
Represents a call to a CUDA kernel function.
Definition: ExprCXX.h:155
Expr * getArg(unsigned Arg)
Return the specified argument.
Definition: ExprCXX.h:1201
decl_range decls()
Definition: Stmt.h:497
Expr * getExprOperand() const
Definition: ExprCXX.h:724
bool isVolatile() const
Definition: Stmt.h:1434
bool hasTemplateKeyword() const
Determines whether the member name was preceded by the template keyword.
Definition: Expr.h:2486
Represents Objective-C's @finally statement.
Definition: StmtObjC.h:120
const Expr * getSubExpr() const
Definition: Expr.h:1442
Expr * getKeyExpr() const
Definition: ExprObjC.h:812
unsigned getNumArgs() const
Return the number of actual arguments in this message, not counting the receiver. ...
Definition: ExprObjC.h:1274
LabelDecl * getLabel() const
Definition: Expr.h:3379
const DeclStmt * getConditionVariableDeclStmt() const
Definition: Stmt.h:1062
An index into an array.
Definition: Expr.h:1793
Capturing the this pointer.
Definition: Lambda.h:35
This represents 'write' clause in the '#pragma omp atomic' directive.
Definition: OpenMPClause.h:836
ObjCPropertyDecl * getExplicitProperty() const
Definition: ExprObjC.h:628
unsigned getNumCatchStmts() const
Retrieve the number of @catch statements in this try-catch-finally block.
Definition: StmtObjC.h:203
const char * getOpenMPDirectiveName(OpenMPDirectiveKind Kind)
Definition: OpenMPKinds.cpp:31
const Expr * getInitializer() const
Definition: Expr.h:2617
ObjCIvarRefExpr - A reference to an ObjC instance variable.
Definition: ExprObjC.h:474
bool hasAssociatedStmt() const
Returns true if directive has associated statement.
Definition: StmtOpenMP.h:181
Expr * getFalseExpr() const
getFalseExpr - Return the subexpression which will be evaluated if the condnition evaluates to false;...
Definition: Expr.h:3317
Describes an explicit type conversion that uses functional notion but could not be resolved because o...
Definition: ExprCXX.h:2848
void printExceptionSpecification(raw_ostream &OS, const PrintingPolicy &Policy) const
ArrayRef< const Attr * > getAttrs() const
Definition: Stmt.h:863
A use of a default initializer in a constructor or in aggregate initialization.
Definition: ExprCXX.h:952
Expr * getTarget()
Definition: Stmt.h:1266
Expr * getBase() const
Definition: Expr.h:2405
A template argument list.
Definition: DeclTemplate.h:150
Expr * getCond()
Definition: Stmt.h:1111
Expr * getWeak() const
Definition: Expr.h:4888
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
const StringLiteral * getInputConstraintLiteral(unsigned i) const
Definition: Stmt.h:1681
OverloadedOperatorKind getOperator() const
Returns the kind of overloaded operator that this expression refers to.
Definition: ExprCXX.h:80
const Expr * getSubExpr() const
Definition: Expr.h:1638
const IdentifierInfo * getUDSuffix() const
Returns the ud-suffix specified for this literal.
Definition: ExprCXX.cpp:760
This represents 'nowait' clause in the '#pragma omp ...' directive.
Definition: OpenMPClause.h:720
bool isGlobalNew() const
Definition: ExprCXX.h:1738
Opcode getOpcode() const
Definition: Expr.h:2961
QualType getEncodedType() const
Definition: ExprObjC.h:377
VarDecl * getLoopVariable()
Definition: Stmt.cpp:874
Represents an explicit C++ type conversion that uses "functional" notation (C++ [expr.type.conv]).
Definition: ExprCXX.h:1241
NestedNameSpecifier * getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
Capturing by reference.
Definition: Lambda.h:37
const Expr * getCond() const
Definition: Stmt.h:914
CompoundStmt * getTryBlock()
Definition: StmtCXX.h:96
The receiver is a class.
Definition: ExprObjC.h:1000
Represents Objective-C's @try ... @catch ... @finally statement.
Definition: StmtObjC.h:154
const Expr * getThrowExpr() const
Definition: StmtObjC.h:325
bool hasExplicitTemplateArgs() const
Determines whether this declaration reference was followed by an explicit template argument list...
Definition: Expr.h:1096
Expr * getRHS() const
Definition: Expr.h:2966
Expr * getPattern()
Retrieve the pattern of the pack expansion.
Definition: ExprCXX.h:3421
bool isIfExists() const
Determine whether this is an __if_exists statement.
Definition: StmtCXX.h:259
static Decl::Kind getKind(const Decl *D)
Definition: DeclBase.cpp:739
Abstract class common to all of the C++ "named"/"keyword" casts.
Definition: ExprCXX.h:187
bool isStdInitListInitialization() const
Whether this constructor call was written as list-initialization, but was interpreted as forming a st...
Definition: ExprCXX.h:1160
This represents '#pragma omp sections' directive.
Definition: StmtOpenMP.h:830
Expr * getBase() const
Definition: Expr.h:4329
const Stmt * getTryBody() const
Retrieve the @try body.
Definition: StmtObjC.h:197
VarDecl * getExceptionDecl() const
Definition: StmtCXX.h:50
A reference to a declared variable, function, enum, etc. [C99 6.5.1p2].
Definition: Expr.h:899
Expr * getChunkSize()
Get chunk size.
Definition: OpenMPClause.h:658
static void PrintTemplateArgumentList(raw_ostream &OS, const TemplateArgument *Args, unsigned NumArgs, const PrintingPolicy &Policy, bool SkipBrackets=false)
Print a template argument list, including the '<' and '>' enclosing the template arguments...
const Expr * getInit(unsigned Init) const
Definition: Expr.h:3794
const Expr * getSubExpr() const
Definition: ExprCXX.h:1056
Stmt * getSubStmt()
Definition: Stmt.h:812
bool hasTemplateKeyword() const
Determines whether the name was preceded by the template keyword.
Definition: ExprCXX.h:2692
ExprIterator arg_iterator
Definition: ExprCXX.h:1179
BinaryOperatorKind getOperator() const
Definition: ExprCXX.h:3887
unsigned getNumClobbers() const
Definition: Stmt.h:1479
static StringRef getOpcodeStr(Opcode Op)
Definition: Expr.cpp:1062
This represents '#pragma omp taskyield' directive.
Definition: StmtOpenMP.h:1351
A boolean literal, per ([C++ lex.bool] Boolean literals).
Definition: ExprCXX.h:434
NestedNameSpecifier * getQualifier() const
Fetches the nested-name qualifier, if one was given.
Definition: ExprCXX.h:2410
QualType getDestroyedType() const
Retrieve the type being destroyed.
Definition: ExprCXX.cpp:270
CompoundStmt * getTryBlock() const
Definition: Stmt.h:1936
This represents '#pragma omp parallel sections' directive.
Definition: StmtOpenMP.h:1237
bool isArrow() const
Definition: ExprCXX.h:668
bool isSignedIntegerType() const
Definition: Type.cpp:1683
const CallExpr * getConfig() const
Definition: ExprCXX.h:170
bool isNull() const
isNull - Return true if this QualType doesn't point to a type yet.
Definition: Type.h:633
bool isTypeOperand() const
Definition: ExprCXX.h:572
The receiver is a superclass.
Definition: ExprObjC.h:1004
const char * getName() const
Definition: Stmt.cpp:307
Stmt * getAssociatedStmt() const
Returns statement associated with the directive.
Definition: StmtOpenMP.h:184
ReceiverKind getReceiverKind() const
Determine the kind of receiver that this message is being sent to.
Definition: ExprObjC.h:1133
Represents Objective-C's @autoreleasepool Statement.
Definition: StmtObjC.h:345
bool isArrow() const
Determine whether this member expression used the '->' operator; otherwise, it used the '...
Definition: ExprCXX.h:3047
Expr * getOrderFail() const
Definition: Expr.h:4878
Stmt * getSubStmt()
Definition: Stmt.h:866
Represents an implicitly-generated value initialization of an object of a given type.
Definition: Expr.h:4352
unsigned getNumElements() const
Definition: ExprObjC.h:314
Attr - This represents one attribute.
Definition: Attr.h:44
operator "" X (unsigned long long)
Definition: ExprCXX.h:389
Expr * getCookedLiteral()
If this is not a raw user-defined literal, get the underlying cooked literal (representing the litera...
Definition: ExprCXX.cpp:752
bool isArrow() const
Definition: ExprObjC.h:508
SEHFinallyStmt * getFinallyHandler() const
Definition: Stmt.cpp:1042
unsigned Indent
The current line's indent.
Stmt * getSubStmt()
Definition: Stmt.h:719
QualType getArgumentType() const
Definition: Expr.h:2014