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