clang  10.0.0svn
StmtPrinter.cpp
Go to the documentation of this file.
1 //===- StmtPrinter.cpp - Printing implementation for Stmt ASTs ------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements the Stmt::dumpPretty/Stmt::printPretty methods, which
10 // pretty print the AST back out to C code.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "clang/AST/ASTContext.h"
15 #include "clang/AST/Attr.h"
16 #include "clang/AST/Decl.h"
17 #include "clang/AST/DeclBase.h"
18 #include "clang/AST/DeclCXX.h"
19 #include "clang/AST/DeclObjC.h"
20 #include "clang/AST/DeclOpenMP.h"
21 #include "clang/AST/DeclTemplate.h"
22 #include "clang/AST/Expr.h"
23 #include "clang/AST/ExprCXX.h"
24 #include "clang/AST/ExprObjC.h"
25 #include "clang/AST/ExprOpenMP.h"
27 #include "clang/AST/OpenMPClause.h"
29 #include "clang/AST/Stmt.h"
30 #include "clang/AST/StmtCXX.h"
31 #include "clang/AST/StmtObjC.h"
32 #include "clang/AST/StmtOpenMP.h"
33 #include "clang/AST/StmtVisitor.h"
34 #include "clang/AST/TemplateBase.h"
35 #include "clang/AST/Type.h"
36 #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  std::string NL;
73  const ASTContext *Context;
74 
75  public:
76  StmtPrinter(raw_ostream &os, PrinterHelper *helper,
77  const PrintingPolicy &Policy, unsigned Indentation = 0,
78  StringRef NL = "\n",
79  const ASTContext *Context = nullptr)
80  : OS(os), IndentLevel(Indentation), Helper(helper), Policy(Policy),
81  NL(NL), Context(Context) {}
82 
83  void PrintStmt(Stmt *S) {
84  PrintStmt(S, Policy.Indentation);
85  }
86 
87  void PrintStmt(Stmt *S, int SubIndent) {
88  IndentLevel += SubIndent;
89  if (S && isa<Expr>(S)) {
90  // If this is an expr used in a stmt context, indent and newline it.
91  Indent();
92  Visit(S);
93  OS << ";" << NL;
94  } else if (S) {
95  Visit(S);
96  } else {
97  Indent() << "<<<NULL STATEMENT>>>" << NL;
98  }
99  IndentLevel -= SubIndent;
100  }
101 
102  void PrintInitStmt(Stmt *S, unsigned PrefixWidth) {
103  // FIXME: Cope better with odd prefix widths.
104  IndentLevel += (PrefixWidth + 1) / 2;
105  if (auto *DS = dyn_cast<DeclStmt>(S))
106  PrintRawDeclStmt(DS);
107  else
108  PrintExpr(cast<Expr>(S));
109  OS << "; ";
110  IndentLevel -= (PrefixWidth + 1) / 2;
111  }
112 
113  void PrintControlledStmt(Stmt *S) {
114  if (auto *CS = dyn_cast<CompoundStmt>(S)) {
115  OS << " ";
116  PrintRawCompoundStmt(CS);
117  OS << NL;
118  } else {
119  OS << NL;
120  PrintStmt(S);
121  }
122  }
123 
124  void PrintRawCompoundStmt(CompoundStmt *S);
125  void PrintRawDecl(Decl *D);
126  void PrintRawDeclStmt(const DeclStmt *S);
127  void PrintRawIfStmt(IfStmt *If);
128  void PrintRawCXXCatchStmt(CXXCatchStmt *Catch);
129  void PrintCallArgs(CallExpr *E);
130  void PrintRawSEHExceptHandler(SEHExceptStmt *S);
131  void PrintRawSEHFinallyStmt(SEHFinallyStmt *S);
132  void PrintOMPExecutableDirective(OMPExecutableDirective *S,
133  bool ForceNoStmt = false);
134 
135  void PrintExpr(Expr *E) {
136  if (E)
137  Visit(E);
138  else
139  OS << "<null expr>";
140  }
141 
142  raw_ostream &Indent(int Delta = 0) {
143  for (int i = 0, e = IndentLevel+Delta; i < e; ++i)
144  OS << " ";
145  return OS;
146  }
147 
148  void Visit(Stmt* S) {
149  if (Helper && Helper->handledStmt(S,OS))
150  return;
152  }
153 
154  void VisitStmt(Stmt *Node) LLVM_ATTRIBUTE_UNUSED {
155  Indent() << "<<unknown stmt type>>" << NL;
156  }
157 
158  void VisitExpr(Expr *Node) LLVM_ATTRIBUTE_UNUSED {
159  OS << "<<unknown expr type>>";
160  }
161 
162  void VisitCXXNamedCastExpr(CXXNamedCastExpr *Node);
163 
164 #define ABSTRACT_STMT(CLASS)
165 #define STMT(CLASS, PARENT) \
166  void Visit##CLASS(CLASS *Node);
167 #include "clang/AST/StmtNodes.inc"
168  };
169 
170 } // namespace
171 
172 //===----------------------------------------------------------------------===//
173 // Stmt printing methods.
174 //===----------------------------------------------------------------------===//
175 
176 /// PrintRawCompoundStmt - Print a compound stmt without indenting the {, and
177 /// with no newline after the }.
178 void StmtPrinter::PrintRawCompoundStmt(CompoundStmt *Node) {
179  OS << "{" << NL;
180  for (auto *I : Node->body())
181  PrintStmt(I);
182 
183  Indent() << "}";
184 }
185 
186 void StmtPrinter::PrintRawDecl(Decl *D) {
187  D->print(OS, Policy, IndentLevel);
188 }
189 
190 void StmtPrinter::PrintRawDeclStmt(const DeclStmt *S) {
191  SmallVector<Decl *, 2> Decls(S->decls());
192  Decl::printGroup(Decls.data(), Decls.size(), OS, Policy, IndentLevel);
193 }
194 
195 void StmtPrinter::VisitNullStmt(NullStmt *Node) {
196  Indent() << ";" << NL;
197 }
198 
199 void StmtPrinter::VisitDeclStmt(DeclStmt *Node) {
200  Indent();
201  PrintRawDeclStmt(Node);
202  OS << ";" << NL;
203 }
204 
205 void StmtPrinter::VisitCompoundStmt(CompoundStmt *Node) {
206  Indent();
207  PrintRawCompoundStmt(Node);
208  OS << "" << NL;
209 }
210 
211 void StmtPrinter::VisitCaseStmt(CaseStmt *Node) {
212  Indent(-1) << "case ";
213  PrintExpr(Node->getLHS());
214  if (Node->getRHS()) {
215  OS << " ... ";
216  PrintExpr(Node->getRHS());
217  }
218  OS << ":" << NL;
219 
220  PrintStmt(Node->getSubStmt(), 0);
221 }
222 
223 void StmtPrinter::VisitDefaultStmt(DefaultStmt *Node) {
224  Indent(-1) << "default:" << NL;
225  PrintStmt(Node->getSubStmt(), 0);
226 }
227 
228 void StmtPrinter::VisitLabelStmt(LabelStmt *Node) {
229  Indent(-1) << Node->getName() << ":" << NL;
230  PrintStmt(Node->getSubStmt(), 0);
231 }
232 
233 void StmtPrinter::VisitAttributedStmt(AttributedStmt *Node) {
234  for (const auto *Attr : Node->getAttrs()) {
235  Attr->printPretty(OS, Policy);
236  }
237 
238  PrintStmt(Node->getSubStmt(), 0);
239 }
240 
241 void StmtPrinter::PrintRawIfStmt(IfStmt *If) {
242  OS << "if (";
243  if (If->getInit())
244  PrintInitStmt(If->getInit(), 4);
245  if (const DeclStmt *DS = If->getConditionVariableDeclStmt())
246  PrintRawDeclStmt(DS);
247  else
248  PrintExpr(If->getCond());
249  OS << ')';
250 
251  if (auto *CS = dyn_cast<CompoundStmt>(If->getThen())) {
252  OS << ' ';
253  PrintRawCompoundStmt(CS);
254  OS << (If->getElse() ? " " : NL);
255  } else {
256  OS << NL;
257  PrintStmt(If->getThen());
258  if (If->getElse()) Indent();
259  }
260 
261  if (Stmt *Else = If->getElse()) {
262  OS << "else";
263 
264  if (auto *CS = dyn_cast<CompoundStmt>(Else)) {
265  OS << ' ';
266  PrintRawCompoundStmt(CS);
267  OS << NL;
268  } else if (auto *ElseIf = dyn_cast<IfStmt>(Else)) {
269  OS << ' ';
270  PrintRawIfStmt(ElseIf);
271  } else {
272  OS << NL;
273  PrintStmt(If->getElse());
274  }
275  }
276 }
277 
278 void StmtPrinter::VisitIfStmt(IfStmt *If) {
279  Indent();
280  PrintRawIfStmt(If);
281 }
282 
283 void StmtPrinter::VisitSwitchStmt(SwitchStmt *Node) {
284  Indent() << "switch (";
285  if (Node->getInit())
286  PrintInitStmt(Node->getInit(), 8);
287  if (const DeclStmt *DS = Node->getConditionVariableDeclStmt())
288  PrintRawDeclStmt(DS);
289  else
290  PrintExpr(Node->getCond());
291  OS << ")";
292  PrintControlledStmt(Node->getBody());
293 }
294 
295 void StmtPrinter::VisitWhileStmt(WhileStmt *Node) {
296  Indent() << "while (";
297  if (const DeclStmt *DS = Node->getConditionVariableDeclStmt())
298  PrintRawDeclStmt(DS);
299  else
300  PrintExpr(Node->getCond());
301  OS << ")" << NL;
302  PrintStmt(Node->getBody());
303 }
304 
305 void StmtPrinter::VisitDoStmt(DoStmt *Node) {
306  Indent() << "do ";
307  if (auto *CS = dyn_cast<CompoundStmt>(Node->getBody())) {
308  PrintRawCompoundStmt(CS);
309  OS << " ";
310  } else {
311  OS << NL;
312  PrintStmt(Node->getBody());
313  Indent();
314  }
315 
316  OS << "while (";
317  PrintExpr(Node->getCond());
318  OS << ");" << NL;
319 }
320 
321 void StmtPrinter::VisitForStmt(ForStmt *Node) {
322  Indent() << "for (";
323  if (Node->getInit())
324  PrintInitStmt(Node->getInit(), 5);
325  else
326  OS << (Node->getCond() ? "; " : ";");
327  if (Node->getCond())
328  PrintExpr(Node->getCond());
329  OS << ";";
330  if (Node->getInc()) {
331  OS << " ";
332  PrintExpr(Node->getInc());
333  }
334  OS << ")";
335  PrintControlledStmt(Node->getBody());
336 }
337 
338 void StmtPrinter::VisitObjCForCollectionStmt(ObjCForCollectionStmt *Node) {
339  Indent() << "for (";
340  if (auto *DS = dyn_cast<DeclStmt>(Node->getElement()))
341  PrintRawDeclStmt(DS);
342  else
343  PrintExpr(cast<Expr>(Node->getElement()));
344  OS << " in ";
345  PrintExpr(Node->getCollection());
346  OS << ")";
347  PrintControlledStmt(Node->getBody());
348 }
349 
350 void StmtPrinter::VisitCXXForRangeStmt(CXXForRangeStmt *Node) {
351  Indent() << "for (";
352  if (Node->getInit())
353  PrintInitStmt(Node->getInit(), 5);
354  PrintingPolicy SubPolicy(Policy);
355  SubPolicy.SuppressInitializers = true;
356  Node->getLoopVariable()->print(OS, SubPolicy, IndentLevel);
357  OS << " : ";
358  PrintExpr(Node->getRangeInit());
359  OS << ")";
360  PrintControlledStmt(Node->getBody());
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 << NL;
382 }
383 
384 void StmtPrinter::VisitIndirectGotoStmt(IndirectGotoStmt *Node) {
385  Indent() << "goto *";
386  PrintExpr(Node->getTarget());
387  OS << ";";
388  if (Policy.IncludeNewlines) OS << NL;
389 }
390 
391 void StmtPrinter::VisitContinueStmt(ContinueStmt *Node) {
392  Indent() << "continue;";
393  if (Policy.IncludeNewlines) OS << NL;
394 }
395 
396 void StmtPrinter::VisitBreakStmt(BreakStmt *Node) {
397  Indent() << "break;";
398  if (Policy.IncludeNewlines) OS << NL;
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 << NL;
409 }
410 
411 void StmtPrinter::VisitGCCAsmStmt(GCCAsmStmt *Node) {
412  Indent() << "asm ";
413 
414  if (Node->isVolatile())
415  OS << "volatile ";
416 
417  if (Node->isAsmGoto())
418  OS << "goto ";
419 
420  OS << "(";
421  VisitStringLiteral(Node->getAsmString());
422 
423  // Outputs
424  if (Node->getNumOutputs() != 0 || Node->getNumInputs() != 0 ||
425  Node->getNumClobbers() != 0 || Node->getNumLabels() != 0)
426  OS << " : ";
427 
428  for (unsigned i = 0, e = Node->getNumOutputs(); i != e; ++i) {
429  if (i != 0)
430  OS << ", ";
431 
432  if (!Node->getOutputName(i).empty()) {
433  OS << '[';
434  OS << Node->getOutputName(i);
435  OS << "] ";
436  }
437 
438  VisitStringLiteral(Node->getOutputConstraintLiteral(i));
439  OS << " (";
440  Visit(Node->getOutputExpr(i));
441  OS << ")";
442  }
443 
444  // Inputs
445  if (Node->getNumInputs() != 0 || Node->getNumClobbers() != 0 ||
446  Node->getNumLabels() != 0)
447  OS << " : ";
448 
449  for (unsigned i = 0, e = Node->getNumInputs(); i != e; ++i) {
450  if (i != 0)
451  OS << ", ";
452 
453  if (!Node->getInputName(i).empty()) {
454  OS << '[';
455  OS << Node->getInputName(i);
456  OS << "] ";
457  }
458 
459  VisitStringLiteral(Node->getInputConstraintLiteral(i));
460  OS << " (";
461  Visit(Node->getInputExpr(i));
462  OS << ")";
463  }
464 
465  // Clobbers
466  if (Node->getNumClobbers() != 0 || Node->getNumLabels())
467  OS << " : ";
468 
469  for (unsigned i = 0, e = Node->getNumClobbers(); i != e; ++i) {
470  if (i != 0)
471  OS << ", ";
472 
473  VisitStringLiteral(Node->getClobberStringLiteral(i));
474  }
475 
476  // Labels
477  if (Node->getNumLabels() != 0)
478  OS << " : ";
479 
480  for (unsigned i = 0, e = Node->getNumLabels(); i != e; ++i) {
481  if (i != 0)
482  OS << ", ";
483  OS << Node->getLabelName(i);
484  }
485 
486  OS << ");";
487  if (Policy.IncludeNewlines) OS << NL;
488 }
489 
490 void StmtPrinter::VisitMSAsmStmt(MSAsmStmt *Node) {
491  // FIXME: Implement MS style inline asm statement printer.
492  Indent() << "__asm ";
493  if (Node->hasBraces())
494  OS << "{" << NL;
495  OS << Node->getAsmString() << NL;
496  if (Node->hasBraces())
497  Indent() << "}" << NL;
498 }
499 
500 void StmtPrinter::VisitCapturedStmt(CapturedStmt *Node) {
501  PrintStmt(Node->getCapturedDecl()->getBody());
502 }
503 
504 void StmtPrinter::VisitObjCAtTryStmt(ObjCAtTryStmt *Node) {
505  Indent() << "@try";
506  if (auto *TS = dyn_cast<CompoundStmt>(Node->getTryBody())) {
507  PrintRawCompoundStmt(TS);
508  OS << NL;
509  }
510 
511  for (unsigned I = 0, N = Node->getNumCatchStmts(); I != N; ++I) {
512  ObjCAtCatchStmt *catchStmt = Node->getCatchStmt(I);
513  Indent() << "@catch(";
514  if (catchStmt->getCatchParamDecl()) {
515  if (Decl *DS = catchStmt->getCatchParamDecl())
516  PrintRawDecl(DS);
517  }
518  OS << ")";
519  if (auto *CS = dyn_cast<CompoundStmt>(catchStmt->getCatchBody())) {
520  PrintRawCompoundStmt(CS);
521  OS << NL;
522  }
523  }
524 
525  if (auto *FS = static_cast<ObjCAtFinallyStmt *>(Node->getFinallyStmt())) {
526  Indent() << "@finally";
527  PrintRawCompoundStmt(dyn_cast<CompoundStmt>(FS->getFinallyBody()));
528  OS << NL;
529  }
530 }
531 
532 void StmtPrinter::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *Node) {
533 }
534 
535 void StmtPrinter::VisitObjCAtCatchStmt (ObjCAtCatchStmt *Node) {
536  Indent() << "@catch (...) { /* todo */ } " << NL;
537 }
538 
539 void StmtPrinter::VisitObjCAtThrowStmt(ObjCAtThrowStmt *Node) {
540  Indent() << "@throw";
541  if (Node->getThrowExpr()) {
542  OS << " ";
543  PrintExpr(Node->getThrowExpr());
544  }
545  OS << ";" << NL;
546 }
547 
548 void StmtPrinter::VisitObjCAvailabilityCheckExpr(
550  OS << "@available(...)";
551 }
552 
553 void StmtPrinter::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *Node) {
554  Indent() << "@synchronized (";
555  PrintExpr(Node->getSynchExpr());
556  OS << ")";
557  PrintRawCompoundStmt(Node->getSynchBody());
558  OS << NL;
559 }
560 
561 void StmtPrinter::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *Node) {
562  Indent() << "@autoreleasepool";
563  PrintRawCompoundStmt(dyn_cast<CompoundStmt>(Node->getSubStmt()));
564  OS << NL;
565 }
566 
567 void StmtPrinter::PrintRawCXXCatchStmt(CXXCatchStmt *Node) {
568  OS << "catch (";
569  if (Decl *ExDecl = Node->getExceptionDecl())
570  PrintRawDecl(ExDecl);
571  else
572  OS << "...";
573  OS << ") ";
574  PrintRawCompoundStmt(cast<CompoundStmt>(Node->getHandlerBlock()));
575 }
576 
577 void StmtPrinter::VisitCXXCatchStmt(CXXCatchStmt *Node) {
578  Indent();
579  PrintRawCXXCatchStmt(Node);
580  OS << NL;
581 }
582 
583 void StmtPrinter::VisitCXXTryStmt(CXXTryStmt *Node) {
584  Indent() << "try ";
585  PrintRawCompoundStmt(Node->getTryBlock());
586  for (unsigned i = 0, e = Node->getNumHandlers(); i < e; ++i) {
587  OS << " ";
588  PrintRawCXXCatchStmt(Node->getHandler(i));
589  }
590  OS << NL;
591 }
592 
593 void StmtPrinter::VisitSEHTryStmt(SEHTryStmt *Node) {
594  Indent() << (Node->getIsCXXTry() ? "try " : "__try ");
595  PrintRawCompoundStmt(Node->getTryBlock());
596  SEHExceptStmt *E = Node->getExceptHandler();
597  SEHFinallyStmt *F = Node->getFinallyHandler();
598  if(E)
599  PrintRawSEHExceptHandler(E);
600  else {
601  assert(F && "Must have a finally block...");
602  PrintRawSEHFinallyStmt(F);
603  }
604  OS << NL;
605 }
606 
607 void StmtPrinter::PrintRawSEHFinallyStmt(SEHFinallyStmt *Node) {
608  OS << "__finally ";
609  PrintRawCompoundStmt(Node->getBlock());
610  OS << NL;
611 }
612 
613 void StmtPrinter::PrintRawSEHExceptHandler(SEHExceptStmt *Node) {
614  OS << "__except (";
615  VisitExpr(Node->getFilterExpr());
616  OS << ")" << NL;
617  PrintRawCompoundStmt(Node->getBlock());
618  OS << NL;
619 }
620 
621 void StmtPrinter::VisitSEHExceptStmt(SEHExceptStmt *Node) {
622  Indent();
623  PrintRawSEHExceptHandler(Node);
624  OS << NL;
625 }
626 
627 void StmtPrinter::VisitSEHFinallyStmt(SEHFinallyStmt *Node) {
628  Indent();
629  PrintRawSEHFinallyStmt(Node);
630  OS << NL;
631 }
632 
633 void StmtPrinter::VisitSEHLeaveStmt(SEHLeaveStmt *Node) {
634  Indent() << "__leave;";
635  if (Policy.IncludeNewlines) OS << NL;
636 }
637 
638 //===----------------------------------------------------------------------===//
639 // OpenMP directives printing methods
640 //===----------------------------------------------------------------------===//
641 
642 void StmtPrinter::PrintOMPExecutableDirective(OMPExecutableDirective *S,
643  bool ForceNoStmt) {
644  OMPClausePrinter Printer(OS, Policy);
645  ArrayRef<OMPClause *> Clauses = S->clauses();
646  for (auto *Clause : Clauses)
647  if (Clause && !Clause->isImplicit()) {
648  OS << ' ';
649  Printer.Visit(Clause);
650  }
651  OS << NL;
652  if (!ForceNoStmt && S->hasAssociatedStmt())
653  PrintStmt(S->getInnermostCapturedStmt()->getCapturedStmt());
654 }
655 
656 void StmtPrinter::VisitOMPParallelDirective(OMPParallelDirective *Node) {
657  Indent() << "#pragma omp parallel";
658  PrintOMPExecutableDirective(Node);
659 }
660 
661 void StmtPrinter::VisitOMPSimdDirective(OMPSimdDirective *Node) {
662  Indent() << "#pragma omp simd";
663  PrintOMPExecutableDirective(Node);
664 }
665 
666 void StmtPrinter::VisitOMPForDirective(OMPForDirective *Node) {
667  Indent() << "#pragma omp for";
668  PrintOMPExecutableDirective(Node);
669 }
670 
671 void StmtPrinter::VisitOMPForSimdDirective(OMPForSimdDirective *Node) {
672  Indent() << "#pragma omp for simd";
673  PrintOMPExecutableDirective(Node);
674 }
675 
676 void StmtPrinter::VisitOMPSectionsDirective(OMPSectionsDirective *Node) {
677  Indent() << "#pragma omp sections";
678  PrintOMPExecutableDirective(Node);
679 }
680 
681 void StmtPrinter::VisitOMPSectionDirective(OMPSectionDirective *Node) {
682  Indent() << "#pragma omp section";
683  PrintOMPExecutableDirective(Node);
684 }
685 
686 void StmtPrinter::VisitOMPSingleDirective(OMPSingleDirective *Node) {
687  Indent() << "#pragma omp single";
688  PrintOMPExecutableDirective(Node);
689 }
690 
691 void StmtPrinter::VisitOMPMasterDirective(OMPMasterDirective *Node) {
692  Indent() << "#pragma omp master";
693  PrintOMPExecutableDirective(Node);
694 }
695 
696 void StmtPrinter::VisitOMPCriticalDirective(OMPCriticalDirective *Node) {
697  Indent() << "#pragma omp critical";
698  if (Node->getDirectiveName().getName()) {
699  OS << " (";
700  Node->getDirectiveName().printName(OS);
701  OS << ")";
702  }
703  PrintOMPExecutableDirective(Node);
704 }
705 
706 void StmtPrinter::VisitOMPParallelForDirective(OMPParallelForDirective *Node) {
707  Indent() << "#pragma omp parallel for";
708  PrintOMPExecutableDirective(Node);
709 }
710 
711 void StmtPrinter::VisitOMPParallelForSimdDirective(
713  Indent() << "#pragma omp parallel for simd";
714  PrintOMPExecutableDirective(Node);
715 }
716 
717 void StmtPrinter::VisitOMPParallelSectionsDirective(
719  Indent() << "#pragma omp parallel sections";
720  PrintOMPExecutableDirective(Node);
721 }
722 
723 void StmtPrinter::VisitOMPTaskDirective(OMPTaskDirective *Node) {
724  Indent() << "#pragma omp task";
725  PrintOMPExecutableDirective(Node);
726 }
727 
728 void StmtPrinter::VisitOMPTaskyieldDirective(OMPTaskyieldDirective *Node) {
729  Indent() << "#pragma omp taskyield";
730  PrintOMPExecutableDirective(Node);
731 }
732 
733 void StmtPrinter::VisitOMPBarrierDirective(OMPBarrierDirective *Node) {
734  Indent() << "#pragma omp barrier";
735  PrintOMPExecutableDirective(Node);
736 }
737 
738 void StmtPrinter::VisitOMPTaskwaitDirective(OMPTaskwaitDirective *Node) {
739  Indent() << "#pragma omp taskwait";
740  PrintOMPExecutableDirective(Node);
741 }
742 
743 void StmtPrinter::VisitOMPTaskgroupDirective(OMPTaskgroupDirective *Node) {
744  Indent() << "#pragma omp taskgroup";
745  PrintOMPExecutableDirective(Node);
746 }
747 
748 void StmtPrinter::VisitOMPFlushDirective(OMPFlushDirective *Node) {
749  Indent() << "#pragma omp flush";
750  PrintOMPExecutableDirective(Node);
751 }
752 
753 void StmtPrinter::VisitOMPOrderedDirective(OMPOrderedDirective *Node) {
754  Indent() << "#pragma omp ordered";
755  PrintOMPExecutableDirective(Node, Node->hasClausesOfKind<OMPDependClause>());
756 }
757 
758 void StmtPrinter::VisitOMPAtomicDirective(OMPAtomicDirective *Node) {
759  Indent() << "#pragma omp atomic";
760  PrintOMPExecutableDirective(Node);
761 }
762 
763 void StmtPrinter::VisitOMPTargetDirective(OMPTargetDirective *Node) {
764  Indent() << "#pragma omp target";
765  PrintOMPExecutableDirective(Node);
766 }
767 
768 void StmtPrinter::VisitOMPTargetDataDirective(OMPTargetDataDirective *Node) {
769  Indent() << "#pragma omp target data";
770  PrintOMPExecutableDirective(Node);
771 }
772 
773 void StmtPrinter::VisitOMPTargetEnterDataDirective(
775  Indent() << "#pragma omp target enter data";
776  PrintOMPExecutableDirective(Node, /*ForceNoStmt=*/true);
777 }
778 
779 void StmtPrinter::VisitOMPTargetExitDataDirective(
781  Indent() << "#pragma omp target exit data";
782  PrintOMPExecutableDirective(Node, /*ForceNoStmt=*/true);
783 }
784 
785 void StmtPrinter::VisitOMPTargetParallelDirective(
787  Indent() << "#pragma omp target parallel";
788  PrintOMPExecutableDirective(Node);
789 }
790 
791 void StmtPrinter::VisitOMPTargetParallelForDirective(
793  Indent() << "#pragma omp target parallel for";
794  PrintOMPExecutableDirective(Node);
795 }
796 
797 void StmtPrinter::VisitOMPTeamsDirective(OMPTeamsDirective *Node) {
798  Indent() << "#pragma omp teams";
799  PrintOMPExecutableDirective(Node);
800 }
801 
802 void StmtPrinter::VisitOMPCancellationPointDirective(
804  Indent() << "#pragma omp cancellation point "
806  PrintOMPExecutableDirective(Node);
807 }
808 
809 void StmtPrinter::VisitOMPCancelDirective(OMPCancelDirective *Node) {
810  Indent() << "#pragma omp cancel "
812  PrintOMPExecutableDirective(Node);
813 }
814 
815 void StmtPrinter::VisitOMPTaskLoopDirective(OMPTaskLoopDirective *Node) {
816  Indent() << "#pragma omp taskloop";
817  PrintOMPExecutableDirective(Node);
818 }
819 
820 void StmtPrinter::VisitOMPTaskLoopSimdDirective(
821  OMPTaskLoopSimdDirective *Node) {
822  Indent() << "#pragma omp taskloop simd";
823  PrintOMPExecutableDirective(Node);
824 }
825 
826 void StmtPrinter::VisitOMPMasterTaskLoopDirective(
828  Indent() << "#pragma omp master taskloop";
829  PrintOMPExecutableDirective(Node);
830 }
831 
832 void StmtPrinter::VisitOMPMasterTaskLoopSimdDirective(
834  Indent() << "#pragma omp master taskloop simd";
835  PrintOMPExecutableDirective(Node);
836 }
837 
838 void StmtPrinter::VisitOMPParallelMasterTaskLoopDirective(
840  Indent() << "#pragma omp parallel master taskloop";
841  PrintOMPExecutableDirective(Node);
842 }
843 
844 void StmtPrinter::VisitOMPDistributeDirective(OMPDistributeDirective *Node) {
845  Indent() << "#pragma omp distribute";
846  PrintOMPExecutableDirective(Node);
847 }
848 
849 void StmtPrinter::VisitOMPTargetUpdateDirective(
850  OMPTargetUpdateDirective *Node) {
851  Indent() << "#pragma omp target update";
852  PrintOMPExecutableDirective(Node, /*ForceNoStmt=*/true);
853 }
854 
855 void StmtPrinter::VisitOMPDistributeParallelForDirective(
857  Indent() << "#pragma omp distribute parallel for";
858  PrintOMPExecutableDirective(Node);
859 }
860 
861 void StmtPrinter::VisitOMPDistributeParallelForSimdDirective(
863  Indent() << "#pragma omp distribute parallel for simd";
864  PrintOMPExecutableDirective(Node);
865 }
866 
867 void StmtPrinter::VisitOMPDistributeSimdDirective(
869  Indent() << "#pragma omp distribute simd";
870  PrintOMPExecutableDirective(Node);
871 }
872 
873 void StmtPrinter::VisitOMPTargetParallelForSimdDirective(
875  Indent() << "#pragma omp target parallel for simd";
876  PrintOMPExecutableDirective(Node);
877 }
878 
879 void StmtPrinter::VisitOMPTargetSimdDirective(OMPTargetSimdDirective *Node) {
880  Indent() << "#pragma omp target simd";
881  PrintOMPExecutableDirective(Node);
882 }
883 
884 void StmtPrinter::VisitOMPTeamsDistributeDirective(
886  Indent() << "#pragma omp teams distribute";
887  PrintOMPExecutableDirective(Node);
888 }
889 
890 void StmtPrinter::VisitOMPTeamsDistributeSimdDirective(
892  Indent() << "#pragma omp teams distribute simd";
893  PrintOMPExecutableDirective(Node);
894 }
895 
896 void StmtPrinter::VisitOMPTeamsDistributeParallelForSimdDirective(
898  Indent() << "#pragma omp teams distribute parallel for simd";
899  PrintOMPExecutableDirective(Node);
900 }
901 
902 void StmtPrinter::VisitOMPTeamsDistributeParallelForDirective(
904  Indent() << "#pragma omp teams distribute parallel for";
905  PrintOMPExecutableDirective(Node);
906 }
907 
908 void StmtPrinter::VisitOMPTargetTeamsDirective(OMPTargetTeamsDirective *Node) {
909  Indent() << "#pragma omp target teams";
910  PrintOMPExecutableDirective(Node);
911 }
912 
913 void StmtPrinter::VisitOMPTargetTeamsDistributeDirective(
915  Indent() << "#pragma omp target teams distribute";
916  PrintOMPExecutableDirective(Node);
917 }
918 
919 void StmtPrinter::VisitOMPTargetTeamsDistributeParallelForDirective(
921  Indent() << "#pragma omp target teams distribute parallel for";
922  PrintOMPExecutableDirective(Node);
923 }
924 
925 void StmtPrinter::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
927  Indent() << "#pragma omp target teams distribute parallel for simd";
928  PrintOMPExecutableDirective(Node);
929 }
930 
931 void StmtPrinter::VisitOMPTargetTeamsDistributeSimdDirective(
933  Indent() << "#pragma omp target teams distribute simd";
934  PrintOMPExecutableDirective(Node);
935 }
936 
937 //===----------------------------------------------------------------------===//
938 // Expr printing methods.
939 //===----------------------------------------------------------------------===//
940 
941 void StmtPrinter::VisitSourceLocExpr(SourceLocExpr *Node) {
942  OS << Node->getBuiltinStr() << "()";
943 }
944 
945 void StmtPrinter::VisitConstantExpr(ConstantExpr *Node) {
946  PrintExpr(Node->getSubExpr());
947 }
948 
949 void StmtPrinter::VisitDeclRefExpr(DeclRefExpr *Node) {
950  if (const auto *OCED = dyn_cast<OMPCapturedExprDecl>(Node->getDecl())) {
951  OCED->getInit()->IgnoreImpCasts()->printPretty(OS, nullptr, Policy);
952  return;
953  }
954  if (NestedNameSpecifier *Qualifier = Node->getQualifier())
955  Qualifier->print(OS, Policy);
956  if (Node->hasTemplateKeyword())
957  OS << "template ";
958  OS << Node->getNameInfo();
959  if (Node->hasExplicitTemplateArgs())
960  printTemplateArgumentList(OS, Node->template_arguments(), Policy);
961 }
962 
963 void StmtPrinter::VisitDependentScopeDeclRefExpr(
965  if (NestedNameSpecifier *Qualifier = Node->getQualifier())
966  Qualifier->print(OS, Policy);
967  if (Node->hasTemplateKeyword())
968  OS << "template ";
969  OS << Node->getNameInfo();
970  if (Node->hasExplicitTemplateArgs())
971  printTemplateArgumentList(OS, Node->template_arguments(), Policy);
972 }
973 
974 void StmtPrinter::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *Node) {
975  if (Node->getQualifier())
976  Node->getQualifier()->print(OS, Policy);
977  if (Node->hasTemplateKeyword())
978  OS << "template ";
979  OS << Node->getNameInfo();
980  if (Node->hasExplicitTemplateArgs())
981  printTemplateArgumentList(OS, Node->template_arguments(), Policy);
982 }
983 
984 static bool isImplicitSelf(const Expr *E) {
985  if (const auto *DRE = dyn_cast<DeclRefExpr>(E)) {
986  if (const auto *PD = dyn_cast<ImplicitParamDecl>(DRE->getDecl())) {
987  if (PD->getParameterKind() == ImplicitParamDecl::ObjCSelf &&
988  DRE->getBeginLoc().isInvalid())
989  return true;
990  }
991  }
992  return false;
993 }
994 
995 void StmtPrinter::VisitObjCIvarRefExpr(ObjCIvarRefExpr *Node) {
996  if (Node->getBase()) {
997  if (!Policy.SuppressImplicitBase ||
998  !isImplicitSelf(Node->getBase()->IgnoreImpCasts())) {
999  PrintExpr(Node->getBase());
1000  OS << (Node->isArrow() ? "->" : ".");
1001  }
1002  }
1003  OS << *Node->getDecl();
1004 }
1005 
1006 void StmtPrinter::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *Node) {
1007  if (Node->isSuperReceiver())
1008  OS << "super.";
1009  else if (Node->isObjectReceiver() && Node->getBase()) {
1010  PrintExpr(Node->getBase());
1011  OS << ".";
1012  } else if (Node->isClassReceiver() && Node->getClassReceiver()) {
1013  OS << Node->getClassReceiver()->getName() << ".";
1014  }
1015 
1016  if (Node->isImplicitProperty()) {
1017  if (const auto *Getter = Node->getImplicitPropertyGetter())
1018  Getter->getSelector().print(OS);
1019  else
1022  } else
1023  OS << Node->getExplicitProperty()->getName();
1024 }
1025 
1026 void StmtPrinter::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *Node) {
1027  PrintExpr(Node->getBaseExpr());
1028  OS << "[";
1029  PrintExpr(Node->getKeyExpr());
1030  OS << "]";
1031 }
1032 
1033 void StmtPrinter::VisitPredefinedExpr(PredefinedExpr *Node) {
1035 }
1036 
1037 void StmtPrinter::VisitCharacterLiteral(CharacterLiteral *Node) {
1038  unsigned value = Node->getValue();
1039 
1040  switch (Node->getKind()) {
1041  case CharacterLiteral::Ascii: break; // no prefix.
1042  case CharacterLiteral::Wide: OS << 'L'; break;
1043  case CharacterLiteral::UTF8: OS << "u8"; break;
1044  case CharacterLiteral::UTF16: OS << 'u'; break;
1045  case CharacterLiteral::UTF32: OS << 'U'; break;
1046  }
1047 
1048  switch (value) {
1049  case '\\':
1050  OS << "'\\\\'";
1051  break;
1052  case '\'':
1053  OS << "'\\''";
1054  break;
1055  case '\a':
1056  // TODO: K&R: the meaning of '\\a' is different in traditional C
1057  OS << "'\\a'";
1058  break;
1059  case '\b':
1060  OS << "'\\b'";
1061  break;
1062  // Nonstandard escape sequence.
1063  /*case '\e':
1064  OS << "'\\e'";
1065  break;*/
1066  case '\f':
1067  OS << "'\\f'";
1068  break;
1069  case '\n':
1070  OS << "'\\n'";
1071  break;
1072  case '\r':
1073  OS << "'\\r'";
1074  break;
1075  case '\t':
1076  OS << "'\\t'";
1077  break;
1078  case '\v':
1079  OS << "'\\v'";
1080  break;
1081  default:
1082  // A character literal might be sign-extended, which
1083  // would result in an invalid \U escape sequence.
1084  // FIXME: multicharacter literals such as '\xFF\xFF\xFF\xFF'
1085  // are not correctly handled.
1086  if ((value & ~0xFFu) == ~0xFFu && Node->getKind() == CharacterLiteral::Ascii)
1087  value &= 0xFFu;
1088  if (value < 256 && isPrintable((unsigned char)value))
1089  OS << "'" << (char)value << "'";
1090  else if (value < 256)
1091  OS << "'\\x" << llvm::format("%02x", value) << "'";
1092  else if (value <= 0xFFFF)
1093  OS << "'\\u" << llvm::format("%04x", value) << "'";
1094  else
1095  OS << "'\\U" << llvm::format("%08x", value) << "'";
1096  }
1097 }
1098 
1099 /// Prints the given expression using the original source text. Returns true on
1100 /// success, false otherwise.
1101 static bool printExprAsWritten(raw_ostream &OS, Expr *E,
1102  const ASTContext *Context) {
1103  if (!Context)
1104  return false;
1105  bool Invalid = false;
1106  StringRef Source = Lexer::getSourceText(
1108  Context->getSourceManager(), Context->getLangOpts(), &Invalid);
1109  if (!Invalid) {
1110  OS << Source;
1111  return true;
1112  }
1113  return false;
1114 }
1115 
1116 void StmtPrinter::VisitIntegerLiteral(IntegerLiteral *Node) {
1117  if (Policy.ConstantsAsWritten && printExprAsWritten(OS, Node, Context))
1118  return;
1119  bool isSigned = Node->getType()->isSignedIntegerType();
1120  OS << Node->getValue().toString(10, isSigned);
1121 
1122  // Emit suffixes. Integer literals are always a builtin integer type.
1123  switch (Node->getType()->castAs<BuiltinType>()->getKind()) {
1124  default: llvm_unreachable("Unexpected type for integer literal!");
1125  case BuiltinType::Char_S:
1126  case BuiltinType::Char_U: OS << "i8"; break;
1127  case BuiltinType::UChar: OS << "Ui8"; break;
1128  case BuiltinType::Short: OS << "i16"; break;
1129  case BuiltinType::UShort: OS << "Ui16"; break;
1130  case BuiltinType::Int: break; // no suffix.
1131  case BuiltinType::UInt: OS << 'U'; break;
1132  case BuiltinType::Long: OS << 'L'; break;
1133  case BuiltinType::ULong: OS << "UL"; break;
1134  case BuiltinType::LongLong: OS << "LL"; break;
1135  case BuiltinType::ULongLong: OS << "ULL"; break;
1136  }
1137 }
1138 
1139 void StmtPrinter::VisitFixedPointLiteral(FixedPointLiteral *Node) {
1140  if (Policy.ConstantsAsWritten && printExprAsWritten(OS, Node, Context))
1141  return;
1142  OS << Node->getValueAsString(/*Radix=*/10);
1143 
1144  switch (Node->getType()->castAs<BuiltinType>()->getKind()) {
1145  default: llvm_unreachable("Unexpected type for fixed point literal!");
1146  case BuiltinType::ShortFract: OS << "hr"; break;
1147  case BuiltinType::ShortAccum: OS << "hk"; break;
1148  case BuiltinType::UShortFract: OS << "uhr"; break;
1149  case BuiltinType::UShortAccum: OS << "uhk"; break;
1150  case BuiltinType::Fract: OS << "r"; break;
1151  case BuiltinType::Accum: OS << "k"; break;
1152  case BuiltinType::UFract: OS << "ur"; break;
1153  case BuiltinType::UAccum: OS << "uk"; break;
1154  case BuiltinType::LongFract: OS << "lr"; break;
1155  case BuiltinType::LongAccum: OS << "lk"; break;
1156  case BuiltinType::ULongFract: OS << "ulr"; break;
1157  case BuiltinType::ULongAccum: OS << "ulk"; break;
1158  }
1159 }
1160 
1161 static void PrintFloatingLiteral(raw_ostream &OS, FloatingLiteral *Node,
1162  bool PrintSuffix) {
1163  SmallString<16> Str;
1164  Node->getValue().toString(Str);
1165  OS << Str;
1166  if (Str.find_first_not_of("-0123456789") == StringRef::npos)
1167  OS << '.'; // Trailing dot in order to separate from ints.
1168 
1169  if (!PrintSuffix)
1170  return;
1171 
1172  // Emit suffixes. Float literals are always a builtin float type.
1173  switch (Node->getType()->castAs<BuiltinType>()->getKind()) {
1174  default: llvm_unreachable("Unexpected type for float literal!");
1175  case BuiltinType::Half: break; // FIXME: suffix?
1176  case BuiltinType::Double: break; // no suffix.
1177  case BuiltinType::Float16: OS << "F16"; break;
1178  case BuiltinType::Float: OS << 'F'; break;
1179  case BuiltinType::LongDouble: OS << 'L'; break;
1180  case BuiltinType::Float128: OS << 'Q'; break;
1181  }
1182 }
1183 
1184 void StmtPrinter::VisitFloatingLiteral(FloatingLiteral *Node) {
1185  if (Policy.ConstantsAsWritten && printExprAsWritten(OS, Node, Context))
1186  return;
1187  PrintFloatingLiteral(OS, Node, /*PrintSuffix=*/true);
1188 }
1189 
1190 void StmtPrinter::VisitImaginaryLiteral(ImaginaryLiteral *Node) {
1191  PrintExpr(Node->getSubExpr());
1192  OS << "i";
1193 }
1194 
1195 void StmtPrinter::VisitStringLiteral(StringLiteral *Str) {
1196  Str->outputString(OS);
1197 }
1198 
1199 void StmtPrinter::VisitParenExpr(ParenExpr *Node) {
1200  OS << "(";
1201  PrintExpr(Node->getSubExpr());
1202  OS << ")";
1203 }
1204 
1205 void StmtPrinter::VisitUnaryOperator(UnaryOperator *Node) {
1206  if (!Node->isPostfix()) {
1207  OS << UnaryOperator::getOpcodeStr(Node->getOpcode());
1208 
1209  // Print a space if this is an "identifier operator" like __real, or if
1210  // it might be concatenated incorrectly like '+'.
1211  switch (Node->getOpcode()) {
1212  default: break;
1213  case UO_Real:
1214  case UO_Imag:
1215  case UO_Extension:
1216  OS << ' ';
1217  break;
1218  case UO_Plus:
1219  case UO_Minus:
1220  if (isa<UnaryOperator>(Node->getSubExpr()))
1221  OS << ' ';
1222  break;
1223  }
1224  }
1225  PrintExpr(Node->getSubExpr());
1226 
1227  if (Node->isPostfix())
1228  OS << UnaryOperator::getOpcodeStr(Node->getOpcode());
1229 }
1230 
1231 void StmtPrinter::VisitOffsetOfExpr(OffsetOfExpr *Node) {
1232  OS << "__builtin_offsetof(";
1233  Node->getTypeSourceInfo()->getType().print(OS, Policy);
1234  OS << ", ";
1235  bool PrintedSomething = false;
1236  for (unsigned i = 0, n = Node->getNumComponents(); i < n; ++i) {
1237  OffsetOfNode ON = Node->getComponent(i);
1238  if (ON.getKind() == OffsetOfNode::Array) {
1239  // Array node
1240  OS << "[";
1241  PrintExpr(Node->getIndexExpr(ON.getArrayExprIndex()));
1242  OS << "]";
1243  PrintedSomething = true;
1244  continue;
1245  }
1246 
1247  // Skip implicit base indirections.
1248  if (ON.getKind() == OffsetOfNode::Base)
1249  continue;
1250 
1251  // Field or identifier node.
1252  IdentifierInfo *Id = ON.getFieldName();
1253  if (!Id)
1254  continue;
1255 
1256  if (PrintedSomething)
1257  OS << ".";
1258  else
1259  PrintedSomething = true;
1260  OS << Id->getName();
1261  }
1262  OS << ")";
1263 }
1264 
1265 void StmtPrinter::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *Node){
1266  switch(Node->getKind()) {
1267  case UETT_SizeOf:
1268  OS << "sizeof";
1269  break;
1270  case UETT_AlignOf:
1271  if (Policy.Alignof)
1272  OS << "alignof";
1273  else if (Policy.UnderscoreAlignof)
1274  OS << "_Alignof";
1275  else
1276  OS << "__alignof";
1277  break;
1278  case UETT_PreferredAlignOf:
1279  OS << "__alignof";
1280  break;
1281  case UETT_VecStep:
1282  OS << "vec_step";
1283  break;
1285  OS << "__builtin_omp_required_simd_align";
1286  break;
1287  }
1288  if (Node->isArgumentType()) {
1289  OS << '(';
1290  Node->getArgumentType().print(OS, Policy);
1291  OS << ')';
1292  } else {
1293  OS << " ";
1294  PrintExpr(Node->getArgumentExpr());
1295  }
1296 }
1297 
1298 void StmtPrinter::VisitGenericSelectionExpr(GenericSelectionExpr *Node) {
1299  OS << "_Generic(";
1300  PrintExpr(Node->getControllingExpr());
1301  for (const GenericSelectionExpr::Association &Assoc : Node->associations()) {
1302  OS << ", ";
1303  QualType T = Assoc.getType();
1304  if (T.isNull())
1305  OS << "default";
1306  else
1307  T.print(OS, Policy);
1308  OS << ": ";
1309  PrintExpr(Assoc.getAssociationExpr());
1310  }
1311  OS << ")";
1312 }
1313 
1314 void StmtPrinter::VisitArraySubscriptExpr(ArraySubscriptExpr *Node) {
1315  PrintExpr(Node->getLHS());
1316  OS << "[";
1317  PrintExpr(Node->getRHS());
1318  OS << "]";
1319 }
1320 
1321 void StmtPrinter::VisitOMPArraySectionExpr(OMPArraySectionExpr *Node) {
1322  PrintExpr(Node->getBase());
1323  OS << "[";
1324  if (Node->getLowerBound())
1325  PrintExpr(Node->getLowerBound());
1326  if (Node->getColonLoc().isValid()) {
1327  OS << ":";
1328  if (Node->getLength())
1329  PrintExpr(Node->getLength());
1330  }
1331  OS << "]";
1332 }
1333 
1334 void StmtPrinter::PrintCallArgs(CallExpr *Call) {
1335  for (unsigned i = 0, e = Call->getNumArgs(); i != e; ++i) {
1336  if (isa<CXXDefaultArgExpr>(Call->getArg(i))) {
1337  // Don't print any defaulted arguments
1338  break;
1339  }
1340 
1341  if (i) OS << ", ";
1342  PrintExpr(Call->getArg(i));
1343  }
1344 }
1345 
1346 void StmtPrinter::VisitCallExpr(CallExpr *Call) {
1347  PrintExpr(Call->getCallee());
1348  OS << "(";
1349  PrintCallArgs(Call);
1350  OS << ")";
1351 }
1352 
1353 static bool isImplicitThis(const Expr *E) {
1354  if (const auto *TE = dyn_cast<CXXThisExpr>(E))
1355  return TE->isImplicit();
1356  return false;
1357 }
1358 
1359 void StmtPrinter::VisitMemberExpr(MemberExpr *Node) {
1360  if (!Policy.SuppressImplicitBase || !isImplicitThis(Node->getBase())) {
1361  PrintExpr(Node->getBase());
1362 
1363  auto *ParentMember = dyn_cast<MemberExpr>(Node->getBase());
1364  FieldDecl *ParentDecl =
1365  ParentMember ? dyn_cast<FieldDecl>(ParentMember->getMemberDecl())
1366  : nullptr;
1367 
1368  if (!ParentDecl || !ParentDecl->isAnonymousStructOrUnion())
1369  OS << (Node->isArrow() ? "->" : ".");
1370  }
1371 
1372  if (auto *FD = dyn_cast<FieldDecl>(Node->getMemberDecl()))
1373  if (FD->isAnonymousStructOrUnion())
1374  return;
1375 
1376  if (NestedNameSpecifier *Qualifier = Node->getQualifier())
1377  Qualifier->print(OS, Policy);
1378  if (Node->hasTemplateKeyword())
1379  OS << "template ";
1380  OS << Node->getMemberNameInfo();
1381  if (Node->hasExplicitTemplateArgs())
1382  printTemplateArgumentList(OS, Node->template_arguments(), Policy);
1383 }
1384 
1385 void StmtPrinter::VisitObjCIsaExpr(ObjCIsaExpr *Node) {
1386  PrintExpr(Node->getBase());
1387  OS << (Node->isArrow() ? "->isa" : ".isa");
1388 }
1389 
1390 void StmtPrinter::VisitExtVectorElementExpr(ExtVectorElementExpr *Node) {
1391  PrintExpr(Node->getBase());
1392  OS << ".";
1393  OS << Node->getAccessor().getName();
1394 }
1395 
1396 void StmtPrinter::VisitCStyleCastExpr(CStyleCastExpr *Node) {
1397  OS << '(';
1398  Node->getTypeAsWritten().print(OS, Policy);
1399  OS << ')';
1400  PrintExpr(Node->getSubExpr());
1401 }
1402 
1403 void StmtPrinter::VisitCompoundLiteralExpr(CompoundLiteralExpr *Node) {
1404  OS << '(';
1405  Node->getType().print(OS, Policy);
1406  OS << ')';
1407  PrintExpr(Node->getInitializer());
1408 }
1409 
1410 void StmtPrinter::VisitImplicitCastExpr(ImplicitCastExpr *Node) {
1411  // No need to print anything, simply forward to the subexpression.
1412  PrintExpr(Node->getSubExpr());
1413 }
1414 
1415 void StmtPrinter::VisitBinaryOperator(BinaryOperator *Node) {
1416  PrintExpr(Node->getLHS());
1417  OS << " " << BinaryOperator::getOpcodeStr(Node->getOpcode()) << " ";
1418  PrintExpr(Node->getRHS());
1419 }
1420 
1421 void StmtPrinter::VisitCompoundAssignOperator(CompoundAssignOperator *Node) {
1422  PrintExpr(Node->getLHS());
1423  OS << " " << BinaryOperator::getOpcodeStr(Node->getOpcode()) << " ";
1424  PrintExpr(Node->getRHS());
1425 }
1426 
1427 void StmtPrinter::VisitConditionalOperator(ConditionalOperator *Node) {
1428  PrintExpr(Node->getCond());
1429  OS << " ? ";
1430  PrintExpr(Node->getLHS());
1431  OS << " : ";
1432  PrintExpr(Node->getRHS());
1433 }
1434 
1435 // GNU extensions.
1436 
1437 void
1438 StmtPrinter::VisitBinaryConditionalOperator(BinaryConditionalOperator *Node) {
1439  PrintExpr(Node->getCommon());
1440  OS << " ?: ";
1441  PrintExpr(Node->getFalseExpr());
1442 }
1443 
1444 void StmtPrinter::VisitAddrLabelExpr(AddrLabelExpr *Node) {
1445  OS << "&&" << Node->getLabel()->getName();
1446 }
1447 
1448 void StmtPrinter::VisitStmtExpr(StmtExpr *E) {
1449  OS << "(";
1450  PrintRawCompoundStmt(E->getSubStmt());
1451  OS << ")";
1452 }
1453 
1454 void StmtPrinter::VisitChooseExpr(ChooseExpr *Node) {
1455  OS << "__builtin_choose_expr(";
1456  PrintExpr(Node->getCond());
1457  OS << ", ";
1458  PrintExpr(Node->getLHS());
1459  OS << ", ";
1460  PrintExpr(Node->getRHS());
1461  OS << ")";
1462 }
1463 
1464 void StmtPrinter::VisitGNUNullExpr(GNUNullExpr *) {
1465  OS << "__null";
1466 }
1467 
1468 void StmtPrinter::VisitShuffleVectorExpr(ShuffleVectorExpr *Node) {
1469  OS << "__builtin_shufflevector(";
1470  for (unsigned i = 0, e = Node->getNumSubExprs(); i != e; ++i) {
1471  if (i) OS << ", ";
1472  PrintExpr(Node->getExpr(i));
1473  }
1474  OS << ")";
1475 }
1476 
1477 void StmtPrinter::VisitConvertVectorExpr(ConvertVectorExpr *Node) {
1478  OS << "__builtin_convertvector(";
1479  PrintExpr(Node->getSrcExpr());
1480  OS << ", ";
1481  Node->getType().print(OS, Policy);
1482  OS << ")";
1483 }
1484 
1485 void StmtPrinter::VisitInitListExpr(InitListExpr* Node) {
1486  if (Node->getSyntacticForm()) {
1487  Visit(Node->getSyntacticForm());
1488  return;
1489  }
1490 
1491  OS << "{";
1492  for (unsigned i = 0, e = Node->getNumInits(); i != e; ++i) {
1493  if (i) OS << ", ";
1494  if (Node->getInit(i))
1495  PrintExpr(Node->getInit(i));
1496  else
1497  OS << "{}";
1498  }
1499  OS << "}";
1500 }
1501 
1502 void StmtPrinter::VisitArrayInitLoopExpr(ArrayInitLoopExpr *Node) {
1503  // There's no way to express this expression in any of our supported
1504  // languages, so just emit something terse and (hopefully) clear.
1505  OS << "{";
1506  PrintExpr(Node->getSubExpr());
1507  OS << "}";
1508 }
1509 
1510 void StmtPrinter::VisitArrayInitIndexExpr(ArrayInitIndexExpr *Node) {
1511  OS << "*";
1512 }
1513 
1514 void StmtPrinter::VisitParenListExpr(ParenListExpr* Node) {
1515  OS << "(";
1516  for (unsigned i = 0, e = Node->getNumExprs(); i != e; ++i) {
1517  if (i) OS << ", ";
1518  PrintExpr(Node->getExpr(i));
1519  }
1520  OS << ")";
1521 }
1522 
1523 void StmtPrinter::VisitDesignatedInitExpr(DesignatedInitExpr *Node) {
1524  bool NeedsEquals = true;
1525  for (const DesignatedInitExpr::Designator &D : Node->designators()) {
1526  if (D.isFieldDesignator()) {
1527  if (D.getDotLoc().isInvalid()) {
1528  if (IdentifierInfo *II = D.getFieldName()) {
1529  OS << II->getName() << ":";
1530  NeedsEquals = false;
1531  }
1532  } else {
1533  OS << "." << D.getFieldName()->getName();
1534  }
1535  } else {
1536  OS << "[";
1537  if (D.isArrayDesignator()) {
1538  PrintExpr(Node->getArrayIndex(D));
1539  } else {
1540  PrintExpr(Node->getArrayRangeStart(D));
1541  OS << " ... ";
1542  PrintExpr(Node->getArrayRangeEnd(D));
1543  }
1544  OS << "]";
1545  }
1546  }
1547 
1548  if (NeedsEquals)
1549  OS << " = ";
1550  else
1551  OS << " ";
1552  PrintExpr(Node->getInit());
1553 }
1554 
1555 void StmtPrinter::VisitDesignatedInitUpdateExpr(
1556  DesignatedInitUpdateExpr *Node) {
1557  OS << "{";
1558  OS << "/*base*/";
1559  PrintExpr(Node->getBase());
1560  OS << ", ";
1561 
1562  OS << "/*updater*/";
1563  PrintExpr(Node->getUpdater());
1564  OS << "}";
1565 }
1566 
1567 void StmtPrinter::VisitNoInitExpr(NoInitExpr *Node) {
1568  OS << "/*no init*/";
1569 }
1570 
1571 void StmtPrinter::VisitImplicitValueInitExpr(ImplicitValueInitExpr *Node) {
1572  if (Node->getType()->getAsCXXRecordDecl()) {
1573  OS << "/*implicit*/";
1574  Node->getType().print(OS, Policy);
1575  OS << "()";
1576  } else {
1577  OS << "/*implicit*/(";
1578  Node->getType().print(OS, Policy);
1579  OS << ')';
1580  if (Node->getType()->isRecordType())
1581  OS << "{}";
1582  else
1583  OS << 0;
1584  }
1585 }
1586 
1587 void StmtPrinter::VisitVAArgExpr(VAArgExpr *Node) {
1588  OS << "__builtin_va_arg(";
1589  PrintExpr(Node->getSubExpr());
1590  OS << ", ";
1591  Node->getType().print(OS, Policy);
1592  OS << ")";
1593 }
1594 
1595 void StmtPrinter::VisitPseudoObjectExpr(PseudoObjectExpr *Node) {
1596  PrintExpr(Node->getSyntacticForm());
1597 }
1598 
1599 void StmtPrinter::VisitAtomicExpr(AtomicExpr *Node) {
1600  const char *Name = nullptr;
1601  switch (Node->getOp()) {
1602 #define BUILTIN(ID, TYPE, ATTRS)
1603 #define ATOMIC_BUILTIN(ID, TYPE, ATTRS) \
1604  case AtomicExpr::AO ## ID: \
1605  Name = #ID "("; \
1606  break;
1607 #include "clang/Basic/Builtins.def"
1608  }
1609  OS << Name;
1610 
1611  // AtomicExpr stores its subexpressions in a permuted order.
1612  PrintExpr(Node->getPtr());
1613  if (Node->getOp() != AtomicExpr::AO__c11_atomic_load &&
1614  Node->getOp() != AtomicExpr::AO__atomic_load_n &&
1615  Node->getOp() != AtomicExpr::AO__opencl_atomic_load) {
1616  OS << ", ";
1617  PrintExpr(Node->getVal1());
1618  }
1619  if (Node->getOp() == AtomicExpr::AO__atomic_exchange ||
1620  Node->isCmpXChg()) {
1621  OS << ", ";
1622  PrintExpr(Node->getVal2());
1623  }
1624  if (Node->getOp() == AtomicExpr::AO__atomic_compare_exchange ||
1625  Node->getOp() == AtomicExpr::AO__atomic_compare_exchange_n) {
1626  OS << ", ";
1627  PrintExpr(Node->getWeak());
1628  }
1629  if (Node->getOp() != AtomicExpr::AO__c11_atomic_init &&
1630  Node->getOp() != AtomicExpr::AO__opencl_atomic_init) {
1631  OS << ", ";
1632  PrintExpr(Node->getOrder());
1633  }
1634  if (Node->isCmpXChg()) {
1635  OS << ", ";
1636  PrintExpr(Node->getOrderFail());
1637  }
1638  OS << ")";
1639 }
1640 
1641 // C++
1642 void StmtPrinter::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *Node) {
1644  if (Kind == OO_PlusPlus || Kind == OO_MinusMinus) {
1645  if (Node->getNumArgs() == 1) {
1646  OS << getOperatorSpelling(Kind) << ' ';
1647  PrintExpr(Node->getArg(0));
1648  } else {
1649  PrintExpr(Node->getArg(0));
1650  OS << ' ' << getOperatorSpelling(Kind);
1651  }
1652  } else if (Kind == OO_Arrow) {
1653  PrintExpr(Node->getArg(0));
1654  } else if (Kind == OO_Call) {
1655  PrintExpr(Node->getArg(0));
1656  OS << '(';
1657  for (unsigned ArgIdx = 1; ArgIdx < Node->getNumArgs(); ++ArgIdx) {
1658  if (ArgIdx > 1)
1659  OS << ", ";
1660  if (!isa<CXXDefaultArgExpr>(Node->getArg(ArgIdx)))
1661  PrintExpr(Node->getArg(ArgIdx));
1662  }
1663  OS << ')';
1664  } else if (Kind == OO_Subscript) {
1665  PrintExpr(Node->getArg(0));
1666  OS << '[';
1667  PrintExpr(Node->getArg(1));
1668  OS << ']';
1669  } else if (Node->getNumArgs() == 1) {
1670  OS << getOperatorSpelling(Kind) << ' ';
1671  PrintExpr(Node->getArg(0));
1672  } else if (Node->getNumArgs() == 2) {
1673  PrintExpr(Node->getArg(0));
1674  OS << ' ' << getOperatorSpelling(Kind) << ' ';
1675  PrintExpr(Node->getArg(1));
1676  } else {
1677  llvm_unreachable("unknown overloaded operator");
1678  }
1679 }
1680 
1681 void StmtPrinter::VisitCXXMemberCallExpr(CXXMemberCallExpr *Node) {
1682  // If we have a conversion operator call only print the argument.
1683  CXXMethodDecl *MD = Node->getMethodDecl();
1684  if (MD && isa<CXXConversionDecl>(MD)) {
1685  PrintExpr(Node->getImplicitObjectArgument());
1686  return;
1687  }
1688  VisitCallExpr(cast<CallExpr>(Node));
1689 }
1690 
1691 void StmtPrinter::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *Node) {
1692  PrintExpr(Node->getCallee());
1693  OS << "<<<";
1694  PrintCallArgs(Node->getConfig());
1695  OS << ">>>(";
1696  PrintCallArgs(Node);
1697  OS << ")";
1698 }
1699 
1700 void StmtPrinter::VisitCXXRewrittenBinaryOperator(
1703  Node->getDecomposedForm();
1704  PrintExpr(const_cast<Expr*>(Decomposed.LHS));
1705  OS << ' ' << BinaryOperator::getOpcodeStr(Decomposed.Opcode) << ' ';
1706  PrintExpr(const_cast<Expr*>(Decomposed.RHS));
1707 }
1708 
1709 void StmtPrinter::VisitCXXNamedCastExpr(CXXNamedCastExpr *Node) {
1710  OS << Node->getCastName() << '<';
1711  Node->getTypeAsWritten().print(OS, Policy);
1712  OS << ">(";
1713  PrintExpr(Node->getSubExpr());
1714  OS << ")";
1715 }
1716 
1717 void StmtPrinter::VisitCXXStaticCastExpr(CXXStaticCastExpr *Node) {
1718  VisitCXXNamedCastExpr(Node);
1719 }
1720 
1721 void StmtPrinter::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *Node) {
1722  VisitCXXNamedCastExpr(Node);
1723 }
1724 
1725 void StmtPrinter::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *Node) {
1726  VisitCXXNamedCastExpr(Node);
1727 }
1728 
1729 void StmtPrinter::VisitCXXConstCastExpr(CXXConstCastExpr *Node) {
1730  VisitCXXNamedCastExpr(Node);
1731 }
1732 
1733 void StmtPrinter::VisitBuiltinBitCastExpr(BuiltinBitCastExpr *Node) {
1734  OS << "__builtin_bit_cast(";
1735  Node->getTypeInfoAsWritten()->getType().print(OS, Policy);
1736  OS << ", ";
1737  PrintExpr(Node->getSubExpr());
1738  OS << ")";
1739 }
1740 
1741 void StmtPrinter::VisitCXXTypeidExpr(CXXTypeidExpr *Node) {
1742  OS << "typeid(";
1743  if (Node->isTypeOperand()) {
1744  Node->getTypeOperandSourceInfo()->getType().print(OS, Policy);
1745  } else {
1746  PrintExpr(Node->getExprOperand());
1747  }
1748  OS << ")";
1749 }
1750 
1751 void StmtPrinter::VisitCXXUuidofExpr(CXXUuidofExpr *Node) {
1752  OS << "__uuidof(";
1753  if (Node->isTypeOperand()) {
1754  Node->getTypeOperandSourceInfo()->getType().print(OS, Policy);
1755  } else {
1756  PrintExpr(Node->getExprOperand());
1757  }
1758  OS << ")";
1759 }
1760 
1761 void StmtPrinter::VisitMSPropertyRefExpr(MSPropertyRefExpr *Node) {
1762  PrintExpr(Node->getBaseExpr());
1763  if (Node->isArrow())
1764  OS << "->";
1765  else
1766  OS << ".";
1767  if (NestedNameSpecifier *Qualifier =
1769  Qualifier->print(OS, Policy);
1770  OS << Node->getPropertyDecl()->getDeclName();
1771 }
1772 
1773 void StmtPrinter::VisitMSPropertySubscriptExpr(MSPropertySubscriptExpr *Node) {
1774  PrintExpr(Node->getBase());
1775  OS << "[";
1776  PrintExpr(Node->getIdx());
1777  OS << "]";
1778 }
1779 
1780 void StmtPrinter::VisitUserDefinedLiteral(UserDefinedLiteral *Node) {
1781  switch (Node->getLiteralOperatorKind()) {
1783  OS << cast<StringLiteral>(Node->getArg(0)->IgnoreImpCasts())->getString();
1784  break;
1786  const auto *DRE = cast<DeclRefExpr>(Node->getCallee()->IgnoreImpCasts());
1787  const TemplateArgumentList *Args =
1788  cast<FunctionDecl>(DRE->getDecl())->getTemplateSpecializationArgs();
1789  assert(Args);
1790 
1791  if (Args->size() != 1) {
1792  OS << "operator\"\"" << Node->getUDSuffix()->getName();
1793  printTemplateArgumentList(OS, Args->asArray(), Policy);
1794  OS << "()";
1795  return;
1796  }
1797 
1798  const TemplateArgument &Pack = Args->get(0);
1799  for (const auto &P : Pack.pack_elements()) {
1800  char C = (char)P.getAsIntegral().getZExtValue();
1801  OS << C;
1802  }
1803  break;
1804  }
1806  // Print integer literal without suffix.
1807  const auto *Int = cast<IntegerLiteral>(Node->getCookedLiteral());
1808  OS << Int->getValue().toString(10, /*isSigned*/false);
1809  break;
1810  }
1812  // Print floating literal without suffix.
1813  auto *Float = cast<FloatingLiteral>(Node->getCookedLiteral());
1814  PrintFloatingLiteral(OS, Float, /*PrintSuffix=*/false);
1815  break;
1816  }
1819  PrintExpr(Node->getCookedLiteral());
1820  break;
1821  }
1822  OS << Node->getUDSuffix()->getName();
1823 }
1824 
1825 void StmtPrinter::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *Node) {
1826  OS << (Node->getValue() ? "true" : "false");
1827 }
1828 
1829 void StmtPrinter::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *Node) {
1830  OS << "nullptr";
1831 }
1832 
1833 void StmtPrinter::VisitCXXThisExpr(CXXThisExpr *Node) {
1834  OS << "this";
1835 }
1836 
1837 void StmtPrinter::VisitCXXThrowExpr(CXXThrowExpr *Node) {
1838  if (!Node->getSubExpr())
1839  OS << "throw";
1840  else {
1841  OS << "throw ";
1842  PrintExpr(Node->getSubExpr());
1843  }
1844 }
1845 
1846 void StmtPrinter::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *Node) {
1847  // Nothing to print: we picked up the default argument.
1848 }
1849 
1850 void StmtPrinter::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *Node) {
1851  // Nothing to print: we picked up the default initializer.
1852 }
1853 
1854 void StmtPrinter::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *Node) {
1855  Node->getType().print(OS, Policy);
1856  // If there are no parens, this is list-initialization, and the braces are
1857  // part of the syntax of the inner construct.
1858  if (Node->getLParenLoc().isValid())
1859  OS << "(";
1860  PrintExpr(Node->getSubExpr());
1861  if (Node->getLParenLoc().isValid())
1862  OS << ")";
1863 }
1864 
1865 void StmtPrinter::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *Node) {
1866  PrintExpr(Node->getSubExpr());
1867 }
1868 
1869 void StmtPrinter::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *Node) {
1870  Node->getType().print(OS, Policy);
1871  if (Node->isStdInitListInitialization())
1872  /* Nothing to do; braces are part of creating the std::initializer_list. */;
1873  else if (Node->isListInitialization())
1874  OS << "{";
1875  else
1876  OS << "(";
1878  ArgEnd = Node->arg_end();
1879  Arg != ArgEnd; ++Arg) {
1880  if ((*Arg)->isDefaultArgument())
1881  break;
1882  if (Arg != Node->arg_begin())
1883  OS << ", ";
1884  PrintExpr(*Arg);
1885  }
1886  if (Node->isStdInitListInitialization())
1887  /* See above. */;
1888  else if (Node->isListInitialization())
1889  OS << "}";
1890  else
1891  OS << ")";
1892 }
1893 
1894 void StmtPrinter::VisitLambdaExpr(LambdaExpr *Node) {
1895  OS << '[';
1896  bool NeedComma = false;
1897  switch (Node->getCaptureDefault()) {
1898  case LCD_None:
1899  break;
1900 
1901  case LCD_ByCopy:
1902  OS << '=';
1903  NeedComma = true;
1904  break;
1905 
1906  case LCD_ByRef:
1907  OS << '&';
1908  NeedComma = true;
1909  break;
1910  }
1912  CEnd = Node->explicit_capture_end();
1913  C != CEnd;
1914  ++C) {
1915  if (C->capturesVLAType())
1916  continue;
1917 
1918  if (NeedComma)
1919  OS << ", ";
1920  NeedComma = true;
1921 
1922  switch (C->getCaptureKind()) {
1923  case LCK_This:
1924  OS << "this";
1925  break;
1926 
1927  case LCK_StarThis:
1928  OS << "*this";
1929  break;
1930 
1931  case LCK_ByRef:
1932  if (Node->getCaptureDefault() != LCD_ByRef || Node->isInitCapture(C))
1933  OS << '&';
1934  OS << C->getCapturedVar()->getName();
1935  break;
1936 
1937  case LCK_ByCopy:
1938  OS << C->getCapturedVar()->getName();
1939  break;
1940 
1941  case LCK_VLAType:
1942  llvm_unreachable("VLA type in explicit captures.");
1943  }
1944 
1945  if (C->isPackExpansion())
1946  OS << "...";
1947 
1948  if (Node->isInitCapture(C))
1949  PrintExpr(C->getCapturedVar()->getInit());
1950  }
1951  OS << ']';
1952 
1953  if (!Node->getExplicitTemplateParameters().empty()) {
1955  OS, Node->getLambdaClass()->getASTContext(),
1956  /*OmitTemplateKW*/true);
1957  }
1958 
1959  if (Node->hasExplicitParameters()) {
1960  OS << '(';
1961  CXXMethodDecl *Method = Node->getCallOperator();
1962  NeedComma = false;
1963  for (const auto *P : Method->parameters()) {
1964  if (NeedComma) {
1965  OS << ", ";
1966  } else {
1967  NeedComma = true;
1968  }
1969  std::string ParamStr = P->getNameAsString();
1970  P->getOriginalType().print(OS, Policy, ParamStr);
1971  }
1972  if (Method->isVariadic()) {
1973  if (NeedComma)
1974  OS << ", ";
1975  OS << "...";
1976  }
1977  OS << ')';
1978 
1979  if (Node->isMutable())
1980  OS << " mutable";
1981 
1982  auto *Proto = Method->getType()->castAs<FunctionProtoType>();
1983  Proto->printExceptionSpecification(OS, Policy);
1984 
1985  // FIXME: Attributes
1986 
1987  // Print the trailing return type if it was specified in the source.
1988  if (Node->hasExplicitResultType()) {
1989  OS << " -> ";
1990  Proto->getReturnType().print(OS, Policy);
1991  }
1992  }
1993 
1994  // Print the body.
1995  OS << ' ';
1996  if (Policy.TerseOutput)
1997  OS << "{}";
1998  else
1999  PrintRawCompoundStmt(Node->getBody());
2000 }
2001 
2002 void StmtPrinter::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *Node) {
2003  if (TypeSourceInfo *TSInfo = Node->getTypeSourceInfo())
2004  TSInfo->getType().print(OS, Policy);
2005  else
2006  Node->getType().print(OS, Policy);
2007  OS << "()";
2008 }
2009 
2010 void StmtPrinter::VisitCXXNewExpr(CXXNewExpr *E) {
2011  if (E->isGlobalNew())
2012  OS << "::";
2013  OS << "new ";
2014  unsigned NumPlace = E->getNumPlacementArgs();
2015  if (NumPlace > 0 && !isa<CXXDefaultArgExpr>(E->getPlacementArg(0))) {
2016  OS << "(";
2017  PrintExpr(E->getPlacementArg(0));
2018  for (unsigned i = 1; i < NumPlace; ++i) {
2019  if (isa<CXXDefaultArgExpr>(E->getPlacementArg(i)))
2020  break;
2021  OS << ", ";
2022  PrintExpr(E->getPlacementArg(i));
2023  }
2024  OS << ") ";
2025  }
2026  if (E->isParenTypeId())
2027  OS << "(";
2028  std::string TypeS;
2029  if (Optional<Expr *> Size = E->getArraySize()) {
2030  llvm::raw_string_ostream s(TypeS);
2031  s << '[';
2032  if (*Size)
2033  (*Size)->printPretty(s, Helper, Policy);
2034  s << ']';
2035  }
2036  E->getAllocatedType().print(OS, Policy, TypeS);
2037  if (E->isParenTypeId())
2038  OS << ")";
2039 
2041  if (InitStyle) {
2042  if (InitStyle == CXXNewExpr::CallInit)
2043  OS << "(";
2044  PrintExpr(E->getInitializer());
2045  if (InitStyle == CXXNewExpr::CallInit)
2046  OS << ")";
2047  }
2048 }
2049 
2050 void StmtPrinter::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
2051  if (E->isGlobalDelete())
2052  OS << "::";
2053  OS << "delete ";
2054  if (E->isArrayForm())
2055  OS << "[] ";
2056  PrintExpr(E->getArgument());
2057 }
2058 
2059 void StmtPrinter::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
2060  PrintExpr(E->getBase());
2061  if (E->isArrow())
2062  OS << "->";
2063  else
2064  OS << '.';
2065  if (E->getQualifier())
2066  E->getQualifier()->print(OS, Policy);
2067  OS << "~";
2068 
2070  OS << II->getName();
2071  else
2072  E->getDestroyedType().print(OS, Policy);
2073 }
2074 
2075 void StmtPrinter::VisitCXXConstructExpr(CXXConstructExpr *E) {
2077  OS << "{";
2078 
2079  for (unsigned i = 0, e = E->getNumArgs(); i != e; ++i) {
2080  if (isa<CXXDefaultArgExpr>(E->getArg(i))) {
2081  // Don't print any defaulted arguments
2082  break;
2083  }
2084 
2085  if (i) OS << ", ";
2086  PrintExpr(E->getArg(i));
2087  }
2088 
2090  OS << "}";
2091 }
2092 
2093 void StmtPrinter::VisitCXXInheritedCtorInitExpr(CXXInheritedCtorInitExpr *E) {
2094  // Parens are printed by the surrounding context.
2095  OS << "<forwarded>";
2096 }
2097 
2098 void StmtPrinter::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E) {
2099  PrintExpr(E->getSubExpr());
2100 }
2101 
2102 void StmtPrinter::VisitExprWithCleanups(ExprWithCleanups *E) {
2103  // Just forward to the subexpression.
2104  PrintExpr(E->getSubExpr());
2105 }
2106 
2107 void
2108 StmtPrinter::VisitCXXUnresolvedConstructExpr(
2110  Node->getTypeAsWritten().print(OS, Policy);
2111  OS << "(";
2113  ArgEnd = Node->arg_end();
2114  Arg != ArgEnd; ++Arg) {
2115  if (Arg != Node->arg_begin())
2116  OS << ", ";
2117  PrintExpr(*Arg);
2118  }
2119  OS << ")";
2120 }
2121 
2122 void StmtPrinter::VisitCXXDependentScopeMemberExpr(
2124  if (!Node->isImplicitAccess()) {
2125  PrintExpr(Node->getBase());
2126  OS << (Node->isArrow() ? "->" : ".");
2127  }
2128  if (NestedNameSpecifier *Qualifier = Node->getQualifier())
2129  Qualifier->print(OS, Policy);
2130  if (Node->hasTemplateKeyword())
2131  OS << "template ";
2132  OS << Node->getMemberNameInfo();
2133  if (Node->hasExplicitTemplateArgs())
2134  printTemplateArgumentList(OS, Node->template_arguments(), Policy);
2135 }
2136 
2137 void StmtPrinter::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *Node) {
2138  if (!Node->isImplicitAccess()) {
2139  PrintExpr(Node->getBase());
2140  OS << (Node->isArrow() ? "->" : ".");
2141  }
2142  if (NestedNameSpecifier *Qualifier = Node->getQualifier())
2143  Qualifier->print(OS, Policy);
2144  if (Node->hasTemplateKeyword())
2145  OS << "template ";
2146  OS << Node->getMemberNameInfo();
2147  if (Node->hasExplicitTemplateArgs())
2148  printTemplateArgumentList(OS, Node->template_arguments(), Policy);
2149 }
2150 
2151 static const char *getTypeTraitName(TypeTrait TT) {
2152  switch (TT) {
2153 #define TYPE_TRAIT_1(Spelling, Name, Key) \
2154 case clang::UTT_##Name: return #Spelling;
2155 #define TYPE_TRAIT_2(Spelling, Name, Key) \
2156 case clang::BTT_##Name: return #Spelling;
2157 #define TYPE_TRAIT_N(Spelling, Name, Key) \
2158  case clang::TT_##Name: return #Spelling;
2159 #include "clang/Basic/TokenKinds.def"
2160  }
2161  llvm_unreachable("Type trait not covered by switch");
2162 }
2163 
2164 static const char *getTypeTraitName(ArrayTypeTrait ATT) {
2165  switch (ATT) {
2166  case ATT_ArrayRank: return "__array_rank";
2167  case ATT_ArrayExtent: return "__array_extent";
2168  }
2169  llvm_unreachable("Array type trait not covered by switch");
2170 }
2171 
2172 static const char *getExpressionTraitName(ExpressionTrait ET) {
2173  switch (ET) {
2174  case ET_IsLValueExpr: return "__is_lvalue_expr";
2175  case ET_IsRValueExpr: return "__is_rvalue_expr";
2176  }
2177  llvm_unreachable("Expression type trait not covered by switch");
2178 }
2179 
2180 void StmtPrinter::VisitTypeTraitExpr(TypeTraitExpr *E) {
2181  OS << getTypeTraitName(E->getTrait()) << "(";
2182  for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) {
2183  if (I > 0)
2184  OS << ", ";
2185  E->getArg(I)->getType().print(OS, Policy);
2186  }
2187  OS << ")";
2188 }
2189 
2190 void StmtPrinter::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
2191  OS << getTypeTraitName(E->getTrait()) << '(';
2192  E->getQueriedType().print(OS, Policy);
2193  OS << ')';
2194 }
2195 
2196 void StmtPrinter::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
2197  OS << getExpressionTraitName(E->getTrait()) << '(';
2198  PrintExpr(E->getQueriedExpression());
2199  OS << ')';
2200 }
2201 
2202 void StmtPrinter::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
2203  OS << "noexcept(";
2204  PrintExpr(E->getOperand());
2205  OS << ")";
2206 }
2207 
2208 void StmtPrinter::VisitPackExpansionExpr(PackExpansionExpr *E) {
2209  PrintExpr(E->getPattern());
2210  OS << "...";
2211 }
2212 
2213 void StmtPrinter::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
2214  OS << "sizeof...(" << *E->getPack() << ")";
2215 }
2216 
2217 void StmtPrinter::VisitSubstNonTypeTemplateParmPackExpr(
2219  OS << *Node->getParameterPack();
2220 }
2221 
2222 void StmtPrinter::VisitSubstNonTypeTemplateParmExpr(
2224  Visit(Node->getReplacement());
2225 }
2226 
2227 void StmtPrinter::VisitFunctionParmPackExpr(FunctionParmPackExpr *E) {
2228  OS << *E->getParameterPack();
2229 }
2230 
2231 void StmtPrinter::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *Node){
2232  PrintExpr(Node->GetTemporaryExpr());
2233 }
2234 
2235 void StmtPrinter::VisitCXXFoldExpr(CXXFoldExpr *E) {
2236  OS << "(";
2237  if (E->getLHS()) {
2238  PrintExpr(E->getLHS());
2239  OS << " " << BinaryOperator::getOpcodeStr(E->getOperator()) << " ";
2240  }
2241  OS << "...";
2242  if (E->getRHS()) {
2243  OS << " " << BinaryOperator::getOpcodeStr(E->getOperator()) << " ";
2244  PrintExpr(E->getRHS());
2245  }
2246  OS << ")";
2247 }
2248 
2249 void StmtPrinter::VisitConceptSpecializationExpr(ConceptSpecializationExpr *E) {
2251  if (NNS)
2252  NNS.getNestedNameSpecifier()->print(OS, Policy);
2253  if (E->getTemplateKWLoc().isValid())
2254  OS << "template ";
2255  OS << E->getFoundDecl()->getName();
2257  Policy);
2258 }
2259 
2260 // C++ Coroutines TS
2261 
2262 void StmtPrinter::VisitCoroutineBodyStmt(CoroutineBodyStmt *S) {
2263  Visit(S->getBody());
2264 }
2265 
2266 void StmtPrinter::VisitCoreturnStmt(CoreturnStmt *S) {
2267  OS << "co_return";
2268  if (S->getOperand()) {
2269  OS << " ";
2270  Visit(S->getOperand());
2271  }
2272  OS << ";";
2273 }
2274 
2275 void StmtPrinter::VisitCoawaitExpr(CoawaitExpr *S) {
2276  OS << "co_await ";
2277  PrintExpr(S->getOperand());
2278 }
2279 
2280 void StmtPrinter::VisitDependentCoawaitExpr(DependentCoawaitExpr *S) {
2281  OS << "co_await ";
2282  PrintExpr(S->getOperand());
2283 }
2284 
2285 void StmtPrinter::VisitCoyieldExpr(CoyieldExpr *S) {
2286  OS << "co_yield ";
2287  PrintExpr(S->getOperand());
2288 }
2289 
2290 // Obj-C
2291 
2292 void StmtPrinter::VisitObjCStringLiteral(ObjCStringLiteral *Node) {
2293  OS << "@";
2294  VisitStringLiteral(Node->getString());
2295 }
2296 
2297 void StmtPrinter::VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
2298  OS << "@";
2299  Visit(E->getSubExpr());
2300 }
2301 
2302 void StmtPrinter::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
2303  OS << "@[ ";
2305  for (auto I = Ch.begin(), E = Ch.end(); I != E; ++I) {
2306  if (I != Ch.begin())
2307  OS << ", ";
2308  Visit(*I);
2309  }
2310  OS << " ]";
2311 }
2312 
2313 void StmtPrinter::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
2314  OS << "@{ ";
2315  for (unsigned I = 0, N = E->getNumElements(); I != N; ++I) {
2316  if (I > 0)
2317  OS << ", ";
2318 
2319  ObjCDictionaryElement Element = E->getKeyValueElement(I);
2320  Visit(Element.Key);
2321  OS << " : ";
2322  Visit(Element.Value);
2323  if (Element.isPackExpansion())
2324  OS << "...";
2325  }
2326  OS << " }";
2327 }
2328 
2329 void StmtPrinter::VisitObjCEncodeExpr(ObjCEncodeExpr *Node) {
2330  OS << "@encode(";
2331  Node->getEncodedType().print(OS, Policy);
2332  OS << ')';
2333 }
2334 
2335 void StmtPrinter::VisitObjCSelectorExpr(ObjCSelectorExpr *Node) {
2336  OS << "@selector(";
2337  Node->getSelector().print(OS);
2338  OS << ')';
2339 }
2340 
2341 void StmtPrinter::VisitObjCProtocolExpr(ObjCProtocolExpr *Node) {
2342  OS << "@protocol(" << *Node->getProtocol() << ')';
2343 }
2344 
2345 void StmtPrinter::VisitObjCMessageExpr(ObjCMessageExpr *Mess) {
2346  OS << "[";
2347  switch (Mess->getReceiverKind()) {
2349  PrintExpr(Mess->getInstanceReceiver());
2350  break;
2351 
2353  Mess->getClassReceiver().print(OS, Policy);
2354  break;
2355 
2358  OS << "Super";
2359  break;
2360  }
2361 
2362  OS << ' ';
2363  Selector selector = Mess->getSelector();
2364  if (selector.isUnarySelector()) {
2365  OS << selector.getNameForSlot(0);
2366  } else {
2367  for (unsigned i = 0, e = Mess->getNumArgs(); i != e; ++i) {
2368  if (i < selector.getNumArgs()) {
2369  if (i > 0) OS << ' ';
2370  if (selector.getIdentifierInfoForSlot(i))
2371  OS << selector.getIdentifierInfoForSlot(i)->getName() << ':';
2372  else
2373  OS << ":";
2374  }
2375  else OS << ", "; // Handle variadic methods.
2376 
2377  PrintExpr(Mess->getArg(i));
2378  }
2379  }
2380  OS << "]";
2381 }
2382 
2383 void StmtPrinter::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *Node) {
2384  OS << (Node->getValue() ? "__objc_yes" : "__objc_no");
2385 }
2386 
2387 void
2388 StmtPrinter::VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
2389  PrintExpr(E->getSubExpr());
2390 }
2391 
2392 void
2393 StmtPrinter::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
2394  OS << '(' << E->getBridgeKindName();
2395  E->getType().print(OS, Policy);
2396  OS << ')';
2397  PrintExpr(E->getSubExpr());
2398 }
2399 
2400 void StmtPrinter::VisitBlockExpr(BlockExpr *Node) {
2401  BlockDecl *BD = Node->getBlockDecl();
2402  OS << "^";
2403 
2404  const FunctionType *AFT = Node->getFunctionType();
2405 
2406  if (isa<FunctionNoProtoType>(AFT)) {
2407  OS << "()";
2408  } else if (!BD->param_empty() || cast<FunctionProtoType>(AFT)->isVariadic()) {
2409  OS << '(';
2410  for (BlockDecl::param_iterator AI = BD->param_begin(),
2411  E = BD->param_end(); AI != E; ++AI) {
2412  if (AI != BD->param_begin()) OS << ", ";
2413  std::string ParamStr = (*AI)->getNameAsString();
2414  (*AI)->getType().print(OS, Policy, ParamStr);
2415  }
2416 
2417  const auto *FT = cast<FunctionProtoType>(AFT);
2418  if (FT->isVariadic()) {
2419  if (!BD->param_empty()) OS << ", ";
2420  OS << "...";
2421  }
2422  OS << ')';
2423  }
2424  OS << "{ }";
2425 }
2426 
2427 void StmtPrinter::VisitOpaqueValueExpr(OpaqueValueExpr *Node) {
2428  PrintExpr(Node->getSourceExpr());
2429 }
2430 
2431 void StmtPrinter::VisitTypoExpr(TypoExpr *Node) {
2432  // TODO: Print something reasonable for a TypoExpr, if necessary.
2433  llvm_unreachable("Cannot print TypoExpr nodes");
2434 }
2435 
2436 void StmtPrinter::VisitAsTypeExpr(AsTypeExpr *Node) {
2437  OS << "__builtin_astype(";
2438  PrintExpr(Node->getSrcExpr());
2439  OS << ", ";
2440  Node->getType().print(OS, Policy);
2441  OS << ")";
2442 }
2443 
2444 //===----------------------------------------------------------------------===//
2445 // Stmt method implementations
2446 //===----------------------------------------------------------------------===//
2447 
2448 void Stmt::dumpPretty(const ASTContext &Context) const {
2449  printPretty(llvm::errs(), nullptr, PrintingPolicy(Context.getLangOpts()));
2450 }
2451 
2452 void Stmt::printPretty(raw_ostream &Out, PrinterHelper *Helper,
2453  const PrintingPolicy &Policy, unsigned Indentation,
2454  StringRef NL, const ASTContext *Context) const {
2455  StmtPrinter P(Out, Helper, Policy, Indentation, NL, Context);
2456  P.Visit(const_cast<Stmt *>(this));
2457 }
2458 
2459 void Stmt::printJson(raw_ostream &Out, PrinterHelper *Helper,
2460  const PrintingPolicy &Policy, bool AddQuotes) const {
2461  std::string Buf;
2462  llvm::raw_string_ostream TempOut(Buf);
2463 
2464  printPretty(TempOut, Helper, Policy);
2465 
2466  Out << JsonFormat(TempOut.str(), AddQuotes);
2467 }
2468 
2469 //===----------------------------------------------------------------------===//
2470 // PrinterHelper
2471 //===----------------------------------------------------------------------===//
2472 
2473 // Implement virtual destructor.
2474 PrinterHelper::~PrinterHelper() = default;
Expr * getInc()
Definition: Stmt.h:2427
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
Definition: ExprObjC.h:614
const Expr * getSubExpr() const
Definition: Expr.h:938
ObjCIndirectCopyRestoreExpr - Represents the passing of a function argument by indirect copy-restore ...
Definition: ExprObjC.h:1577
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:1107
ExprIterator arg_iterator
Definition: ExprCXX.h:1549
Represents a single C99 designator.
Definition: Expr.h:4686
Raw form: operator "" X (const char *)
Definition: ExprCXX.h:592
Expr * getVal2() const
Definition: Expr.h:5859
Defines the clang::ASTContext interface.
const BlockDecl * getBlockDecl() const
Definition: Expr.h:5565
This represents &#39;#pragma omp distribute simd&#39; composite directive.
Definition: StmtOpenMP.h:3614
This represents &#39;#pragma omp master&#39; directive.
Definition: StmtOpenMP.h:1592
operator "" X (long double)
Definition: ExprCXX.h:601
TypeSourceInfo * getTypeOperandSourceInfo() const
Retrieve source information for the type operand.
Definition: ExprCXX.h:1036
The null pointer literal (C++11 [lex.nullptr])
Definition: ExprCXX.h:683
capture_iterator explicit_capture_end() const
Retrieve an iterator pointing past the end of the sequence of explicit lambda captures.
Definition: ExprCXX.cpp:1260
This represents &#39;#pragma omp task&#39; directive.
Definition: StmtOpenMP.h:1932
This represents a GCC inline-assembly statement extension.
Definition: Stmt.h:2862
Represents a &#39;co_await&#39; expression while the type of the promise is dependent.
Definition: ExprCXX.h:4741
Expr * getArrayIndex(const Designator &D) const
Definition: Expr.cpp:4354
bool getValue() const
Definition: ExprObjC.h:97
The receiver is an object instance.
Definition: ExprObjC.h:1101
Expr * getLHS() const
Definition: Expr.h:3752
bool hasExplicitTemplateArgs() const
Determines whether this expression had explicit template arguments.
Definition: ExprCXX.h:2995
unsigned getNumInputs() const
Definition: Stmt.h:2774
Expr * getSyntacticForm()
Return the syntactic form of this expression, i.e.
Definition: Expr.h:5717
bool hasTemplateKeyword() const
Determines whether the name was preceded by the template keyword.
Definition: ExprCXX.h:3240
bool hasTemplateKeyword() const
Determines whether the member name was preceded by the template keyword.
Definition: Expr.h:2951
ObjCDictionaryElement getKeyValueElement(unsigned Index) const
Definition: ExprObjC.h:360
const FunctionProtoType * getFunctionType() const
getFunctionType - Return the underlying function type for this block.
Definition: Expr.cpp:2358
CompoundStmt * getBlock() const
Definition: Stmt.h:3253
Smart pointer class that efficiently represents Objective-C method names.
A (possibly-)qualified type.
Definition: Type.h:643
ArrayRef< TemplateArgumentLoc > template_arguments() const
Definition: ExprCXX.h:3267
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
Definition: Expr.h:2894
ArrayRef< OMPClause * > clauses()
Definition: StmtOpenMP.h:325
unsigned SuppressInitializers
Suppress printing of variable initializers.
Expr * getCond() const
Definition: Expr.h:4147
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
Definition: Expr.h:2677
Selector getSelector() const
Definition: ExprObjC.cpp:337
Defines enumerations for the type traits support.
const Expr * getSubExpr() const
Definition: ExprCXX.h:1162
Expr * getCond()
Definition: Stmt.h:2259
Expr * getExpr(unsigned Index)
getExpr - Return the Expr at the specified index.
Definition: Expr.h:4011
unsigned getNumSubExprs() const
getNumSubExprs - Return the size of the SubExprs array.
Definition: Expr.h:4005
bool isSuperReceiver() const
Definition: ExprObjC.h:776
A type trait used in the implementation of various C++11 and Library TR1 trait templates.
Definition: ExprCXX.h:2627
VarDecl * getParameterPack() const
Get the parameter pack which this expression refers to.
Definition: ExprCXX.h:4366
CompoundStmt * getSubStmt()
Definition: Expr.h:3942
BinaryOperatorKind Opcode
The original opcode, prior to rewriting.
Definition: ExprCXX.h:298
const Expr * getInit(unsigned Init) const
Definition: Expr.h:4423
Expr * getControllingExpr()
Return the controlling expression of this generic selection expression.
Definition: Expr.h:5389
bool hasExplicitResultType() const
Whether this lambda had its result type explicitly specified.
Definition: ExprCXX.h:2028
ObjCProtocolDecl * getProtocol() const
Definition: ExprObjC.h:519
Represents a &#39;co_return&#39; statement in the C++ Coroutines TS.
Definition: StmtCXX.h:456
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:2664
const ObjCAtFinallyStmt * getFinallyStmt() const
Retrieve the @finally statement, if any.
Definition: StmtObjC.h:235
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition: Type.h:3393
CXXCatchStmt * getHandler(unsigned i)
Definition: StmtCXX.h:107
IfStmt - This represents an if/then/else.
Definition: Stmt.h:1822
C Language Family Type Representation.
bool param_empty() const
Definition: Decl.h:4048
unsigned getNumOutputs() const
Definition: Stmt.h:2752
static CharSourceRange getTokenRange(SourceRange R)
This represents &#39;#pragma omp for simd&#39; directive.
Definition: StmtOpenMP.h:1342
bool isRecordType() const
Definition: Type.h:6471
Expr * getBase() const
Definition: Expr.h:2888
const StringLiteral * getAsmString() const
Definition: Stmt.h:2890
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:88
This represents &#39;#pragma omp teams distribute parallel for&#39; composite directive.
Definition: StmtOpenMP.h:4025
Expr * getImplicitObjectArgument() const
Retrieve the implicit object argument for the member call.
Definition: ExprCXX.cpp:718
Stmt * getHandlerBlock() const
Definition: StmtCXX.h:51
arg_iterator arg_begin()
Definition: ExprCXX.h:1559
llvm::APFloat getValue() const
Definition: Expr.h:1572
ObjCMethodDecl * getImplicitPropertySetter() const
Definition: ExprObjC.h:717
Represents the index of the current element of an array being initialized by an ArrayInitLoopExpr.
Definition: Expr.h:5054
param_iterator param_end()
Definition: Decl.h:4050
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
Definition: ExprCXX.h:3037
const Expr * getSubExpr() const
Definition: Expr.h:4234
DeclarationNameInfo getNameInfo() const
Retrieve the name of the entity we&#39;re testing for, along with location information.
Definition: StmtCXX.h:288
Defines the C++ template declaration subclasses.
Opcode getOpcode() const
Definition: Expr.h:3444
StringRef P
CapturedStmt * getInnermostCapturedStmt()
Get innermost captured statement for the construct.
Definition: StmtOpenMP.h:283
Represents an attribute applied to a statement.
Definition: Stmt.h:1764
ParenExpr - This represents a parethesized expression, e.g.
Definition: Expr.h:1969
static bool isImplicitThis(const Expr *E)
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies this name, if any.
Definition: StmtCXX.h:284
Expr * getLowerBound()
Get lower bound of array section.
Definition: ExprOpenMP.h:90
This represents &#39;#pragma omp target teams distribute&#39; combined directive.
Definition: StmtOpenMP.h:4162
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies this declaration.
Definition: ExprCXX.h:3211
Represents Objective-C&#39;s @throw statement.
Definition: StmtObjC.h:332
bool hasExplicitTemplateArgs() const
Determines whether this declaration reference was followed by an explicit template argument list...
Definition: Expr.h:1303
llvm::iterator_range< child_iterator > child_range
Definition: Stmt.h:1168
Represents a call to a C++ constructor.
Definition: ExprCXX.h:1422
ObjCSubscriptRefExpr - used for array and dictionary subscripting.
Definition: ExprObjC.h:845
TypeSourceInfo * getTypeInfoAsWritten() const
getTypeInfoAsWritten - Returns the type source info for the type that this expression is casting to...
Definition: Expr.h:3330
An Embarcadero array type trait, as used in the implementation of __array_rank and __array_extent...
Definition: ExprCXX.h:2715
bool getIsCXXTry() const
Definition: Stmt.h:3295
A container of type source information.
Definition: Decl.h:86
const Expr * RHS
The original right-hand side.
Definition: ExprCXX.h:302
NestedNameSpecifier * getQualifier() const
If the member name was qualified, retrieves the nested-name-specifier that precedes the member name...
Definition: ExprCXX.h:2536
static void printGroup(Decl **Begin, unsigned NumDecls, raw_ostream &Out, const PrintingPolicy &Policy, unsigned Indentation=0)
This represents &#39;#pragma omp parallel for&#39; directive.
Definition: StmtOpenMP.h:1713
MS property subscript expression.
Definition: ExprCXX.h:937
IdentKind getIdentKind() const
Definition: Expr.h:1926
This represents &#39;#pragma omp target teams distribute parallel for&#39; combined directive.
Definition: StmtOpenMP.h:4230
Describes the capture of a variable or of this, or of a C++1y init-capture.
Definition: LambdaCapture.h:25
Represents a prvalue temporary that is written into memory so that a reference can bind to it...
Definition: ExprCXX.h:4419
MutableArrayRef< ParmVarDecl * >::iterator param_iterator
Definition: Decl.h:4045
void printExceptionSpecification(raw_ostream &OS, const PrintingPolicy &Policy) const
const Expr * getSubExpr() const
Definition: Expr.h:1649
Expr * getIndexExpr(unsigned Idx)
Definition: Expr.h:2305
This represents &#39;#pragma omp target exit data&#39; directive.
Definition: StmtOpenMP.h:2624
Stmt * getSubStmt()
Definition: Stmt.h:1655
ObjCIsaExpr - Represent X->isa and X.isa when X is an ObjC &#39;id&#39; type.
Definition: ExprObjC.h:1492
CompoundLiteralExpr - [C99 6.5.2.5].
Definition: Expr.h:3052
unsigned getNumArgs() const
Determine the number of arguments to this type trait.
Definition: ExprCXX.h:2676
ObjCInterfaceDecl * getClassReceiver() const
Definition: ExprObjC.h:771
DecomposedForm getDecomposedForm() const LLVM_READONLY
Decompose this operator into its syntactic form.
Definition: ExprCXX.cpp:62
bool isArrow() const
Definition: ExprObjC.h:1520
Expr * getVal1() const
Definition: Expr.h:5849
Implicit construction of a std::initializer_list<T> object from an array temporary within list-initia...
Definition: ExprCXX.h:715
const char * getName() const
Definition: Stmt.cpp:351
Stmt * getThen()
Definition: Stmt.h:1909
unsigned getNumPlacementArgs() const
Definition: ExprCXX.h:2236
Describes how types, statements, expressions, and declarations should be printed. ...
Definition: PrettyPrinter.h:37
Defines the Objective-C statement AST node classes.
A C++ throw-expression (C++ [except.throw]).
Definition: ExprCXX.h:1140
llvm::ArrayRef< TemplateArgumentLoc > arguments() const
Definition: TemplateBase.h:631
Expr * getExprOperand() const
Definition: ExprCXX.h:821
Represents an expression – generally a full-expression – that introduces cleanups to be run at the ...
Definition: ExprCXX.h:3306
TypeSourceInfo * getArg(unsigned I) const
Retrieve the Ith argument.
Definition: ExprCXX.h:2679
Defines the clang::Expr interface and subclasses for C++ expressions.
StringRef getInputName(unsigned i) const
Definition: Stmt.h:2982
unsigned TerseOutput
Provide a &#39;terse&#39; output.
CXXRecordDecl * getLambdaClass() const
Retrieve the class that corresponds to the lambda.
Definition: ExprCXX.cpp:1282
ObjCPropertyDecl * getExplicitProperty() const
Definition: ExprObjC.h:707
A C++ static_cast expression (C++ [expr.static.cast]).
Definition: ExprCXX.h:409
virtual ~PrinterHelper()
Expr * getExprOperand() const
Definition: ExprCXX.h:1046
const Stmt * getSubStmt() const
Definition: StmtObjC.h:379
LabelStmt - Represents a label, which has a substatement.
Definition: Stmt.h:1720
Represents a C99 designated initializer expression.
Definition: Expr.h:4611
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:2363
Expr * GetTemporaryExpr() const
Retrieve the temporary-generating subexpression whose value will be materialized into a glvalue...
Definition: ExprCXX.h:4457
Represents a function call to one of __builtin_LINE(), __builtin_COLUMN(), __builtin_FUNCTION(), or __builtin_FILE().
Definition: Expr.h:4267
An element in an Objective-C dictionary literal.
Definition: ExprObjC.h:261
This represents &#39;#pragma omp parallel&#39; directive.
Definition: StmtOpenMP.h:357
ShuffleVectorExpr - clang-specific builtin-in function __builtin_shufflevector.
Definition: Expr.h:3971
void print(raw_ostream &Out, unsigned Indentation=0, bool PrintInstantiation=false) const
DeclStmt * getConditionVariableDeclStmt()
If this SwitchStmt has a condition variable, return the faux DeclStmt associated with the creation of...
Definition: Stmt.h:2144
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:160
A C++ nested-name-specifier augmented with source location information.
Expr * getInit() const
Retrieve the initializer value.
Definition: Expr.h:4849
Used for GCC&#39;s __alignof.
Definition: TypeTraits.h:106
child_range children()
Definition: ExprObjC.h:244
void printJson(raw_ostream &Out, PrinterHelper *Helper, const PrintingPolicy &Policy, bool AddQuotes) const
Pretty-prints in JSON format.
Represents a member of a struct/union/class.
Definition: Decl.h:2643
Expr * getBase()
Retrieve the base object of this member expressions, e.g., the x in x.m.
Definition: ExprCXX.h:3848
Represents a place-holder for an object not to be initialized by anything.
Definition: Expr.h:4909
const DeclarationNameInfo & getNameInfo() const
Gets the full name info.
Definition: ExprCXX.h:2950
StringLiteral * getString()
Definition: ExprObjC.h:62
RetTy Visit(PTR(OMPClause) S)
CompoundStmt * getBody() const
Retrieve the body of the lambda.
Definition: ExprCXX.cpp:1306
unsigned getArrayExprIndex() const
For an array element node, returns the index into the array of expressions.
Definition: Expr.h:2196
bool hasExplicitTemplateArgs() const
Determines whether the member name was followed by an explicit template argument list.
Definition: Expr.h:2955
GNUNullExpr - Implements the GNU __null extension, which is a name for a null pointer constant that h...
Definition: Expr.h:4182
QualType getDestroyedType() const
Retrieve the type being destroyed.
Definition: ExprCXX.cpp:368
This represents &#39;#pragma omp target simd&#39; directive.
Definition: StmtOpenMP.h:3750
Expr * getSourceExpr() const
The source expression of an opaque value expression is the expression which originally generated the ...
Definition: Expr.h:1108
bool isAsmGoto() const
Definition: Stmt.h:3007
Represents a C++ member access expression for which lookup produced a set of overloaded functions...
Definition: ExprCXX.h:3771
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:5490
Expr * getSubExpr()
Definition: Expr.h:3177
This represents &#39;#pragma omp barrier&#39; directive.
Definition: StmtOpenMP.h:2044
ObjCArrayLiteral - used for objective-c array containers; as in: @["Hello", NSApp, [NSNumber numberWithInt:42]];.
Definition: ExprObjC.h:188
Represents a reference to a non-type template parameter pack that has been substituted with a non-tem...
Definition: ExprCXX.h:4269
This represents &#39;#pragma omp critical&#39; directive.
Definition: StmtOpenMP.h:1639
LambdaCaptureDefault getCaptureDefault() const
Determine the default capture kind for this lambda.
Definition: ExprCXX.h:1889
OpenMPDirectiveKind getCancelRegion() const
Get cancellation region for the current cancellation point.
Definition: StmtOpenMP.h:2923
ArrayRef< TemplateArgumentLoc > template_arguments() const
Definition: ExprCXX.h:3010
bool hasExplicitTemplateArgs() const
Determines whether this lookup had explicit template arguments.
Definition: ExprCXX.h:3243
Selector getSelector() const
Definition: ExprObjC.h:467
ArrayRef< ParmVarDecl * > parameters() const
Definition: Decl.h:2325
bool isUnarySelector() const
Represents Objective-C&#39;s @catch statement.
Definition: StmtObjC.h:77
Expr * getLHS() const
Definition: ExprCXX.h:4563
StringRef getOpcodeStr() const
Definition: Expr.h:3465
IndirectGotoStmt - This represents an indirect goto.
Definition: Stmt.h:2504
Describes an C or C++ initializer list.
Definition: Expr.h:4375
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
Definition: ExprCXX.h:764
This represents &#39;#pragma omp distribute parallel for&#39; composite directive.
Definition: StmtOpenMP.h:3465
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:4664
bool isArrow() const
Definition: ExprObjC.h:584
Expr * getKeyExpr() const
Definition: ExprObjC.h:893
This represents &#39;#pragma omp teams distribute parallel for simd&#39; composite directive.
Definition: StmtOpenMP.h:3954
Optional< Expr * > getArraySize()
Definition: ExprCXX.h:2225
std::string JsonFormat(StringRef RawSR, bool AddQuotes)
Definition: JsonSupport.h:27
ForStmt - This represents a &#39;for (init;cond;inc)&#39; stmt.
Definition: Stmt.h:2394
Expr * getBaseExpr() const
Definition: ExprObjC.h:890
Expr * getOperand() const
Definition: ExprCXX.h:3978
const Expr * getThrowExpr() const
Definition: StmtObjC.h:344
< Capturing the *this object by copy
Definition: Lambda.h:36
bool isGlobalNew() const
Definition: ExprCXX.h:2259
Expr * getPtr() const
Definition: Expr.h:5839
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
void print(raw_ostream &OS, const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) const
Expr * getInitializer()
The initializer of this new-expression.
Definition: ExprCXX.h:2275
Stmt * getBody()
Definition: Stmt.h:2428
A builtin binary operation expression such as "x + y" or "x <= y".
Definition: Expr.h:3409
Stmt * getInit()
Definition: Stmt.h:2407
Expr * getOutputExpr(unsigned i)
Definition: Stmt.cpp:439
ArrayRef< TemplateArgumentLoc > template_arguments() const
Definition: Expr.h:2983
bool isClassReceiver() const
Definition: ExprObjC.h:777
const StringLiteral * getInputConstraintLiteral(unsigned i) const
Definition: Stmt.h:2991
static bool isPostfix(Opcode Op)
isPostfix - Return true if this is a postfix operation, like x++.
Definition: Expr.h:2068
CXXForRangeStmt - This represents C++0x [stmt.ranged]&#39;s ranged for statement, represented as &#39;for (ra...
Definition: StmtCXX.h:134
bool isArrow() const
Definition: Expr.h:2995
This represents &#39;#pragma omp cancellation point&#39; directive.
Definition: StmtOpenMP.h:2879
ObjCStringLiteral, used for Objective-C string literals i.e.
Definition: ExprObjC.h:50
Expr * getRHS() const
Definition: ExprCXX.h:4564
const CallExpr * getConfig() const
Definition: ExprCXX.h:247
bool isArrow() const
Definition: ExprCXX.h:921
New-expression has a C++98 paren-delimited initializer.
Definition: ExprCXX.h:2157
CaseStmt - Represent a case statement.
Definition: Stmt.h:1488
TypoExpr - Internal placeholder for expressions where typo correction still needs to be performed and...
Definition: Expr.h:5936
Expr * getCond()
Definition: Stmt.h:2426
This represents &#39;#pragma omp teams&#39; directive.
Definition: StmtOpenMP.h:2822
NestedNameSpecifier * getQualifier() const
Fetches the nested-name qualifier, if one was given.
Definition: ExprCXX.h:2959
Helper class for OffsetOfExpr.
Definition: Expr.h:2138
Expr * getOperand() const
Definition: ExprCXX.h:4766
This represents &#39;#pragma omp teams distribute simd&#39; combined directive.
Definition: StmtOpenMP.h:3884
AssociationTy< false > Association
Definition: Expr.h:5365
Represents binding an expression to a temporary.
Definition: ExprCXX.h:1373
StringLiteral * getClobberStringLiteral(unsigned i)
Definition: Stmt.h:3071
StringRef getOutputName(unsigned i) const
Definition: Stmt.h:2954
ArrayTypeTrait
Names for the array type traits.
Definition: TypeTraits.h:90
Expr * Key
The key for the dictionary element.
Definition: ExprObjC.h:263
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
Definition: ExprCXX.h:1818
Represents a C++ member access expression where the actual member referenced could not be resolved be...
Definition: ExprCXX.h:3511
bool isCmpXChg() const
Definition: Expr.h:5883
bool isInitCapture(const LambdaCapture *Capture) const
Determine whether one of this lambda&#39;s captures is an init-capture.
Definition: ExprCXX.cpp:1239
void print(raw_ostream &OS, const PrintingPolicy &Policy, bool ResolveTemplateArguments=false) const
Print this nested name specifier to the given output stream.
TypeSourceInfo * getTypeSourceInfo() const
Definition: ExprCXX.h:2073
Stmt * getBody()
Definition: Stmt.h:2099
A default argument (C++ [dcl.fct.default]).
Definition: ExprCXX.h:1202
Stmt * getInit()
Definition: Stmt.h:1965
bool isTypeOperand() const
Definition: ExprCXX.h:1029
const IdentifierInfo * getUDSuffix() const
Returns the ud-suffix specified for this literal.
Definition: ExprCXX.cpp:988
Expr * IgnoreImpCasts() LLVM_READONLY
Skip past any implicit casts which might surround this expression until reaching a fixed point...
Definition: Expr.cpp:2950
Represents the this expression in C++.
Definition: ExprCXX.h:1097
ObjCIvarDecl * getDecl()
Definition: ExprObjC.h:576
TypeTrait
Names for traits that operate specifically on types.
Definition: TypeTraits.h:20
bool isArrayForm() const
Definition: ExprCXX.h:2386
const ObjCAtCatchStmt * getCatchStmt(unsigned I) const
Retrieve a @catch statement.
Definition: StmtObjC.h:217
This represents &#39;#pragma omp target parallel for simd&#39; directive.
Definition: StmtOpenMP.h:3682
QualType getTypeAsWritten() const
getTypeAsWritten - Returns the type that this expression is casting to, as written in the source code...
Definition: Expr.h:3335
OpenMP 4.0 [2.4, Array Sections].
Definition: ExprOpenMP.h:44
ConditionalOperator - The ?: ternary operator.
Definition: Expr.h:3707
bool isStdInitListInitialization() const
Whether this constructor call was written as list-initialization, but was interpreted as forming a st...
Definition: ExprCXX.h:1524
Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
Definition: ExprCXX.h:2479
CompoundStmt - This represents a group of statements like { stmt stmt }.
Definition: Stmt.h:1320
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Definition: Type.cpp:1692
Represents a prototype with parameter type info, e.g.
Definition: Type.h:3725
QualType getQueriedType() const
Definition: ExprCXX.h:2756
CompoundStmt * getSubStmt() const
Retrieve the compound statement that will be included in the program only if the existence of the sym...
Definition: StmtCXX.h:292
This represents &#39;#pragma omp taskgroup&#39; directive.
Definition: StmtOpenMP.h:2132
unsigned SuppressImplicitBase
When true, don&#39;t print the implicit &#39;self&#39; or &#39;this&#39; expressions.
NestedNameSpecifier * getQualifier() const
If the member name was qualified, retrieves the nested-name-specifier that precedes the member name...
Definition: Expr.h:2922
StringRef getBuiltinStr() const
Return a string representing the name of the specific builtin function.
Definition: Expr.cpp:2159
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand...
Definition: Expr.h:2347
arg_iterator arg_end()
Definition: ExprCXX.h:1560
InitListExpr * getUpdater() const
Definition: Expr.h:4967
ConstantExpr - An expression that occurs in a constant context and optionally the result of evaluatin...
Definition: Expr.h:953
Represents a call to the builtin function __builtin_va_arg.
Definition: Expr.h:4216
void outputString(raw_ostream &OS) const
Definition: Expr.cpp:1103
bool isImplicitAccess() const
True if this is an implicit access, i.e.
Definition: ExprCXX.h:3601
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:939
unsigned getValue() const
Definition: Expr.h:1539
This represents &#39;#pragma omp distribute&#39; directive.
Definition: StmtOpenMP.h:3338
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:5623
An expression "T()" which creates a value-initialized rvalue of type T, which is a non-class type...
Definition: ExprCXX.h:2053
Expr * getCond() const
Definition: Expr.h:3741
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Definition: Decl.h:3951
llvm::MutableArrayRef< Designator > designators()
Definition: Expr.h:4814
This represents one expression.
Definition: Expr.h:108
bool isVariadic() const
Whether this function is variadic.
Definition: Decl.cpp:2807
IdentifierInfo * getFieldName() const
For a field or identifier offsetof node, returns the name of the field.
Definition: Expr.cpp:1593
bool isArrow() const
Determine whether this member expression used the &#39;->&#39; operator; otherwise, it used the &#39;...
Definition: ExprCXX.h:3867
int Id
Definition: ASTDiff.cpp:190
static void PrintFloatingLiteral(raw_ostream &OS, FloatingLiteral *Node, bool PrintSuffix)
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:1530
This represents &#39;#pragma omp master taskloop&#39; directive.
Definition: StmtOpenMP.h:3134
const T * castAs() const
Member-template castAs<specific type>.
Definition: Type.h:6923
Represents a C++ functional cast expression that builds a temporary object.
Definition: ExprCXX.h:1750
A C++ const_cast expression (C++ [expr.const.cast]).
Definition: ExprCXX.h:527
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Definition: Expr.h:5551
VarDecl * getExceptionDecl() const
Definition: StmtCXX.h:49
IdentifierInfo * getDestroyedTypeIdentifier() const
In a dependent pseudo-destructor expression for which we do not have full type information on the des...
Definition: ExprCXX.h:2579
Expr * getCallee()
Definition: Expr.h:2638
unsigned getNumInits() const
Definition: Expr.h:4405
Expr * getSubExpr() const
Get the initializer to use for each array element.
Definition: Expr.h:5021
Defines an enumeration for C++ overloaded operators.
This represents &#39;#pragma omp target teams distribute parallel for simd&#39; combined directive.
Definition: StmtOpenMP.h:4314
QualType getArgumentType() const
Definition: Expr.h:2384
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Definition: ExprCXX.h:4924
bool isArrow() const
Determine whether this pseudo-destructor expression was written using an &#39;->&#39; (otherwise, it used a &#39;.
Definition: ExprCXX.h:2542
Stmt * getBody()
Definition: Stmt.h:2271
Expr * getOrder() const
Definition: Expr.h:5842
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:304
const CompoundStmt * getSynchBody() const
Definition: StmtObjC.h:297
Expr * getRHS()
Definition: Stmt.h:1589
Represents Objective-C&#39;s @synchronized statement.
Definition: StmtObjC.h:277
ObjCSelectorExpr used for @selector in Objective-C.
Definition: ExprObjC.h:454
TypeSourceInfo * getTypeSourceInfo() const
Definition: Expr.h:2284
Represents an expression that computes the length of a parameter pack.
Definition: ExprCXX.h:4091
CXXTryStmt - A C++ try block, including all handlers.
Definition: StmtCXX.h:68
AsTypeExpr - Clang builtin function __builtin_astype [OpenCL 6.2.4.2] This AST node provides support ...
Definition: Expr.h:5600
IdentifierInfo & getAccessor() const
Definition: Expr.h:5512
This represents &#39;#pragma omp target teams distribute simd&#39; combined directive.
Definition: StmtOpenMP.h:4387
ArrayTypeTrait getTrait() const
Definition: ExprCXX.h:2754
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.
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:1931
Kind getKind() const
Determine what kind of offsetof node this is.
Definition: Expr.h:2192
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:137
virtual bool handledStmt(Stmt *E, raw_ostream &OS)=0
This represents &#39;#pragma omp for&#39; directive.
Definition: StmtOpenMP.h:1265
LabelDecl * getLabel() const
Definition: Stmt.h:2478
const Stmt * getTryBody() const
Retrieve the @try body.
Definition: StmtObjC.h:208
Represents a folding of a pack over an operator.
Definition: ExprCXX.h:4535
QualType getEncodedType() const
Definition: ExprObjC.h:428
ReturnStmt - This represents a return, optionally of an expression: return; return 4;...
Definition: Stmt.h:2620
This represents &#39;#pragma omp target teams&#39; directive.
Definition: StmtOpenMP.h:4103
An expression that sends a message to the given Objective-C object or class.
Definition: ExprObjC.h:950
This represents a Microsoft inline-assembly statement extension.
Definition: Stmt.h:3085
ObjCMethodDecl * getImplicitPropertyGetter() const
Definition: ExprObjC.h:712
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:2021
CXXMethodDecl * getMethodDecl() const
Retrieve the declaration of the called method.
Definition: ExprCXX.cpp:737
ReceiverKind getReceiverKind() const
Determine the kind of receiver that this message is being sent to.
Definition: ExprObjC.h:1234
AtomicOp getOp() const
Definition: Expr.h:5871
A member reference to an MSPropertyDecl.
Definition: ExprCXX.h:863
Represents a reference to a non-type template parameter that has been substituted with a template arg...
Definition: ExprCXX.h:4209
const OffsetOfNode & getComponent(unsigned Idx) const
Definition: Expr.h:2291
unsigned getNumArgs() const
This represents &#39;#pragma omp cancel&#39; directive.
Definition: StmtOpenMP.h:2937
Expr * getCond()
Definition: Stmt.h:1897
ValueDecl * getDecl()
Definition: Expr.h:1222
Selector getSelector() const
Definition: DeclObjC.h:320
SourceLocation getTemplateKWLoc() const
Definition: ExprCXX.h:4943
const Expr * getSubExpr() const
Definition: Expr.h:1985
const Expr * getSubExpr() const
Definition: ExprCXX.h:1396
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:3346
CXXMethodDecl * getCallOperator() const
Retrieve the function call operator associated with this lambda expression.
Definition: ExprCXX.cpp:1286
bool isNull() const
Return true if this QualType doesn&#39;t point to a type yet.
Definition: Type.h:708
Expr * getLHS()
An array access can be written A[4] or 4[A] (both are equivalent).
Definition: Expr.h:2472
bool getValue() const
Definition: ExprCXX.h:657
This file defines OpenMP AST classes for clauses.
ImaginaryLiteral - We support imaginary integer and floating point literals, like "1...
Definition: Expr.h:1637
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
Definition: ExprObjC.h:1395
This represents &#39;#pragma omp flush&#39; directive.
Definition: StmtOpenMP.h:2205
bool hasClausesOfKind() const
Returns true if the current directive has one or more clauses of a specific kind. ...
Definition: StmtOpenMP.h:219
This represents &#39;#pragma omp parallel for simd&#39; directive.
Definition: StmtOpenMP.h:1793
DoStmt - This represents a &#39;do/while&#39; stmt.
Definition: Stmt.h:2338
StringRef getBridgeKindName() const
Retrieve the kind of bridge being performed as a string.
Definition: ExprObjC.cpp:385
param_iterator param_begin()
Definition: Decl.h:4049
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the member name.
Definition: ExprCXX.h:3626
This represents &#39;#pragma omp parallel master taskloop&#39; directive.
Definition: StmtOpenMP.h:3270
const DeclarationNameInfo & getNameInfo() const
Retrieve the name that this expression refers to.
Definition: ExprCXX.h:3195
Expr * getArgument()
Definition: ExprCXX.h:2401
LiteralOperatorKind getLiteralOperatorKind() const
Returns the kind of literal operator invocation which this expression represents. ...
Definition: ExprCXX.cpp:959
This represents &#39;#pragma omp target enter data&#39; directive.
Definition: StmtOpenMP.h:2565
This represents &#39;#pragma omp master taskloop simd&#39; directive.
Definition: StmtOpenMP.h:3202
A C++ dynamic_cast expression (C++ [expr.dynamic.cast]).
Definition: ExprCXX.h:445
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
Definition: Expr.h:1050
Expr * getBase() const
Definition: Expr.h:4964
ConvertVectorExpr - Clang builtin function __builtin_convertvector This AST node provides support for...
Definition: Expr.h:4039
unsigned getNumArgs() const
Return the number of actual arguments in this message, not counting the receiver. ...
Definition: ExprObjC.h:1382
static StringRef getIdentKindName(IdentKind IK)
Definition: Expr.cpp:646
Kind
This captures a statement into a function.
Definition: Stmt.h:3360
Represents a call to an inherited base class constructor from an inheriting constructor.
Definition: ExprCXX.h:1613
operator "" X (const CharT *, size_t)
Definition: ExprCXX.h:604
ExpressionTrait getTrait() const
Definition: ExprCXX.h:2822
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
Definition: Expr.h:5673
bool isImplicitProperty() const
Definition: ExprObjC.h:704
IdentifierInfo * getIdentifierInfoForSlot(unsigned argIndex) const
Retrieve the identifier at a given position in the selector.
Raw form: operator "" X<cs...> ()
Definition: ExprCXX.h:595
unsigned getNumExprs() const
Return the number of expressions in this paren list.
Definition: Expr.h:5141
This represents &#39;#pragma omp single&#39; directive.
Definition: StmtOpenMP.h:1537
unsigned Indentation
The number of spaces to use to indent each line.
Definition: PrettyPrinter.h:66
const Expr * LHS
The original left-hand side.
Definition: ExprCXX.h:300
body_range body()
Definition: Stmt.h:1353
capture_iterator explicit_capture_begin() const
Retrieve an iterator pointing to the first explicit lambda capture.
Definition: ExprCXX.cpp:1256
Expr * getRetValue()
Definition: Stmt.h:2653
Defines enumerations for expression traits intrinsics.
unsigned ConstantsAsWritten
Whether we should print the constant expressions as written in the sources.
unsigned UnderscoreAlignof
Whether we can use &#39;_Alignof&#39; rather than &#39;__alignof&#39;.
const Stmt * getCatchBody() const
Definition: StmtObjC.h:93
StringRef getLabelName(unsigned i) const
Definition: Stmt.cpp:462
unsigned getNumHandlers() const
Definition: StmtCXX.h:106
Expr * getSubExpr() const
Definition: Expr.h:2051
bool hasExplicitTemplateArgs() const
Determines whether this member expression actually had a C++ template argument list explicitly specif...
Definition: ExprCXX.h:3692
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:2100
unsigned getNumElements() const
getNumElements - Return number of elements of objective-c dictionary literal.
Definition: ExprObjC.h:358
Expr * getLHS()
Definition: Stmt.h:1577
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:564
DeclarationName getName() const
getName - Returns the embedded declaration name.
Represents a C++2a __builtin_bit_cast(T, v) expression.
Definition: ExprCXX.h:4818
Represents a call to a member function that may be written either with member call syntax (e...
Definition: ExprCXX.h:171
ASTContext & getASTContext() const LLVM_READONLY
Definition: DeclBase.cpp:377
Stmt * getElse()
Definition: Stmt.h:1918
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:1213
DeclarationNameInfo getDirectiveName() const
Return name of the directive.
Definition: StmtOpenMP.h:1697
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:1905
std::string getValueAsString(unsigned Radix) const
Definition: Expr.cpp:955
Expr * getCond()
Definition: Stmt.h:2087
StmtVisitor - This class implements a simple visitor for Stmt subclasses.
Definition: StmtVisitor.h:182
SourceLocation getColonLoc() const
Definition: ExprOpenMP.h:108
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
This represents &#39;#pragma omp taskwait&#39; directive.
Definition: StmtOpenMP.h:2088
QualType getAllocatedType() const
Definition: ExprCXX.h:2193
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:5807
UnaryExprOrTypeTrait getKind() const
Definition: Expr.h:2378
ArrayRef< NamedDecl * > getExplicitTemplateParameters() const
Get the template parameters were explicitly specified (as opposed to being invented by use of an auto...
Definition: ExprCXX.cpp:1301
Expr * getExpr(unsigned Init)
Definition: Expr.h:5143
ObjCProtocolExpr used for protocol expression in Objective-C.
Definition: ExprObjC.h:503
const StringLiteral * getOutputConstraintLiteral(unsigned i) const
Definition: Stmt.h:2963
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
Definition: Expr.h:3249
Stmt * getCapturedStmt()
Retrieve the statement being captured.
Definition: Stmt.h:3461
bool hasTemplateKeyword() const
Determines whether the member name was preceded by the template keyword.
Definition: ExprCXX.h:3688
CharacterKind getKind() const
Definition: Expr.h:1532
This represents &#39;#pragma omp target&#39; directive.
Definition: StmtOpenMP.h:2449
Expr * getInputExpr(unsigned i)
Definition: Stmt.cpp:450
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...
Used for C&#39;s _Alignof and C++&#39;s alignof.
Definition: TypeTraits.h:100
bool isParenTypeId() const
Definition: ExprCXX.h:2253
void printPretty(raw_ostream &OS, const PrintingPolicy &Policy) const
Expr * getArrayRangeStart(const Designator &D) const
Definition: Expr.cpp:4359
Expr * getSubExpr()
Definition: ExprObjC.h:142
An expression trait intrinsic.
Definition: ExprCXX.h:2785
DeclStmt * getConditionVariableDeclStmt()
If this WhileStmt has a condition variable, return the faux DeclStmt associated with the creation of ...
Definition: Stmt.h:2299
This represents &#39;#pragma omp ordered&#39; directive.
Definition: StmtOpenMP.h:2260
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
Definition: Expr.h:3926
This represents &#39;#pragma omp target update&#39; directive.
Definition: StmtOpenMP.h:3406
ObjCBoxedExpr - used for generalized expression boxing.
Definition: ExprObjC.h:124
bool isArgumentType() const
Definition: Expr.h:2383
ArrayRef< TemplateArgumentLoc > template_arguments() const
Definition: ExprCXX.h:3720
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:139
Representation of a Microsoft __if_exists or __if_not_exists statement with a dependent name...
Definition: StmtCXX.h:252
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:1299
A qualified reference to a name whose declaration cannot yet be resolved.
Definition: ExprCXX.h:3155
Expr * Value
The value of the dictionary element.
Definition: ExprObjC.h:266
const Expr * getInitializer() const
Definition: Expr.h:3078
InitializationStyle getInitializationStyle() const
The kind of initializer this new-expression has.
Definition: ExprCXX.h:2267
Expr * getLHS() const
Definition: Expr.h:3449
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
Definition: TemplateBase.h:353
CompoundAssignOperator - For compound assignments (e.g.
Definition: Expr.h:3629
NamedDecl * getFoundDecl() const
Definition: ExprCXX.h:4911
Represents a C11 generic selection.
Definition: Expr.h:5206
StringRef getName() const
Return the actual identifier string.
const Expr * getBase() const
Definition: Expr.h:5508
Expr * getInstanceReceiver()
Returns the object expression (receiver) for an instance message, or null for a message that is not a...
Definition: ExprObjC.h:1260
AddrLabelExpr - The GNU address of label extension, representing &&label.
Definition: Expr.h:3882
An Objective-C "bridged" cast expression, which casts between Objective-C pointers and C pointers...
Definition: ExprObjC.h:1638
ast_type_traits::DynTypedNode Node
Represents a reference to a function parameter pack or init-capture pack that has been substituted bu...
Definition: ExprCXX.h:4337
Represents a template argument.
Definition: TemplateBase.h:50
Expr * getFalseExpr() const
getFalseExpr - Return the subexpression which will be evaluated if the condnition evaluates to false;...
Definition: Expr.h:3839
NullStmt - This is the null statement ";": C99 6.8.3p3.
Definition: Stmt.h:1285
bool isMutable() const
Determine whether the lambda is mutable, meaning that any captures values can be modified.
Definition: ExprCXX.cpp:1317
bool isTypeOperand() const
Definition: ExprCXX.h:804
Dataflow Directional Tag Classes.
static std::string getPropertyNameFromSetterSelector(Selector Sel)
Return the property name for the given setter selector.
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:2739
[C99 6.4.2.2] - A predefined identifier such as func.
Definition: Expr.h:1878
DeclarationNameInfo getMemberNameInfo() const
Retrieve the member declaration name info.
Definition: Expr.h:2988
Represents a delete expression for memory deallocation and destructor calls, e.g. ...
Definition: ExprCXX.h:2359
OverloadedOperatorKind getOperator() const
Returns the kind of overloaded operator that this expression refers to.
Definition: ExprCXX.h:107
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
Definition: OperatorKinds.h:21
NonTypeTemplateParmDecl * getParameterPack() const
Retrieve the non-type template parameter pack being substituted.
Definition: ExprCXX.h:4297
MSPropertyDecl * getPropertyDecl() const
Definition: ExprCXX.h:920
ArrayRef< const Attr * > getAttrs() const
Definition: Stmt.h:1800
Parameter for Objective-C &#39;self&#39; argument.
Definition: Decl.h:1545
This represents &#39;#pragma omp section&#39; directive.
Definition: StmtOpenMP.h:1475
This represents &#39;#pragma omp teams distribute&#39; directive.
Definition: StmtOpenMP.h:3816
A runtime availability query.
Definition: ExprObjC.h:1699
void print(raw_ostream &Out, const ASTContext &Context, bool OmitTemplateKW=false) const
A C++ reinterpret_cast expression (C++ [expr.reinterpret.cast]).
Definition: ExprCXX.h:487
This represents &#39;#pragma omp simd&#39; directive.
Definition: StmtOpenMP.h:1200
Represents a &#39;co_yield&#39; expression.
Definition: ExprCXX.h:4792
Expr * getOperand() const
Retrieve the operand of the &#39;co_return&#39; statement.
Definition: StmtCXX.h:480
Represents a C++11 pack expansion that produces a sequence of expressions.
Definition: ExprCXX.h:4015
bool isListInitialization() const
Whether this constructor call was written as list-initialization.
Definition: ExprCXX.h:1513
SEHExceptStmt * getExceptHandler() const
Returns 0 if not defined.
Definition: Stmt.cpp:1135
const Expr * getSynchExpr() const
Definition: StmtObjC.h:305
bool isIfExists() const
Determine whether this is an __if_exists statement.
Definition: StmtCXX.h:277
NestedNameSpecifierLoc getQualifierLoc() const
Definition: ExprCXX.h:923
const DeclarationNameInfo & getMemberNameInfo() const
Retrieve the full name info for the member that this expression refers to.
Definition: ExprCXX.h:3880
TemplateParameterList * getTemplateParameterList() const
If this is a generic lambda expression, retrieve the template parameter list associated with it...
Definition: ExprCXX.cpp:1296
Expr * getPlacementArg(unsigned I)
Definition: ExprCXX.h:2245
This represents &#39;#pragma omp atomic&#39; directive.
Definition: StmtOpenMP.h:2315
DeclStmt * getConditionVariableDeclStmt()
If this IfStmt has a condition variable, return the faux DeclStmt associated with the creation of tha...
Definition: Stmt.h:1953
TypeSourceInfo * getTypeOperandSourceInfo() const
Retrieve source information for the type operand.
Definition: ExprCXX.h:811
Expr * getArrayRangeEnd(const Designator &D) const
Definition: Expr.cpp:4365
llvm::APInt getValue() const
Definition: Expr.h:1405
Represents a __leave statement.
Definition: Stmt.h:3321
LabelDecl * getLabel() const
Definition: Expr.h:3904
QualType getClassReceiver() const
Returns the type of a class message send, or NULL if the message is not a class message.
Definition: ExprObjC.h:1279
Represents a C++11 noexcept expression (C++ [expr.unary.noexcept]).
Definition: ExprCXX.h:3958
SwitchStmt - This represents a &#39;switch&#39; stmt.
Definition: Stmt.h:2027
Capturing variable-length array type.
Definition: Lambda.h:38
Expr * getOrderFail() const
Definition: Expr.h:5855
DeclarationNameInfo getNameInfo() const
Definition: Expr.h:1226
Represents the body of a coroutine.
Definition: StmtCXX.h:317
bool hasTemplateKeyword() const
Determines whether the name was preceded by the template keyword.
Definition: ExprCXX.h:2992
Expr * getBase() const
Definition: ExprObjC.h:1518
Indicates that the tracking object is a descendant of a referenced-counted OSObject, used in the Darwin kernel.
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
Definition: Expr.h:2437
This file defines OpenMP AST classes for executable directives and clauses.
bool hasBraces() const
Definition: Stmt.h:3113
Represents Objective-C&#39;s collection statement.
Definition: StmtObjC.h:23
ObjCEncodeExpr, used for @encode in Objective-C.
Definition: ExprObjC.h:407
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:2150
Represents a call to a CUDA kernel function.
Definition: ExprCXX.h:224
Represents a &#39;co_await&#39; expression.
Definition: ExprCXX.h:4705
Stmt * getInit()
Definition: Stmt.h:2108
const NestedNameSpecifierLoc & getNestedNameSpecifierLoc() const
Definition: ExprCXX.h:4907
Opcode getOpcode() const
Definition: Expr.h:2046
Expr * getArg(unsigned Arg)
Return the specified argument.
Definition: ExprCXX.h:1573
decl_range decls()
Definition: Stmt.h:1261
Represents Objective-C&#39;s @finally statement.
Definition: StmtObjC.h:127
StringRef getAsmString() const
Definition: Stmt.h:3119
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:250
const Expr * getBase() const
Definition: ExprObjC.h:580
bool isArrow() const
Determine whether this member expression used the &#39;->&#39; operator; otherwise, it used the &#39;...
Definition: ExprCXX.h:3618
Capturing the *this object by reference.
Definition: Lambda.h:34
const char * getOpenMPDirectiveName(OpenMPDirectiveKind Kind)
Definition: OpenMPKinds.cpp:30
unsigned getNumClobbers() const
Definition: Stmt.h:2784
ObjCIvarRefExpr - A reference to an ObjC instance variable.
Definition: ExprObjC.h:546
SourceManager & getSourceManager()
Definition: ASTContext.h:678
Expr * getRHS() const
Definition: Expr.h:4151
Describes an explicit type conversion that uses functional notion but could not be resolved because o...
Definition: ExprCXX.h:3390
SEHFinallyStmt * getFinallyHandler() const
Definition: Stmt.cpp:1139
GotoStmt - This represents a direct goto.
Definition: Stmt.h:2465
A use of a default initializer in a constructor or in aggregate initialization.
Definition: ExprCXX.h:1279
Expr * getTarget()
Definition: Stmt.h:2524
A template argument list.
Definition: DeclTemplate.h:224
Expr * getSrcExpr() const
getSrcExpr - Return the Expr to be converted.
Definition: Expr.h:4063
ArrayRef< TemplateArgumentLoc > template_arguments() const
Definition: Expr.h:1329
CapturedDecl * getCapturedDecl()
Retrieve the outlined function declaration.
Definition: Stmt.cpp:1291
Expr * getCond()
Definition: Stmt.h:2356
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
void printPretty(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation=0, StringRef NewlineSymbol="\, const ASTContext *Context=nullptr) const
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Definition: Expr.h:2811
Defines the clang::SourceLocation class and associated facilities.
This represents &#39;#pragma omp target parallel&#39; directive.
Definition: StmtOpenMP.h:2682
ContinueStmt - This represents a continue.
Definition: Stmt.h:2553
Represents a loop initializing the elements of an array.
Definition: Expr.h:4999
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
Definition: Expr.h:4102
Expr * getFilterExpr() const
Definition: Stmt.h:3212
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
Definition: Expr.h:3780
CXXCatchStmt - This represents a C++ catch block.
Definition: StmtCXX.h:28
VarDecl * getLoopVariable()
Definition: StmtCXX.cpp:76
An index into an array.
Definition: Expr.h:2143
Represents an explicit C++ type conversion that uses "functional" notation (C++ [expr.type.conv]).
Definition: ExprCXX.h:1688
bool isPackExpansion() const
Determines whether this dictionary element is a pack expansion.
Definition: ExprObjC.h:276
Expr * getOperand() const
Definition: ExprCXX.h:4726
Expr * getRHS() const
Definition: Expr.h:3753
WhileStmt - This represents a &#39;while&#39; stmt.
Definition: Stmt.h:2210
Capturing by reference.
Definition: Lambda.h:37
Represents the specialization of a concept - evaluates to a prvalue of type bool. ...
Definition: ExprCXX.h:4849
SourceLocation getLParenLoc() const
Definition: ExprCXX.h:1719
This class is used for builtin types like &#39;int&#39;.
Definition: Type.h:2436
CompoundStmt * getTryBlock()
Definition: StmtCXX.h:99
The receiver is a class.
Definition: ExprObjC.h:1098
Represents Objective-C&#39;s @try ... @catch ... @finally statement.
Definition: StmtObjC.h:165
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
Definition: Stmt.cpp:262
bool isGlobalDelete() const
Definition: ExprCXX.h:2385
This represents &#39;#pragma omp taskloop simd&#39; directive.
Definition: StmtOpenMP.h:3067
unsigned getNumCatchStmts() const
Retrieve the number of @catch statements in this try-catch-finally block.
Definition: StmtObjC.h:214
Expr * getBase() const
Retrieve the base object of this member expressions, e.g., the x in x.m.
Definition: ExprCXX.h:3609
StringLiteral - This represents a string literal expression, e.g.
Definition: Expr.h:1686
bool hasExplicitParameters() const
Determine whether this lambda has an explicit parameter list vs.
Definition: ExprCXX.h:2025
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition: Expr.h:2521
Expr * getPattern()
Retrieve the pattern of the pack expansion.
Definition: ExprCXX.h:4044
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
Definition: Decl.h:275
Expr * getLHS() const
Definition: Expr.h:4149
Stmt * getBody() const
Retrieve the body of the coroutine as written.
Definition: StmtCXX.h:378
static Decl::Kind getKind(const Decl *D)
Definition: DeclBase.cpp:945
Abstract class common to all of the C++ "named"/"keyword" casts.
Definition: ExprCXX.h:353
This represents &#39;#pragma omp sections&#39; directive.
Definition: StmtOpenMP.h:1407
ObjCBoolLiteralExpr - Objective-C Boolean Literal.
Definition: ExprObjC.h:85
bool isObjectReceiver() const
Definition: ExprObjC.h:775
unsigned getNumComponents() const
Definition: Expr.h:2301
This represents &#39;#pragma omp target data&#39; directive.
Definition: StmtOpenMP.h:2507
OpenMPDirectiveKind getCancelRegion() const
Get cancellation region for the current cancellation point.
Definition: StmtOpenMP.h:2986
raw_ostream & Indent(raw_ostream &Out, const unsigned int Space, bool IsDot)
Definition: JsonSupport.h:20
A rewritten comparison expression that was originally written using operator syntax.
Definition: ExprCXX.h:273
A reference to a declared variable, function, enum, etc.
Definition: Expr.h:1146
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:3451
unsigned IncludeNewlines
When true, include newlines after statements like "break", etc.
BreakStmt - This represents a break.
Definition: Stmt.h:2583
const VarDecl * getCatchParamDecl() const
Definition: StmtObjC.h:97
static bool isImplicitSelf(const Expr *E)
unsigned getNumLabels() const
Definition: Stmt.h:3011
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:763
Expr * getOperand() const
Definition: ExprCXX.h:4805
Stmt * getSubStmt()
Definition: Stmt.h:1741
QualType getTypeAsWritten() const
Retrieve the type that is being constructed, as specified in the source code.
Definition: ExprCXX.h:3425
QualType getType() const
Definition: Decl.h:655
unsigned getNumArgs() const
Return the number of arguments to the constructor call.
Definition: ExprCXX.h:1570
const Expr * getBase() const
Definition: ExprObjC.h:756
static StringRef getOpcodeStr(Opcode Op)
getOpcodeStr - Turn an Opcode enum value into the punctuation char it corresponds to...
Definition: Expr.cpp:1291
This represents &#39;#pragma omp taskyield&#39; directive.
Definition: StmtOpenMP.h:2000
This represents &#39;#pragma omp distribute parallel for simd&#39; composite directive.
Definition: StmtOpenMP.h:3545
A boolean literal, per ([C++ lex.bool] Boolean literals).
Definition: ExprCXX.h:645
NestedNameSpecifier * getQualifier() const
If the name was qualified, retrieves the nested-name-specifier that precedes the name.
Definition: Expr.h:1249
OffsetOfExpr - [C99 7.17] - This represents an expression of the form offsetof(record-type, member-designator).
Definition: Expr.h:2242
Expr * getQueriedExpression() const
Definition: ExprCXX.h:2824
This represents &#39;#pragma omp parallel sections&#39; directive.
Definition: StmtOpenMP.h:1861
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
Definition: ExprCXX.h:1000
Expr * getCommon() const
getCommon - Return the common expression, written to the left of the condition.
Definition: Expr.h:3820
The receiver is a superclass.
Definition: ExprObjC.h:1104
BinaryOperatorKind getOperator() const
Definition: ExprCXX.h:4581
const LangOptions & getLangOpts() const
Definition: ASTContext.h:723
NamedDecl * getPack() const
Retrieve the parameter pack.
Definition: ExprCXX.h:4162
Represents Objective-C&#39;s @autoreleasepool Statement.
Definition: StmtObjC.h:368
CompoundStmt * getTryBlock() const
Definition: Stmt.h:3297
Stmt * getSubStmt()
Definition: Stmt.h:1804
InitListExpr * getSyntacticForm() const
Definition: Expr.h:4534
Expr * getBaseExpr() const
Definition: ExprCXX.h:919
Represents an implicitly-generated value initialization of an object of a given type.
Definition: Expr.h:5089
CompoundStmt * getBlock() const
Definition: Stmt.h:3216
Expr * getWeak() const
Definition: Expr.h:5865
This represents &#39;#pragma omp target parallel for&#39; directive.
Definition: StmtOpenMP.h:2742
Attr - This represents one attribute.
Definition: Attr.h:45
operator "" X (unsigned long long)
Definition: ExprCXX.h:598
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:2666
association_range associations()
Definition: Expr.h:5435
Expr * getLength()
Get length of array section.
Definition: ExprOpenMP.h:98
const DeclarationNameInfo & getMemberNameInfo() const
Retrieve the name of the member that this expression refers to.
Definition: ExprCXX.h:3652
Expr * getCookedLiteral()
If this is not a raw user-defined literal, get the underlying cooked literal (representing the litera...
Definition: ExprCXX.cpp:980
Expr * getBase()
An array section can be written only as Base[LowerBound:Length].
Definition: ExprOpenMP.h:81
Stmt * getSubStmt()
Definition: Stmt.h:1607
This represents &#39;#pragma omp taskloop&#39; directive.
Definition: StmtOpenMP.h:3002