clang  6.0.0svn
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/DeclOpenMP.h"
20 #include "clang/AST/DeclTemplate.h"
21 #include "clang/AST/Expr.h"
22 #include "clang/AST/ExprCXX.h"
23 #include "clang/AST/ExprOpenMP.h"
25 #include "clang/AST/StmtVisitor.h"
26 #include "clang/Basic/CharInfo.h"
27 #include "clang/Lex/Lexer.h"
28 #include "llvm/ADT/SmallString.h"
29 #include "llvm/Support/Format.h"
30 using namespace clang;
31 
32 //===----------------------------------------------------------------------===//
33 // StmtPrinter Visitor
34 //===----------------------------------------------------------------------===//
35 
36 namespace {
37  class StmtPrinter : public StmtVisitor<StmtPrinter> {
38  raw_ostream &OS;
39  unsigned IndentLevel;
40  clang::PrinterHelper* Helper;
41  PrintingPolicy Policy;
42  const ASTContext *Context;
43 
44  public:
45  StmtPrinter(raw_ostream &os, PrinterHelper *helper,
46  const PrintingPolicy &Policy, unsigned Indentation = 0,
47  const ASTContext *Context = nullptr)
48  : OS(os), IndentLevel(Indentation), Helper(helper), Policy(Policy),
49  Context(Context) {}
50 
51  void PrintStmt(Stmt *S) {
52  PrintStmt(S, Policy.Indentation);
53  }
54 
55  void PrintStmt(Stmt *S, int SubIndent) {
56  IndentLevel += SubIndent;
57  if (S && isa<Expr>(S)) {
58  // If this is an expr used in a stmt context, indent and newline it.
59  Indent();
60  Visit(S);
61  OS << ";\n";
62  } else if (S) {
63  Visit(S);
64  } else {
65  Indent() << "<<<NULL STATEMENT>>>\n";
66  }
67  IndentLevel -= SubIndent;
68  }
69 
70  void PrintRawCompoundStmt(CompoundStmt *S);
71  void PrintRawDecl(Decl *D);
72  void PrintRawDeclStmt(const DeclStmt *S);
73  void PrintRawIfStmt(IfStmt *If);
74  void PrintRawCXXCatchStmt(CXXCatchStmt *Catch);
75  void PrintCallArgs(CallExpr *E);
76  void PrintRawSEHExceptHandler(SEHExceptStmt *S);
77  void PrintRawSEHFinallyStmt(SEHFinallyStmt *S);
78  void PrintOMPExecutableDirective(OMPExecutableDirective *S);
79 
80  void PrintExpr(Expr *E) {
81  if (E)
82  Visit(E);
83  else
84  OS << "<null expr>";
85  }
86 
87  raw_ostream &Indent(int Delta = 0) {
88  for (int i = 0, e = IndentLevel+Delta; i < e; ++i)
89  OS << " ";
90  return OS;
91  }
92 
93  void Visit(Stmt* S) {
94  if (Helper && Helper->handledStmt(S,OS))
95  return;
97  }
98 
99  void VisitStmt(Stmt *Node) LLVM_ATTRIBUTE_UNUSED {
100  Indent() << "<<unknown stmt type>>\n";
101  }
102  void VisitExpr(Expr *Node) LLVM_ATTRIBUTE_UNUSED {
103  OS << "<<unknown expr type>>";
104  }
105  void VisitCXXNamedCastExpr(CXXNamedCastExpr *Node);
106 
107 #define ABSTRACT_STMT(CLASS)
108 #define STMT(CLASS, PARENT) \
109  void Visit##CLASS(CLASS *Node);
110 #include "clang/AST/StmtNodes.inc"
111  };
112 }
113 
114 //===----------------------------------------------------------------------===//
115 // Stmt printing methods.
116 //===----------------------------------------------------------------------===//
117 
118 /// PrintRawCompoundStmt - Print a compound stmt without indenting the {, and
119 /// with no newline after the }.
120 void StmtPrinter::PrintRawCompoundStmt(CompoundStmt *Node) {
121  OS << "{\n";
122  for (auto *I : Node->body())
123  PrintStmt(I);
124 
125  Indent() << "}";
126 }
127 
128 void StmtPrinter::PrintRawDecl(Decl *D) {
129  D->print(OS, Policy, IndentLevel);
130 }
131 
132 void StmtPrinter::PrintRawDeclStmt(const DeclStmt *S) {
133  SmallVector<Decl*, 2> Decls(S->decls());
134  Decl::printGroup(Decls.data(), Decls.size(), OS, Policy, IndentLevel);
135 }
136 
137 void StmtPrinter::VisitNullStmt(NullStmt *Node) {
138  Indent() << ";\n";
139 }
140 
141 void StmtPrinter::VisitDeclStmt(DeclStmt *Node) {
142  Indent();
143  PrintRawDeclStmt(Node);
144  OS << ";\n";
145 }
146 
147 void StmtPrinter::VisitCompoundStmt(CompoundStmt *Node) {
148  Indent();
149  PrintRawCompoundStmt(Node);
150  OS << "\n";
151 }
152 
153 void StmtPrinter::VisitCaseStmt(CaseStmt *Node) {
154  Indent(-1) << "case ";
155  PrintExpr(Node->getLHS());
156  if (Node->getRHS()) {
157  OS << " ... ";
158  PrintExpr(Node->getRHS());
159  }
160  OS << ":\n";
161 
162  PrintStmt(Node->getSubStmt(), 0);
163 }
164 
165 void StmtPrinter::VisitDefaultStmt(DefaultStmt *Node) {
166  Indent(-1) << "default:\n";
167  PrintStmt(Node->getSubStmt(), 0);
168 }
169 
170 void StmtPrinter::VisitLabelStmt(LabelStmt *Node) {
171  Indent(-1) << Node->getName() << ":\n";
172  PrintStmt(Node->getSubStmt(), 0);
173 }
174 
175 void StmtPrinter::VisitAttributedStmt(AttributedStmt *Node) {
176  for (const auto *Attr : Node->getAttrs()) {
177  Attr->printPretty(OS, Policy);
178  }
179 
180  PrintStmt(Node->getSubStmt(), 0);
181 }
182 
183 void StmtPrinter::PrintRawIfStmt(IfStmt *If) {
184  OS << "if (";
185  if (const DeclStmt *DS = If->getConditionVariableDeclStmt())
186  PrintRawDeclStmt(DS);
187  else
188  PrintExpr(If->getCond());
189  OS << ')';
190 
191  if (CompoundStmt *CS = dyn_cast<CompoundStmt>(If->getThen())) {
192  OS << ' ';
193  PrintRawCompoundStmt(CS);
194  OS << (If->getElse() ? ' ' : '\n');
195  } else {
196  OS << '\n';
197  PrintStmt(If->getThen());
198  if (If->getElse()) Indent();
199  }
200 
201  if (Stmt *Else = If->getElse()) {
202  OS << "else";
203 
204  if (CompoundStmt *CS = dyn_cast<CompoundStmt>(Else)) {
205  OS << ' ';
206  PrintRawCompoundStmt(CS);
207  OS << '\n';
208  } else if (IfStmt *ElseIf = dyn_cast<IfStmt>(Else)) {
209  OS << ' ';
210  PrintRawIfStmt(ElseIf);
211  } else {
212  OS << '\n';
213  PrintStmt(If->getElse());
214  }
215  }
216 }
217 
218 void StmtPrinter::VisitIfStmt(IfStmt *If) {
219  Indent();
220  PrintRawIfStmt(If);
221 }
222 
223 void StmtPrinter::VisitSwitchStmt(SwitchStmt *Node) {
224  Indent() << "switch (";
225  if (const DeclStmt *DS = Node->getConditionVariableDeclStmt())
226  PrintRawDeclStmt(DS);
227  else
228  PrintExpr(Node->getCond());
229  OS << ")";
230 
231  // Pretty print compoundstmt bodies (very common).
232  if (CompoundStmt *CS = dyn_cast<CompoundStmt>(Node->getBody())) {
233  OS << " ";
234  PrintRawCompoundStmt(CS);
235  OS << "\n";
236  } else {
237  OS << "\n";
238  PrintStmt(Node->getBody());
239  }
240 }
241 
242 void StmtPrinter::VisitWhileStmt(WhileStmt *Node) {
243  Indent() << "while (";
244  if (const DeclStmt *DS = Node->getConditionVariableDeclStmt())
245  PrintRawDeclStmt(DS);
246  else
247  PrintExpr(Node->getCond());
248  OS << ")\n";
249  PrintStmt(Node->getBody());
250 }
251 
252 void StmtPrinter::VisitDoStmt(DoStmt *Node) {
253  Indent() << "do ";
254  if (CompoundStmt *CS = dyn_cast<CompoundStmt>(Node->getBody())) {
255  PrintRawCompoundStmt(CS);
256  OS << " ";
257  } else {
258  OS << "\n";
259  PrintStmt(Node->getBody());
260  Indent();
261  }
262 
263  OS << "while (";
264  PrintExpr(Node->getCond());
265  OS << ");\n";
266 }
267 
268 void StmtPrinter::VisitForStmt(ForStmt *Node) {
269  Indent() << "for (";
270  if (Node->getInit()) {
271  if (DeclStmt *DS = dyn_cast<DeclStmt>(Node->getInit()))
272  PrintRawDeclStmt(DS);
273  else
274  PrintExpr(cast<Expr>(Node->getInit()));
275  }
276  OS << ";";
277  if (Node->getCond()) {
278  OS << " ";
279  PrintExpr(Node->getCond());
280  }
281  OS << ";";
282  if (Node->getInc()) {
283  OS << " ";
284  PrintExpr(Node->getInc());
285  }
286  OS << ") ";
287 
288  if (CompoundStmt *CS = dyn_cast<CompoundStmt>(Node->getBody())) {
289  PrintRawCompoundStmt(CS);
290  OS << "\n";
291  } else {
292  OS << "\n";
293  PrintStmt(Node->getBody());
294  }
295 }
296 
297 void StmtPrinter::VisitObjCForCollectionStmt(ObjCForCollectionStmt *Node) {
298  Indent() << "for (";
299  if (DeclStmt *DS = dyn_cast<DeclStmt>(Node->getElement()))
300  PrintRawDeclStmt(DS);
301  else
302  PrintExpr(cast<Expr>(Node->getElement()));
303  OS << " in ";
304  PrintExpr(Node->getCollection());
305  OS << ") ";
306 
307  if (CompoundStmt *CS = dyn_cast<CompoundStmt>(Node->getBody())) {
308  PrintRawCompoundStmt(CS);
309  OS << "\n";
310  } else {
311  OS << "\n";
312  PrintStmt(Node->getBody());
313  }
314 }
315 
316 void StmtPrinter::VisitCXXForRangeStmt(CXXForRangeStmt *Node) {
317  Indent() << "for (";
318  PrintingPolicy SubPolicy(Policy);
319  SubPolicy.SuppressInitializers = true;
320  Node->getLoopVariable()->print(OS, SubPolicy, IndentLevel);
321  OS << " : ";
322  PrintExpr(Node->getRangeInit());
323  OS << ") {\n";
324  PrintStmt(Node->getBody());
325  Indent() << "}";
326  if (Policy.IncludeNewlines) OS << "\n";
327 }
328 
329 void StmtPrinter::VisitMSDependentExistsStmt(MSDependentExistsStmt *Node) {
330  Indent();
331  if (Node->isIfExists())
332  OS << "__if_exists (";
333  else
334  OS << "__if_not_exists (";
335 
336  if (NestedNameSpecifier *Qualifier
338  Qualifier->print(OS, Policy);
339 
340  OS << Node->getNameInfo() << ") ";
341 
342  PrintRawCompoundStmt(Node->getSubStmt());
343 }
344 
345 void StmtPrinter::VisitGotoStmt(GotoStmt *Node) {
346  Indent() << "goto " << Node->getLabel()->getName() << ";";
347  if (Policy.IncludeNewlines) OS << "\n";
348 }
349 
350 void StmtPrinter::VisitIndirectGotoStmt(IndirectGotoStmt *Node) {
351  Indent() << "goto *";
352  PrintExpr(Node->getTarget());
353  OS << ";";
354  if (Policy.IncludeNewlines) OS << "\n";
355 }
356 
357 void StmtPrinter::VisitContinueStmt(ContinueStmt *Node) {
358  Indent() << "continue;";
359  if (Policy.IncludeNewlines) OS << "\n";
360 }
361 
362 void StmtPrinter::VisitBreakStmt(BreakStmt *Node) {
363  Indent() << "break;";
364  if (Policy.IncludeNewlines) OS << "\n";
365 }
366 
367 
368 void StmtPrinter::VisitReturnStmt(ReturnStmt *Node) {
369  Indent() << "return";
370  if (Node->getRetValue()) {
371  OS << " ";
372  PrintExpr(Node->getRetValue());
373  }
374  OS << ";";
375  if (Policy.IncludeNewlines) OS << "\n";
376 }
377 
378 
379 void StmtPrinter::VisitGCCAsmStmt(GCCAsmStmt *Node) {
380  Indent() << "asm ";
381 
382  if (Node->isVolatile())
383  OS << "volatile ";
384 
385  OS << "(";
386  VisitStringLiteral(Node->getAsmString());
387 
388  // Outputs
389  if (Node->getNumOutputs() != 0 || Node->getNumInputs() != 0 ||
390  Node->getNumClobbers() != 0)
391  OS << " : ";
392 
393  for (unsigned i = 0, e = Node->getNumOutputs(); i != e; ++i) {
394  if (i != 0)
395  OS << ", ";
396 
397  if (!Node->getOutputName(i).empty()) {
398  OS << '[';
399  OS << Node->getOutputName(i);
400  OS << "] ";
401  }
402 
403  VisitStringLiteral(Node->getOutputConstraintLiteral(i));
404  OS << " (";
405  Visit(Node->getOutputExpr(i));
406  OS << ")";
407  }
408 
409  // Inputs
410  if (Node->getNumInputs() != 0 || Node->getNumClobbers() != 0)
411  OS << " : ";
412 
413  for (unsigned i = 0, e = Node->getNumInputs(); i != e; ++i) {
414  if (i != 0)
415  OS << ", ";
416 
417  if (!Node->getInputName(i).empty()) {
418  OS << '[';
419  OS << Node->getInputName(i);
420  OS << "] ";
421  }
422 
423  VisitStringLiteral(Node->getInputConstraintLiteral(i));
424  OS << " (";
425  Visit(Node->getInputExpr(i));
426  OS << ")";
427  }
428 
429  // Clobbers
430  if (Node->getNumClobbers() != 0)
431  OS << " : ";
432 
433  for (unsigned i = 0, e = Node->getNumClobbers(); i != e; ++i) {
434  if (i != 0)
435  OS << ", ";
436 
437  VisitStringLiteral(Node->getClobberStringLiteral(i));
438  }
439 
440  OS << ");";
441  if (Policy.IncludeNewlines) OS << "\n";
442 }
443 
444 void StmtPrinter::VisitMSAsmStmt(MSAsmStmt *Node) {
445  // FIXME: Implement MS style inline asm statement printer.
446  Indent() << "__asm ";
447  if (Node->hasBraces())
448  OS << "{\n";
449  OS << Node->getAsmString() << "\n";
450  if (Node->hasBraces())
451  Indent() << "}\n";
452 }
453 
454 void StmtPrinter::VisitCapturedStmt(CapturedStmt *Node) {
455  PrintStmt(Node->getCapturedDecl()->getBody());
456 }
457 
458 void StmtPrinter::VisitObjCAtTryStmt(ObjCAtTryStmt *Node) {
459  Indent() << "@try";
460  if (CompoundStmt *TS = dyn_cast<CompoundStmt>(Node->getTryBody())) {
461  PrintRawCompoundStmt(TS);
462  OS << "\n";
463  }
464 
465  for (unsigned I = 0, N = Node->getNumCatchStmts(); I != N; ++I) {
466  ObjCAtCatchStmt *catchStmt = Node->getCatchStmt(I);
467  Indent() << "@catch(";
468  if (catchStmt->getCatchParamDecl()) {
469  if (Decl *DS = catchStmt->getCatchParamDecl())
470  PrintRawDecl(DS);
471  }
472  OS << ")";
473  if (CompoundStmt *CS = dyn_cast<CompoundStmt>(catchStmt->getCatchBody())) {
474  PrintRawCompoundStmt(CS);
475  OS << "\n";
476  }
477  }
478 
479  if (ObjCAtFinallyStmt *FS = static_cast<ObjCAtFinallyStmt *>(
480  Node->getFinallyStmt())) {
481  Indent() << "@finally";
482  PrintRawCompoundStmt(dyn_cast<CompoundStmt>(FS->getFinallyBody()));
483  OS << "\n";
484  }
485 }
486 
487 void StmtPrinter::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *Node) {
488 }
489 
490 void StmtPrinter::VisitObjCAtCatchStmt (ObjCAtCatchStmt *Node) {
491  Indent() << "@catch (...) { /* todo */ } \n";
492 }
493 
494 void StmtPrinter::VisitObjCAtThrowStmt(ObjCAtThrowStmt *Node) {
495  Indent() << "@throw";
496  if (Node->getThrowExpr()) {
497  OS << " ";
498  PrintExpr(Node->getThrowExpr());
499  }
500  OS << ";\n";
501 }
502 
503 void StmtPrinter::VisitObjCAvailabilityCheckExpr(
505  OS << "@available(...)";
506 }
507 
508 void StmtPrinter::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *Node) {
509  Indent() << "@synchronized (";
510  PrintExpr(Node->getSynchExpr());
511  OS << ")";
512  PrintRawCompoundStmt(Node->getSynchBody());
513  OS << "\n";
514 }
515 
516 void StmtPrinter::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *Node) {
517  Indent() << "@autoreleasepool";
518  PrintRawCompoundStmt(dyn_cast<CompoundStmt>(Node->getSubStmt()));
519  OS << "\n";
520 }
521 
522 void StmtPrinter::PrintRawCXXCatchStmt(CXXCatchStmt *Node) {
523  OS << "catch (";
524  if (Decl *ExDecl = Node->getExceptionDecl())
525  PrintRawDecl(ExDecl);
526  else
527  OS << "...";
528  OS << ") ";
529  PrintRawCompoundStmt(cast<CompoundStmt>(Node->getHandlerBlock()));
530 }
531 
532 void StmtPrinter::VisitCXXCatchStmt(CXXCatchStmt *Node) {
533  Indent();
534  PrintRawCXXCatchStmt(Node);
535  OS << "\n";
536 }
537 
538 void StmtPrinter::VisitCXXTryStmt(CXXTryStmt *Node) {
539  Indent() << "try ";
540  PrintRawCompoundStmt(Node->getTryBlock());
541  for (unsigned i = 0, e = Node->getNumHandlers(); i < e; ++i) {
542  OS << " ";
543  PrintRawCXXCatchStmt(Node->getHandler(i));
544  }
545  OS << "\n";
546 }
547 
548 void StmtPrinter::VisitSEHTryStmt(SEHTryStmt *Node) {
549  Indent() << (Node->getIsCXXTry() ? "try " : "__try ");
550  PrintRawCompoundStmt(Node->getTryBlock());
551  SEHExceptStmt *E = Node->getExceptHandler();
552  SEHFinallyStmt *F = Node->getFinallyHandler();
553  if(E)
554  PrintRawSEHExceptHandler(E);
555  else {
556  assert(F && "Must have a finally block...");
557  PrintRawSEHFinallyStmt(F);
558  }
559  OS << "\n";
560 }
561 
562 void StmtPrinter::PrintRawSEHFinallyStmt(SEHFinallyStmt *Node) {
563  OS << "__finally ";
564  PrintRawCompoundStmt(Node->getBlock());
565  OS << "\n";
566 }
567 
568 void StmtPrinter::PrintRawSEHExceptHandler(SEHExceptStmt *Node) {
569  OS << "__except (";
570  VisitExpr(Node->getFilterExpr());
571  OS << ")\n";
572  PrintRawCompoundStmt(Node->getBlock());
573  OS << "\n";
574 }
575 
576 void StmtPrinter::VisitSEHExceptStmt(SEHExceptStmt *Node) {
577  Indent();
578  PrintRawSEHExceptHandler(Node);
579  OS << "\n";
580 }
581 
582 void StmtPrinter::VisitSEHFinallyStmt(SEHFinallyStmt *Node) {
583  Indent();
584  PrintRawSEHFinallyStmt(Node);
585  OS << "\n";
586 }
587 
588 void StmtPrinter::VisitSEHLeaveStmt(SEHLeaveStmt *Node) {
589  Indent() << "__leave;";
590  if (Policy.IncludeNewlines) OS << "\n";
591 }
592 
593 //===----------------------------------------------------------------------===//
594 // OpenMP clauses printing methods
595 //===----------------------------------------------------------------------===//
596 
597 namespace {
598 class OMPClausePrinter : public OMPClauseVisitor<OMPClausePrinter> {
599  raw_ostream &OS;
600  const PrintingPolicy &Policy;
601  /// \brief Process clauses with list of variables.
602  template <typename T>
603  void VisitOMPClauseList(T *Node, char StartSym);
604 public:
605  OMPClausePrinter(raw_ostream &OS, const PrintingPolicy &Policy)
606  : OS(OS), Policy(Policy) { }
607 #define OPENMP_CLAUSE(Name, Class) \
608  void Visit##Class(Class *S);
609 #include "clang/Basic/OpenMPKinds.def"
610 };
611 
612 void OMPClausePrinter::VisitOMPIfClause(OMPIfClause *Node) {
613  OS << "if(";
614  if (Node->getNameModifier() != OMPD_unknown)
615  OS << getOpenMPDirectiveName(Node->getNameModifier()) << ": ";
616  Node->getCondition()->printPretty(OS, nullptr, Policy, 0);
617  OS << ")";
618 }
619 
620 void OMPClausePrinter::VisitOMPFinalClause(OMPFinalClause *Node) {
621  OS << "final(";
622  Node->getCondition()->printPretty(OS, nullptr, Policy, 0);
623  OS << ")";
624 }
625 
626 void OMPClausePrinter::VisitOMPNumThreadsClause(OMPNumThreadsClause *Node) {
627  OS << "num_threads(";
628  Node->getNumThreads()->printPretty(OS, nullptr, Policy, 0);
629  OS << ")";
630 }
631 
632 void OMPClausePrinter::VisitOMPSafelenClause(OMPSafelenClause *Node) {
633  OS << "safelen(";
634  Node->getSafelen()->printPretty(OS, nullptr, Policy, 0);
635  OS << ")";
636 }
637 
638 void OMPClausePrinter::VisitOMPSimdlenClause(OMPSimdlenClause *Node) {
639  OS << "simdlen(";
640  Node->getSimdlen()->printPretty(OS, nullptr, Policy, 0);
641  OS << ")";
642 }
643 
644 void OMPClausePrinter::VisitOMPCollapseClause(OMPCollapseClause *Node) {
645  OS << "collapse(";
646  Node->getNumForLoops()->printPretty(OS, nullptr, Policy, 0);
647  OS << ")";
648 }
649 
650 void OMPClausePrinter::VisitOMPDefaultClause(OMPDefaultClause *Node) {
651  OS << "default("
652  << getOpenMPSimpleClauseTypeName(OMPC_default, Node->getDefaultKind())
653  << ")";
654 }
655 
656 void OMPClausePrinter::VisitOMPProcBindClause(OMPProcBindClause *Node) {
657  OS << "proc_bind("
658  << getOpenMPSimpleClauseTypeName(OMPC_proc_bind, Node->getProcBindKind())
659  << ")";
660 }
661 
662 void OMPClausePrinter::VisitOMPScheduleClause(OMPScheduleClause *Node) {
663  OS << "schedule(";
665  OS << getOpenMPSimpleClauseTypeName(OMPC_schedule,
666  Node->getFirstScheduleModifier());
668  OS << ", ";
669  OS << getOpenMPSimpleClauseTypeName(OMPC_schedule,
670  Node->getSecondScheduleModifier());
671  }
672  OS << ": ";
673  }
674  OS << getOpenMPSimpleClauseTypeName(OMPC_schedule, Node->getScheduleKind());
675  if (auto *E = Node->getChunkSize()) {
676  OS << ", ";
677  E->printPretty(OS, nullptr, Policy);
678  }
679  OS << ")";
680 }
681 
682 void OMPClausePrinter::VisitOMPOrderedClause(OMPOrderedClause *Node) {
683  OS << "ordered";
684  if (auto *Num = Node->getNumForLoops()) {
685  OS << "(";
686  Num->printPretty(OS, nullptr, Policy, 0);
687  OS << ")";
688  }
689 }
690 
691 void OMPClausePrinter::VisitOMPNowaitClause(OMPNowaitClause *) {
692  OS << "nowait";
693 }
694 
695 void OMPClausePrinter::VisitOMPUntiedClause(OMPUntiedClause *) {
696  OS << "untied";
697 }
698 
699 void OMPClausePrinter::VisitOMPNogroupClause(OMPNogroupClause *) {
700  OS << "nogroup";
701 }
702 
703 void OMPClausePrinter::VisitOMPMergeableClause(OMPMergeableClause *) {
704  OS << "mergeable";
705 }
706 
707 void OMPClausePrinter::VisitOMPReadClause(OMPReadClause *) { OS << "read"; }
708 
709 void OMPClausePrinter::VisitOMPWriteClause(OMPWriteClause *) { OS << "write"; }
710 
711 void OMPClausePrinter::VisitOMPUpdateClause(OMPUpdateClause *) {
712  OS << "update";
713 }
714 
715 void OMPClausePrinter::VisitOMPCaptureClause(OMPCaptureClause *) {
716  OS << "capture";
717 }
718 
719 void OMPClausePrinter::VisitOMPSeqCstClause(OMPSeqCstClause *) {
720  OS << "seq_cst";
721 }
722 
723 void OMPClausePrinter::VisitOMPThreadsClause(OMPThreadsClause *) {
724  OS << "threads";
725 }
726 
727 void OMPClausePrinter::VisitOMPSIMDClause(OMPSIMDClause *) { OS << "simd"; }
728 
729 void OMPClausePrinter::VisitOMPDeviceClause(OMPDeviceClause *Node) {
730  OS << "device(";
731  Node->getDevice()->printPretty(OS, nullptr, Policy, 0);
732  OS << ")";
733 }
734 
735 void OMPClausePrinter::VisitOMPNumTeamsClause(OMPNumTeamsClause *Node) {
736  OS << "num_teams(";
737  Node->getNumTeams()->printPretty(OS, nullptr, Policy, 0);
738  OS << ")";
739 }
740 
741 void OMPClausePrinter::VisitOMPThreadLimitClause(OMPThreadLimitClause *Node) {
742  OS << "thread_limit(";
743  Node->getThreadLimit()->printPretty(OS, nullptr, Policy, 0);
744  OS << ")";
745 }
746 
747 void OMPClausePrinter::VisitOMPPriorityClause(OMPPriorityClause *Node) {
748  OS << "priority(";
749  Node->getPriority()->printPretty(OS, nullptr, Policy, 0);
750  OS << ")";
751 }
752 
753 void OMPClausePrinter::VisitOMPGrainsizeClause(OMPGrainsizeClause *Node) {
754  OS << "grainsize(";
755  Node->getGrainsize()->printPretty(OS, nullptr, Policy, 0);
756  OS << ")";
757 }
758 
759 void OMPClausePrinter::VisitOMPNumTasksClause(OMPNumTasksClause *Node) {
760  OS << "num_tasks(";
761  Node->getNumTasks()->printPretty(OS, nullptr, Policy, 0);
762  OS << ")";
763 }
764 
765 void OMPClausePrinter::VisitOMPHintClause(OMPHintClause *Node) {
766  OS << "hint(";
767  Node->getHint()->printPretty(OS, nullptr, Policy, 0);
768  OS << ")";
769 }
770 
771 template<typename T>
772 void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) {
773  for (typename T::varlist_iterator I = Node->varlist_begin(),
774  E = Node->varlist_end();
775  I != E; ++I) {
776  assert(*I && "Expected non-null Stmt");
777  OS << (I == Node->varlist_begin() ? StartSym : ',');
778  if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(*I)) {
779  if (isa<OMPCapturedExprDecl>(DRE->getDecl()))
780  DRE->printPretty(OS, nullptr, Policy, 0);
781  else
782  DRE->getDecl()->printQualifiedName(OS);
783  } else
784  (*I)->printPretty(OS, nullptr, Policy, 0);
785  }
786 }
787 
788 void OMPClausePrinter::VisitOMPPrivateClause(OMPPrivateClause *Node) {
789  if (!Node->varlist_empty()) {
790  OS << "private";
791  VisitOMPClauseList(Node, '(');
792  OS << ")";
793  }
794 }
795 
796 void OMPClausePrinter::VisitOMPFirstprivateClause(OMPFirstprivateClause *Node) {
797  if (!Node->varlist_empty()) {
798  OS << "firstprivate";
799  VisitOMPClauseList(Node, '(');
800  OS << ")";
801  }
802 }
803 
804 void OMPClausePrinter::VisitOMPLastprivateClause(OMPLastprivateClause *Node) {
805  if (!Node->varlist_empty()) {
806  OS << "lastprivate";
807  VisitOMPClauseList(Node, '(');
808  OS << ")";
809  }
810 }
811 
812 void OMPClausePrinter::VisitOMPSharedClause(OMPSharedClause *Node) {
813  if (!Node->varlist_empty()) {
814  OS << "shared";
815  VisitOMPClauseList(Node, '(');
816  OS << ")";
817  }
818 }
819 
820 void OMPClausePrinter::VisitOMPReductionClause(OMPReductionClause *Node) {
821  if (!Node->varlist_empty()) {
822  OS << "reduction(";
823  NestedNameSpecifier *QualifierLoc =
827  if (QualifierLoc == nullptr && OOK != OO_None) {
828  // Print reduction identifier in C format
829  OS << getOperatorSpelling(OOK);
830  } else {
831  // Use C++ format
832  if (QualifierLoc != nullptr)
833  QualifierLoc->print(OS, Policy);
834  OS << Node->getNameInfo();
835  }
836  OS << ":";
837  VisitOMPClauseList(Node, ' ');
838  OS << ")";
839  }
840 }
841 
842 void OMPClausePrinter::VisitOMPTaskReductionClause(
843  OMPTaskReductionClause *Node) {
844  if (!Node->varlist_empty()) {
845  OS << "task_reduction(";
846  NestedNameSpecifier *QualifierLoc =
850  if (QualifierLoc == nullptr && OOK != OO_None) {
851  // Print reduction identifier in C format
852  OS << getOperatorSpelling(OOK);
853  } else {
854  // Use C++ format
855  if (QualifierLoc != nullptr)
856  QualifierLoc->print(OS, Policy);
857  OS << Node->getNameInfo();
858  }
859  OS << ":";
860  VisitOMPClauseList(Node, ' ');
861  OS << ")";
862  }
863 }
864 
865 void OMPClausePrinter::VisitOMPInReductionClause(OMPInReductionClause *Node) {
866  if (!Node->varlist_empty()) {
867  OS << "in_reduction(";
868  NestedNameSpecifier *QualifierLoc =
872  if (QualifierLoc == nullptr && OOK != OO_None) {
873  // Print reduction identifier in C format
874  OS << getOperatorSpelling(OOK);
875  } else {
876  // Use C++ format
877  if (QualifierLoc != nullptr)
878  QualifierLoc->print(OS, Policy);
879  OS << Node->getNameInfo();
880  }
881  OS << ":";
882  VisitOMPClauseList(Node, ' ');
883  OS << ")";
884  }
885 }
886 
887 void OMPClausePrinter::VisitOMPLinearClause(OMPLinearClause *Node) {
888  if (!Node->varlist_empty()) {
889  OS << "linear";
890  if (Node->getModifierLoc().isValid()) {
891  OS << '('
892  << getOpenMPSimpleClauseTypeName(OMPC_linear, Node->getModifier());
893  }
894  VisitOMPClauseList(Node, '(');
895  if (Node->getModifierLoc().isValid())
896  OS << ')';
897  if (Node->getStep() != nullptr) {
898  OS << ": ";
899  Node->getStep()->printPretty(OS, nullptr, Policy, 0);
900  }
901  OS << ")";
902  }
903 }
904 
905 void OMPClausePrinter::VisitOMPAlignedClause(OMPAlignedClause *Node) {
906  if (!Node->varlist_empty()) {
907  OS << "aligned";
908  VisitOMPClauseList(Node, '(');
909  if (Node->getAlignment() != nullptr) {
910  OS << ": ";
911  Node->getAlignment()->printPretty(OS, nullptr, Policy, 0);
912  }
913  OS << ")";
914  }
915 }
916 
917 void OMPClausePrinter::VisitOMPCopyinClause(OMPCopyinClause *Node) {
918  if (!Node->varlist_empty()) {
919  OS << "copyin";
920  VisitOMPClauseList(Node, '(');
921  OS << ")";
922  }
923 }
924 
925 void OMPClausePrinter::VisitOMPCopyprivateClause(OMPCopyprivateClause *Node) {
926  if (!Node->varlist_empty()) {
927  OS << "copyprivate";
928  VisitOMPClauseList(Node, '(');
929  OS << ")";
930  }
931 }
932 
933 void OMPClausePrinter::VisitOMPFlushClause(OMPFlushClause *Node) {
934  if (!Node->varlist_empty()) {
935  VisitOMPClauseList(Node, '(');
936  OS << ")";
937  }
938 }
939 
940 void OMPClausePrinter::VisitOMPDependClause(OMPDependClause *Node) {
941  OS << "depend(";
942  OS << getOpenMPSimpleClauseTypeName(Node->getClauseKind(),
943  Node->getDependencyKind());
944  if (!Node->varlist_empty()) {
945  OS << " :";
946  VisitOMPClauseList(Node, ' ');
947  }
948  OS << ")";
949 }
950 
951 void OMPClausePrinter::VisitOMPMapClause(OMPMapClause *Node) {
952  if (!Node->varlist_empty()) {
953  OS << "map(";
954  if (Node->getMapType() != OMPC_MAP_unknown) {
955  if (Node->getMapTypeModifier() != OMPC_MAP_unknown) {
956  OS << getOpenMPSimpleClauseTypeName(OMPC_map,
957  Node->getMapTypeModifier());
958  OS << ',';
959  }
960  OS << getOpenMPSimpleClauseTypeName(OMPC_map, Node->getMapType());
961  OS << ':';
962  }
963  VisitOMPClauseList(Node, ' ');
964  OS << ")";
965  }
966 }
967 
968 void OMPClausePrinter::VisitOMPToClause(OMPToClause *Node) {
969  if (!Node->varlist_empty()) {
970  OS << "to";
971  VisitOMPClauseList(Node, '(');
972  OS << ")";
973  }
974 }
975 
976 void OMPClausePrinter::VisitOMPFromClause(OMPFromClause *Node) {
977  if (!Node->varlist_empty()) {
978  OS << "from";
979  VisitOMPClauseList(Node, '(');
980  OS << ")";
981  }
982 }
983 
984 void OMPClausePrinter::VisitOMPDistScheduleClause(OMPDistScheduleClause *Node) {
985  OS << "dist_schedule(" << getOpenMPSimpleClauseTypeName(
986  OMPC_dist_schedule, Node->getDistScheduleKind());
987  if (auto *E = Node->getChunkSize()) {
988  OS << ", ";
989  E->printPretty(OS, nullptr, Policy);
990  }
991  OS << ")";
992 }
993 
994 void OMPClausePrinter::VisitOMPDefaultmapClause(OMPDefaultmapClause *Node) {
995  OS << "defaultmap(";
996  OS << getOpenMPSimpleClauseTypeName(OMPC_defaultmap,
997  Node->getDefaultmapModifier());
998  OS << ": ";
999  OS << getOpenMPSimpleClauseTypeName(OMPC_defaultmap,
1000  Node->getDefaultmapKind());
1001  OS << ")";
1002 }
1003 
1004 void OMPClausePrinter::VisitOMPUseDevicePtrClause(OMPUseDevicePtrClause *Node) {
1005  if (!Node->varlist_empty()) {
1006  OS << "use_device_ptr";
1007  VisitOMPClauseList(Node, '(');
1008  OS << ")";
1009  }
1010 }
1011 
1012 void OMPClausePrinter::VisitOMPIsDevicePtrClause(OMPIsDevicePtrClause *Node) {
1013  if (!Node->varlist_empty()) {
1014  OS << "is_device_ptr";
1015  VisitOMPClauseList(Node, '(');
1016  OS << ")";
1017  }
1018 }
1019 }
1020 
1021 //===----------------------------------------------------------------------===//
1022 // OpenMP directives printing methods
1023 //===----------------------------------------------------------------------===//
1024 
1025 void StmtPrinter::PrintOMPExecutableDirective(OMPExecutableDirective *S) {
1026  OMPClausePrinter Printer(OS, Policy);
1027  ArrayRef<OMPClause *> Clauses = S->clauses();
1028  for (ArrayRef<OMPClause *>::iterator I = Clauses.begin(), E = Clauses.end();
1029  I != E; ++I)
1030  if (*I && !(*I)->isImplicit()) {
1031  Printer.Visit(*I);
1032  OS << ' ';
1033  }
1034  OS << "\n";
1035  if (S->hasAssociatedStmt() && S->getAssociatedStmt()) {
1036  assert(isa<CapturedStmt>(S->getAssociatedStmt()) &&
1037  "Expected captured statement!");
1038  Stmt *CS = cast<CapturedStmt>(S->getAssociatedStmt())->getCapturedStmt();
1039  PrintStmt(CS);
1040  }
1041 }
1042 
1043 void StmtPrinter::VisitOMPParallelDirective(OMPParallelDirective *Node) {
1044  Indent() << "#pragma omp parallel ";
1045  PrintOMPExecutableDirective(Node);
1046 }
1047 
1048 void StmtPrinter::VisitOMPSimdDirective(OMPSimdDirective *Node) {
1049  Indent() << "#pragma omp simd ";
1050  PrintOMPExecutableDirective(Node);
1051 }
1052 
1053 void StmtPrinter::VisitOMPForDirective(OMPForDirective *Node) {
1054  Indent() << "#pragma omp for ";
1055  PrintOMPExecutableDirective(Node);
1056 }
1057 
1058 void StmtPrinter::VisitOMPForSimdDirective(OMPForSimdDirective *Node) {
1059  Indent() << "#pragma omp for simd ";
1060  PrintOMPExecutableDirective(Node);
1061 }
1062 
1063 void StmtPrinter::VisitOMPSectionsDirective(OMPSectionsDirective *Node) {
1064  Indent() << "#pragma omp sections ";
1065  PrintOMPExecutableDirective(Node);
1066 }
1067 
1068 void StmtPrinter::VisitOMPSectionDirective(OMPSectionDirective *Node) {
1069  Indent() << "#pragma omp section";
1070  PrintOMPExecutableDirective(Node);
1071 }
1072 
1073 void StmtPrinter::VisitOMPSingleDirective(OMPSingleDirective *Node) {
1074  Indent() << "#pragma omp single ";
1075  PrintOMPExecutableDirective(Node);
1076 }
1077 
1078 void StmtPrinter::VisitOMPMasterDirective(OMPMasterDirective *Node) {
1079  Indent() << "#pragma omp master";
1080  PrintOMPExecutableDirective(Node);
1081 }
1082 
1083 void StmtPrinter::VisitOMPCriticalDirective(OMPCriticalDirective *Node) {
1084  Indent() << "#pragma omp critical";
1085  if (Node->getDirectiveName().getName()) {
1086  OS << " (";
1087  Node->getDirectiveName().printName(OS);
1088  OS << ")";
1089  }
1090  OS << " ";
1091  PrintOMPExecutableDirective(Node);
1092 }
1093 
1094 void StmtPrinter::VisitOMPParallelForDirective(OMPParallelForDirective *Node) {
1095  Indent() << "#pragma omp parallel for ";
1096  PrintOMPExecutableDirective(Node);
1097 }
1098 
1099 void StmtPrinter::VisitOMPParallelForSimdDirective(
1101  Indent() << "#pragma omp parallel for simd ";
1102  PrintOMPExecutableDirective(Node);
1103 }
1104 
1105 void StmtPrinter::VisitOMPParallelSectionsDirective(
1107  Indent() << "#pragma omp parallel sections ";
1108  PrintOMPExecutableDirective(Node);
1109 }
1110 
1111 void StmtPrinter::VisitOMPTaskDirective(OMPTaskDirective *Node) {
1112  Indent() << "#pragma omp task ";
1113  PrintOMPExecutableDirective(Node);
1114 }
1115 
1116 void StmtPrinter::VisitOMPTaskyieldDirective(OMPTaskyieldDirective *Node) {
1117  Indent() << "#pragma omp taskyield";
1118  PrintOMPExecutableDirective(Node);
1119 }
1120 
1121 void StmtPrinter::VisitOMPBarrierDirective(OMPBarrierDirective *Node) {
1122  Indent() << "#pragma omp barrier";
1123  PrintOMPExecutableDirective(Node);
1124 }
1125 
1126 void StmtPrinter::VisitOMPTaskwaitDirective(OMPTaskwaitDirective *Node) {
1127  Indent() << "#pragma omp taskwait";
1128  PrintOMPExecutableDirective(Node);
1129 }
1130 
1131 void StmtPrinter::VisitOMPTaskgroupDirective(OMPTaskgroupDirective *Node) {
1132  Indent() << "#pragma omp taskgroup ";
1133  PrintOMPExecutableDirective(Node);
1134 }
1135 
1136 void StmtPrinter::VisitOMPFlushDirective(OMPFlushDirective *Node) {
1137  Indent() << "#pragma omp flush ";
1138  PrintOMPExecutableDirective(Node);
1139 }
1140 
1141 void StmtPrinter::VisitOMPOrderedDirective(OMPOrderedDirective *Node) {
1142  Indent() << "#pragma omp ordered ";
1143  PrintOMPExecutableDirective(Node);
1144 }
1145 
1146 void StmtPrinter::VisitOMPAtomicDirective(OMPAtomicDirective *Node) {
1147  Indent() << "#pragma omp atomic ";
1148  PrintOMPExecutableDirective(Node);
1149 }
1150 
1151 void StmtPrinter::VisitOMPTargetDirective(OMPTargetDirective *Node) {
1152  Indent() << "#pragma omp target ";
1153  PrintOMPExecutableDirective(Node);
1154 }
1155 
1156 void StmtPrinter::VisitOMPTargetDataDirective(OMPTargetDataDirective *Node) {
1157  Indent() << "#pragma omp target data ";
1158  PrintOMPExecutableDirective(Node);
1159 }
1160 
1161 void StmtPrinter::VisitOMPTargetEnterDataDirective(
1163  Indent() << "#pragma omp target enter data ";
1164  PrintOMPExecutableDirective(Node);
1165 }
1166 
1167 void StmtPrinter::VisitOMPTargetExitDataDirective(
1169  Indent() << "#pragma omp target exit data ";
1170  PrintOMPExecutableDirective(Node);
1171 }
1172 
1173 void StmtPrinter::VisitOMPTargetParallelDirective(
1175  Indent() << "#pragma omp target parallel ";
1176  PrintOMPExecutableDirective(Node);
1177 }
1178 
1179 void StmtPrinter::VisitOMPTargetParallelForDirective(
1181  Indent() << "#pragma omp target parallel for ";
1182  PrintOMPExecutableDirective(Node);
1183 }
1184 
1185 void StmtPrinter::VisitOMPTeamsDirective(OMPTeamsDirective *Node) {
1186  Indent() << "#pragma omp teams ";
1187  PrintOMPExecutableDirective(Node);
1188 }
1189 
1190 void StmtPrinter::VisitOMPCancellationPointDirective(
1192  Indent() << "#pragma omp cancellation point "
1194  PrintOMPExecutableDirective(Node);
1195 }
1196 
1197 void StmtPrinter::VisitOMPCancelDirective(OMPCancelDirective *Node) {
1198  Indent() << "#pragma omp cancel "
1199  << getOpenMPDirectiveName(Node->getCancelRegion()) << " ";
1200  PrintOMPExecutableDirective(Node);
1201 }
1202 
1203 void StmtPrinter::VisitOMPTaskLoopDirective(OMPTaskLoopDirective *Node) {
1204  Indent() << "#pragma omp taskloop ";
1205  PrintOMPExecutableDirective(Node);
1206 }
1207 
1208 void StmtPrinter::VisitOMPTaskLoopSimdDirective(
1209  OMPTaskLoopSimdDirective *Node) {
1210  Indent() << "#pragma omp taskloop simd ";
1211  PrintOMPExecutableDirective(Node);
1212 }
1213 
1214 void StmtPrinter::VisitOMPDistributeDirective(OMPDistributeDirective *Node) {
1215  Indent() << "#pragma omp distribute ";
1216  PrintOMPExecutableDirective(Node);
1217 }
1218 
1219 void StmtPrinter::VisitOMPTargetUpdateDirective(
1220  OMPTargetUpdateDirective *Node) {
1221  Indent() << "#pragma omp target update ";
1222  PrintOMPExecutableDirective(Node);
1223 }
1224 
1225 void StmtPrinter::VisitOMPDistributeParallelForDirective(
1227  Indent() << "#pragma omp distribute parallel for ";
1228  PrintOMPExecutableDirective(Node);
1229 }
1230 
1231 void StmtPrinter::VisitOMPDistributeParallelForSimdDirective(
1233  Indent() << "#pragma omp distribute parallel for simd ";
1234  PrintOMPExecutableDirective(Node);
1235 }
1236 
1237 void StmtPrinter::VisitOMPDistributeSimdDirective(
1239  Indent() << "#pragma omp distribute simd ";
1240  PrintOMPExecutableDirective(Node);
1241 }
1242 
1243 void StmtPrinter::VisitOMPTargetParallelForSimdDirective(
1245  Indent() << "#pragma omp target parallel for simd ";
1246  PrintOMPExecutableDirective(Node);
1247 }
1248 
1249 void StmtPrinter::VisitOMPTargetSimdDirective(OMPTargetSimdDirective *Node) {
1250  Indent() << "#pragma omp target simd ";
1251  PrintOMPExecutableDirective(Node);
1252 }
1253 
1254 void StmtPrinter::VisitOMPTeamsDistributeDirective(
1256  Indent() << "#pragma omp teams distribute ";
1257  PrintOMPExecutableDirective(Node);
1258 }
1259 
1260 void StmtPrinter::VisitOMPTeamsDistributeSimdDirective(
1262  Indent() << "#pragma omp teams distribute simd ";
1263  PrintOMPExecutableDirective(Node);
1264 }
1265 
1266 void StmtPrinter::VisitOMPTeamsDistributeParallelForSimdDirective(
1268  Indent() << "#pragma omp teams distribute parallel for simd ";
1269  PrintOMPExecutableDirective(Node);
1270 }
1271 
1272 void StmtPrinter::VisitOMPTeamsDistributeParallelForDirective(
1274  Indent() << "#pragma omp teams distribute parallel for ";
1275  PrintOMPExecutableDirective(Node);
1276 }
1277 
1278 void StmtPrinter::VisitOMPTargetTeamsDirective(OMPTargetTeamsDirective *Node) {
1279  Indent() << "#pragma omp target teams ";
1280  PrintOMPExecutableDirective(Node);
1281 }
1282 
1283 void StmtPrinter::VisitOMPTargetTeamsDistributeDirective(
1285  Indent() << "#pragma omp target teams distribute ";
1286  PrintOMPExecutableDirective(Node);
1287 }
1288 
1289 void StmtPrinter::VisitOMPTargetTeamsDistributeParallelForDirective(
1291  Indent() << "#pragma omp target teams distribute parallel for ";
1292  PrintOMPExecutableDirective(Node);
1293 }
1294 
1295 void StmtPrinter::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
1297  Indent() << "#pragma omp target teams distribute parallel for simd ";
1298  PrintOMPExecutableDirective(Node);
1299 }
1300 
1301 void StmtPrinter::VisitOMPTargetTeamsDistributeSimdDirective(
1303  Indent() << "#pragma omp target teams distribute simd ";
1304  PrintOMPExecutableDirective(Node);
1305 }
1306 
1307 //===----------------------------------------------------------------------===//
1308 // Expr printing methods.
1309 //===----------------------------------------------------------------------===//
1310 
1311 void StmtPrinter::VisitDeclRefExpr(DeclRefExpr *Node) {
1312  if (auto *OCED = dyn_cast<OMPCapturedExprDecl>(Node->getDecl())) {
1313  OCED->getInit()->IgnoreImpCasts()->printPretty(OS, nullptr, Policy);
1314  return;
1315  }
1316  if (NestedNameSpecifier *Qualifier = Node->getQualifier())
1317  Qualifier->print(OS, Policy);
1318  if (Node->hasTemplateKeyword())
1319  OS << "template ";
1320  OS << Node->getNameInfo();
1321  if (Node->hasExplicitTemplateArgs())
1323  OS, Node->template_arguments(), Policy);
1324 }
1325 
1326 void StmtPrinter::VisitDependentScopeDeclRefExpr(
1327  DependentScopeDeclRefExpr *Node) {
1328  if (NestedNameSpecifier *Qualifier = Node->getQualifier())
1329  Qualifier->print(OS, Policy);
1330  if (Node->hasTemplateKeyword())
1331  OS << "template ";
1332  OS << Node->getNameInfo();
1333  if (Node->hasExplicitTemplateArgs())
1335  OS, Node->template_arguments(), Policy);
1336 }
1337 
1338 void StmtPrinter::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *Node) {
1339  if (Node->getQualifier())
1340  Node->getQualifier()->print(OS, Policy);
1341  if (Node->hasTemplateKeyword())
1342  OS << "template ";
1343  OS << Node->getNameInfo();
1344  if (Node->hasExplicitTemplateArgs())
1346  OS, Node->template_arguments(), Policy);
1347 }
1348 
1349 void StmtPrinter::VisitObjCIvarRefExpr(ObjCIvarRefExpr *Node) {
1350  if (Node->getBase()) {
1351  PrintExpr(Node->getBase());
1352  OS << (Node->isArrow() ? "->" : ".");
1353  }
1354  OS << *Node->getDecl();
1355 }
1356 
1357 void StmtPrinter::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *Node) {
1358  if (Node->isSuperReceiver())
1359  OS << "super.";
1360  else if (Node->isObjectReceiver() && Node->getBase()) {
1361  PrintExpr(Node->getBase());
1362  OS << ".";
1363  } else if (Node->isClassReceiver() && Node->getClassReceiver()) {
1364  OS << Node->getClassReceiver()->getName() << ".";
1365  }
1366 
1367  if (Node->isImplicitProperty())
1369  else
1370  OS << Node->getExplicitProperty()->getName();
1371 }
1372 
1373 void StmtPrinter::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *Node) {
1374 
1375  PrintExpr(Node->getBaseExpr());
1376  OS << "[";
1377  PrintExpr(Node->getKeyExpr());
1378  OS << "]";
1379 }
1380 
1381 void StmtPrinter::VisitPredefinedExpr(PredefinedExpr *Node) {
1383 }
1384 
1385 void StmtPrinter::VisitCharacterLiteral(CharacterLiteral *Node) {
1386  unsigned value = Node->getValue();
1387 
1388  switch (Node->getKind()) {
1389  case CharacterLiteral::Ascii: break; // no prefix.
1390  case CharacterLiteral::Wide: OS << 'L'; break;
1391  case CharacterLiteral::UTF8: OS << "u8"; break;
1392  case CharacterLiteral::UTF16: OS << 'u'; break;
1393  case CharacterLiteral::UTF32: OS << 'U'; break;
1394  }
1395 
1396  switch (value) {
1397  case '\\':
1398  OS << "'\\\\'";
1399  break;
1400  case '\'':
1401  OS << "'\\''";
1402  break;
1403  case '\a':
1404  // TODO: K&R: the meaning of '\\a' is different in traditional C
1405  OS << "'\\a'";
1406  break;
1407  case '\b':
1408  OS << "'\\b'";
1409  break;
1410  // Nonstandard escape sequence.
1411  /*case '\e':
1412  OS << "'\\e'";
1413  break;*/
1414  case '\f':
1415  OS << "'\\f'";
1416  break;
1417  case '\n':
1418  OS << "'\\n'";
1419  break;
1420  case '\r':
1421  OS << "'\\r'";
1422  break;
1423  case '\t':
1424  OS << "'\\t'";
1425  break;
1426  case '\v':
1427  OS << "'\\v'";
1428  break;
1429  default:
1430  // A character literal might be sign-extended, which
1431  // would result in an invalid \U escape sequence.
1432  // FIXME: multicharacter literals such as '\xFF\xFF\xFF\xFF'
1433  // are not correctly handled.
1434  if ((value & ~0xFFu) == ~0xFFu && Node->getKind() == CharacterLiteral::Ascii)
1435  value &= 0xFFu;
1436  if (value < 256 && isPrintable((unsigned char)value))
1437  OS << "'" << (char)value << "'";
1438  else if (value < 256)
1439  OS << "'\\x" << llvm::format("%02x", value) << "'";
1440  else if (value <= 0xFFFF)
1441  OS << "'\\u" << llvm::format("%04x", value) << "'";
1442  else
1443  OS << "'\\U" << llvm::format("%08x", value) << "'";
1444  }
1445 }
1446 
1447 /// Prints the given expression using the original source text. Returns true on
1448 /// success, false otherwise.
1449 static bool printExprAsWritten(raw_ostream &OS, Expr *E,
1450  const ASTContext *Context) {
1451  if (!Context)
1452  return false;
1453  bool Invalid = false;
1454  StringRef Source = Lexer::getSourceText(
1456  Context->getSourceManager(), Context->getLangOpts(), &Invalid);
1457  if (!Invalid) {
1458  OS << Source;
1459  return true;
1460  }
1461  return false;
1462 }
1463 
1464 void StmtPrinter::VisitIntegerLiteral(IntegerLiteral *Node) {
1465  if (Policy.ConstantsAsWritten && printExprAsWritten(OS, Node, Context))
1466  return;
1467  bool isSigned = Node->getType()->isSignedIntegerType();
1468  OS << Node->getValue().toString(10, isSigned);
1469 
1470  // Emit suffixes. Integer literals are always a builtin integer type.
1471  switch (Node->getType()->getAs<BuiltinType>()->getKind()) {
1472  default: llvm_unreachable("Unexpected type for integer literal!");
1473  case BuiltinType::Char_S:
1474  case BuiltinType::Char_U: OS << "i8"; break;
1475  case BuiltinType::UChar: OS << "Ui8"; break;
1476  case BuiltinType::Short: OS << "i16"; break;
1477  case BuiltinType::UShort: OS << "Ui16"; break;
1478  case BuiltinType::Int: break; // no suffix.
1479  case BuiltinType::UInt: OS << 'U'; break;
1480  case BuiltinType::Long: OS << 'L'; break;
1481  case BuiltinType::ULong: OS << "UL"; break;
1482  case BuiltinType::LongLong: OS << "LL"; break;
1483  case BuiltinType::ULongLong: OS << "ULL"; break;
1484  }
1485 }
1486 
1487 static void PrintFloatingLiteral(raw_ostream &OS, FloatingLiteral *Node,
1488  bool PrintSuffix) {
1489  SmallString<16> Str;
1490  Node->getValue().toString(Str);
1491  OS << Str;
1492  if (Str.find_first_not_of("-0123456789") == StringRef::npos)
1493  OS << '.'; // Trailing dot in order to separate from ints.
1494 
1495  if (!PrintSuffix)
1496  return;
1497 
1498  // Emit suffixes. Float literals are always a builtin float type.
1499  switch (Node->getType()->getAs<BuiltinType>()->getKind()) {
1500  default: llvm_unreachable("Unexpected type for float literal!");
1501  case BuiltinType::Half: break; // FIXME: suffix?
1502  case BuiltinType::Double: break; // no suffix.
1503  case BuiltinType::Float16: OS << "F16"; break;
1504  case BuiltinType::Float: OS << 'F'; break;
1505  case BuiltinType::LongDouble: OS << 'L'; break;
1506  case BuiltinType::Float128: OS << 'Q'; break;
1507  }
1508 }
1509 
1510 void StmtPrinter::VisitFloatingLiteral(FloatingLiteral *Node) {
1511  if (Policy.ConstantsAsWritten && printExprAsWritten(OS, Node, Context))
1512  return;
1513  PrintFloatingLiteral(OS, Node, /*PrintSuffix=*/true);
1514 }
1515 
1516 void StmtPrinter::VisitImaginaryLiteral(ImaginaryLiteral *Node) {
1517  PrintExpr(Node->getSubExpr());
1518  OS << "i";
1519 }
1520 
1521 void StmtPrinter::VisitStringLiteral(StringLiteral *Str) {
1522  Str->outputString(OS);
1523 }
1524 void StmtPrinter::VisitParenExpr(ParenExpr *Node) {
1525  OS << "(";
1526  PrintExpr(Node->getSubExpr());
1527  OS << ")";
1528 }
1529 void StmtPrinter::VisitUnaryOperator(UnaryOperator *Node) {
1530  if (!Node->isPostfix()) {
1531  OS << UnaryOperator::getOpcodeStr(Node->getOpcode());
1532 
1533  // Print a space if this is an "identifier operator" like __real, or if
1534  // it might be concatenated incorrectly like '+'.
1535  switch (Node->getOpcode()) {
1536  default: break;
1537  case UO_Real:
1538  case UO_Imag:
1539  case UO_Extension:
1540  OS << ' ';
1541  break;
1542  case UO_Plus:
1543  case UO_Minus:
1544  if (isa<UnaryOperator>(Node->getSubExpr()))
1545  OS << ' ';
1546  break;
1547  }
1548  }
1549  PrintExpr(Node->getSubExpr());
1550 
1551  if (Node->isPostfix())
1552  OS << UnaryOperator::getOpcodeStr(Node->getOpcode());
1553 }
1554 
1555 void StmtPrinter::VisitOffsetOfExpr(OffsetOfExpr *Node) {
1556  OS << "__builtin_offsetof(";
1557  Node->getTypeSourceInfo()->getType().print(OS, Policy);
1558  OS << ", ";
1559  bool PrintedSomething = false;
1560  for (unsigned i = 0, n = Node->getNumComponents(); i < n; ++i) {
1561  OffsetOfNode ON = Node->getComponent(i);
1562  if (ON.getKind() == OffsetOfNode::Array) {
1563  // Array node
1564  OS << "[";
1565  PrintExpr(Node->getIndexExpr(ON.getArrayExprIndex()));
1566  OS << "]";
1567  PrintedSomething = true;
1568  continue;
1569  }
1570 
1571  // Skip implicit base indirections.
1572  if (ON.getKind() == OffsetOfNode::Base)
1573  continue;
1574 
1575  // Field or identifier node.
1576  IdentifierInfo *Id = ON.getFieldName();
1577  if (!Id)
1578  continue;
1579 
1580  if (PrintedSomething)
1581  OS << ".";
1582  else
1583  PrintedSomething = true;
1584  OS << Id->getName();
1585  }
1586  OS << ")";
1587 }
1588 
1589 void StmtPrinter::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *Node){
1590  switch(Node->getKind()) {
1591  case UETT_SizeOf:
1592  OS << "sizeof";
1593  break;
1594  case UETT_AlignOf:
1595  if (Policy.Alignof)
1596  OS << "alignof";
1597  else if (Policy.UnderscoreAlignof)
1598  OS << "_Alignof";
1599  else
1600  OS << "__alignof";
1601  break;
1602  case UETT_VecStep:
1603  OS << "vec_step";
1604  break;
1606  OS << "__builtin_omp_required_simd_align";
1607  break;
1608  }
1609  if (Node->isArgumentType()) {
1610  OS << '(';
1611  Node->getArgumentType().print(OS, Policy);
1612  OS << ')';
1613  } else {
1614  OS << " ";
1615  PrintExpr(Node->getArgumentExpr());
1616  }
1617 }
1618 
1619 void StmtPrinter::VisitGenericSelectionExpr(GenericSelectionExpr *Node) {
1620  OS << "_Generic(";
1621  PrintExpr(Node->getControllingExpr());
1622  for (unsigned i = 0; i != Node->getNumAssocs(); ++i) {
1623  OS << ", ";
1624  QualType T = Node->getAssocType(i);
1625  if (T.isNull())
1626  OS << "default";
1627  else
1628  T.print(OS, Policy);
1629  OS << ": ";
1630  PrintExpr(Node->getAssocExpr(i));
1631  }
1632  OS << ")";
1633 }
1634 
1635 void StmtPrinter::VisitArraySubscriptExpr(ArraySubscriptExpr *Node) {
1636  PrintExpr(Node->getLHS());
1637  OS << "[";
1638  PrintExpr(Node->getRHS());
1639  OS << "]";
1640 }
1641 
1642 void StmtPrinter::VisitOMPArraySectionExpr(OMPArraySectionExpr *Node) {
1643  PrintExpr(Node->getBase());
1644  OS << "[";
1645  if (Node->getLowerBound())
1646  PrintExpr(Node->getLowerBound());
1647  if (Node->getColonLoc().isValid()) {
1648  OS << ":";
1649  if (Node->getLength())
1650  PrintExpr(Node->getLength());
1651  }
1652  OS << "]";
1653 }
1654 
1655 void StmtPrinter::PrintCallArgs(CallExpr *Call) {
1656  for (unsigned i = 0, e = Call->getNumArgs(); i != e; ++i) {
1657  if (isa<CXXDefaultArgExpr>(Call->getArg(i))) {
1658  // Don't print any defaulted arguments
1659  break;
1660  }
1661 
1662  if (i) OS << ", ";
1663  PrintExpr(Call->getArg(i));
1664  }
1665 }
1666 
1667 void StmtPrinter::VisitCallExpr(CallExpr *Call) {
1668  PrintExpr(Call->getCallee());
1669  OS << "(";
1670  PrintCallArgs(Call);
1671  OS << ")";
1672 }
1673 void StmtPrinter::VisitMemberExpr(MemberExpr *Node) {
1674  // FIXME: Suppress printing implicit bases (like "this")
1675  PrintExpr(Node->getBase());
1676 
1677  MemberExpr *ParentMember = dyn_cast<MemberExpr>(Node->getBase());
1678  FieldDecl *ParentDecl = ParentMember
1679  ? dyn_cast<FieldDecl>(ParentMember->getMemberDecl()) : nullptr;
1680 
1681  if (!ParentDecl || !ParentDecl->isAnonymousStructOrUnion())
1682  OS << (Node->isArrow() ? "->" : ".");
1683 
1684  if (FieldDecl *FD = dyn_cast<FieldDecl>(Node->getMemberDecl()))
1685  if (FD->isAnonymousStructOrUnion())
1686  return;
1687 
1688  if (NestedNameSpecifier *Qualifier = Node->getQualifier())
1689  Qualifier->print(OS, Policy);
1690  if (Node->hasTemplateKeyword())
1691  OS << "template ";
1692  OS << Node->getMemberNameInfo();
1693  if (Node->hasExplicitTemplateArgs())
1695  OS, Node->template_arguments(), Policy);
1696 }
1697 void StmtPrinter::VisitObjCIsaExpr(ObjCIsaExpr *Node) {
1698  PrintExpr(Node->getBase());
1699  OS << (Node->isArrow() ? "->isa" : ".isa");
1700 }
1701 
1702 void StmtPrinter::VisitExtVectorElementExpr(ExtVectorElementExpr *Node) {
1703  PrintExpr(Node->getBase());
1704  OS << ".";
1705  OS << Node->getAccessor().getName();
1706 }
1707 void StmtPrinter::VisitCStyleCastExpr(CStyleCastExpr *Node) {
1708  OS << '(';
1709  Node->getTypeAsWritten().print(OS, Policy);
1710  OS << ')';
1711  PrintExpr(Node->getSubExpr());
1712 }
1713 void StmtPrinter::VisitCompoundLiteralExpr(CompoundLiteralExpr *Node) {
1714  OS << '(';
1715  Node->getType().print(OS, Policy);
1716  OS << ')';
1717  PrintExpr(Node->getInitializer());
1718 }
1719 void StmtPrinter::VisitImplicitCastExpr(ImplicitCastExpr *Node) {
1720  // No need to print anything, simply forward to the subexpression.
1721  PrintExpr(Node->getSubExpr());
1722 }
1723 void StmtPrinter::VisitBinaryOperator(BinaryOperator *Node) {
1724  PrintExpr(Node->getLHS());
1725  OS << " " << BinaryOperator::getOpcodeStr(Node->getOpcode()) << " ";
1726  PrintExpr(Node->getRHS());
1727 }
1728 void StmtPrinter::VisitCompoundAssignOperator(CompoundAssignOperator *Node) {
1729  PrintExpr(Node->getLHS());
1730  OS << " " << BinaryOperator::getOpcodeStr(Node->getOpcode()) << " ";
1731  PrintExpr(Node->getRHS());
1732 }
1733 void StmtPrinter::VisitConditionalOperator(ConditionalOperator *Node) {
1734  PrintExpr(Node->getCond());
1735  OS << " ? ";
1736  PrintExpr(Node->getLHS());
1737  OS << " : ";
1738  PrintExpr(Node->getRHS());
1739 }
1740 
1741 // GNU extensions.
1742 
1743 void
1744 StmtPrinter::VisitBinaryConditionalOperator(BinaryConditionalOperator *Node) {
1745  PrintExpr(Node->getCommon());
1746  OS << " ?: ";
1747  PrintExpr(Node->getFalseExpr());
1748 }
1749 void StmtPrinter::VisitAddrLabelExpr(AddrLabelExpr *Node) {
1750  OS << "&&" << Node->getLabel()->getName();
1751 }
1752 
1753 void StmtPrinter::VisitStmtExpr(StmtExpr *E) {
1754  OS << "(";
1755  PrintRawCompoundStmt(E->getSubStmt());
1756  OS << ")";
1757 }
1758 
1759 void StmtPrinter::VisitChooseExpr(ChooseExpr *Node) {
1760  OS << "__builtin_choose_expr(";
1761  PrintExpr(Node->getCond());
1762  OS << ", ";
1763  PrintExpr(Node->getLHS());
1764  OS << ", ";
1765  PrintExpr(Node->getRHS());
1766  OS << ")";
1767 }
1768 
1769 void StmtPrinter::VisitGNUNullExpr(GNUNullExpr *) {
1770  OS << "__null";
1771 }
1772 
1773 void StmtPrinter::VisitShuffleVectorExpr(ShuffleVectorExpr *Node) {
1774  OS << "__builtin_shufflevector(";
1775  for (unsigned i = 0, e = Node->getNumSubExprs(); i != e; ++i) {
1776  if (i) OS << ", ";
1777  PrintExpr(Node->getExpr(i));
1778  }
1779  OS << ")";
1780 }
1781 
1782 void StmtPrinter::VisitConvertVectorExpr(ConvertVectorExpr *Node) {
1783  OS << "__builtin_convertvector(";
1784  PrintExpr(Node->getSrcExpr());
1785  OS << ", ";
1786  Node->getType().print(OS, Policy);
1787  OS << ")";
1788 }
1789 
1790 void StmtPrinter::VisitInitListExpr(InitListExpr* Node) {
1791  if (Node->getSyntacticForm()) {
1792  Visit(Node->getSyntacticForm());
1793  return;
1794  }
1795 
1796  OS << "{";
1797  for (unsigned i = 0, e = Node->getNumInits(); i != e; ++i) {
1798  if (i) OS << ", ";
1799  if (Node->getInit(i))
1800  PrintExpr(Node->getInit(i));
1801  else
1802  OS << "{}";
1803  }
1804  OS << "}";
1805 }
1806 
1807 void StmtPrinter::VisitArrayInitLoopExpr(ArrayInitLoopExpr *Node) {
1808  // There's no way to express this expression in any of our supported
1809  // languages, so just emit something terse and (hopefully) clear.
1810  OS << "{";
1811  PrintExpr(Node->getSubExpr());
1812  OS << "}";
1813 }
1814 
1815 void StmtPrinter::VisitArrayInitIndexExpr(ArrayInitIndexExpr *Node) {
1816  OS << "*";
1817 }
1818 
1819 void StmtPrinter::VisitParenListExpr(ParenListExpr* Node) {
1820  OS << "(";
1821  for (unsigned i = 0, e = Node->getNumExprs(); i != e; ++i) {
1822  if (i) OS << ", ";
1823  PrintExpr(Node->getExpr(i));
1824  }
1825  OS << ")";
1826 }
1827 
1828 void StmtPrinter::VisitDesignatedInitExpr(DesignatedInitExpr *Node) {
1829  bool NeedsEquals = true;
1830  for (const DesignatedInitExpr::Designator &D : Node->designators()) {
1831  if (D.isFieldDesignator()) {
1832  if (D.getDotLoc().isInvalid()) {
1833  if (IdentifierInfo *II = D.getFieldName()) {
1834  OS << II->getName() << ":";
1835  NeedsEquals = false;
1836  }
1837  } else {
1838  OS << "." << D.getFieldName()->getName();
1839  }
1840  } else {
1841  OS << "[";
1842  if (D.isArrayDesignator()) {
1843  PrintExpr(Node->getArrayIndex(D));
1844  } else {
1845  PrintExpr(Node->getArrayRangeStart(D));
1846  OS << " ... ";
1847  PrintExpr(Node->getArrayRangeEnd(D));
1848  }
1849  OS << "]";
1850  }
1851  }
1852 
1853  if (NeedsEquals)
1854  OS << " = ";
1855  else
1856  OS << " ";
1857  PrintExpr(Node->getInit());
1858 }
1859 
1860 void StmtPrinter::VisitDesignatedInitUpdateExpr(
1861  DesignatedInitUpdateExpr *Node) {
1862  OS << "{";
1863  OS << "/*base*/";
1864  PrintExpr(Node->getBase());
1865  OS << ", ";
1866 
1867  OS << "/*updater*/";
1868  PrintExpr(Node->getUpdater());
1869  OS << "}";
1870 }
1871 
1872 void StmtPrinter::VisitNoInitExpr(NoInitExpr *Node) {
1873  OS << "/*no init*/";
1874 }
1875 
1876 void StmtPrinter::VisitImplicitValueInitExpr(ImplicitValueInitExpr *Node) {
1877  if (Node->getType()->getAsCXXRecordDecl()) {
1878  OS << "/*implicit*/";
1879  Node->getType().print(OS, Policy);
1880  OS << "()";
1881  } else {
1882  OS << "/*implicit*/(";
1883  Node->getType().print(OS, Policy);
1884  OS << ')';
1885  if (Node->getType()->isRecordType())
1886  OS << "{}";
1887  else
1888  OS << 0;
1889  }
1890 }
1891 
1892 void StmtPrinter::VisitVAArgExpr(VAArgExpr *Node) {
1893  OS << "__builtin_va_arg(";
1894  PrintExpr(Node->getSubExpr());
1895  OS << ", ";
1896  Node->getType().print(OS, Policy);
1897  OS << ")";
1898 }
1899 
1900 void StmtPrinter::VisitPseudoObjectExpr(PseudoObjectExpr *Node) {
1901  PrintExpr(Node->getSyntacticForm());
1902 }
1903 
1904 void StmtPrinter::VisitAtomicExpr(AtomicExpr *Node) {
1905  const char *Name = nullptr;
1906  switch (Node->getOp()) {
1907 #define BUILTIN(ID, TYPE, ATTRS)
1908 #define ATOMIC_BUILTIN(ID, TYPE, ATTRS) \
1909  case AtomicExpr::AO ## ID: \
1910  Name = #ID "("; \
1911  break;
1912 #include "clang/Basic/Builtins.def"
1913  }
1914  OS << Name;
1915 
1916  // AtomicExpr stores its subexpressions in a permuted order.
1917  PrintExpr(Node->getPtr());
1918  if (Node->getOp() != AtomicExpr::AO__c11_atomic_load &&
1919  Node->getOp() != AtomicExpr::AO__atomic_load_n &&
1920  Node->getOp() != AtomicExpr::AO__opencl_atomic_load) {
1921  OS << ", ";
1922  PrintExpr(Node->getVal1());
1923  }
1924  if (Node->getOp() == AtomicExpr::AO__atomic_exchange ||
1925  Node->isCmpXChg()) {
1926  OS << ", ";
1927  PrintExpr(Node->getVal2());
1928  }
1929  if (Node->getOp() == AtomicExpr::AO__atomic_compare_exchange ||
1930  Node->getOp() == AtomicExpr::AO__atomic_compare_exchange_n) {
1931  OS << ", ";
1932  PrintExpr(Node->getWeak());
1933  }
1934  if (Node->getOp() != AtomicExpr::AO__c11_atomic_init &&
1935  Node->getOp() != AtomicExpr::AO__opencl_atomic_init) {
1936  OS << ", ";
1937  PrintExpr(Node->getOrder());
1938  }
1939  if (Node->isCmpXChg()) {
1940  OS << ", ";
1941  PrintExpr(Node->getOrderFail());
1942  }
1943  OS << ")";
1944 }
1945 
1946 // C++
1947 void StmtPrinter::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *Node) {
1948  const char *OpStrings[NUM_OVERLOADED_OPERATORS] = {
1949  "",
1950 #define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \
1951  Spelling,
1952 #include "clang/Basic/OperatorKinds.def"
1953  };
1954 
1956  if (Kind == OO_PlusPlus || Kind == OO_MinusMinus) {
1957  if (Node->getNumArgs() == 1) {
1958  OS << OpStrings[Kind] << ' ';
1959  PrintExpr(Node->getArg(0));
1960  } else {
1961  PrintExpr(Node->getArg(0));
1962  OS << ' ' << OpStrings[Kind];
1963  }
1964  } else if (Kind == OO_Arrow) {
1965  PrintExpr(Node->getArg(0));
1966  } else if (Kind == OO_Call) {
1967  PrintExpr(Node->getArg(0));
1968  OS << '(';
1969  for (unsigned ArgIdx = 1; ArgIdx < Node->getNumArgs(); ++ArgIdx) {
1970  if (ArgIdx > 1)
1971  OS << ", ";
1972  if (!isa<CXXDefaultArgExpr>(Node->getArg(ArgIdx)))
1973  PrintExpr(Node->getArg(ArgIdx));
1974  }
1975  OS << ')';
1976  } else if (Kind == OO_Subscript) {
1977  PrintExpr(Node->getArg(0));
1978  OS << '[';
1979  PrintExpr(Node->getArg(1));
1980  OS << ']';
1981  } else if (Node->getNumArgs() == 1) {
1982  OS << OpStrings[Kind] << ' ';
1983  PrintExpr(Node->getArg(0));
1984  } else if (Node->getNumArgs() == 2) {
1985  PrintExpr(Node->getArg(0));
1986  OS << ' ' << OpStrings[Kind] << ' ';
1987  PrintExpr(Node->getArg(1));
1988  } else {
1989  llvm_unreachable("unknown overloaded operator");
1990  }
1991 }
1992 
1993 void StmtPrinter::VisitCXXMemberCallExpr(CXXMemberCallExpr *Node) {
1994  // If we have a conversion operator call only print the argument.
1995  CXXMethodDecl *MD = Node->getMethodDecl();
1996  if (MD && isa<CXXConversionDecl>(MD)) {
1997  PrintExpr(Node->getImplicitObjectArgument());
1998  return;
1999  }
2000  VisitCallExpr(cast<CallExpr>(Node));
2001 }
2002 
2003 void StmtPrinter::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *Node) {
2004  PrintExpr(Node->getCallee());
2005  OS << "<<<";
2006  PrintCallArgs(Node->getConfig());
2007  OS << ">>>(";
2008  PrintCallArgs(Node);
2009  OS << ")";
2010 }
2011 
2012 void StmtPrinter::VisitCXXNamedCastExpr(CXXNamedCastExpr *Node) {
2013  OS << Node->getCastName() << '<';
2014  Node->getTypeAsWritten().print(OS, Policy);
2015  OS << ">(";
2016  PrintExpr(Node->getSubExpr());
2017  OS << ")";
2018 }
2019 
2020 void StmtPrinter::VisitCXXStaticCastExpr(CXXStaticCastExpr *Node) {
2021  VisitCXXNamedCastExpr(Node);
2022 }
2023 
2024 void StmtPrinter::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *Node) {
2025  VisitCXXNamedCastExpr(Node);
2026 }
2027 
2028 void StmtPrinter::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *Node) {
2029  VisitCXXNamedCastExpr(Node);
2030 }
2031 
2032 void StmtPrinter::VisitCXXConstCastExpr(CXXConstCastExpr *Node) {
2033  VisitCXXNamedCastExpr(Node);
2034 }
2035 
2036 void StmtPrinter::VisitCXXTypeidExpr(CXXTypeidExpr *Node) {
2037  OS << "typeid(";
2038  if (Node->isTypeOperand()) {
2039  Node->getTypeOperandSourceInfo()->getType().print(OS, Policy);
2040  } else {
2041  PrintExpr(Node->getExprOperand());
2042  }
2043  OS << ")";
2044 }
2045 
2046 void StmtPrinter::VisitCXXUuidofExpr(CXXUuidofExpr *Node) {
2047  OS << "__uuidof(";
2048  if (Node->isTypeOperand()) {
2049  Node->getTypeOperandSourceInfo()->getType().print(OS, Policy);
2050  } else {
2051  PrintExpr(Node->getExprOperand());
2052  }
2053  OS << ")";
2054 }
2055 
2056 void StmtPrinter::VisitMSPropertyRefExpr(MSPropertyRefExpr *Node) {
2057  PrintExpr(Node->getBaseExpr());
2058  if (Node->isArrow())
2059  OS << "->";
2060  else
2061  OS << ".";
2062  if (NestedNameSpecifier *Qualifier =
2064  Qualifier->print(OS, Policy);
2065  OS << Node->getPropertyDecl()->getDeclName();
2066 }
2067 
2068 void StmtPrinter::VisitMSPropertySubscriptExpr(MSPropertySubscriptExpr *Node) {
2069  PrintExpr(Node->getBase());
2070  OS << "[";
2071  PrintExpr(Node->getIdx());
2072  OS << "]";
2073 }
2074 
2075 void StmtPrinter::VisitUserDefinedLiteral(UserDefinedLiteral *Node) {
2076  switch (Node->getLiteralOperatorKind()) {
2078  OS << cast<StringLiteral>(Node->getArg(0)->IgnoreImpCasts())->getString();
2079  break;
2081  DeclRefExpr *DRE = cast<DeclRefExpr>(Node->getCallee()->IgnoreImpCasts());
2082  const TemplateArgumentList *Args =
2083  cast<FunctionDecl>(DRE->getDecl())->getTemplateSpecializationArgs();
2084  assert(Args);
2085 
2086  if (Args->size() != 1) {
2087  OS << "operator\"\"" << Node->getUDSuffix()->getName();
2089  OS, Args->asArray(), Policy);
2090  OS << "()";
2091  return;
2092  }
2093 
2094  const TemplateArgument &Pack = Args->get(0);
2095  for (const auto &P : Pack.pack_elements()) {
2096  char C = (char)P.getAsIntegral().getZExtValue();
2097  OS << C;
2098  }
2099  break;
2100  }
2102  // Print integer literal without suffix.
2103  IntegerLiteral *Int = cast<IntegerLiteral>(Node->getCookedLiteral());
2104  OS << Int->getValue().toString(10, /*isSigned*/false);
2105  break;
2106  }
2108  // Print floating literal without suffix.
2109  FloatingLiteral *Float = cast<FloatingLiteral>(Node->getCookedLiteral());
2110  PrintFloatingLiteral(OS, Float, /*PrintSuffix=*/false);
2111  break;
2112  }
2115  PrintExpr(Node->getCookedLiteral());
2116  break;
2117  }
2118  OS << Node->getUDSuffix()->getName();
2119 }
2120 
2121 void StmtPrinter::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *Node) {
2122  OS << (Node->getValue() ? "true" : "false");
2123 }
2124 
2125 void StmtPrinter::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *Node) {
2126  OS << "nullptr";
2127 }
2128 
2129 void StmtPrinter::VisitCXXThisExpr(CXXThisExpr *Node) {
2130  OS << "this";
2131 }
2132 
2133 void StmtPrinter::VisitCXXThrowExpr(CXXThrowExpr *Node) {
2134  if (!Node->getSubExpr())
2135  OS << "throw";
2136  else {
2137  OS << "throw ";
2138  PrintExpr(Node->getSubExpr());
2139  }
2140 }
2141 
2142 void StmtPrinter::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *Node) {
2143  // Nothing to print: we picked up the default argument.
2144 }
2145 
2146 void StmtPrinter::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *Node) {
2147  // Nothing to print: we picked up the default initializer.
2148 }
2149 
2150 void StmtPrinter::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *Node) {
2151  Node->getType().print(OS, Policy);
2152  // If there are no parens, this is list-initialization, and the braces are
2153  // part of the syntax of the inner construct.
2154  if (Node->getLParenLoc().isValid())
2155  OS << "(";
2156  PrintExpr(Node->getSubExpr());
2157  if (Node->getLParenLoc().isValid())
2158  OS << ")";
2159 }
2160 
2161 void StmtPrinter::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *Node) {
2162  PrintExpr(Node->getSubExpr());
2163 }
2164 
2165 void StmtPrinter::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *Node) {
2166  Node->getType().print(OS, Policy);
2167  if (Node->isStdInitListInitialization())
2168  /* Nothing to do; braces are part of creating the std::initializer_list. */;
2169  else if (Node->isListInitialization())
2170  OS << "{";
2171  else
2172  OS << "(";
2174  ArgEnd = Node->arg_end();
2175  Arg != ArgEnd; ++Arg) {
2176  if ((*Arg)->isDefaultArgument())
2177  break;
2178  if (Arg != Node->arg_begin())
2179  OS << ", ";
2180  PrintExpr(*Arg);
2181  }
2182  if (Node->isStdInitListInitialization())
2183  /* See above. */;
2184  else if (Node->isListInitialization())
2185  OS << "}";
2186  else
2187  OS << ")";
2188 }
2189 
2190 void StmtPrinter::VisitLambdaExpr(LambdaExpr *Node) {
2191  OS << '[';
2192  bool NeedComma = false;
2193  switch (Node->getCaptureDefault()) {
2194  case LCD_None:
2195  break;
2196 
2197  case LCD_ByCopy:
2198  OS << '=';
2199  NeedComma = true;
2200  break;
2201 
2202  case LCD_ByRef:
2203  OS << '&';
2204  NeedComma = true;
2205  break;
2206  }
2208  CEnd = Node->explicit_capture_end();
2209  C != CEnd;
2210  ++C) {
2211  if (NeedComma)
2212  OS << ", ";
2213  NeedComma = true;
2214 
2215  switch (C->getCaptureKind()) {
2216  case LCK_This:
2217  OS << "this";
2218  break;
2219  case LCK_StarThis:
2220  OS << "*this";
2221  break;
2222  case LCK_ByRef:
2223  if (Node->getCaptureDefault() != LCD_ByRef || Node->isInitCapture(C))
2224  OS << '&';
2225  OS << C->getCapturedVar()->getName();
2226  break;
2227 
2228  case LCK_ByCopy:
2229  OS << C->getCapturedVar()->getName();
2230  break;
2231  case LCK_VLAType:
2232  llvm_unreachable("VLA type in explicit captures.");
2233  }
2234 
2235  if (Node->isInitCapture(C))
2236  PrintExpr(C->getCapturedVar()->getInit());
2237  }
2238  OS << ']';
2239 
2240  if (Node->hasExplicitParameters()) {
2241  OS << " (";
2242  CXXMethodDecl *Method = Node->getCallOperator();
2243  NeedComma = false;
2244  for (auto P : Method->parameters()) {
2245  if (NeedComma) {
2246  OS << ", ";
2247  } else {
2248  NeedComma = true;
2249  }
2250  std::string ParamStr = P->getNameAsString();
2251  P->getOriginalType().print(OS, Policy, ParamStr);
2252  }
2253  if (Method->isVariadic()) {
2254  if (NeedComma)
2255  OS << ", ";
2256  OS << "...";
2257  }
2258  OS << ')';
2259 
2260  if (Node->isMutable())
2261  OS << " mutable";
2262 
2263  const FunctionProtoType *Proto
2264  = Method->getType()->getAs<FunctionProtoType>();
2265  Proto->printExceptionSpecification(OS, Policy);
2266 
2267  // FIXME: Attributes
2268 
2269  // Print the trailing return type if it was specified in the source.
2270  if (Node->hasExplicitResultType()) {
2271  OS << " -> ";
2272  Proto->getReturnType().print(OS, Policy);
2273  }
2274  }
2275 
2276  // Print the body.
2277  CompoundStmt *Body = Node->getBody();
2278  OS << ' ';
2279  PrintStmt(Body);
2280 }
2281 
2282 void StmtPrinter::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *Node) {
2283  if (TypeSourceInfo *TSInfo = Node->getTypeSourceInfo())
2284  TSInfo->getType().print(OS, Policy);
2285  else
2286  Node->getType().print(OS, Policy);
2287  OS << "()";
2288 }
2289 
2290 void StmtPrinter::VisitCXXNewExpr(CXXNewExpr *E) {
2291  if (E->isGlobalNew())
2292  OS << "::";
2293  OS << "new ";
2294  unsigned NumPlace = E->getNumPlacementArgs();
2295  if (NumPlace > 0 && !isa<CXXDefaultArgExpr>(E->getPlacementArg(0))) {
2296  OS << "(";
2297  PrintExpr(E->getPlacementArg(0));
2298  for (unsigned i = 1; i < NumPlace; ++i) {
2299  if (isa<CXXDefaultArgExpr>(E->getPlacementArg(i)))
2300  break;
2301  OS << ", ";
2302  PrintExpr(E->getPlacementArg(i));
2303  }
2304  OS << ") ";
2305  }
2306  if (E->isParenTypeId())
2307  OS << "(";
2308  std::string TypeS;
2309  if (Expr *Size = E->getArraySize()) {
2310  llvm::raw_string_ostream s(TypeS);
2311  s << '[';
2312  Size->printPretty(s, Helper, Policy);
2313  s << ']';
2314  }
2315  E->getAllocatedType().print(OS, Policy, TypeS);
2316  if (E->isParenTypeId())
2317  OS << ")";
2318 
2320  if (InitStyle) {
2321  if (InitStyle == CXXNewExpr::CallInit)
2322  OS << "(";
2323  PrintExpr(E->getInitializer());
2324  if (InitStyle == CXXNewExpr::CallInit)
2325  OS << ")";
2326  }
2327 }
2328 
2329 void StmtPrinter::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
2330  if (E->isGlobalDelete())
2331  OS << "::";
2332  OS << "delete ";
2333  if (E->isArrayForm())
2334  OS << "[] ";
2335  PrintExpr(E->getArgument());
2336 }
2337 
2338 void StmtPrinter::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
2339  PrintExpr(E->getBase());
2340  if (E->isArrow())
2341  OS << "->";
2342  else
2343  OS << '.';
2344  if (E->getQualifier())
2345  E->getQualifier()->print(OS, Policy);
2346  OS << "~";
2347 
2349  OS << II->getName();
2350  else
2351  E->getDestroyedType().print(OS, Policy);
2352 }
2353 
2354 void StmtPrinter::VisitCXXConstructExpr(CXXConstructExpr *E) {
2356  OS << "{";
2357 
2358  for (unsigned i = 0, e = E->getNumArgs(); i != e; ++i) {
2359  if (isa<CXXDefaultArgExpr>(E->getArg(i))) {
2360  // Don't print any defaulted arguments
2361  break;
2362  }
2363 
2364  if (i) OS << ", ";
2365  PrintExpr(E->getArg(i));
2366  }
2367 
2369  OS << "}";
2370 }
2371 
2372 void StmtPrinter::VisitCXXInheritedCtorInitExpr(CXXInheritedCtorInitExpr *E) {
2373  // Parens are printed by the surrounding context.
2374  OS << "<forwarded>";
2375 }
2376 
2377 void StmtPrinter::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E) {
2378  PrintExpr(E->getSubExpr());
2379 }
2380 
2381 void StmtPrinter::VisitExprWithCleanups(ExprWithCleanups *E) {
2382  // Just forward to the subexpression.
2383  PrintExpr(E->getSubExpr());
2384 }
2385 
2386 void
2387 StmtPrinter::VisitCXXUnresolvedConstructExpr(
2389  Node->getTypeAsWritten().print(OS, Policy);
2390  OS << "(";
2392  ArgEnd = Node->arg_end();
2393  Arg != ArgEnd; ++Arg) {
2394  if (Arg != Node->arg_begin())
2395  OS << ", ";
2396  PrintExpr(*Arg);
2397  }
2398  OS << ")";
2399 }
2400 
2401 void StmtPrinter::VisitCXXDependentScopeMemberExpr(
2403  if (!Node->isImplicitAccess()) {
2404  PrintExpr(Node->getBase());
2405  OS << (Node->isArrow() ? "->" : ".");
2406  }
2407  if (NestedNameSpecifier *Qualifier = Node->getQualifier())
2408  Qualifier->print(OS, Policy);
2409  if (Node->hasTemplateKeyword())
2410  OS << "template ";
2411  OS << Node->getMemberNameInfo();
2412  if (Node->hasExplicitTemplateArgs())
2414  OS, Node->template_arguments(), Policy);
2415 }
2416 
2417 void StmtPrinter::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *Node) {
2418  if (!Node->isImplicitAccess()) {
2419  PrintExpr(Node->getBase());
2420  OS << (Node->isArrow() ? "->" : ".");
2421  }
2422  if (NestedNameSpecifier *Qualifier = Node->getQualifier())
2423  Qualifier->print(OS, Policy);
2424  if (Node->hasTemplateKeyword())
2425  OS << "template ";
2426  OS << Node->getMemberNameInfo();
2427  if (Node->hasExplicitTemplateArgs())
2429  OS, Node->template_arguments(), Policy);
2430 }
2431 
2432 static const char *getTypeTraitName(TypeTrait TT) {
2433  switch (TT) {
2434 #define TYPE_TRAIT_1(Spelling, Name, Key) \
2435 case clang::UTT_##Name: return #Spelling;
2436 #define TYPE_TRAIT_2(Spelling, Name, Key) \
2437 case clang::BTT_##Name: return #Spelling;
2438 #define TYPE_TRAIT_N(Spelling, Name, Key) \
2439  case clang::TT_##Name: return #Spelling;
2440 #include "clang/Basic/TokenKinds.def"
2441  }
2442  llvm_unreachable("Type trait not covered by switch");
2443 }
2444 
2445 static const char *getTypeTraitName(ArrayTypeTrait ATT) {
2446  switch (ATT) {
2447  case ATT_ArrayRank: return "__array_rank";
2448  case ATT_ArrayExtent: return "__array_extent";
2449  }
2450  llvm_unreachable("Array type trait not covered by switch");
2451 }
2452 
2453 static const char *getExpressionTraitName(ExpressionTrait ET) {
2454  switch (ET) {
2455  case ET_IsLValueExpr: return "__is_lvalue_expr";
2456  case ET_IsRValueExpr: return "__is_rvalue_expr";
2457  }
2458  llvm_unreachable("Expression type trait not covered by switch");
2459 }
2460 
2461 void StmtPrinter::VisitTypeTraitExpr(TypeTraitExpr *E) {
2462  OS << getTypeTraitName(E->getTrait()) << "(";
2463  for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) {
2464  if (I > 0)
2465  OS << ", ";
2466  E->getArg(I)->getType().print(OS, Policy);
2467  }
2468  OS << ")";
2469 }
2470 
2471 void StmtPrinter::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
2472  OS << getTypeTraitName(E->getTrait()) << '(';
2473  E->getQueriedType().print(OS, Policy);
2474  OS << ')';
2475 }
2476 
2477 void StmtPrinter::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
2478  OS << getExpressionTraitName(E->getTrait()) << '(';
2479  PrintExpr(E->getQueriedExpression());
2480  OS << ')';
2481 }
2482 
2483 void StmtPrinter::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
2484  OS << "noexcept(";
2485  PrintExpr(E->getOperand());
2486  OS << ")";
2487 }
2488 
2489 void StmtPrinter::VisitPackExpansionExpr(PackExpansionExpr *E) {
2490  PrintExpr(E->getPattern());
2491  OS << "...";
2492 }
2493 
2494 void StmtPrinter::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
2495  OS << "sizeof...(" << *E->getPack() << ")";
2496 }
2497 
2498 void StmtPrinter::VisitSubstNonTypeTemplateParmPackExpr(
2500  OS << *Node->getParameterPack();
2501 }
2502 
2503 void StmtPrinter::VisitSubstNonTypeTemplateParmExpr(
2505  Visit(Node->getReplacement());
2506 }
2507 
2508 void StmtPrinter::VisitFunctionParmPackExpr(FunctionParmPackExpr *E) {
2509  OS << *E->getParameterPack();
2510 }
2511 
2512 void StmtPrinter::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *Node){
2513  PrintExpr(Node->GetTemporaryExpr());
2514 }
2515 
2516 void StmtPrinter::VisitCXXFoldExpr(CXXFoldExpr *E) {
2517  OS << "(";
2518  if (E->getLHS()) {
2519  PrintExpr(E->getLHS());
2520  OS << " " << BinaryOperator::getOpcodeStr(E->getOperator()) << " ";
2521  }
2522  OS << "...";
2523  if (E->getRHS()) {
2524  OS << " " << BinaryOperator::getOpcodeStr(E->getOperator()) << " ";
2525  PrintExpr(E->getRHS());
2526  }
2527  OS << ")";
2528 }
2529 
2530 // C++ Coroutines TS
2531 
2532 void StmtPrinter::VisitCoroutineBodyStmt(CoroutineBodyStmt *S) {
2533  Visit(S->getBody());
2534 }
2535 
2536 void StmtPrinter::VisitCoreturnStmt(CoreturnStmt *S) {
2537  OS << "co_return";
2538  if (S->getOperand()) {
2539  OS << " ";
2540  Visit(S->getOperand());
2541  }
2542  OS << ";";
2543 }
2544 
2545 void StmtPrinter::VisitCoawaitExpr(CoawaitExpr *S) {
2546  OS << "co_await ";
2547  PrintExpr(S->getOperand());
2548 }
2549 
2550 
2551 void StmtPrinter::VisitDependentCoawaitExpr(DependentCoawaitExpr *S) {
2552  OS << "co_await ";
2553  PrintExpr(S->getOperand());
2554 }
2555 
2556 
2557 void StmtPrinter::VisitCoyieldExpr(CoyieldExpr *S) {
2558  OS << "co_yield ";
2559  PrintExpr(S->getOperand());
2560 }
2561 
2562 // Obj-C
2563 
2564 void StmtPrinter::VisitObjCStringLiteral(ObjCStringLiteral *Node) {
2565  OS << "@";
2566  VisitStringLiteral(Node->getString());
2567 }
2568 
2569 void StmtPrinter::VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
2570  OS << "@";
2571  Visit(E->getSubExpr());
2572 }
2573 
2574 void StmtPrinter::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
2575  OS << "@[ ";
2577  for (auto I = Ch.begin(), E = Ch.end(); I != E; ++I) {
2578  if (I != Ch.begin())
2579  OS << ", ";
2580  Visit(*I);
2581  }
2582  OS << " ]";
2583 }
2584 
2585 void StmtPrinter::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
2586  OS << "@{ ";
2587  for (unsigned I = 0, N = E->getNumElements(); I != N; ++I) {
2588  if (I > 0)
2589  OS << ", ";
2590 
2591  ObjCDictionaryElement Element = E->getKeyValueElement(I);
2592  Visit(Element.Key);
2593  OS << " : ";
2594  Visit(Element.Value);
2595  if (Element.isPackExpansion())
2596  OS << "...";
2597  }
2598  OS << " }";
2599 }
2600 
2601 void StmtPrinter::VisitObjCEncodeExpr(ObjCEncodeExpr *Node) {
2602  OS << "@encode(";
2603  Node->getEncodedType().print(OS, Policy);
2604  OS << ')';
2605 }
2606 
2607 void StmtPrinter::VisitObjCSelectorExpr(ObjCSelectorExpr *Node) {
2608  OS << "@selector(";
2609  Node->getSelector().print(OS);
2610  OS << ')';
2611 }
2612 
2613 void StmtPrinter::VisitObjCProtocolExpr(ObjCProtocolExpr *Node) {
2614  OS << "@protocol(" << *Node->getProtocol() << ')';
2615 }
2616 
2617 void StmtPrinter::VisitObjCMessageExpr(ObjCMessageExpr *Mess) {
2618  OS << "[";
2619  switch (Mess->getReceiverKind()) {
2621  PrintExpr(Mess->getInstanceReceiver());
2622  break;
2623 
2625  Mess->getClassReceiver().print(OS, Policy);
2626  break;
2627 
2630  OS << "Super";
2631  break;
2632  }
2633 
2634  OS << ' ';
2635  Selector selector = Mess->getSelector();
2636  if (selector.isUnarySelector()) {
2637  OS << selector.getNameForSlot(0);
2638  } else {
2639  for (unsigned i = 0, e = Mess->getNumArgs(); i != e; ++i) {
2640  if (i < selector.getNumArgs()) {
2641  if (i > 0) OS << ' ';
2642  if (selector.getIdentifierInfoForSlot(i))
2643  OS << selector.getIdentifierInfoForSlot(i)->getName() << ':';
2644  else
2645  OS << ":";
2646  }
2647  else OS << ", "; // Handle variadic methods.
2648 
2649  PrintExpr(Mess->getArg(i));
2650  }
2651  }
2652  OS << "]";
2653 }
2654 
2655 void StmtPrinter::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *Node) {
2656  OS << (Node->getValue() ? "__objc_yes" : "__objc_no");
2657 }
2658 
2659 void
2660 StmtPrinter::VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
2661  PrintExpr(E->getSubExpr());
2662 }
2663 
2664 void
2665 StmtPrinter::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
2666  OS << '(' << E->getBridgeKindName();
2667  E->getType().print(OS, Policy);
2668  OS << ')';
2669  PrintExpr(E->getSubExpr());
2670 }
2671 
2672 void StmtPrinter::VisitBlockExpr(BlockExpr *Node) {
2673  BlockDecl *BD = Node->getBlockDecl();
2674  OS << "^";
2675 
2676  const FunctionType *AFT = Node->getFunctionType();
2677 
2678  if (isa<FunctionNoProtoType>(AFT)) {
2679  OS << "()";
2680  } else if (!BD->param_empty() || cast<FunctionProtoType>(AFT)->isVariadic()) {
2681  OS << '(';
2682  for (BlockDecl::param_iterator AI = BD->param_begin(),
2683  E = BD->param_end(); AI != E; ++AI) {
2684  if (AI != BD->param_begin()) OS << ", ";
2685  std::string ParamStr = (*AI)->getNameAsString();
2686  (*AI)->getType().print(OS, Policy, ParamStr);
2687  }
2688 
2689  const FunctionProtoType *FT = cast<FunctionProtoType>(AFT);
2690  if (FT->isVariadic()) {
2691  if (!BD->param_empty()) OS << ", ";
2692  OS << "...";
2693  }
2694  OS << ')';
2695  }
2696  OS << "{ }";
2697 }
2698 
2699 void StmtPrinter::VisitOpaqueValueExpr(OpaqueValueExpr *Node) {
2700  PrintExpr(Node->getSourceExpr());
2701 }
2702 
2703 void StmtPrinter::VisitTypoExpr(TypoExpr *Node) {
2704  // TODO: Print something reasonable for a TypoExpr, if necessary.
2705  llvm_unreachable("Cannot print TypoExpr nodes");
2706 }
2707 
2708 void StmtPrinter::VisitAsTypeExpr(AsTypeExpr *Node) {
2709  OS << "__builtin_astype(";
2710  PrintExpr(Node->getSrcExpr());
2711  OS << ", ";
2712  Node->getType().print(OS, Policy);
2713  OS << ")";
2714 }
2715 
2716 //===----------------------------------------------------------------------===//
2717 // Stmt method implementations
2718 //===----------------------------------------------------------------------===//
2719 
2720 void Stmt::dumpPretty(const ASTContext &Context) const {
2721  printPretty(llvm::errs(), nullptr, PrintingPolicy(Context.getLangOpts()));
2722 }
2723 
2724 void Stmt::printPretty(raw_ostream &OS, PrinterHelper *Helper,
2725  const PrintingPolicy &Policy, unsigned Indentation,
2726  const ASTContext *Context) const {
2727  StmtPrinter P(OS, Helper, Policy, Indentation, Context);
2728  P.Visit(const_cast<Stmt*>(this));
2729 }
2730 
2731 //===----------------------------------------------------------------------===//
2732 // PrinterHelper
2733 //===----------------------------------------------------------------------===//
2734 
2735 // Implement virtual destructor.
Expr * getInc()
Definition: Stmt.h:1213
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
Definition: ExprObjC.h:539
ObjCIndirectCopyRestoreExpr - Represents the passing of a function argument by indirect copy-restore ...
Definition: ExprObjC.h:1464
A call to an overloaded operator written using operator syntax.
Definition: ExprCXX.h:52
The receiver is the instance of the superclass object.
Definition: ExprObjC.h:1009
Represents a single C99 designator.
Definition: Expr.h:4182
Raw form: operator "" X (const char *)
Definition: ExprCXX.h:439
Expr * getVal2() const
Definition: Expr.h:5156
Defines the clang::ASTContext interface.
const BlockDecl * getBlockDecl() const
Definition: Expr.h:4866
This represents &#39;#pragma omp distribute simd&#39; composite directive.
Definition: StmtOpenMP.h:3171
This represents &#39;#pragma omp master&#39; directive.
Definition: StmtOpenMP.h:1364
operator "" X (long double)
Definition: ExprCXX.h:442
TypeSourceInfo * getTypeOperandSourceInfo() const
Retrieve source information for the type operand.
Definition: ExprCXX.h:835
The null pointer literal (C++11 [lex.nullptr])
Definition: ExprCXX.h:520
capture_iterator explicit_capture_end() const
Retrieve an iterator pointing past the end of the sequence of explicit lambda captures.
Definition: ExprCXX.cpp:972
This represents &#39;#pragma omp task&#39; directive.
Definition: StmtOpenMP.h:1704
This represents a GCC inline-assembly statement extension.
Definition: Stmt.h:1591
Represents a &#39;co_await&#39; expression while the type of the promise is dependent.
Definition: ExprCXX.h:4237
Expr * getArrayIndex(const Designator &D) const
Definition: Expr.cpp:3796
bool getValue() const
Definition: ExprObjC.h:71
This represents &#39;thread_limit&#39; clause in the &#39;#pragma omp ...&#39; directive.
The receiver is an object instance.
Definition: ExprObjC.h:1005
Expr * getLHS() const
Definition: Expr.h:3315
bool hasExplicitTemplateArgs() const
Determines whether this expression had explicit template arguments.
Definition: ExprCXX.h:2610
const Stmt * getElse() const
Definition: Stmt.h:945
unsigned getNumInputs() const
Definition: Stmt.h:1510
Expr * getSyntacticForm()
Return the syntactic form of this expression, i.e.
Definition: Expr.h:5014
bool hasTemplateKeyword() const
Determines whether the name was preceded by the template keyword.
Definition: ExprCXX.h:2855
bool hasTemplateKeyword() const
Determines whether the member name was preceded by the template keyword.
Definition: Expr.h:2538
ObjCDictionaryElement getKeyValueElement(unsigned Index) const
Definition: ExprObjC.h:309
const FunctionProtoType * getFunctionType() const
getFunctionType - Return the underlying function type for this block.
Definition: Expr.cpp:2003
CompoundStmt * getBlock() const
Definition: Stmt.h:1936
Smart pointer class that efficiently represents Objective-C method names.
This represents clause &#39;copyin&#39; in the &#39;#pragma omp ...&#39; directives.
A (possibly-)qualified type.
Definition: Type.h:614
ArrayRef< TemplateArgumentLoc > template_arguments() const
Definition: ExprCXX.h:2882
bool varlist_empty() const
Definition: OpenMPClause.h:172
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
Definition: Expr.h:2483
ArrayRef< OMPClause * > clauses()
Definition: StmtOpenMP.h:235
Expr * getCond() const
Definition: Expr.h:3710
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
Definition: Expr.h:2278
Selector getSelector() const
Definition: ExprObjC.cpp:306
const Expr * getSubExpr() const
Definition: ExprCXX.h:948
void print(raw_ostream &OS, const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) const
Definition: Type.h:950
Expr * getCond()
Definition: Stmt.h:1101
Expr * getExpr(unsigned Index)
getExpr - Return the Expr at the specified index.
Definition: Expr.h:3574
unsigned getNumSubExprs() const
getNumSubExprs - Return the size of the SubExprs array.
Definition: Expr.h:3568
bool isSuperReceiver() const
Definition: ExprObjC.h:700
A type trait used in the implementation of various C++11 and Library TR1 trait templates.
Definition: ExprCXX.h:2256
CompoundStmt * getSubStmt()
Definition: Expr.h:3505
const Expr * getInit(unsigned Init) const
Definition: Expr.h:3921
bool hasExplicitResultType() const
Whether this lambda had its result type explicitly specified.
Definition: ExprCXX.h:1717
ObjCProtocolDecl * getProtocol() const
Definition: ExprObjC.h:453
Represents a &#39;co_return&#39; statement in the C++ Coroutines TS.
Definition: StmtCXX.h:432
Stmt - This represents one statement.
Definition: Stmt.h:60
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
Definition: Expr.h:2266
This represents clause &#39;in_reduction&#39; in the &#39;#pragma omp task&#39; directives.
const ObjCAtFinallyStmt * getFinallyStmt() const
Retrieve the @finally statement, if any.
Definition: StmtObjC.h:224
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition: Type.h:2964
CXXCatchStmt * getHandler(unsigned i)
Definition: StmtCXX.h:104
IfStmt - This represents an if/then/else.
Definition: Stmt.h:905
bool param_empty() const
Definition: Decl.h:3692
unsigned getNumOutputs() const
Definition: Stmt.h:1488
static CharSourceRange getTokenRange(SourceRange R)
This represents &#39;#pragma omp for simd&#39; directive.
Definition: StmtOpenMP.h:1114
bool isRecordType() const
Definition: Type.h:5823
Expr * getBase() const
Definition: Expr.h:2477
const StringLiteral * getAsmString() const
Definition: Stmt.h:1618
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:81
This represents &#39;grainsize&#39; clause in the &#39;#pragma omp ...&#39; directive.
This represents &#39;#pragma omp teams distribute parallel for&#39; composite directive.
Definition: StmtOpenMP.h:3582
Expr * getImplicitObjectArgument() const
Retrieves the implicit object argument for the member call.
Definition: ExprCXX.cpp:491
Stmt * getHandlerBlock() const
Definition: StmtCXX.h:52
bool isVariadic() const
Definition: Type.h:3497
arg_iterator arg_begin()
Definition: ExprCXX.h:1291
llvm::APFloat getValue() const
Definition: Expr.h:1405
Represents the index of the current element of an array being initialized by an ArrayInitLoopExpr.
Definition: Expr.h:4546
param_iterator param_end()
Definition: Decl.h:3694
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
Definition: ExprCXX.h:2655
This represents &#39;if&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:207
const Expr * getSubExpr() const
Definition: Expr.h:3797
DeclarationNameInfo getNameInfo() const
Retrieve the name of the entity we&#39;re testing for, along with location information.
Definition: StmtCXX.h:276
Defines the C++ template declaration subclasses.
Opcode getOpcode() const
Definition: Expr.h:3027
StringRef P
Represents an attribute applied to a statement.
Definition: Stmt.h:854
ParenExpr - This represents a parethesized expression, e.g.
Definition: Expr.h:1665
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies this name, if any.
Definition: StmtCXX.h:272
Expr * getLowerBound()
Get lower bound of array section.
Definition: ExprOpenMP.h:91
This represents &#39;priority&#39; clause in the &#39;#pragma omp ...&#39; directive.
This represents &#39;#pragma omp target teams distribute&#39; combined directive.
Definition: StmtOpenMP.h:3709
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies this declaration.
Definition: ExprCXX.h:2829
Represents Objective-C&#39;s @throw statement.
Definition: StmtObjC.h:313
const char * getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind, unsigned Type)
bool hasExplicitTemplateArgs() const
Determines whether this declaration reference was followed by an explicit template argument list...
Definition: Expr.h:1119
static void PrintTemplateArgumentList(raw_ostream &OS, ArrayRef< TemplateArgument > Args, const PrintingPolicy &Policy, bool SkipBrackets=false)
Print a template argument list, including the &#39;<&#39; and &#39;>&#39; enclosing the template arguments.
Represents a call to a C++ constructor.
Definition: ExprCXX.h:1177
ObjCSubscriptRefExpr - used for array and dictionary subscripting.
Definition: ExprObjC.h:760
An Embarcadero array type trait, as used in the implementation of __array_rank and __array_extent...
Definition: ExprCXX.h:2340
bool getIsCXXTry() const
Definition: Stmt.h:1975
Expr * getCondition() const
Returns condition.
Definition: OpenMPClause.h:331
A container of type source information.
Definition: Decl.h:62
This represents &#39;update&#39; clause in the &#39;#pragma omp atomic&#39; directive.
NestedNameSpecifier * getQualifier() const
If the member name was qualified, retrieves the nested-name-specifier that precedes the member name...
Definition: ExprCXX.h:2171
static void printGroup(Decl **Begin, unsigned NumDecls, raw_ostream &Out, const PrintingPolicy &Policy, unsigned Indentation=0)
Expr * getCondition() const
Returns condition.
Definition: OpenMPClause.h:273
This represents &#39;#pragma omp parallel for&#39; directive.
Definition: StmtOpenMP.h:1485
MS property subscript expression.
Definition: ExprCXX.h:743
This represents &#39;#pragma omp target teams distribute parallel for&#39; combined directive.
Definition: StmtOpenMP.h:3777
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:3951
Expr * getAlignment()
Returns alignment.
void printExceptionSpecification(raw_ostream &OS, const PrintingPolicy &Policy) const
Expr * getNumForLoops() const
Return the number of associated for-loops.
Definition: OpenMPClause.h:937
const Expr * getSubExpr() const
Definition: Expr.h:1475
Expr * getIndexExpr(unsigned Idx)
Definition: Expr.h:1989
This represents &#39;#pragma omp target exit data&#39; directive.
Definition: StmtOpenMP.h:2396
Stmt * getSubStmt()
Definition: Stmt.h:784
This represents &#39;read&#39; clause in the &#39;#pragma omp atomic&#39; directive.
This represents clause &#39;private&#39; in the &#39;#pragma omp ...&#39; directives.
ObjCIsaExpr - Represent X->isa and X.isa when X is an ObjC &#39;id&#39; type.
Definition: ExprObjC.h:1383
CompoundLiteralExpr - [C99 6.5.2.5].
Definition: Expr.h:2637
This represents &#39;num_threads&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:349
const T * getAs() const
Member-template getAs<specific type>&#39;.
Definition: Type.h:6099
unsigned getNumArgs() const
Determine the number of arguments to this type trait.
Definition: ExprCXX.h:2301
This represents &#39;defaultmap&#39; clause in the &#39;#pragma omp ...&#39; directive.
ObjCInterfaceDecl * getClassReceiver() const
Definition: ExprObjC.h:696
bool isArrow() const
Definition: ExprObjC.h:1410
Expr * getVal1() const
Definition: Expr.h:5146
Implicit construction of a std::initializer_list<T> object from an array temporary within list-initia...
Definition: ExprCXX.h:548
const char * getName() const
Definition: Stmt.cpp:309
unsigned getNumPlacementArgs() const
Definition: ExprCXX.h:1880
This represents implicit clause &#39;flush&#39; for the &#39;#pragma omp flush&#39; directive.
Describes how types, statements, expressions, and declarations should be printed. ...
Definition: PrettyPrinter.h:38
const DeclarationNameInfo & getNameInfo() const
Gets the name info for specified reduction identifier.
A C++ throw-expression (C++ [except.throw]).
Definition: ExprCXX.h:928
Expr * getExprOperand() const
Definition: ExprCXX.h:645
Represents an expression – generally a full-expression – that introduces cleanups to be run at the ...
Definition: ExprCXX.h:2920
TypeSourceInfo * getArg(unsigned I) const
Retrieve the Ith argument.
Definition: ExprCXX.h:2304
Defines the clang::Expr interface and subclasses for C++ expressions.
StringRef getInputName(unsigned i) const
Definition: Stmt.h:1713
Expr * getGrainsize() const
Return safe iteration space distance.
This represents &#39;nogroup&#39; clause in the &#39;#pragma omp ...&#39; directive.
This represents &#39;safelen&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:416
ObjCPropertyDecl * getExplicitProperty() const
Definition: ExprObjC.h:633
A C++ static_cast expression (C++ [expr.static.cast]).
Definition: ExprCXX.h:269
Expr * getExprOperand() const
Definition: ExprCXX.h:845
const Stmt * getSubStmt() const
Definition: StmtObjC.h:356
LabelStmt - Represents a label, which has a substatement.
Definition: Stmt.h:813
Expr * IgnoreImpCasts() LLVM_READONLY
IgnoreImpCasts - Skip past any implicit casts which might surround this expression.
Definition: Expr.h:2866
Represents a C99 designated initializer expression.
Definition: Expr.h:4107
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
Definition: Decl.h:258
One of these records is kept for each identifier that is lexed.
Stmt * getBody()
Definition: Stmt.h:1149
Expr * GetTemporaryExpr() const
Retrieve the temporary-generating subexpression whose value will be materialized into a glvalue...
Definition: ExprCXX.h:3992
An element in an Objective-C dictionary literal.
Definition: ExprObjC.h:212
This represents &#39;#pragma omp parallel&#39; directive.
Definition: StmtOpenMP.h:251
ShuffleVectorExpr - clang-specific builtin-in function __builtin_shufflevector.
Definition: Expr.h:3534
void print(raw_ostream &Out, unsigned Indentation=0, bool PrintInstantiation=false) const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:128
Expr * getInit() const
Retrieve the initializer value.
Definition: Expr.h:4341
This represents &#39;simd&#39; clause in the &#39;#pragma omp ...&#39; directive.
child_range children()
Definition: ExprObjC.h:201
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
Definition: Decl.h:2390
This represents clause &#39;lastprivate&#39; in the &#39;#pragma omp ...&#39; directives.
Expr * getBase()
Retrieve the base object of this member expressions, e.g., the x in x.m.
Definition: ExprCXX.h:3423
Represents a place-holder for an object not to be initialized by anything.
Definition: Expr.h:4401
const DeclarationNameInfo & getNameInfo() const
Gets the full name info.
Definition: ExprCXX.h:2568
StringLiteral * getString()
Definition: ExprObjC.h:40
CompoundStmt * getBody() const
Retrieve the body of the lambda.
Definition: ExprCXX.cpp:1009
unsigned getArrayExprIndex() const
For an array element node, returns the index into the array of expressions.
Definition: Expr.h:1880
const Expr * getRetValue() const
Definition: Stmt.cpp:905
bool SuppressInitializers
Suppress printing of variable initializers.
bool hasExplicitTemplateArgs() const
Determines whether the member name was followed by an explicit template argument list.
Definition: Expr.h:2542
Expr * getChunkSize()
Get chunk size.
GNUNullExpr - Implements the GNU __null extension, which is a name for a null pointer constant that h...
Definition: Expr.h:3745
This represents clause &#39;map&#39; in the &#39;#pragma omp ...&#39; directives.
QualType getDestroyedType() const
Retrieve the type being destroyed.
Definition: ExprCXX.cpp:230
This represents clause &#39;to&#39; in the &#39;#pragma omp ...&#39; directives.
Expr * getPlacementArg(unsigned i)
Definition: ExprCXX.h:1885
This represents &#39;#pragma omp target simd&#39; directive.
Definition: StmtOpenMP.h:3307
Expr * getSourceExpr() const
The source expression of an opaque value expression is the expression which originally generated the ...
Definition: Expr.h:926
Represents a C++ member access expression for which lookup produced a set of overloaded functions...
Definition: ExprCXX.h:3355
ExtVectorElementExpr - This represents access to specific elements of a vector, and may occur on the ...
Definition: Expr.h:4791
Expr * getSafelen() const
Return safe iteration space distance.
Definition: OpenMPClause.h:450
Expr * getSubExpr()
Definition: Expr.h:2762
This represents &#39;#pragma omp barrier&#39; directive.
Definition: StmtOpenMP.h:1816
ObjCArrayLiteral - used for objective-c array containers; as in: @["Hello", NSApp, [NSNumber numberWithInt:42]];.
Definition: ExprObjC.h:144
Expr * getNumTeams()
Return NumTeams number.
Represents a reference to a non-type template parameter pack that has been substituted with a non-tem...
Definition: ExprCXX.h:3811
This represents &#39;#pragma omp critical&#39; directive.
Definition: StmtOpenMP.h:1411
LambdaCaptureDefault getCaptureDefault() const
Determine the default capture kind for this lambda.
Definition: ExprCXX.h:1586
OpenMPDirectiveKind getCancelRegion() const
Get cancellation region for the current cancellation point.
Definition: StmtOpenMP.h:2695
ArrayRef< TemplateArgumentLoc > template_arguments() const
Definition: ExprCXX.h:2625
bool hasExplicitTemplateArgs() const
Determines whether this lookup had explicit template arguments.
Definition: ExprCXX.h:2858
Selector getSelector() const
Definition: ExprObjC.h:409
ArrayRef< ParmVarDecl * > parameters() const
Definition: Decl.h:2090
bool isUnarySelector() const
Represents Objective-C&#39;s @catch statement.
Definition: StmtObjC.h:74
Expr * getLHS() const
Definition: ExprCXX.h:4083
StringRef getOpcodeStr() const
Definition: Expr.h:3046
This represents clause &#39;copyprivate&#39; in the &#39;#pragma omp ...&#39; directives.
IndirectGotoStmt - This represents an indirect goto.
Definition: Stmt.h:1284
Describes an C or C++ initializer list.
Definition: Expr.h:3873
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
Definition: ExprCXX.h:590
This represents &#39;#pragma omp distribute parallel for&#39; composite directive.
Definition: StmtOpenMP.h:3032
Stmt * getBody() const override
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
Definition: Decl.cpp:4217
bool isArrow() const
Definition: ExprObjC.h:513
Expr * getKeyExpr() const
Definition: ExprObjC.h:810
This represents &#39;#pragma omp teams distribute parallel for simd&#39; composite directive.
Definition: StmtOpenMP.h:3511
Expr * getArraySize()
Definition: ExprCXX.h:1873
ForStmt - This represents a &#39;for (init;cond;inc)&#39; stmt.
Definition: Stmt.h:1179
NestedNameSpecifierLoc getQualifierLoc() const
Gets the nested name specifier.
Expr * getBaseExpr() const
Definition: ExprObjC.h:807
Expr * getOperand() const
Definition: ExprCXX.h:3537
const Expr * getThrowExpr() const
Definition: StmtObjC.h:325
< Capturing the *this object by copy
Definition: Lambda.h:37
bool isGlobalNew() const
Definition: ExprCXX.h:1897
Expr * getPtr() const
Definition: Expr.h:5136
Expr * getInitializer()
The initializer of this new-expression.
Definition: ExprCXX.h:1910
Stmt * getBody()
Definition: Stmt.h:1214
A builtin binary operation expression such as "x + y" or "x <= y".
Definition: Expr.h:2986
const Expr * getAssocExpr(unsigned i) const
Definition: Expr.h:4718
Stmt * getInit()
Definition: Stmt.h:1193
Expr * getOutputExpr(unsigned i)
Definition: Stmt.cpp:397
ArrayRef< TemplateArgumentLoc > template_arguments() const
Definition: Expr.h:2570
bool isClassReceiver() const
Definition: ExprObjC.h:701
const StringLiteral * getInputConstraintLiteral(unsigned i) const
Definition: Stmt.h:1722
static bool isPostfix(Opcode Op)
isPostfix - Return true if this is a postfix operation, like x++.
Definition: Expr.h:1752
CXXForRangeStmt - This represents C++0x [stmt.ranged]&#39;s ranged for statement, represented as &#39;for (ra...
Definition: StmtCXX.h:128
bool isArrow() const
Definition: Expr.h:2582
This represents &#39;#pragma omp cancellation point&#39; directive.
Definition: StmtOpenMP.h:2651
This represents &#39;default&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:578
ObjCStringLiteral, used for Objective-C string literals i.e.
Definition: ExprObjC.h:29
Expr * getRHS() const
Definition: ExprCXX.h:4084
void printPretty(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation=0, const ASTContext *Context=nullptr) const
const CallExpr * getConfig() const
Definition: ExprCXX.h:188
bool isArrow() const
Definition: ExprCXX.h:725
New-expression has a C++98 paren-delimited initializer.
Definition: ExprCXX.h:1824
TypoExpr - Internal placeholder for expressions where typo correction still needs to be performed and...
Definition: Expr.h:5233
This represents &#39;final&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:295
This represents &#39;mergeable&#39; clause in the &#39;#pragma omp ...&#39; directive.
Expr * getCond()
Definition: Stmt.h:1212
This represents &#39;#pragma omp teams&#39; directive.
Definition: StmtOpenMP.h:2594
OpenMPDependClauseKind getDependencyKind() const
Get dependency type.
NestedNameSpecifier * getQualifier() const
Fetches the nested-name qualifier, if one was given.
Definition: ExprCXX.h:2577
const Expr * getControllingExpr() const
Definition: Expr.h:4743
This represents clause &#39;reduction&#39; in the &#39;#pragma omp ...&#39; directives.
Helper class for OffsetOfExpr.
Definition: Expr.h:1822
Expr * getOperand() const
Definition: ExprCXX.h:4262
This represents &#39;#pragma omp teams distribute simd&#39; combined directive.
Definition: StmtOpenMP.h:3441
Represents binding an expression to a temporary.
Definition: ExprCXX.h:1134
StringLiteral * getClobberStringLiteral(unsigned i)
Definition: Stmt.h:1755
StringRef getOutputName(unsigned i) const
Definition: Stmt.h:1685
ArrayTypeTrait
Names for the array type traits.
Definition: TypeTraits.h:89
Expr * Key
The key for the dictionary element.
Definition: ExprObjC.h:214
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
Definition: ExprCXX.h:1519
Represents a C++ member access expression where the actual member referenced could not be resolved be...
Definition: ExprCXX.h:3117
This represents clause &#39;is_device_ptr&#39; in the &#39;#pragma omp ...&#39; directives.
bool isCmpXChg() const
Definition: Expr.h:5180
bool isInitCapture(const LambdaCapture *Capture) const
Determine whether one of this lambda&#39;s captures is an init-capture.
Definition: ExprCXX.cpp:951
TypeSourceInfo * getTypeSourceInfo() const
Definition: ExprCXX.h:1759
A default argument (C++ [dcl.fct.default]).
Definition: ExprCXX.h:982
bool isTypeOperand() const
Definition: ExprCXX.h:828
const IdentifierInfo * getUDSuffix() const
Returns the ud-suffix specified for this literal.
Definition: ExprCXX.cpp:721
This represents clause &#39;from&#39; in the &#39;#pragma omp ...&#39; directives.
Represents the this expression in C++.
Definition: ExprCXX.h:888
ObjCIvarDecl * getDecl()
Definition: ExprObjC.h:505
TypeTrait
Names for traits that operate specifically on types.
Definition: TypeTraits.h:21
bool isArrayForm() const
Definition: ExprCXX.h:2026
const ObjCAtCatchStmt * getCatchStmt(unsigned I) const
Retrieve a @catch statement.
Definition: StmtObjC.h:206
This represents &#39;#pragma omp target parallel for simd&#39; directive.
Definition: StmtOpenMP.h:3239
QualType getTypeAsWritten() const
getTypeAsWritten - Returns the type that this expression is casting to, as written in the source code...
Definition: Expr.h:2912
OpenMP 4.0 [2.4, Array Sections].
Definition: ExprOpenMP.h:45
ConditionalOperator - The ?: ternary operator.
Definition: Expr.h:3270
bool isStdInitListInitialization() const
Whether this constructor call was written as list-initialization, but was interpreted as forming a st...
Definition: ExprCXX.h:1262
Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
Definition: ExprCXX.h:2113
CompoundStmt - This represents a group of statements like { stmt stmt }.
Definition: Stmt.h:575
OpenMPDefaultClauseKind getDefaultKind() const
Returns kind of the clause.
Definition: OpenMPClause.h:627
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Definition: Type.cpp:1569
Represents a prototype with parameter type info, e.g.
Definition: Type.h:3170
QualType getQueriedType() const
Definition: ExprCXX.h:2385
This represents &#39;threads&#39; clause in the &#39;#pragma omp ...&#39; directive.
CompoundStmt * getSubStmt() const
Retrieve the compound statement that will be included in the program only if the existence of the sym...
Definition: StmtCXX.h:280
This represents &#39;#pragma omp taskgroup&#39; directive.
Definition: StmtOpenMP.h:1904
Expr * getSimdlen() const
Return safe iteration space distance.
Definition: OpenMPClause.h:505
NestedNameSpecifier * getQualifier() const
If the member name was qualified, retrieves the nested-name-specifier that precedes the member name...
Definition: Expr.h:2512
This represents clause &#39;aligned&#39; in the &#39;#pragma omp ...&#39; directives.
OverloadedOperatorKind getCXXOverloadedOperator() const
getCXXOverloadedOperator - If this name is the name of an overloadable operator in C++ (e...
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand...
Definition: Expr.h:2031
arg_iterator arg_end()
Definition: ExprCXX.h:1292
This represents clause &#39;task_reduction&#39; in the &#39;#pragma omp taskgroup&#39; directives.
InitListExpr * getUpdater() const
Definition: Expr.h:4459
Represents a call to the builtin function __builtin_va_arg.
Definition: Expr.h:3779
void print(raw_ostream &OS, const PrintingPolicy &Policy) const
Print this nested name specifier to the given output stream.
void outputString(raw_ostream &OS) const
Definition: Expr.cpp:891
const DeclStmt * getConditionVariableDeclStmt() const
If this IfStmt has a condition variable, return the faux DeclStmt associated with the creation of tha...
Definition: Stmt.h:934
OpenMPProcBindClauseKind getProcBindKind() const
Returns kind of the clause.
Definition: OpenMPClause.h:700
static StringRef getSourceText(CharSourceRange Range, const SourceManager &SM, const LangOptions &LangOpts, bool *Invalid=nullptr)
Returns a string for the source that the range encompasses.
Definition: Lexer.cpp:916
unsigned getValue() const
Definition: Expr.h:1372
This represents &#39;#pragma omp distribute&#39; directive.
Definition: StmtOpenMP.h:2905
This represents implicit clause &#39;depend&#39; for the &#39;#pragma omp task&#39; directive.
Expr * getSrcExpr() const
getSrcExpr - Return the Expr to be converted.
Definition: Expr.h:4920
An expression "T()" which creates a value-initialized rvalue of type T, which is a non-class type...
Definition: ExprCXX.h:1740
Expr * getCond() const
Definition: Expr.h:3304
BlockDecl - This represents a block literal declaration, which is like an unnamed FunctionDecl...
Definition: Decl.h:3595
llvm::MutableArrayRef< Designator > designators()
Definition: Expr.h:4310
This represents &#39;proc_bind&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:650
This represents &#39;capture&#39; clause in the &#39;#pragma omp atomic&#39; directive.
Expr - This represents one expression.
Definition: Expr.h:106
bool isVariadic() const
Whether this function is variadic.
Definition: Decl.cpp:2540
IdentifierInfo * getFieldName() const
For a field or identifier offsetof node, returns the name of the field.
Definition: Expr.cpp:1391
bool isArrow() const
Determine whether this member expression used the &#39;->&#39; operator; otherwise, it used the &#39;...
Definition: ExprCXX.h:3440
int Id
Definition: ASTDiff.cpp:191
static void PrintFloatingLiteral(raw_ostream &OS, FloatingLiteral *Node, bool PrintSuffix)
const FunctionProtoType * T
This represents &#39;simdlen&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:471
Expr * getNumTasks() const
Return safe iteration space distance.
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:1240
Represents a C++ functional cast expression that builds a temporary object.
Definition: ExprCXX.h:1469
const Stmt * getThen() const
Definition: Stmt.h:943
A C++ const_cast expression (C++ [expr.const.cast]).
Definition: ExprCXX.h:387
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Definition: Expr.h:4852
VarDecl * getExceptionDecl() const
Definition: StmtCXX.h:50
IdentifierInfo * getDestroyedTypeIdentifier() const
In a dependent pseudo-destructor expression for which we do not have full type information on the des...
Definition: ExprCXX.h:2214
unsigned getNumInits() const
Definition: Expr.h:3903
bool isImplicitAccess() const
True if this is an implicit access, i.e.
Definition: ExprCXX.cpp:1186
Expr * getSubExpr() const
Get the initializer to use for each array element.
Definition: Expr.h:4513
const Expr * getCallee() const
Definition: Expr.h:2249
This represents &#39;#pragma omp target teams distribute parallel for simd&#39; combined directive.
Definition: StmtOpenMP.h:3850
QualType getArgumentType() const
Definition: Expr.h:2068
bool isArrow() const
Determine whether this pseudo-destructor expression was written using an &#39;->&#39; (otherwise, it used a &#39;.
Definition: ExprCXX.h:2177
Stmt * getBody()
Definition: Stmt.h:1104
Expr * getOrder() const
Definition: Expr.h:5139
StringRef getNameForSlot(unsigned argIndex) const
Retrieve the name at a given position in the selector.
ObjCDictionaryLiteral - AST node to represent objective-c dictionary literals; as in:"name" : NSUserN...
Definition: ExprObjC.h:257
const CompoundStmt * getSynchBody() const
Definition: StmtObjC.h:282
Expr * getRHS()
Definition: Stmt.h:739
Represents Objective-C&#39;s @synchronized statement.
Definition: StmtObjC.h:262
ObjCSelectorExpr used for @selector in Objective-C.
Definition: ExprObjC.h:397
TypeSourceInfo * getTypeSourceInfo() const
Definition: Expr.h:1968
Represents an expression that computes the length of a parameter pack.
Definition: ExprCXX.h:3642
CXXTryStmt - A C++ try block, including all handlers.
Definition: StmtCXX.h:65
AsTypeExpr - Clang builtin function __builtin_astype [OpenCL 6.2.4.2] This AST node provides support ...
Definition: Expr.h:4897
OpenMPDistScheduleClauseKind getDistScheduleKind() const
Get kind of the clause.
IdentifierInfo & getAccessor() const
Definition: Expr.h:4813
This represents &#39;#pragma omp target teams distribute simd&#39; combined directive.
Definition: StmtOpenMP.h:3923
ArrayTypeTrait getTrait() const
Definition: ExprCXX.h:2383
This represents &#39;ordered&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:902
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char, signed char, short, int, long..], or an enum decl which has a signed representation.
Definition: Type.cpp:1765
Kind getKind() const
Determine what kind of offsetof node this is.
Definition: Expr.h:1876
void print(llvm::raw_ostream &OS) const
Prints the full selector name (e.g. "foo:bar:").
QualType getType() const
Definition: Expr.h:128
virtual bool handledStmt(Stmt *E, raw_ostream &OS)=0
This represents &#39;#pragma omp for&#39; directive.
Definition: StmtOpenMP.h:1037
LabelDecl * getLabel() const
Definition: Stmt.h:1261
const Stmt * getTryBody() const
Retrieve the @try body.
Definition: StmtObjC.h:197
Represents a folding of a pack over an operator.
Definition: ExprCXX.h:4060
QualType getEncodedType() const
Definition: ExprObjC.h:376
ReturnStmt - This represents a return, optionally of an expression: return; return 4;...
Definition: Stmt.h:1392
This represents &#39;#pragma omp target teams&#39; directive.
Definition: StmtOpenMP.h:3650
An expression that sends a message to the given Objective-C object or class.
Definition: ExprObjC.h:860
This represents a Microsoft inline-assembly statement extension.
Definition: Stmt.h:1770
ObjCMethodDecl * getImplicitPropertyGetter() const
Definition: ExprObjC.h:638
UnaryOperator - This represents the unary-expression&#39;s (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
Definition: Expr.h:1717
CXXMethodDecl * getMethodDecl() const
Retrieves the declaration of the called method.
Definition: ExprCXX.cpp:503
ReceiverKind getReceiverKind() const
Determine the kind of receiver that this message is being sent to.
Definition: ExprObjC.h:1136
AtomicOp getOp() const
Definition: Expr.h:5168
A member reference to an MSPropertyDecl.
Definition: ExprCXX.h:678
Represents a reference to a non-type template parameter that has been substituted with a template arg...
Definition: ExprCXX.h:3756
const OffsetOfNode & getComponent(unsigned Idx) const
Definition: Expr.h:1975
unsigned getNumArgs() const
Expr * getDevice()
Return device number.
This represents &#39;#pragma omp cancel&#39; directive.
Definition: StmtOpenMP.h:2709
This represents &#39;collapse&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:526
This represents clause &#39;firstprivate&#39; in the &#39;#pragma omp ...&#39; directives.
ValueDecl * getDecl()
Definition: Expr.h:1041
Selector getSelector() const
Definition: DeclObjC.h:328
const Expr * getSubExpr() const
Definition: Expr.h:1681
const Expr * getSubExpr() const
Definition: ExprCXX.h:1158
CStyleCastExpr - An explicit cast in C (C99 6.5.4) or a C-style cast in C++ (C++ [expr.cast]), which uses the syntax (Type)expr.
Definition: Expr.h:2923
CXXMethodDecl * getCallOperator() const
Retrieve the function call operator associated with this lambda expression.
Definition: ExprCXX.cpp:998
bool isNull() const
Return true if this QualType doesn&#39;t point to a type yet.
Definition: Type.h:681
Expr * getLHS()
An array access can be written A[4] or 4[A] (both are equivalent).
Definition: Expr.h:2154
bool getValue() const
Definition: ExprCXX.h:498
ImaginaryLiteral - We support imaginary integer and floating point literals, like "1...
Definition: Expr.h:1463
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
Definition: ExprObjC.h:1290
This represents &#39;#pragma omp flush&#39; directive.
Definition: StmtOpenMP.h:1977
This represents &#39;#pragma omp parallel for simd&#39; directive.
Definition: StmtOpenMP.h:1565
DoStmt - This represents a &#39;do/while&#39; stmt.
Definition: Stmt.h:1128
This represents &#39;seq_cst&#39; clause in the &#39;#pragma omp atomic&#39; directive.
This represents &#39;untied&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:984
StringRef getBridgeKindName() const
Retrieve the kind of bridge being performed as a string.
Definition: ExprObjC.cpp:349
param_iterator param_begin()
Definition: Decl.h:3693
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the member name.
Definition: ExprCXX.h:3214
const DeclarationNameInfo & getNameInfo() const
Retrieve the name that this expression refers to.
Definition: ExprCXX.h:2813
Expr * getArgument()
Definition: ExprCXX.h:2039
LiteralOperatorKind getLiteralOperatorKind() const
Returns the kind of literal operator invocation which this expression represents. ...
Definition: ExprCXX.cpp:692
This represents &#39;#pragma omp target enter data&#39; directive.
Definition: StmtOpenMP.h:2337
This represents &#39;num_teams&#39; clause in the &#39;#pragma omp ...&#39; directive.
A C++ dynamic_cast expression (C++ [expr.dynamic.cast]).
Definition: ExprCXX.h:305
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
Definition: Expr.h:868
Expr * getBase() const
Definition: Expr.h:4456
ConvertVectorExpr - Clang builtin function __builtin_convertvector This AST node provides support for...
Definition: Expr.h:3602
unsigned getNumArgs() const
Return the number of actual arguments in this message, not counting the receiver. ...
Definition: ExprObjC.h:1277
Kind
This captures a statement into a function.
Definition: Stmt.h:2032
Represents a call to an inherited base class constructor from an inheriting constructor.
Definition: ExprCXX.h:1340
operator "" X (const CharT *, size_t)
Definition: ExprCXX.h:443
ExpressionTrait getTrait() const
Definition: ExprCXX.h:2446
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
Definition: Expr.h:4970
bool isImplicitProperty() const
Definition: ExprObjC.h:630
IdentifierInfo * getIdentifierInfoForSlot(unsigned argIndex) const
Retrieve the identifier at a given position in the selector.
Raw form: operator "" X<cs...> ()
Definition: ExprCXX.h:440
unsigned getNumExprs() const
Definition: Expr.h:4619
This represents &#39;#pragma omp single&#39; directive.
Definition: StmtOpenMP.h:1309
unsigned Indentation
The number of spaces to use to indent each line.
Definition: PrettyPrinter.h:67
body_range body()
Definition: Stmt.h:605
QualType getReturnType() const
Definition: Type.h:3106
capture_iterator explicit_capture_begin() const
Retrieve an iterator pointing to the first explicit lambda capture.
Definition: ExprCXX.cpp:968
This represents &#39;hint&#39; clause in the &#39;#pragma omp ...&#39; directive.
llvm::iterator_range< child_iterator > child_range
Definition: Stmt.h:422
unsigned UnderscoreAlignof
Whether we can use &#39;_Alignof&#39; rather than &#39;__alignof&#39;.
const Stmt * getCatchBody() const
Definition: StmtObjC.h:90
unsigned getNumHandlers() const
Definition: StmtCXX.h:103
Expr * getSubExpr() const
Definition: Expr.h:1744
bool hasExplicitTemplateArgs() const
Determines whether this member expression actually had a C++ template argument list explicitly specif...
Definition: ExprCXX.h:3278
This is a basic class for representing single OpenMP executable directive.
Definition: StmtOpenMP.h:33
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)"...
Definition: ExprCXX.h:1780
unsigned getNumElements() const
getNumElements - Return number of elements of objective-c dictionary literal.
Definition: ExprObjC.h:307
Expr * getLHS()
Definition: Stmt.h:738
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:424
DeclarationName getName() const
getName - Returns the embedded declaration name.
ArrayRef< const Attr * > getAttrs() const
Definition: Stmt.h:886
This represents &#39;schedule&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:722
Represents a call to a member function that may be written either with member call syntax (e...
Definition: ExprCXX.h:136
DeclStmt - Adaptor class for mixing declarations with statements and expressions. ...
Definition: Stmt.h:467
This represents clause &#39;shared&#39; in the &#39;#pragma omp ...&#39; directives.
const Expr * getExpr(unsigned Init) const
Definition: Expr.h:4621
DeclarationNameInfo getDirectiveName() const
Return name of the directive.
Definition: StmtOpenMP.h:1469
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:1928
Expr * getPriority()
Return Priority number.
StmtVisitor - This class implements a simple visitor for Stmt subclasses.
Definition: StmtVisitor.h:180
SourceLocation getColonLoc() const
Definition: ExprOpenMP.h:109
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
This represents &#39;#pragma omp taskwait&#39; directive.
Definition: StmtOpenMP.h:1860
QualType getAllocatedType() const
Definition: ExprCXX.h:1841
OpenMPMapClauseKind getMapType() const LLVM_READONLY
Fetches mapping kind for the clause.
This file defines OpenMP nodes for declarative directives.
AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*, __atomic_load, __atomic_store, and __atomic_compare_exchange_*, for the similarly-named C++11 instructions, and __c11 variants for <stdatomic.h>, and corresponding __opencl_atomic_* for OpenCL 2.0.
Definition: Expr.h:5104
UnaryExprOrTypeTrait getKind() const
Definition: Expr.h:2062
ObjCProtocolExpr used for protocol expression in Objective-C.
Definition: ExprObjC.h:441
const StringLiteral * getOutputConstraintLiteral(unsigned i) const
Definition: Stmt.h:1694
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
Definition: Expr.h:2823
bool hasTemplateKeyword() const
Determines whether the member name was preceded by the template keyword.
Definition: ExprCXX.h:3274
OpenMPMapClauseKind getMapTypeModifier() const LLVM_READONLY
Fetches the map type modifier for the clause.
CharacterKind getKind() const
Definition: Expr.h:1365
This represents &#39;#pragma omp target&#39; directive.
Definition: StmtOpenMP.h:2221
Expr * getInputExpr(unsigned i)
Definition: Stmt.cpp:408
static const char * getTypeTraitName(TypeTrait TT)
void dumpPretty(const ASTContext &Context) const
dumpPretty/printPretty - These two methods do a "pretty print" of the AST back to its original source...
Expr * getNumForLoops() const
Return the number of associated for-loops.
Definition: OpenMPClause.h:561
bool isParenTypeId() const
Definition: ExprCXX.h:1894
IdentType getIdentType() const
Definition: Expr.h:1215
void printPretty(raw_ostream &OS, const PrintingPolicy &Policy) const
Expr * getArrayRangeStart(const Designator &D) const
Definition: Expr.cpp:3801
Expr * getSubExpr()
Definition: ExprObjC.h:108
An expression trait intrinsic.
Definition: ExprCXX.h:2412
This represents &#39;#pragma omp ordered&#39; directive.
Definition: StmtOpenMP.h:2032
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
Definition: Expr.h:3489
This represents &#39;#pragma omp target update&#39; directive.
Definition: StmtOpenMP.h:2973
ObjCBoxedExpr - used for generalized expression boxing.
Definition: ExprObjC.h:94
bool isArgumentType() const
Definition: Expr.h:2067
ArrayRef< TemplateArgumentLoc > template_arguments() const
Definition: ExprCXX.h:3306
const DeclStmt * getConditionVariableDeclStmt() const
If this WhileStmt has a condition variable, return the faux DeclStmt associated with the creation of ...
Definition: Stmt.h:1097
Representation of a Microsoft __if_exists or __if_not_exists statement with a dependent name...
Definition: StmtCXX.h:240
void printName(raw_ostream &OS) const
printName - Print the human-readable name to a stream.
bool hasTemplateKeyword() const
Determines whether the name in this declaration reference was preceded by the template keyword...
Definition: Expr.h:1115
A qualified reference to a name whose declaration cannot yet be resolved.
Definition: ExprCXX.h:2775
Expr * Value
The value of the dictionary element.
Definition: ExprObjC.h:217
const Expr * getInitializer() const
Definition: Expr.h:2663
InitializationStyle getInitializationStyle() const
The kind of initializer this new-expression has.
Definition: ExprCXX.h:1903
Expr * getLHS() const
Definition: Expr.h:3030
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
Definition: TemplateBase.h:330
CompoundAssignOperator - For compound assignments (e.g.
Definition: Expr.h:3192
Represents a C11 generic selection.
Definition: Expr.h:4685
StringRef getName() const
Return the actual identifier string.
const Expr * getBase() const
Definition: Expr.h:4809
Expr * getInstanceReceiver()
Returns the object expression (receiver) for an instance message, or null for a message that is not a...
Definition: ExprObjC.h:1155
AddrLabelExpr - The GNU address of label extension, representing &&label.
Definition: Expr.h:3445
An Objective-C "bridged" cast expression, which casts between Objective-C pointers and C pointers...
Definition: ExprObjC.h:1519
ast_type_traits::DynTypedNode Node
Represents a reference to a function parameter pack that has been substituted but not yet expanded...
Definition: ExprCXX.h:3873
Represents a template argument.
Definition: TemplateBase.h:40
Expr * getFalseExpr() const
getFalseExpr - Return the subexpression which will be evaluated if the condnition evaluates to false;...
Definition: Expr.h:3402
NullStmt - This is the null statement ";": C99 6.8.3p3.
Definition: Stmt.h:535
bool isMutable() const
Determine whether the lambda is mutable, meaning that any captures values can be modified.
Definition: ExprCXX.cpp:1020
bool isTypeOperand() const
Definition: ExprCXX.h:628
unsigned getNumAssocs() const
Definition: Expr.h:4712
Dataflow Directional Tag Classes.
This represents &#39;device&#39; clause in the &#39;#pragma omp ...&#39; directive.
NestedNameSpecifier * getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
bool isValid() const
Return true if this is a valid SourceLocation object.
bool isVolatile() const
Definition: Stmt.h:1475
OpenMPDefaultmapClauseKind getDefaultmapKind() const
Get kind of the clause.
[C99 6.4.2.2] - A predefined identifier such as func.
Definition: Expr.h:1188
DeclarationNameInfo getMemberNameInfo() const
Retrieve the member declaration name info.
Definition: Expr.h:2575
Represents a delete expression for memory deallocation and destructor calls, e.g. ...
Definition: ExprCXX.h:1992
OverloadedOperatorKind getOperator() const
Returns the kind of overloaded operator that this expression refers to.
Definition: ExprCXX.h:75
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
Definition: OperatorKinds.h:22
NonTypeTemplateParmDecl * getParameterPack() const
Retrieve the non-type template parameter pack being substituted.
Definition: ExprCXX.h:3837
MSPropertyDecl * getPropertyDecl() const
Definition: ExprCXX.h:724
static LLVM_READONLY bool isPrintable(unsigned char c)
Return true if this character is an ASCII printable character; that is, a character that should take ...
Definition: CharInfo.h:140
This represents &#39;#pragma omp section&#39; directive.
Definition: StmtOpenMP.h:1247
This represents &#39;#pragma omp teams distribute&#39; directive.
Definition: StmtOpenMP.h:3373
QualType getAssocType(unsigned i) const
Definition: Expr.h:4736
A runtime availability query.
Definition: ExprObjC.h:1579
A C++ reinterpret_cast expression (C++ [expr.reinterpret.cast]).
Definition: ExprCXX.h:347
This represents &#39;#pragma omp simd&#39; directive.
Definition: StmtOpenMP.h:972
Represents a &#39;co_yield&#39; expression.
Definition: ExprCXX.h:4281
Expr * getOperand() const
Retrieve the operand of the &#39;co_return&#39; statement.
Definition: StmtCXX.h:456
Represents a C++11 pack expansion that produces a sequence of expressions.
Definition: ExprCXX.h:3570
bool isListInitialization() const
Whether this constructor call was written as list-initialization.
Definition: ExprCXX.h:1255
SEHExceptStmt * getExceptHandler() const
Returns 0 if not defined.
Definition: Stmt.cpp:930
This represents clause &#39;linear&#39; in the &#39;#pragma omp ...&#39; directives.
const Expr * getSynchExpr() const
Definition: StmtObjC.h:290
bool isIfExists() const
Determine whether this is an __if_exists statement.
Definition: StmtCXX.h:265
NestedNameSpecifierLoc getQualifierLoc() const
Definition: ExprCXX.h:727
const DeclarationNameInfo & getMemberNameInfo() const
Retrieve the full name info for the member that this expression refers to.
Definition: ExprCXX.h:3450
OpenMPDefaultmapClauseModifier getDefaultmapModifier() const
Get the modifier of the clause.
This represents &#39;#pragma omp atomic&#39; directive.
Definition: StmtOpenMP.h:2087
TypeSourceInfo * getTypeOperandSourceInfo() const
Retrieve source information for the type operand.
Definition: ExprCXX.h:635
Expr * getArrayRangeEnd(const Designator &D) const
Definition: Expr.cpp:3807
const Stmt * getBody() const
Definition: Stmt.h:1021
llvm::APInt getValue() const
Definition: Expr.h:1279
Represents a __leave statement.
Definition: Stmt.h:1998
LabelDecl * getLabel() const
Definition: Expr.h:3467
QualType getClassReceiver() const
Returns the type of a class message send, or NULL if the message is not a class message.
Definition: ExprObjC.h:1174
Represents a C++11 noexcept expression (C++ [expr.unary.noexcept]).
Definition: ExprCXX.h:3515
SwitchStmt - This represents a &#39;switch&#39; stmt.
Definition: Stmt.h:983
Capturing variable-length array type.
Definition: Lambda.h:39
Not an overloaded operator.
Definition: OperatorKinds.h:23
Expr * getOrderFail() const
Definition: Expr.h:5152
DeclarationNameInfo getNameInfo() const
Definition: Expr.h:1045
Represents the body of a coroutine.
Definition: StmtCXX.h:299
bool hasTemplateKeyword() const
Determines whether the name was preceded by the template keyword.
Definition: ExprCXX.h:2607
Expr * getBase() const
Definition: ExprObjC.h:1408
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
Definition: Expr.h:2121
OpenMPDirectiveKind getNameModifier() const
Return directive name modifier associated with the clause.
Definition: OpenMPClause.h:275
bool hasBraces() const
Definition: Stmt.h:1799
Represents Objective-C&#39;s collection statement.
Definition: StmtObjC.h:24
static StringRef getIdentTypeName(IdentType IT)
Definition: Expr.cpp:473
ObjCEncodeExpr, used for @encode in Objective-C.
Definition: ExprObjC.h:355
const char * getOperatorSpelling(OverloadedOperatorKind Operator)
Retrieve the spelling of the given overloaded operator, without the preceding "operator" keyword...
An implicit indirection through a C++ base class, when the field found is in a base class...
Definition: Expr.h:1834
Represents a call to a CUDA kernel function.
Definition: ExprCXX.h:175
Represents a &#39;co_await&#39; expression.
Definition: ExprCXX.h:4204
MutableArrayRef< ParmVarDecl * >::iterator param_iterator
Definition: Decl.h:3690
Opcode getOpcode() const
Definition: Expr.h:1741
Expr * getArg(unsigned Arg)
Return the specified argument.
Definition: ExprCXX.h:1303
decl_range decls()
Definition: Stmt.h:515
Represents Objective-C&#39;s @finally statement.
Definition: StmtObjC.h:120
StringRef getAsmString() const
Definition: Stmt.h:1805
unsigned Alignof
Whether we can use &#39;alignof&#39; rather than &#39;__alignof&#39;.
bool hasAssociatedStmt() const
Returns true if directive has associated statement.
Definition: StmtOpenMP.h:193
const Expr * getBase() const
Definition: ExprObjC.h:509
bool isArrow() const
Determine whether this member expression used the &#39;->&#39; operator; otherwise, it used the &#39;...
Definition: ExprCXX.h:3207
const DeclarationNameInfo & getNameInfo() const
Gets the name info for specified reduction identifier.
Capturing the *this object by reference.
Definition: Lambda.h:35
This represents &#39;write&#39; clause in the &#39;#pragma omp atomic&#39; directive.
const char * getOpenMPDirectiveName(OpenMPDirectiveKind Kind)
Definition: OpenMPKinds.cpp:31
unsigned getNumClobbers() const
Definition: Stmt.h:1520
ObjCIvarRefExpr - A reference to an ObjC instance variable.
Definition: ExprObjC.h:479
bool ConstantsAsWritten
Whether we should print the constant expressions as written in the sources.
SourceManager & getSourceManager()
Definition: ASTContext.h:618
Expr * getRHS() const
Definition: Expr.h:3714
Describes an explicit type conversion that uses functional notion but could not be resolved because o...
Definition: ExprCXX.h:3005
SEHFinallyStmt * getFinallyHandler() const
Definition: Stmt.cpp:934
GotoStmt - This represents a direct goto.
Definition: Stmt.h:1250
A use of a default initializer in a constructor or in aggregate initialization.
Definition: ExprCXX.h:1052
Expr * getTarget()
Definition: Stmt.h:1303
A template argument list.
Definition: DeclTemplate.h:195
Expr * getSrcExpr() const
getSrcExpr - Return the Expr to be converted.
Definition: Expr.h:3626
ArrayRef< TemplateArgumentLoc > template_arguments() const
Definition: Expr.h:1147
CapturedDecl * getCapturedDecl()
Retrieve the outlined function declaration.
Definition: Stmt.cpp:1090
Expr * getCond()
Definition: Stmt.h:1146
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
const DeclarationNameInfo & getNameInfo() const
Gets the name info for specified reduction identifier.
OpenMPScheduleClauseModifier getSecondScheduleModifier() const
Get the second modifier of the clause.
Definition: OpenMPClause.h:855
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Definition: Expr.h:2387
This represents &#39;#pragma omp target parallel&#39; directive.
Definition: StmtOpenMP.h:2454
This represents &#39;nowait&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:953
ContinueStmt - This represents a continue.
Definition: Stmt.h:1328
OpenMPScheduleClauseModifier getFirstScheduleModifier() const
Get the first modifier of the clause.
Definition: OpenMPClause.h:850
Represents a loop initializing the elements of an array.
Definition: Expr.h:4491
This represents &#39;num_tasks&#39; clause in the &#39;#pragma omp ...&#39; directive.
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
Definition: Expr.h:3665
Expr * getFilterExpr() const
Definition: Stmt.h:1896
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
Definition: Expr.h:3343
CXXCatchStmt - This represents a C++ catch block.
Definition: StmtCXX.h:29
VarDecl * getLoopVariable()
Definition: StmtCXX.cpp:80
An index into an array.
Definition: Expr.h:1827
Represents an explicit C++ type conversion that uses "functional" notation (C++ [expr.type.conv]).
Definition: ExprCXX.h:1410
OpenMPScheduleClauseKind getScheduleKind() const
Get kind of the clause.
Definition: OpenMPClause.h:847
bool isPackExpansion() const
Determines whether this dictionary element is a pack expansion.
Definition: ExprObjC.h:227
Expr * getOperand() const
Definition: ExprCXX.h:4222
Expr * getRHS() const
Definition: Expr.h:3316
WhileStmt - This represents a &#39;while&#39; stmt.
Definition: Stmt.h:1073
Capturing by reference.
Definition: Lambda.h:38
SourceLocation getLParenLoc() const
Definition: ExprCXX.h:1438
Expr * getThreadLimit()
Return ThreadLimit number.
This class is used for builtin types like &#39;int&#39;.
Definition: Type.h:2082
CompoundStmt * getTryBlock()
Definition: StmtCXX.h:96
The receiver is a class.
Definition: ExprObjC.h:1003
Represents Objective-C&#39;s @try ... @catch ... @finally statement.
Definition: StmtObjC.h:154
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
Definition: Stmt.cpp:245
bool isGlobalDelete() const
Definition: ExprCXX.h:2025
This represents &#39;#pragma omp taskloop simd&#39; directive.
Definition: StmtOpenMP.h:2839
unsigned getNumCatchStmts() const
Retrieve the number of @catch statements in this try-catch-finally block.
Definition: StmtObjC.h:203
Expr * getBase() const
Retrieve the base object of this member expressions, e.g., the x in x.m.
Definition: ExprCXX.h:3198
StringLiteral - This represents a string literal expression, e.g.
Definition: Expr.h:1509
bool hasExplicitParameters() const
Determine whether this lambda has an explicit parameter list vs.
Definition: ExprCXX.h:1714
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition: Expr.h:2209
Expr * getPattern()
Retrieve the pattern of the pack expansion.
Definition: ExprCXX.h:3599
StringRef getName() const
getName - Get the name of identifier for this declaration as a StringRef.
Definition: Decl.h:237
This represents &#39;dist_schedule&#39; clause in the &#39;#pragma omp ...&#39; directive.
Expr * getLHS() const
Definition: Expr.h:3712
Stmt * getBody() const
Retrieve the body of the coroutine as written.
Definition: StmtCXX.h:360
static Decl::Kind getKind(const Decl *D)
Definition: DeclBase.cpp:896
Abstract class common to all of the C++ "named"/"keyword" casts.
Definition: ExprCXX.h:218
This represents &#39;#pragma omp sections&#39; directive.
Definition: StmtOpenMP.h:1179
Expr * getHint() const
Returns number of threads.
NestedNameSpecifierLoc getQualifierLoc() const
Gets the nested name specifier.
ObjCBoolLiteralExpr - Objective-C Boolean Literal.
Definition: ExprObjC.h:60
bool isObjectReceiver() const
Definition: ExprObjC.h:699
unsigned getNumComponents() const
Definition: Expr.h:1985
This represents &#39;#pragma omp target data&#39; directive.
Definition: StmtOpenMP.h:2279
OpenMPDirectiveKind getCancelRegion() const
Get cancellation region for the current cancellation point.
Definition: StmtOpenMP.h:2758
A reference to a declared variable, function, enum, etc.
Definition: Expr.h:956
static bool printExprAsWritten(raw_ostream &OS, Expr *E, const ASTContext *Context)
Prints the given expression using the original source text.
Expr * getRHS() const
Definition: Expr.h:3032
NestedNameSpecifierLoc getQualifierLoc() const
Gets the nested name specifier.
unsigned IncludeNewlines
When true, include newlines after statements like "break", etc.
BreakStmt - This represents a break.
Definition: Stmt.h:1354
Expr * getChunkSize()
Get chunk size.
Definition: OpenMPClause.h:879
const VarDecl * getCatchParamDecl() const
Definition: StmtObjC.h:94
const char * getCastName() const
getCastName - Get the name of the C++ cast being used, e.g., "static_cast", "dynamic_cast", "reinterpret_cast", or "const_cast".
Definition: ExprCXX.cpp:532
Expr * getOperand() const
Definition: ExprCXX.h:4293
Expr * getNumThreads() const
Returns number of threads.
Definition: OpenMPClause.h:394
Stmt * getSubStmt()
Definition: Stmt.h:833
ExprIterator arg_iterator
Definition: ExprCXX.h:1281
QualType getTypeAsWritten() const
Retrieve the type that is being constructed, as specified in the source code.
Definition: ExprCXX.h:3043
QualType getType() const
Definition: Decl.h:602
ParmVarDecl * getParameterPack() const
Get the parameter pack which this expression refers to.
Definition: ExprCXX.h:3902
unsigned getNumArgs() const
Definition: ExprCXX.h:1300
const Expr * getBase() const
Definition: ExprObjC.h:682
const Expr * getCond() const
Definition: Stmt.h:941
static StringRef getOpcodeStr(Opcode Op)
getOpcodeStr - Turn an Opcode enum value into the punctuation char it corresponds to...
Definition: Expr.cpp:1116
This represents &#39;#pragma omp taskyield&#39; directive.
Definition: StmtOpenMP.h:1772
This represents &#39;#pragma omp distribute parallel for simd&#39; composite directive.
Definition: StmtOpenMP.h:3102
A boolean literal, per ([C++ lex.bool] Boolean literals).
Definition: ExprCXX.h:486
NestedNameSpecifier * getQualifier() const
If the name was qualified, retrieves the nested-name-specifier that precedes the name.
Definition: Expr.h:1068
OffsetOfExpr - [C99 7.17] - This represents an expression of the form offsetof(record-type, member-designator).
Definition: Expr.h:1926
Expr * getQueriedExpression() const
Definition: ExprCXX.h:2448
This represents &#39;#pragma omp parallel sections&#39; directive.
Definition: StmtOpenMP.h:1633
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
Definition: ExprCXX.h:799
Expr * getCommon() const
getCommon - Return the common expression, written to the left of the condition.
Definition: Expr.h:3383
const Expr * getCond() const
Definition: Stmt.h:1020
The receiver is a superclass.
Definition: ExprObjC.h:1007
BinaryOperatorKind getOperator() const
Definition: ExprCXX.h:4098
const LangOptions & getLangOpts() const
Definition: ASTContext.h:661
NamedDecl * getPack() const
Retrieve the parameter pack.
Definition: ExprCXX.h:3713
Represents Objective-C&#39;s @autoreleasepool Statement.
Definition: StmtObjC.h:345
CompoundStmt * getTryBlock() const
Definition: Stmt.h:1977
Stmt * getSubStmt()
Definition: Stmt.h:889
InitListExpr * getSyntacticForm() const
Definition: Expr.h:4030
Stmt * getAssociatedStmt() const
Returns statement associated with the directive.
Definition: StmtOpenMP.h:196
Expr * getBaseExpr() const
Definition: ExprCXX.h:723
Represents an implicitly-generated value initialization of an object of a given type.
Definition: Expr.h:4581
CompoundStmt * getBlock() const
Definition: Stmt.h:1900
Expr * getWeak() const
Definition: Expr.h:5162
This represents &#39;#pragma omp target parallel for&#39; directive.
Definition: StmtOpenMP.h:2514
Attr - This represents one attribute.
Definition: Attr.h:43
This represents clause &#39;use_device_ptr&#39; in the &#39;#pragma omp ...&#39; directives.
operator "" X (unsigned long long)
Definition: ExprCXX.h:441
QualType getType() const
Return the type wrapped by this type source info.
Definition: Decl.h:70
TypeTrait getTrait() const
Determine which type trait this expression uses.
Definition: ExprCXX.h:2291
Expr * getLength()
Get length of array section.
Definition: ExprOpenMP.h:99
const DeclarationNameInfo & getMemberNameInfo() const
Retrieve the name of the member that this expression refers to.
Definition: ExprCXX.h:3240
Expr * getCookedLiteral()
If this is not a raw user-defined literal, get the underlying cooked literal (representing the litera...
Definition: ExprCXX.cpp:713
Expr * getBase()
An array section can be written only as Base[LowerBound:Length].
Definition: ExprOpenMP.h:82
Stmt * getSubStmt()
Definition: Stmt.h:740
const DeclStmt * getConditionVariableDeclStmt() const
If this SwitchStmt has a condition variable, return the faux DeclStmt associated with the creation of...
Definition: Stmt.h:1013
This represents &#39;#pragma omp taskloop&#39; directive.
Definition: StmtOpenMP.h:2774