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