clang  10.0.0git
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, Policy);
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::VisitOMPParallelMasterDirective(
719  Indent() << "#pragma omp parallel master";
720  PrintOMPExecutableDirective(Node);
721 }
722 
723 void StmtPrinter::VisitOMPParallelSectionsDirective(
725  Indent() << "#pragma omp parallel sections";
726  PrintOMPExecutableDirective(Node);
727 }
728 
729 void StmtPrinter::VisitOMPTaskDirective(OMPTaskDirective *Node) {
730  Indent() << "#pragma omp task";
731  PrintOMPExecutableDirective(Node);
732 }
733 
734 void StmtPrinter::VisitOMPTaskyieldDirective(OMPTaskyieldDirective *Node) {
735  Indent() << "#pragma omp taskyield";
736  PrintOMPExecutableDirective(Node);
737 }
738 
739 void StmtPrinter::VisitOMPBarrierDirective(OMPBarrierDirective *Node) {
740  Indent() << "#pragma omp barrier";
741  PrintOMPExecutableDirective(Node);
742 }
743 
744 void StmtPrinter::VisitOMPTaskwaitDirective(OMPTaskwaitDirective *Node) {
745  Indent() << "#pragma omp taskwait";
746  PrintOMPExecutableDirective(Node);
747 }
748 
749 void StmtPrinter::VisitOMPTaskgroupDirective(OMPTaskgroupDirective *Node) {
750  Indent() << "#pragma omp taskgroup";
751  PrintOMPExecutableDirective(Node);
752 }
753 
754 void StmtPrinter::VisitOMPFlushDirective(OMPFlushDirective *Node) {
755  Indent() << "#pragma omp flush";
756  PrintOMPExecutableDirective(Node);
757 }
758 
759 void StmtPrinter::VisitOMPOrderedDirective(OMPOrderedDirective *Node) {
760  Indent() << "#pragma omp ordered";
761  PrintOMPExecutableDirective(Node, Node->hasClausesOfKind<OMPDependClause>());
762 }
763 
764 void StmtPrinter::VisitOMPAtomicDirective(OMPAtomicDirective *Node) {
765  Indent() << "#pragma omp atomic";
766  PrintOMPExecutableDirective(Node);
767 }
768 
769 void StmtPrinter::VisitOMPTargetDirective(OMPTargetDirective *Node) {
770  Indent() << "#pragma omp target";
771  PrintOMPExecutableDirective(Node);
772 }
773 
774 void StmtPrinter::VisitOMPTargetDataDirective(OMPTargetDataDirective *Node) {
775  Indent() << "#pragma omp target data";
776  PrintOMPExecutableDirective(Node);
777 }
778 
779 void StmtPrinter::VisitOMPTargetEnterDataDirective(
781  Indent() << "#pragma omp target enter data";
782  PrintOMPExecutableDirective(Node, /*ForceNoStmt=*/true);
783 }
784 
785 void StmtPrinter::VisitOMPTargetExitDataDirective(
787  Indent() << "#pragma omp target exit data";
788  PrintOMPExecutableDirective(Node, /*ForceNoStmt=*/true);
789 }
790 
791 void StmtPrinter::VisitOMPTargetParallelDirective(
793  Indent() << "#pragma omp target parallel";
794  PrintOMPExecutableDirective(Node);
795 }
796 
797 void StmtPrinter::VisitOMPTargetParallelForDirective(
799  Indent() << "#pragma omp target parallel for";
800  PrintOMPExecutableDirective(Node);
801 }
802 
803 void StmtPrinter::VisitOMPTeamsDirective(OMPTeamsDirective *Node) {
804  Indent() << "#pragma omp teams";
805  PrintOMPExecutableDirective(Node);
806 }
807 
808 void StmtPrinter::VisitOMPCancellationPointDirective(
810  Indent() << "#pragma omp cancellation point "
811  << getOpenMPDirectiveName(Node->getCancelRegion());
812  PrintOMPExecutableDirective(Node);
813 }
814 
815 void StmtPrinter::VisitOMPCancelDirective(OMPCancelDirective *Node) {
816  Indent() << "#pragma omp cancel "
817  << getOpenMPDirectiveName(Node->getCancelRegion());
818  PrintOMPExecutableDirective(Node);
819 }
820 
821 void StmtPrinter::VisitOMPTaskLoopDirective(OMPTaskLoopDirective *Node) {
822  Indent() << "#pragma omp taskloop";
823  PrintOMPExecutableDirective(Node);
824 }
825 
826 void StmtPrinter::VisitOMPTaskLoopSimdDirective(
827  OMPTaskLoopSimdDirective *Node) {
828  Indent() << "#pragma omp taskloop simd";
829  PrintOMPExecutableDirective(Node);
830 }
831 
832 void StmtPrinter::VisitOMPMasterTaskLoopDirective(
834  Indent() << "#pragma omp master taskloop";
835  PrintOMPExecutableDirective(Node);
836 }
837 
838 void StmtPrinter::VisitOMPMasterTaskLoopSimdDirective(
840  Indent() << "#pragma omp master taskloop simd";
841  PrintOMPExecutableDirective(Node);
842 }
843 
844 void StmtPrinter::VisitOMPParallelMasterTaskLoopDirective(
846  Indent() << "#pragma omp parallel master taskloop";
847  PrintOMPExecutableDirective(Node);
848 }
849 
850 void StmtPrinter::VisitOMPParallelMasterTaskLoopSimdDirective(
852  Indent() << "#pragma omp parallel master taskloop simd";
853  PrintOMPExecutableDirective(Node);
854 }
855 
856 void StmtPrinter::VisitOMPDistributeDirective(OMPDistributeDirective *Node) {
857  Indent() << "#pragma omp distribute";
858  PrintOMPExecutableDirective(Node);
859 }
860 
861 void StmtPrinter::VisitOMPTargetUpdateDirective(
862  OMPTargetUpdateDirective *Node) {
863  Indent() << "#pragma omp target update";
864  PrintOMPExecutableDirective(Node, /*ForceNoStmt=*/true);
865 }
866 
867 void StmtPrinter::VisitOMPDistributeParallelForDirective(
869  Indent() << "#pragma omp distribute parallel for";
870  PrintOMPExecutableDirective(Node);
871 }
872 
873 void StmtPrinter::VisitOMPDistributeParallelForSimdDirective(
875  Indent() << "#pragma omp distribute parallel for simd";
876  PrintOMPExecutableDirective(Node);
877 }
878 
879 void StmtPrinter::VisitOMPDistributeSimdDirective(
881  Indent() << "#pragma omp distribute simd";
882  PrintOMPExecutableDirective(Node);
883 }
884 
885 void StmtPrinter::VisitOMPTargetParallelForSimdDirective(
887  Indent() << "#pragma omp target parallel for simd";
888  PrintOMPExecutableDirective(Node);
889 }
890 
891 void StmtPrinter::VisitOMPTargetSimdDirective(OMPTargetSimdDirective *Node) {
892  Indent() << "#pragma omp target simd";
893  PrintOMPExecutableDirective(Node);
894 }
895 
896 void StmtPrinter::VisitOMPTeamsDistributeDirective(
898  Indent() << "#pragma omp teams distribute";
899  PrintOMPExecutableDirective(Node);
900 }
901 
902 void StmtPrinter::VisitOMPTeamsDistributeSimdDirective(
904  Indent() << "#pragma omp teams distribute simd";
905  PrintOMPExecutableDirective(Node);
906 }
907 
908 void StmtPrinter::VisitOMPTeamsDistributeParallelForSimdDirective(
910  Indent() << "#pragma omp teams distribute parallel for simd";
911  PrintOMPExecutableDirective(Node);
912 }
913 
914 void StmtPrinter::VisitOMPTeamsDistributeParallelForDirective(
916  Indent() << "#pragma omp teams distribute parallel for";
917  PrintOMPExecutableDirective(Node);
918 }
919 
920 void StmtPrinter::VisitOMPTargetTeamsDirective(OMPTargetTeamsDirective *Node) {
921  Indent() << "#pragma omp target teams";
922  PrintOMPExecutableDirective(Node);
923 }
924 
925 void StmtPrinter::VisitOMPTargetTeamsDistributeDirective(
927  Indent() << "#pragma omp target teams distribute";
928  PrintOMPExecutableDirective(Node);
929 }
930 
931 void StmtPrinter::VisitOMPTargetTeamsDistributeParallelForDirective(
933  Indent() << "#pragma omp target teams distribute parallel for";
934  PrintOMPExecutableDirective(Node);
935 }
936 
937 void StmtPrinter::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
939  Indent() << "#pragma omp target teams distribute parallel for simd";
940  PrintOMPExecutableDirective(Node);
941 }
942 
943 void StmtPrinter::VisitOMPTargetTeamsDistributeSimdDirective(
945  Indent() << "#pragma omp target teams distribute simd";
946  PrintOMPExecutableDirective(Node);
947 }
948 
949 //===----------------------------------------------------------------------===//
950 // Expr printing methods.
951 //===----------------------------------------------------------------------===//
952 
953 void StmtPrinter::VisitSourceLocExpr(SourceLocExpr *Node) {
954  OS << Node->getBuiltinStr() << "()";
955 }
956 
957 void StmtPrinter::VisitConstantExpr(ConstantExpr *Node) {
958  PrintExpr(Node->getSubExpr());
959 }
960 
961 void StmtPrinter::VisitDeclRefExpr(DeclRefExpr *Node) {
962  if (const auto *OCED = dyn_cast<OMPCapturedExprDecl>(Node->getDecl())) {
963  OCED->getInit()->IgnoreImpCasts()->printPretty(OS, nullptr, Policy);
964  return;
965  }
966  if (NestedNameSpecifier *Qualifier = Node->getQualifier())
967  Qualifier->print(OS, Policy);
968  if (Node->hasTemplateKeyword())
969  OS << "template ";
970  OS << Node->getNameInfo();
971  if (Node->hasExplicitTemplateArgs())
972  printTemplateArgumentList(OS, Node->template_arguments(), Policy);
973 }
974 
975 void StmtPrinter::VisitDependentScopeDeclRefExpr(
977  if (NestedNameSpecifier *Qualifier = Node->getQualifier())
978  Qualifier->print(OS, Policy);
979  if (Node->hasTemplateKeyword())
980  OS << "template ";
981  OS << Node->getNameInfo();
982  if (Node->hasExplicitTemplateArgs())
983  printTemplateArgumentList(OS, Node->template_arguments(), Policy);
984 }
985 
986 void StmtPrinter::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *Node) {
987  if (Node->getQualifier())
988  Node->getQualifier()->print(OS, Policy);
989  if (Node->hasTemplateKeyword())
990  OS << "template ";
991  OS << Node->getNameInfo();
992  if (Node->hasExplicitTemplateArgs())
993  printTemplateArgumentList(OS, Node->template_arguments(), Policy);
994 }
995 
996 static bool isImplicitSelf(const Expr *E) {
997  if (const auto *DRE = dyn_cast<DeclRefExpr>(E)) {
998  if (const auto *PD = dyn_cast<ImplicitParamDecl>(DRE->getDecl())) {
999  if (PD->getParameterKind() == ImplicitParamDecl::ObjCSelf &&
1000  DRE->getBeginLoc().isInvalid())
1001  return true;
1002  }
1003  }
1004  return false;
1005 }
1006 
1007 void StmtPrinter::VisitObjCIvarRefExpr(ObjCIvarRefExpr *Node) {
1008  if (Node->getBase()) {
1009  if (!Policy.SuppressImplicitBase ||
1010  !isImplicitSelf(Node->getBase()->IgnoreImpCasts())) {
1011  PrintExpr(Node->getBase());
1012  OS << (Node->isArrow() ? "->" : ".");
1013  }
1014  }
1015  OS << *Node->getDecl();
1016 }
1017 
1018 void StmtPrinter::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *Node) {
1019  if (Node->isSuperReceiver())
1020  OS << "super.";
1021  else if (Node->isObjectReceiver() && Node->getBase()) {
1022  PrintExpr(Node->getBase());
1023  OS << ".";
1024  } else if (Node->isClassReceiver() && Node->getClassReceiver()) {
1025  OS << Node->getClassReceiver()->getName() << ".";
1026  }
1027 
1028  if (Node->isImplicitProperty()) {
1029  if (const auto *Getter = Node->getImplicitPropertyGetter())
1030  Getter->getSelector().print(OS);
1031  else
1034  } else
1035  OS << Node->getExplicitProperty()->getName();
1036 }
1037 
1038 void StmtPrinter::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *Node) {
1039  PrintExpr(Node->getBaseExpr());
1040  OS << "[";
1041  PrintExpr(Node->getKeyExpr());
1042  OS << "]";
1043 }
1044 
1045 void StmtPrinter::VisitPredefinedExpr(PredefinedExpr *Node) {
1047 }
1048 
1049 void StmtPrinter::VisitCharacterLiteral(CharacterLiteral *Node) {
1050  unsigned value = Node->getValue();
1051 
1052  switch (Node->getKind()) {
1053  case CharacterLiteral::Ascii: break; // no prefix.
1054  case CharacterLiteral::Wide: OS << 'L'; break;
1055  case CharacterLiteral::UTF8: OS << "u8"; break;
1056  case CharacterLiteral::UTF16: OS << 'u'; break;
1057  case CharacterLiteral::UTF32: OS << 'U'; break;
1058  }
1059 
1060  switch (value) {
1061  case '\\':
1062  OS << "'\\\\'";
1063  break;
1064  case '\'':
1065  OS << "'\\''";
1066  break;
1067  case '\a':
1068  // TODO: K&R: the meaning of '\\a' is different in traditional C
1069  OS << "'\\a'";
1070  break;
1071  case '\b':
1072  OS << "'\\b'";
1073  break;
1074  // Nonstandard escape sequence.
1075  /*case '\e':
1076  OS << "'\\e'";
1077  break;*/
1078  case '\f':
1079  OS << "'\\f'";
1080  break;
1081  case '\n':
1082  OS << "'\\n'";
1083  break;
1084  case '\r':
1085  OS << "'\\r'";
1086  break;
1087  case '\t':
1088  OS << "'\\t'";
1089  break;
1090  case '\v':
1091  OS << "'\\v'";
1092  break;
1093  default:
1094  // A character literal might be sign-extended, which
1095  // would result in an invalid \U escape sequence.
1096  // FIXME: multicharacter literals such as '\xFF\xFF\xFF\xFF'
1097  // are not correctly handled.
1098  if ((value & ~0xFFu) == ~0xFFu && Node->getKind() == CharacterLiteral::Ascii)
1099  value &= 0xFFu;
1100  if (value < 256 && isPrintable((unsigned char)value))
1101  OS << "'" << (char)value << "'";
1102  else if (value < 256)
1103  OS << "'\\x" << llvm::format("%02x", value) << "'";
1104  else if (value <= 0xFFFF)
1105  OS << "'\\u" << llvm::format("%04x", value) << "'";
1106  else
1107  OS << "'\\U" << llvm::format("%08x", value) << "'";
1108  }
1109 }
1110 
1111 /// Prints the given expression using the original source text. Returns true on
1112 /// success, false otherwise.
1113 static bool printExprAsWritten(raw_ostream &OS, Expr *E,
1114  const ASTContext *Context) {
1115  if (!Context)
1116  return false;
1117  bool Invalid = false;
1118  StringRef Source = Lexer::getSourceText(
1120  Context->getSourceManager(), Context->getLangOpts(), &Invalid);
1121  if (!Invalid) {
1122  OS << Source;
1123  return true;
1124  }
1125  return false;
1126 }
1127 
1128 void StmtPrinter::VisitIntegerLiteral(IntegerLiteral *Node) {
1129  if (Policy.ConstantsAsWritten && printExprAsWritten(OS, Node, Context))
1130  return;
1131  bool isSigned = Node->getType()->isSignedIntegerType();
1132  OS << Node->getValue().toString(10, isSigned);
1133 
1134  // Emit suffixes. Integer literals are always a builtin integer type.
1135  switch (Node->getType()->castAs<BuiltinType>()->getKind()) {
1136  default: llvm_unreachable("Unexpected type for integer literal!");
1137  case BuiltinType::Char_S:
1138  case BuiltinType::Char_U: OS << "i8"; break;
1139  case BuiltinType::UChar: OS << "Ui8"; break;
1140  case BuiltinType::Short: OS << "i16"; break;
1141  case BuiltinType::UShort: OS << "Ui16"; break;
1142  case BuiltinType::Int: break; // no suffix.
1143  case BuiltinType::UInt: OS << 'U'; break;
1144  case BuiltinType::Long: OS << 'L'; break;
1145  case BuiltinType::ULong: OS << "UL"; break;
1146  case BuiltinType::LongLong: OS << "LL"; break;
1147  case BuiltinType::ULongLong: OS << "ULL"; break;
1148  }
1149 }
1150 
1151 void StmtPrinter::VisitFixedPointLiteral(FixedPointLiteral *Node) {
1152  if (Policy.ConstantsAsWritten && printExprAsWritten(OS, Node, Context))
1153  return;
1154  OS << Node->getValueAsString(/*Radix=*/10);
1155 
1156  switch (Node->getType()->castAs<BuiltinType>()->getKind()) {
1157  default: llvm_unreachable("Unexpected type for fixed point literal!");
1158  case BuiltinType::ShortFract: OS << "hr"; break;
1159  case BuiltinType::ShortAccum: OS << "hk"; break;
1160  case BuiltinType::UShortFract: OS << "uhr"; break;
1161  case BuiltinType::UShortAccum: OS << "uhk"; break;
1162  case BuiltinType::Fract: OS << "r"; break;
1163  case BuiltinType::Accum: OS << "k"; break;
1164  case BuiltinType::UFract: OS << "ur"; break;
1165  case BuiltinType::UAccum: OS << "uk"; break;
1166  case BuiltinType::LongFract: OS << "lr"; break;
1167  case BuiltinType::LongAccum: OS << "lk"; break;
1168  case BuiltinType::ULongFract: OS << "ulr"; break;
1169  case BuiltinType::ULongAccum: OS << "ulk"; break;
1170  }
1171 }
1172 
1173 static void PrintFloatingLiteral(raw_ostream &OS, FloatingLiteral *Node,
1174  bool PrintSuffix) {
1175  SmallString<16> Str;
1176  Node->getValue().toString(Str);
1177  OS << Str;
1178  if (Str.find_first_not_of("-0123456789") == StringRef::npos)
1179  OS << '.'; // Trailing dot in order to separate from ints.
1180 
1181  if (!PrintSuffix)
1182  return;
1183 
1184  // Emit suffixes. Float literals are always a builtin float type.
1185  switch (Node->getType()->castAs<BuiltinType>()->getKind()) {
1186  default: llvm_unreachable("Unexpected type for float literal!");
1187  case BuiltinType::Half: break; // FIXME: suffix?
1188  case BuiltinType::Double: break; // no suffix.
1189  case BuiltinType::Float16: OS << "F16"; break;
1190  case BuiltinType::Float: OS << 'F'; break;
1191  case BuiltinType::LongDouble: OS << 'L'; break;
1192  case BuiltinType::Float128: OS << 'Q'; break;
1193  }
1194 }
1195 
1196 void StmtPrinter::VisitFloatingLiteral(FloatingLiteral *Node) {
1197  if (Policy.ConstantsAsWritten && printExprAsWritten(OS, Node, Context))
1198  return;
1199  PrintFloatingLiteral(OS, Node, /*PrintSuffix=*/true);
1200 }
1201 
1202 void StmtPrinter::VisitImaginaryLiteral(ImaginaryLiteral *Node) {
1203  PrintExpr(Node->getSubExpr());
1204  OS << "i";
1205 }
1206 
1207 void StmtPrinter::VisitStringLiteral(StringLiteral *Str) {
1208  Str->outputString(OS);
1209 }
1210 
1211 void StmtPrinter::VisitParenExpr(ParenExpr *Node) {
1212  OS << "(";
1213  PrintExpr(Node->getSubExpr());
1214  OS << ")";
1215 }
1216 
1217 void StmtPrinter::VisitUnaryOperator(UnaryOperator *Node) {
1218  if (!Node->isPostfix()) {
1219  OS << UnaryOperator::getOpcodeStr(Node->getOpcode());
1220 
1221  // Print a space if this is an "identifier operator" like __real, or if
1222  // it might be concatenated incorrectly like '+'.
1223  switch (Node->getOpcode()) {
1224  default: break;
1225  case UO_Real:
1226  case UO_Imag:
1227  case UO_Extension:
1228  OS << ' ';
1229  break;
1230  case UO_Plus:
1231  case UO_Minus:
1232  if (isa<UnaryOperator>(Node->getSubExpr()))
1233  OS << ' ';
1234  break;
1235  }
1236  }
1237  PrintExpr(Node->getSubExpr());
1238 
1239  if (Node->isPostfix())
1240  OS << UnaryOperator::getOpcodeStr(Node->getOpcode());
1241 }
1242 
1243 void StmtPrinter::VisitOffsetOfExpr(OffsetOfExpr *Node) {
1244  OS << "__builtin_offsetof(";
1245  Node->getTypeSourceInfo()->getType().print(OS, Policy);
1246  OS << ", ";
1247  bool PrintedSomething = false;
1248  for (unsigned i = 0, n = Node->getNumComponents(); i < n; ++i) {
1249  OffsetOfNode ON = Node->getComponent(i);
1250  if (ON.getKind() == OffsetOfNode::Array) {
1251  // Array node
1252  OS << "[";
1253  PrintExpr(Node->getIndexExpr(ON.getArrayExprIndex()));
1254  OS << "]";
1255  PrintedSomething = true;
1256  continue;
1257  }
1258 
1259  // Skip implicit base indirections.
1260  if (ON.getKind() == OffsetOfNode::Base)
1261  continue;
1262 
1263  // Field or identifier node.
1264  IdentifierInfo *Id = ON.getFieldName();
1265  if (!Id)
1266  continue;
1267 
1268  if (PrintedSomething)
1269  OS << ".";
1270  else
1271  PrintedSomething = true;
1272  OS << Id->getName();
1273  }
1274  OS << ")";
1275 }
1276 
1277 void StmtPrinter::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *Node){
1278  switch(Node->getKind()) {
1279  case UETT_SizeOf:
1280  OS << "sizeof";
1281  break;
1282  case UETT_AlignOf:
1283  if (Policy.Alignof)
1284  OS << "alignof";
1285  else if (Policy.UnderscoreAlignof)
1286  OS << "_Alignof";
1287  else
1288  OS << "__alignof";
1289  break;
1290  case UETT_PreferredAlignOf:
1291  OS << "__alignof";
1292  break;
1293  case UETT_VecStep:
1294  OS << "vec_step";
1295  break;
1297  OS << "__builtin_omp_required_simd_align";
1298  break;
1299  }
1300  if (Node->isArgumentType()) {
1301  OS << '(';
1302  Node->getArgumentType().print(OS, Policy);
1303  OS << ')';
1304  } else {
1305  OS << " ";
1306  PrintExpr(Node->getArgumentExpr());
1307  }
1308 }
1309 
1310 void StmtPrinter::VisitGenericSelectionExpr(GenericSelectionExpr *Node) {
1311  OS << "_Generic(";
1312  PrintExpr(Node->getControllingExpr());
1313  for (const GenericSelectionExpr::Association Assoc : Node->associations()) {
1314  OS << ", ";
1315  QualType T = Assoc.getType();
1316  if (T.isNull())
1317  OS << "default";
1318  else
1319  T.print(OS, Policy);
1320  OS << ": ";
1321  PrintExpr(Assoc.getAssociationExpr());
1322  }
1323  OS << ")";
1324 }
1325 
1326 void StmtPrinter::VisitArraySubscriptExpr(ArraySubscriptExpr *Node) {
1327  PrintExpr(Node->getLHS());
1328  OS << "[";
1329  PrintExpr(Node->getRHS());
1330  OS << "]";
1331 }
1332 
1333 void StmtPrinter::VisitOMPArraySectionExpr(OMPArraySectionExpr *Node) {
1334  PrintExpr(Node->getBase());
1335  OS << "[";
1336  if (Node->getLowerBound())
1337  PrintExpr(Node->getLowerBound());
1338  if (Node->getColonLoc().isValid()) {
1339  OS << ":";
1340  if (Node->getLength())
1341  PrintExpr(Node->getLength());
1342  }
1343  OS << "]";
1344 }
1345 
1346 void StmtPrinter::PrintCallArgs(CallExpr *Call) {
1347  for (unsigned i = 0, e = Call->getNumArgs(); i != e; ++i) {
1348  if (isa<CXXDefaultArgExpr>(Call->getArg(i))) {
1349  // Don't print any defaulted arguments
1350  break;
1351  }
1352 
1353  if (i) OS << ", ";
1354  PrintExpr(Call->getArg(i));
1355  }
1356 }
1357 
1358 void StmtPrinter::VisitCallExpr(CallExpr *Call) {
1359  PrintExpr(Call->getCallee());
1360  OS << "(";
1361  PrintCallArgs(Call);
1362  OS << ")";
1363 }
1364 
1365 static bool isImplicitThis(const Expr *E) {
1366  if (const auto *TE = dyn_cast<CXXThisExpr>(E))
1367  return TE->isImplicit();
1368  return false;
1369 }
1370 
1371 void StmtPrinter::VisitMemberExpr(MemberExpr *Node) {
1372  if (!Policy.SuppressImplicitBase || !isImplicitThis(Node->getBase())) {
1373  PrintExpr(Node->getBase());
1374 
1375  auto *ParentMember = dyn_cast<MemberExpr>(Node->getBase());
1376  FieldDecl *ParentDecl =
1377  ParentMember ? dyn_cast<FieldDecl>(ParentMember->getMemberDecl())
1378  : nullptr;
1379 
1380  if (!ParentDecl || !ParentDecl->isAnonymousStructOrUnion())
1381  OS << (Node->isArrow() ? "->" : ".");
1382  }
1383 
1384  if (auto *FD = dyn_cast<FieldDecl>(Node->getMemberDecl()))
1385  if (FD->isAnonymousStructOrUnion())
1386  return;
1387 
1388  if (NestedNameSpecifier *Qualifier = Node->getQualifier())
1389  Qualifier->print(OS, Policy);
1390  if (Node->hasTemplateKeyword())
1391  OS << "template ";
1392  OS << Node->getMemberNameInfo();
1393  if (Node->hasExplicitTemplateArgs())
1394  printTemplateArgumentList(OS, Node->template_arguments(), Policy);
1395 }
1396 
1397 void StmtPrinter::VisitObjCIsaExpr(ObjCIsaExpr *Node) {
1398  PrintExpr(Node->getBase());
1399  OS << (Node->isArrow() ? "->isa" : ".isa");
1400 }
1401 
1402 void StmtPrinter::VisitExtVectorElementExpr(ExtVectorElementExpr *Node) {
1403  PrintExpr(Node->getBase());
1404  OS << ".";
1405  OS << Node->getAccessor().getName();
1406 }
1407 
1408 void StmtPrinter::VisitCStyleCastExpr(CStyleCastExpr *Node) {
1409  OS << '(';
1410  Node->getTypeAsWritten().print(OS, Policy);
1411  OS << ')';
1412  PrintExpr(Node->getSubExpr());
1413 }
1414 
1415 void StmtPrinter::VisitCompoundLiteralExpr(CompoundLiteralExpr *Node) {
1416  OS << '(';
1417  Node->getType().print(OS, Policy);
1418  OS << ')';
1419  PrintExpr(Node->getInitializer());
1420 }
1421 
1422 void StmtPrinter::VisitImplicitCastExpr(ImplicitCastExpr *Node) {
1423  // No need to print anything, simply forward to the subexpression.
1424  PrintExpr(Node->getSubExpr());
1425 }
1426 
1427 void StmtPrinter::VisitBinaryOperator(BinaryOperator *Node) {
1428  PrintExpr(Node->getLHS());
1429  OS << " " << BinaryOperator::getOpcodeStr(Node->getOpcode()) << " ";
1430  PrintExpr(Node->getRHS());
1431 }
1432 
1433 void StmtPrinter::VisitCompoundAssignOperator(CompoundAssignOperator *Node) {
1434  PrintExpr(Node->getLHS());
1435  OS << " " << BinaryOperator::getOpcodeStr(Node->getOpcode()) << " ";
1436  PrintExpr(Node->getRHS());
1437 }
1438 
1439 void StmtPrinter::VisitConditionalOperator(ConditionalOperator *Node) {
1440  PrintExpr(Node->getCond());
1441  OS << " ? ";
1442  PrintExpr(Node->getLHS());
1443  OS << " : ";
1444  PrintExpr(Node->getRHS());
1445 }
1446 
1447 // GNU extensions.
1448 
1449 void
1450 StmtPrinter::VisitBinaryConditionalOperator(BinaryConditionalOperator *Node) {
1451  PrintExpr(Node->getCommon());
1452  OS << " ?: ";
1453  PrintExpr(Node->getFalseExpr());
1454 }
1455 
1456 void StmtPrinter::VisitAddrLabelExpr(AddrLabelExpr *Node) {
1457  OS << "&&" << Node->getLabel()->getName();
1458 }
1459 
1460 void StmtPrinter::VisitStmtExpr(StmtExpr *E) {
1461  OS << "(";
1462  PrintRawCompoundStmt(E->getSubStmt());
1463  OS << ")";
1464 }
1465 
1466 void StmtPrinter::VisitChooseExpr(ChooseExpr *Node) {
1467  OS << "__builtin_choose_expr(";
1468  PrintExpr(Node->getCond());
1469  OS << ", ";
1470  PrintExpr(Node->getLHS());
1471  OS << ", ";
1472  PrintExpr(Node->getRHS());
1473  OS << ")";
1474 }
1475 
1476 void StmtPrinter::VisitGNUNullExpr(GNUNullExpr *) {
1477  OS << "__null";
1478 }
1479 
1480 void StmtPrinter::VisitShuffleVectorExpr(ShuffleVectorExpr *Node) {
1481  OS << "__builtin_shufflevector(";
1482  for (unsigned i = 0, e = Node->getNumSubExprs(); i != e; ++i) {
1483  if (i) OS << ", ";
1484  PrintExpr(Node->getExpr(i));
1485  }
1486  OS << ")";
1487 }
1488 
1489 void StmtPrinter::VisitConvertVectorExpr(ConvertVectorExpr *Node) {
1490  OS << "__builtin_convertvector(";
1491  PrintExpr(Node->getSrcExpr());
1492  OS << ", ";
1493  Node->getType().print(OS, Policy);
1494  OS << ")";
1495 }
1496 
1497 void StmtPrinter::VisitInitListExpr(InitListExpr* Node) {
1498  if (Node->getSyntacticForm()) {
1499  Visit(Node->getSyntacticForm());
1500  return;
1501  }
1502 
1503  OS << "{";
1504  for (unsigned i = 0, e = Node->getNumInits(); i != e; ++i) {
1505  if (i) OS << ", ";
1506  if (Node->getInit(i))
1507  PrintExpr(Node->getInit(i));
1508  else
1509  OS << "{}";
1510  }
1511  OS << "}";
1512 }
1513 
1514 void StmtPrinter::VisitArrayInitLoopExpr(ArrayInitLoopExpr *Node) {
1515  // There's no way to express this expression in any of our supported
1516  // languages, so just emit something terse and (hopefully) clear.
1517  OS << "{";
1518  PrintExpr(Node->getSubExpr());
1519  OS << "}";
1520 }
1521 
1522 void StmtPrinter::VisitArrayInitIndexExpr(ArrayInitIndexExpr *Node) {
1523  OS << "*";
1524 }
1525 
1526 void StmtPrinter::VisitParenListExpr(ParenListExpr* Node) {
1527  OS << "(";
1528  for (unsigned i = 0, e = Node->getNumExprs(); i != e; ++i) {
1529  if (i) OS << ", ";
1530  PrintExpr(Node->getExpr(i));
1531  }
1532  OS << ")";
1533 }
1534 
1535 void StmtPrinter::VisitDesignatedInitExpr(DesignatedInitExpr *Node) {
1536  bool NeedsEquals = true;
1537  for (const DesignatedInitExpr::Designator &D : Node->designators()) {
1538  if (D.isFieldDesignator()) {
1539  if (D.getDotLoc().isInvalid()) {
1540  if (IdentifierInfo *II = D.getFieldName()) {
1541  OS << II->getName() << ":";
1542  NeedsEquals = false;
1543  }
1544  } else {
1545  OS << "." << D.getFieldName()->getName();
1546  }
1547  } else {
1548  OS << "[";
1549  if (D.isArrayDesignator()) {
1550  PrintExpr(Node->getArrayIndex(D));
1551  } else {
1552  PrintExpr(Node->getArrayRangeStart(D));
1553  OS << " ... ";
1554  PrintExpr(Node->getArrayRangeEnd(D));
1555  }
1556  OS << "]";
1557  }
1558  }
1559 
1560  if (NeedsEquals)
1561  OS << " = ";
1562  else
1563  OS << " ";
1564  PrintExpr(Node->getInit());
1565 }
1566 
1567 void StmtPrinter::VisitDesignatedInitUpdateExpr(
1568  DesignatedInitUpdateExpr *Node) {
1569  OS << "{";
1570  OS << "/*base*/";
1571  PrintExpr(Node->getBase());
1572  OS << ", ";
1573 
1574  OS << "/*updater*/";
1575  PrintExpr(Node->getUpdater());
1576  OS << "}";
1577 }
1578 
1579 void StmtPrinter::VisitNoInitExpr(NoInitExpr *Node) {
1580  OS << "/*no init*/";
1581 }
1582 
1583 void StmtPrinter::VisitImplicitValueInitExpr(ImplicitValueInitExpr *Node) {
1584  if (Node->getType()->getAsCXXRecordDecl()) {
1585  OS << "/*implicit*/";
1586  Node->getType().print(OS, Policy);
1587  OS << "()";
1588  } else {
1589  OS << "/*implicit*/(";
1590  Node->getType().print(OS, Policy);
1591  OS << ')';
1592  if (Node->getType()->isRecordType())
1593  OS << "{}";
1594  else
1595  OS << 0;
1596  }
1597 }
1598 
1599 void StmtPrinter::VisitVAArgExpr(VAArgExpr *Node) {
1600  OS << "__builtin_va_arg(";
1601  PrintExpr(Node->getSubExpr());
1602  OS << ", ";
1603  Node->getType().print(OS, Policy);
1604  OS << ")";
1605 }
1606 
1607 void StmtPrinter::VisitPseudoObjectExpr(PseudoObjectExpr *Node) {
1608  PrintExpr(Node->getSyntacticForm());
1609 }
1610 
1611 void StmtPrinter::VisitAtomicExpr(AtomicExpr *Node) {
1612  const char *Name = nullptr;
1613  switch (Node->getOp()) {
1614 #define BUILTIN(ID, TYPE, ATTRS)
1615 #define ATOMIC_BUILTIN(ID, TYPE, ATTRS) \
1616  case AtomicExpr::AO ## ID: \
1617  Name = #ID "("; \
1618  break;
1619 #include "clang/Basic/Builtins.def"
1620  }
1621  OS << Name;
1622 
1623  // AtomicExpr stores its subexpressions in a permuted order.
1624  PrintExpr(Node->getPtr());
1625  if (Node->getOp() != AtomicExpr::AO__c11_atomic_load &&
1626  Node->getOp() != AtomicExpr::AO__atomic_load_n &&
1627  Node->getOp() != AtomicExpr::AO__opencl_atomic_load) {
1628  OS << ", ";
1629  PrintExpr(Node->getVal1());
1630  }
1631  if (Node->getOp() == AtomicExpr::AO__atomic_exchange ||
1632  Node->isCmpXChg()) {
1633  OS << ", ";
1634  PrintExpr(Node->getVal2());
1635  }
1636  if (Node->getOp() == AtomicExpr::AO__atomic_compare_exchange ||
1637  Node->getOp() == AtomicExpr::AO__atomic_compare_exchange_n) {
1638  OS << ", ";
1639  PrintExpr(Node->getWeak());
1640  }
1641  if (Node->getOp() != AtomicExpr::AO__c11_atomic_init &&
1642  Node->getOp() != AtomicExpr::AO__opencl_atomic_init) {
1643  OS << ", ";
1644  PrintExpr(Node->getOrder());
1645  }
1646  if (Node->isCmpXChg()) {
1647  OS << ", ";
1648  PrintExpr(Node->getOrderFail());
1649  }
1650  OS << ")";
1651 }
1652 
1653 // C++
1654 void StmtPrinter::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *Node) {
1656  if (Kind == OO_PlusPlus || Kind == OO_MinusMinus) {
1657  if (Node->getNumArgs() == 1) {
1658  OS << getOperatorSpelling(Kind) << ' ';
1659  PrintExpr(Node->getArg(0));
1660  } else {
1661  PrintExpr(Node->getArg(0));
1662  OS << ' ' << getOperatorSpelling(Kind);
1663  }
1664  } else if (Kind == OO_Arrow) {
1665  PrintExpr(Node->getArg(0));
1666  } else if (Kind == OO_Call) {
1667  PrintExpr(Node->getArg(0));
1668  OS << '(';
1669  for (unsigned ArgIdx = 1; ArgIdx < Node->getNumArgs(); ++ArgIdx) {
1670  if (ArgIdx > 1)
1671  OS << ", ";
1672  if (!isa<CXXDefaultArgExpr>(Node->getArg(ArgIdx)))
1673  PrintExpr(Node->getArg(ArgIdx));
1674  }
1675  OS << ')';
1676  } else if (Kind == OO_Subscript) {
1677  PrintExpr(Node->getArg(0));
1678  OS << '[';
1679  PrintExpr(Node->getArg(1));
1680  OS << ']';
1681  } else if (Node->getNumArgs() == 1) {
1682  OS << getOperatorSpelling(Kind) << ' ';
1683  PrintExpr(Node->getArg(0));
1684  } else if (Node->getNumArgs() == 2) {
1685  PrintExpr(Node->getArg(0));
1686  OS << ' ' << getOperatorSpelling(Kind) << ' ';
1687  PrintExpr(Node->getArg(1));
1688  } else {
1689  llvm_unreachable("unknown overloaded operator");
1690  }
1691 }
1692 
1693 void StmtPrinter::VisitCXXMemberCallExpr(CXXMemberCallExpr *Node) {
1694  // If we have a conversion operator call only print the argument.
1695  CXXMethodDecl *MD = Node->getMethodDecl();
1696  if (MD && isa<CXXConversionDecl>(MD)) {
1697  PrintExpr(Node->getImplicitObjectArgument());
1698  return;
1699  }
1700  VisitCallExpr(cast<CallExpr>(Node));
1701 }
1702 
1703 void StmtPrinter::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *Node) {
1704  PrintExpr(Node->getCallee());
1705  OS << "<<<";
1706  PrintCallArgs(Node->getConfig());
1707  OS << ">>>(";
1708  PrintCallArgs(Node);
1709  OS << ")";
1710 }
1711 
1712 void StmtPrinter::VisitCXXRewrittenBinaryOperator(
1715  Node->getDecomposedForm();
1716  PrintExpr(const_cast<Expr*>(Decomposed.LHS));
1717  OS << ' ' << BinaryOperator::getOpcodeStr(Decomposed.Opcode) << ' ';
1718  PrintExpr(const_cast<Expr*>(Decomposed.RHS));
1719 }
1720 
1721 void StmtPrinter::VisitCXXNamedCastExpr(CXXNamedCastExpr *Node) {
1722  OS << Node->getCastName() << '<';
1723  Node->getTypeAsWritten().print(OS, Policy);
1724  OS << ">(";
1725  PrintExpr(Node->getSubExpr());
1726  OS << ")";
1727 }
1728 
1729 void StmtPrinter::VisitCXXStaticCastExpr(CXXStaticCastExpr *Node) {
1730  VisitCXXNamedCastExpr(Node);
1731 }
1732 
1733 void StmtPrinter::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *Node) {
1734  VisitCXXNamedCastExpr(Node);
1735 }
1736 
1737 void StmtPrinter::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *Node) {
1738  VisitCXXNamedCastExpr(Node);
1739 }
1740 
1741 void StmtPrinter::VisitCXXConstCastExpr(CXXConstCastExpr *Node) {
1742  VisitCXXNamedCastExpr(Node);
1743 }
1744 
1745 void StmtPrinter::VisitBuiltinBitCastExpr(BuiltinBitCastExpr *Node) {
1746  OS << "__builtin_bit_cast(";
1747  Node->getTypeInfoAsWritten()->getType().print(OS, Policy);
1748  OS << ", ";
1749  PrintExpr(Node->getSubExpr());
1750  OS << ")";
1751 }
1752 
1753 void StmtPrinter::VisitCXXTypeidExpr(CXXTypeidExpr *Node) {
1754  OS << "typeid(";
1755  if (Node->isTypeOperand()) {
1756  Node->getTypeOperandSourceInfo()->getType().print(OS, Policy);
1757  } else {
1758  PrintExpr(Node->getExprOperand());
1759  }
1760  OS << ")";
1761 }
1762 
1763 void StmtPrinter::VisitCXXUuidofExpr(CXXUuidofExpr *Node) {
1764  OS << "__uuidof(";
1765  if (Node->isTypeOperand()) {
1766  Node->getTypeOperandSourceInfo()->getType().print(OS, Policy);
1767  } else {
1768  PrintExpr(Node->getExprOperand());
1769  }
1770  OS << ")";
1771 }
1772 
1773 void StmtPrinter::VisitMSPropertyRefExpr(MSPropertyRefExpr *Node) {
1774  PrintExpr(Node->getBaseExpr());
1775  if (Node->isArrow())
1776  OS << "->";
1777  else
1778  OS << ".";
1779  if (NestedNameSpecifier *Qualifier =
1781  Qualifier->print(OS, Policy);
1782  OS << Node->getPropertyDecl()->getDeclName();
1783 }
1784 
1785 void StmtPrinter::VisitMSPropertySubscriptExpr(MSPropertySubscriptExpr *Node) {
1786  PrintExpr(Node->getBase());
1787  OS << "[";
1788  PrintExpr(Node->getIdx());
1789  OS << "]";
1790 }
1791 
1792 void StmtPrinter::VisitUserDefinedLiteral(UserDefinedLiteral *Node) {
1793  switch (Node->getLiteralOperatorKind()) {
1795  OS << cast<StringLiteral>(Node->getArg(0)->IgnoreImpCasts())->getString();
1796  break;
1798  const auto *DRE = cast<DeclRefExpr>(Node->getCallee()->IgnoreImpCasts());
1799  const TemplateArgumentList *Args =
1800  cast<FunctionDecl>(DRE->getDecl())->getTemplateSpecializationArgs();
1801  assert(Args);
1802 
1803  if (Args->size() != 1) {
1804  OS << "operator\"\"" << Node->getUDSuffix()->getName();
1805  printTemplateArgumentList(OS, Args->asArray(), Policy);
1806  OS << "()";
1807  return;
1808  }
1809 
1810  const TemplateArgument &Pack = Args->get(0);
1811  for (const auto &P : Pack.pack_elements()) {
1812  char C = (char)P.getAsIntegral().getZExtValue();
1813  OS << C;
1814  }
1815  break;
1816  }
1818  // Print integer literal without suffix.
1819  const auto *Int = cast<IntegerLiteral>(Node->getCookedLiteral());
1820  OS << Int->getValue().toString(10, /*isSigned*/false);
1821  break;
1822  }
1824  // Print floating literal without suffix.
1825  auto *Float = cast<FloatingLiteral>(Node->getCookedLiteral());
1826  PrintFloatingLiteral(OS, Float, /*PrintSuffix=*/false);
1827  break;
1828  }
1831  PrintExpr(Node->getCookedLiteral());
1832  break;
1833  }
1834  OS << Node->getUDSuffix()->getName();
1835 }
1836 
1837 void StmtPrinter::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *Node) {
1838  OS << (Node->getValue() ? "true" : "false");
1839 }
1840 
1841 void StmtPrinter::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *Node) {
1842  OS << "nullptr";
1843 }
1844 
1845 void StmtPrinter::VisitCXXThisExpr(CXXThisExpr *Node) {
1846  OS << "this";
1847 }
1848 
1849 void StmtPrinter::VisitCXXThrowExpr(CXXThrowExpr *Node) {
1850  if (!Node->getSubExpr())
1851  OS << "throw";
1852  else {
1853  OS << "throw ";
1854  PrintExpr(Node->getSubExpr());
1855  }
1856 }
1857 
1858 void StmtPrinter::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *Node) {
1859  // Nothing to print: we picked up the default argument.
1860 }
1861 
1862 void StmtPrinter::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *Node) {
1863  // Nothing to print: we picked up the default initializer.
1864 }
1865 
1866 void StmtPrinter::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *Node) {
1867  Node->getType().print(OS, Policy);
1868  // If there are no parens, this is list-initialization, and the braces are
1869  // part of the syntax of the inner construct.
1870  if (Node->getLParenLoc().isValid())
1871  OS << "(";
1872  PrintExpr(Node->getSubExpr());
1873  if (Node->getLParenLoc().isValid())
1874  OS << ")";
1875 }
1876 
1877 void StmtPrinter::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *Node) {
1878  PrintExpr(Node->getSubExpr());
1879 }
1880 
1881 void StmtPrinter::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *Node) {
1882  Node->getType().print(OS, Policy);
1883  if (Node->isStdInitListInitialization())
1884  /* Nothing to do; braces are part of creating the std::initializer_list. */;
1885  else if (Node->isListInitialization())
1886  OS << "{";
1887  else
1888  OS << "(";
1890  ArgEnd = Node->arg_end();
1891  Arg != ArgEnd; ++Arg) {
1892  if ((*Arg)->isDefaultArgument())
1893  break;
1894  if (Arg != Node->arg_begin())
1895  OS << ", ";
1896  PrintExpr(*Arg);
1897  }
1898  if (Node->isStdInitListInitialization())
1899  /* See above. */;
1900  else if (Node->isListInitialization())
1901  OS << "}";
1902  else
1903  OS << ")";
1904 }
1905 
1906 void StmtPrinter::VisitLambdaExpr(LambdaExpr *Node) {
1907  OS << '[';
1908  bool NeedComma = false;
1909  switch (Node->getCaptureDefault()) {
1910  case LCD_None:
1911  break;
1912 
1913  case LCD_ByCopy:
1914  OS << '=';
1915  NeedComma = true;
1916  break;
1917 
1918  case LCD_ByRef:
1919  OS << '&';
1920  NeedComma = true;
1921  break;
1922  }
1924  CEnd = Node->explicit_capture_end();
1925  C != CEnd;
1926  ++C) {
1927  if (C->capturesVLAType())
1928  continue;
1929 
1930  if (NeedComma)
1931  OS << ", ";
1932  NeedComma = true;
1933 
1934  switch (C->getCaptureKind()) {
1935  case LCK_This:
1936  OS << "this";
1937  break;
1938 
1939  case LCK_StarThis:
1940  OS << "*this";
1941  break;
1942 
1943  case LCK_ByRef:
1944  if (Node->getCaptureDefault() != LCD_ByRef || Node->isInitCapture(C))
1945  OS << '&';
1946  OS << C->getCapturedVar()->getName();
1947  break;
1948 
1949  case LCK_ByCopy:
1950  OS << C->getCapturedVar()->getName();
1951  break;
1952 
1953  case LCK_VLAType:
1954  llvm_unreachable("VLA type in explicit captures.");
1955  }
1956 
1957  if (C->isPackExpansion())
1958  OS << "...";
1959 
1960  if (Node->isInitCapture(C))
1961  PrintExpr(C->getCapturedVar()->getInit());
1962  }
1963  OS << ']';
1964 
1965  if (!Node->getExplicitTemplateParameters().empty()) {
1967  OS, Node->getLambdaClass()->getASTContext(),
1968  /*OmitTemplateKW*/true);
1969  }
1970 
1971  if (Node->hasExplicitParameters()) {
1972  OS << '(';
1973  CXXMethodDecl *Method = Node->getCallOperator();
1974  NeedComma = false;
1975  for (const auto *P : Method->parameters()) {
1976  if (NeedComma) {
1977  OS << ", ";
1978  } else {
1979  NeedComma = true;
1980  }
1981  std::string ParamStr = P->getNameAsString();
1982  P->getOriginalType().print(OS, Policy, ParamStr);
1983  }
1984  if (Method->isVariadic()) {
1985  if (NeedComma)
1986  OS << ", ";
1987  OS << "...";
1988  }
1989  OS << ')';
1990 
1991  if (Node->isMutable())
1992  OS << " mutable";
1993 
1994  auto *Proto = Method->getType()->castAs<FunctionProtoType>();
1995  Proto->printExceptionSpecification(OS, Policy);
1996 
1997  // FIXME: Attributes
1998 
1999  // Print the trailing return type if it was specified in the source.
2000  if (Node->hasExplicitResultType()) {
2001  OS << " -> ";
2002  Proto->getReturnType().print(OS, Policy);
2003  }
2004  }
2005 
2006  // Print the body.
2007  OS << ' ';
2008  if (Policy.TerseOutput)
2009  OS << "{}";
2010  else
2011  PrintRawCompoundStmt(Node->getBody());
2012 }
2013 
2014 void StmtPrinter::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *Node) {
2015  if (TypeSourceInfo *TSInfo = Node->getTypeSourceInfo())
2016  TSInfo->getType().print(OS, Policy);
2017  else
2018  Node->getType().print(OS, Policy);
2019  OS << "()";
2020 }
2021 
2022 void StmtPrinter::VisitCXXNewExpr(CXXNewExpr *E) {
2023  if (E->isGlobalNew())
2024  OS << "::";
2025  OS << "new ";
2026  unsigned NumPlace = E->getNumPlacementArgs();
2027  if (NumPlace > 0 && !isa<CXXDefaultArgExpr>(E->getPlacementArg(0))) {
2028  OS << "(";
2029  PrintExpr(E->getPlacementArg(0));
2030  for (unsigned i = 1; i < NumPlace; ++i) {
2031  if (isa<CXXDefaultArgExpr>(E->getPlacementArg(i)))
2032  break;
2033  OS << ", ";
2034  PrintExpr(E->getPlacementArg(i));
2035  }
2036  OS << ") ";
2037  }
2038  if (E->isParenTypeId())
2039  OS << "(";
2040  std::string TypeS;
2041  if (Optional<Expr *> Size = E->getArraySize()) {
2042  llvm::raw_string_ostream s(TypeS);
2043  s << '[';
2044  if (*Size)
2045  (*Size)->printPretty(s, Helper, Policy);
2046  s << ']';
2047  }
2048  E->getAllocatedType().print(OS, Policy, TypeS);
2049  if (E->isParenTypeId())
2050  OS << ")";
2051 
2053  if (InitStyle) {
2054  if (InitStyle == CXXNewExpr::CallInit)
2055  OS << "(";
2056  PrintExpr(E->getInitializer());
2057  if (InitStyle == CXXNewExpr::CallInit)
2058  OS << ")";
2059  }
2060 }
2061 
2062 void StmtPrinter::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
2063  if (E->isGlobalDelete())
2064  OS << "::";
2065  OS << "delete ";
2066  if (E->isArrayForm())
2067  OS << "[] ";
2068  PrintExpr(E->getArgument());
2069 }
2070 
2071 void StmtPrinter::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
2072  PrintExpr(E->getBase());
2073  if (E->isArrow())
2074  OS << "->";
2075  else
2076  OS << '.';
2077  if (E->getQualifier())
2078  E->getQualifier()->print(OS, Policy);
2079  OS << "~";
2080 
2082  OS << II->getName();
2083  else
2084  E->getDestroyedType().print(OS, Policy);
2085 }
2086 
2087 void StmtPrinter::VisitCXXConstructExpr(CXXConstructExpr *E) {
2089  OS << "{";
2090 
2091  for (unsigned i = 0, e = E->getNumArgs(); i != e; ++i) {
2092  if (isa<CXXDefaultArgExpr>(E->getArg(i))) {
2093  // Don't print any defaulted arguments
2094  break;
2095  }
2096 
2097  if (i) OS << ", ";
2098  PrintExpr(E->getArg(i));
2099  }
2100 
2102  OS << "}";
2103 }
2104 
2105 void StmtPrinter::VisitCXXInheritedCtorInitExpr(CXXInheritedCtorInitExpr *E) {
2106  // Parens are printed by the surrounding context.
2107  OS << "<forwarded>";
2108 }
2109 
2110 void StmtPrinter::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E) {
2111  PrintExpr(E->getSubExpr());
2112 }
2113 
2114 void StmtPrinter::VisitExprWithCleanups(ExprWithCleanups *E) {
2115  // Just forward to the subexpression.
2116  PrintExpr(E->getSubExpr());
2117 }
2118 
2119 void
2120 StmtPrinter::VisitCXXUnresolvedConstructExpr(
2122  Node->getTypeAsWritten().print(OS, Policy);
2123  OS << "(";
2125  ArgEnd = Node->arg_end();
2126  Arg != ArgEnd; ++Arg) {
2127  if (Arg != Node->arg_begin())
2128  OS << ", ";
2129  PrintExpr(*Arg);
2130  }
2131  OS << ")";
2132 }
2133 
2134 void StmtPrinter::VisitCXXDependentScopeMemberExpr(
2136  if (!Node->isImplicitAccess()) {
2137  PrintExpr(Node->getBase());
2138  OS << (Node->isArrow() ? "->" : ".");
2139  }
2140  if (NestedNameSpecifier *Qualifier = Node->getQualifier())
2141  Qualifier->print(OS, Policy);
2142  if (Node->hasTemplateKeyword())
2143  OS << "template ";
2144  OS << Node->getMemberNameInfo();
2145  if (Node->hasExplicitTemplateArgs())
2146  printTemplateArgumentList(OS, Node->template_arguments(), Policy);
2147 }
2148 
2149 void StmtPrinter::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *Node) {
2150  if (!Node->isImplicitAccess()) {
2151  PrintExpr(Node->getBase());
2152  OS << (Node->isArrow() ? "->" : ".");
2153  }
2154  if (NestedNameSpecifier *Qualifier = Node->getQualifier())
2155  Qualifier->print(OS, Policy);
2156  if (Node->hasTemplateKeyword())
2157  OS << "template ";
2158  OS << Node->getMemberNameInfo();
2159  if (Node->hasExplicitTemplateArgs())
2160  printTemplateArgumentList(OS, Node->template_arguments(), Policy);
2161 }
2162 
2163 static const char *getTypeTraitName(TypeTrait TT) {
2164  switch (TT) {
2165 #define TYPE_TRAIT_1(Spelling, Name, Key) \
2166 case clang::UTT_##Name: return #Spelling;
2167 #define TYPE_TRAIT_2(Spelling, Name, Key) \
2168 case clang::BTT_##Name: return #Spelling;
2169 #define TYPE_TRAIT_N(Spelling, Name, Key) \
2170  case clang::TT_##Name: return #Spelling;
2171 #include "clang/Basic/TokenKinds.def"
2172  }
2173  llvm_unreachable("Type trait not covered by switch");
2174 }
2175 
2176 static const char *getTypeTraitName(ArrayTypeTrait ATT) {
2177  switch (ATT) {
2178  case ATT_ArrayRank: return "__array_rank";
2179  case ATT_ArrayExtent: return "__array_extent";
2180  }
2181  llvm_unreachable("Array type trait not covered by switch");
2182 }
2183 
2184 static const char *getExpressionTraitName(ExpressionTrait ET) {
2185  switch (ET) {
2186  case ET_IsLValueExpr: return "__is_lvalue_expr";
2187  case ET_IsRValueExpr: return "__is_rvalue_expr";
2188  }
2189  llvm_unreachable("Expression type trait not covered by switch");
2190 }
2191 
2192 void StmtPrinter::VisitTypeTraitExpr(TypeTraitExpr *E) {
2193  OS << getTypeTraitName(E->getTrait()) << "(";
2194  for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) {
2195  if (I > 0)
2196  OS << ", ";
2197  E->getArg(I)->getType().print(OS, Policy);
2198  }
2199  OS << ")";
2200 }
2201 
2202 void StmtPrinter::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
2203  OS << getTypeTraitName(E->getTrait()) << '(';
2204  E->getQueriedType().print(OS, Policy);
2205  OS << ')';
2206 }
2207 
2208 void StmtPrinter::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
2209  OS << getExpressionTraitName(E->getTrait()) << '(';
2210  PrintExpr(E->getQueriedExpression());
2211  OS << ')';
2212 }
2213 
2214 void StmtPrinter::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
2215  OS << "noexcept(";
2216  PrintExpr(E->getOperand());
2217  OS << ")";
2218 }
2219 
2220 void StmtPrinter::VisitPackExpansionExpr(PackExpansionExpr *E) {
2221  PrintExpr(E->getPattern());
2222  OS << "...";
2223 }
2224 
2225 void StmtPrinter::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
2226  OS << "sizeof...(" << *E->getPack() << ")";
2227 }
2228 
2229 void StmtPrinter::VisitSubstNonTypeTemplateParmPackExpr(
2231  OS << *Node->getParameterPack();
2232 }
2233 
2234 void StmtPrinter::VisitSubstNonTypeTemplateParmExpr(
2236  Visit(Node->getReplacement());
2237 }
2238 
2239 void StmtPrinter::VisitFunctionParmPackExpr(FunctionParmPackExpr *E) {
2240  OS << *E->getParameterPack();
2241 }
2242 
2243 void StmtPrinter::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *Node){
2244  PrintExpr(Node->getSubExpr());
2245 }
2246 
2247 void StmtPrinter::VisitCXXFoldExpr(CXXFoldExpr *E) {
2248  OS << "(";
2249  if (E->getLHS()) {
2250  PrintExpr(E->getLHS());
2251  OS << " " << BinaryOperator::getOpcodeStr(E->getOperator()) << " ";
2252  }
2253  OS << "...";
2254  if (E->getRHS()) {
2255  OS << " " << BinaryOperator::getOpcodeStr(E->getOperator()) << " ";
2256  PrintExpr(E->getRHS());
2257  }
2258  OS << ")";
2259 }
2260 
2261 void StmtPrinter::VisitConceptSpecializationExpr(ConceptSpecializationExpr *E) {
2263  if (NNS)
2264  NNS.getNestedNameSpecifier()->print(OS, Policy);
2265  if (E->getTemplateKWLoc().isValid())
2266  OS << "template ";
2267  OS << E->getFoundDecl()->getName();
2269  Policy);
2270 }
2271 
2272 void StmtPrinter::VisitRequiresExpr(RequiresExpr *E) {
2273  OS << "requires ";
2274  auto LocalParameters = E->getLocalParameters();
2275  if (!LocalParameters.empty()) {
2276  OS << "(";
2277  for (ParmVarDecl *LocalParam : LocalParameters) {
2278  PrintRawDecl(LocalParam);
2279  if (LocalParam != LocalParameters.back())
2280  OS << ", ";
2281  }
2282 
2283  OS << ") ";
2284  }
2285  OS << "{ ";
2286  auto Requirements = E->getRequirements();
2287  for (concepts::Requirement *Req : Requirements) {
2288  if (auto *TypeReq = dyn_cast<concepts::TypeRequirement>(Req)) {
2289  if (TypeReq->isSubstitutionFailure())
2290  OS << "<<error-type>>";
2291  else
2292  TypeReq->getType()->getType().print(OS, Policy);
2293  } else if (auto *ExprReq = dyn_cast<concepts::ExprRequirement>(Req)) {
2294  if (ExprReq->isCompound())
2295  OS << "{ ";
2296  if (ExprReq->isExprSubstitutionFailure())
2297  OS << "<<error-expression>>";
2298  else
2299  PrintExpr(ExprReq->getExpr());
2300  if (ExprReq->isCompound()) {
2301  OS << " }";
2302  if (ExprReq->getNoexceptLoc().isValid())
2303  OS << " noexcept";
2304  const auto &RetReq = ExprReq->getReturnTypeRequirement();
2305  if (!RetReq.isEmpty()) {
2306  OS << " -> ";
2307  if (RetReq.isSubstitutionFailure())
2308  OS << "<<error-type>>";
2309  else if (RetReq.isTypeConstraint())
2310  RetReq.getTypeConstraint()->print(OS, Policy);
2311  }
2312  }
2313  } else {
2314  auto *NestedReq = cast<concepts::NestedRequirement>(Req);
2315  OS << "requires ";
2316  if (NestedReq->isSubstitutionFailure())
2317  OS << "<<error-expression>>";
2318  else
2319  PrintExpr(NestedReq->getConstraintExpr());
2320  }
2321  OS << "; ";
2322  }
2323  OS << "}";
2324 }
2325 
2326 // C++ Coroutines TS
2327 
2328 void StmtPrinter::VisitCoroutineBodyStmt(CoroutineBodyStmt *S) {
2329  Visit(S->getBody());
2330 }
2331 
2332 void StmtPrinter::VisitCoreturnStmt(CoreturnStmt *S) {
2333  OS << "co_return";
2334  if (S->getOperand()) {
2335  OS << " ";
2336  Visit(S->getOperand());
2337  }
2338  OS << ";";
2339 }
2340 
2341 void StmtPrinter::VisitCoawaitExpr(CoawaitExpr *S) {
2342  OS << "co_await ";
2343  PrintExpr(S->getOperand());
2344 }
2345 
2346 void StmtPrinter::VisitDependentCoawaitExpr(DependentCoawaitExpr *S) {
2347  OS << "co_await ";
2348  PrintExpr(S->getOperand());
2349 }
2350 
2351 void StmtPrinter::VisitCoyieldExpr(CoyieldExpr *S) {
2352  OS << "co_yield ";
2353  PrintExpr(S->getOperand());
2354 }
2355 
2356 // Obj-C
2357 
2358 void StmtPrinter::VisitObjCStringLiteral(ObjCStringLiteral *Node) {
2359  OS << "@";
2360  VisitStringLiteral(Node->getString());
2361 }
2362 
2363 void StmtPrinter::VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
2364  OS << "@";
2365  Visit(E->getSubExpr());
2366 }
2367 
2368 void StmtPrinter::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
2369  OS << "@[ ";
2371  for (auto I = Ch.begin(), E = Ch.end(); I != E; ++I) {
2372  if (I != Ch.begin())
2373  OS << ", ";
2374  Visit(*I);
2375  }
2376  OS << " ]";
2377 }
2378 
2379 void StmtPrinter::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
2380  OS << "@{ ";
2381  for (unsigned I = 0, N = E->getNumElements(); I != N; ++I) {
2382  if (I > 0)
2383  OS << ", ";
2384 
2385  ObjCDictionaryElement Element = E->getKeyValueElement(I);
2386  Visit(Element.Key);
2387  OS << " : ";
2388  Visit(Element.Value);
2389  if (Element.isPackExpansion())
2390  OS << "...";
2391  }
2392  OS << " }";
2393 }
2394 
2395 void StmtPrinter::VisitObjCEncodeExpr(ObjCEncodeExpr *Node) {
2396  OS << "@encode(";
2397  Node->getEncodedType().print(OS, Policy);
2398  OS << ')';
2399 }
2400 
2401 void StmtPrinter::VisitObjCSelectorExpr(ObjCSelectorExpr *Node) {
2402  OS << "@selector(";
2403  Node->getSelector().print(OS);
2404  OS << ')';
2405 }
2406 
2407 void StmtPrinter::VisitObjCProtocolExpr(ObjCProtocolExpr *Node) {
2408  OS << "@protocol(" << *Node->getProtocol() << ')';
2409 }
2410 
2411 void StmtPrinter::VisitObjCMessageExpr(ObjCMessageExpr *Mess) {
2412  OS << "[";
2413  switch (Mess->getReceiverKind()) {
2415  PrintExpr(Mess->getInstanceReceiver());
2416  break;
2417 
2419  Mess->getClassReceiver().print(OS, Policy);
2420  break;
2421 
2424  OS << "Super";
2425  break;
2426  }
2427 
2428  OS << ' ';
2429  Selector selector = Mess->getSelector();
2430  if (selector.isUnarySelector()) {
2431  OS << selector.getNameForSlot(0);
2432  } else {
2433  for (unsigned i = 0, e = Mess->getNumArgs(); i != e; ++i) {
2434  if (i < selector.getNumArgs()) {
2435  if (i > 0) OS << ' ';
2436  if (selector.getIdentifierInfoForSlot(i))
2437  OS << selector.getIdentifierInfoForSlot(i)->getName() << ':';
2438  else
2439  OS << ":";
2440  }
2441  else OS << ", "; // Handle variadic methods.
2442 
2443  PrintExpr(Mess->getArg(i));
2444  }
2445  }
2446  OS << "]";
2447 }
2448 
2449 void StmtPrinter::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *Node) {
2450  OS << (Node->getValue() ? "__objc_yes" : "__objc_no");
2451 }
2452 
2453 void
2454 StmtPrinter::VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
2455  PrintExpr(E->getSubExpr());
2456 }
2457 
2458 void
2459 StmtPrinter::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
2460  OS << '(' << E->getBridgeKindName();
2461  E->getType().print(OS, Policy);
2462  OS << ')';
2463  PrintExpr(E->getSubExpr());
2464 }
2465 
2466 void StmtPrinter::VisitBlockExpr(BlockExpr *Node) {
2467  BlockDecl *BD = Node->getBlockDecl();
2468  OS << "^";
2469 
2470  const FunctionType *AFT = Node->getFunctionType();
2471 
2472  if (isa<FunctionNoProtoType>(AFT)) {
2473  OS << "()";
2474  } else if (!BD->param_empty() || cast<FunctionProtoType>(AFT)->isVariadic()) {
2475  OS << '(';
2476  for (BlockDecl::param_iterator AI = BD->param_begin(),
2477  E = BD->param_end(); AI != E; ++AI) {
2478  if (AI != BD->param_begin()) OS << ", ";
2479  std::string ParamStr = (*AI)->getNameAsString();
2480  (*AI)->getType().print(OS, Policy, ParamStr);
2481  }
2482 
2483  const auto *FT = cast<FunctionProtoType>(AFT);
2484  if (FT->isVariadic()) {
2485  if (!BD->param_empty()) OS << ", ";
2486  OS << "...";
2487  }
2488  OS << ')';
2489  }
2490  OS << "{ }";
2491 }
2492 
2493 void StmtPrinter::VisitOpaqueValueExpr(OpaqueValueExpr *Node) {
2494  PrintExpr(Node->getSourceExpr());
2495 }
2496 
2497 void StmtPrinter::VisitTypoExpr(TypoExpr *Node) {
2498  // TODO: Print something reasonable for a TypoExpr, if necessary.
2499  llvm_unreachable("Cannot print TypoExpr nodes");
2500 }
2501 
2502 void StmtPrinter::VisitAsTypeExpr(AsTypeExpr *Node) {
2503  OS << "__builtin_astype(";
2504  PrintExpr(Node->getSrcExpr());
2505  OS << ", ";
2506  Node->getType().print(OS, Policy);
2507  OS << ")";
2508 }
2509 
2510 //===----------------------------------------------------------------------===//
2511 // Stmt method implementations
2512 //===----------------------------------------------------------------------===//
2513 
2514 void Stmt::dumpPretty(const ASTContext &Context) const {
2515  printPretty(llvm::errs(), nullptr, PrintingPolicy(Context.getLangOpts()));
2516 }
2517 
2518 void Stmt::printPretty(raw_ostream &Out, PrinterHelper *Helper,
2519  const PrintingPolicy &Policy, unsigned Indentation,
2520  StringRef NL, const ASTContext *Context) const {
2521  StmtPrinter P(Out, Helper, Policy, Indentation, NL, Context);
2522  P.Visit(const_cast<Stmt *>(this));
2523 }
2524 
2525 void Stmt::printJson(raw_ostream &Out, PrinterHelper *Helper,
2526  const PrintingPolicy &Policy, bool AddQuotes) const {
2527  std::string Buf;
2528  llvm::raw_string_ostream TempOut(Buf);
2529 
2530  printPretty(TempOut, Helper, Policy);
2531 
2532  Out << JsonFormat(TempOut.str(), AddQuotes);
2533 }
2534 
2535 //===----------------------------------------------------------------------===//
2536 // PrinterHelper
2537 //===----------------------------------------------------------------------===//
2538 
2539 // Implement virtual destructor.
2540 PrinterHelper::~PrinterHelper() = default;
Expr * getInc()
Definition: Stmt.h:2443
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
Definition: ExprObjC.h:614
const Expr * getSubExpr() const
Definition: Expr.h:963
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:4714
Raw form: operator "" X (const char *)
Definition: ExprCXX.h:592
Expr * getVal2() const
Definition: Expr.h:5901
Defines the clang::ASTContext interface.
const BlockDecl * getBlockDecl() const
Definition: Expr.h:5593
This represents &#39;#pragma omp distribute simd&#39; composite directive.
Definition: StmtOpenMP.h:3757
This represents &#39;#pragma omp master&#39; directive.
Definition: StmtOpenMP.h:1591
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:1261
This represents &#39;#pragma omp task&#39; directive.
Definition: StmtOpenMP.h:1986
This represents a GCC inline-assembly statement extension.
Definition: Stmt.h:2878
Represents a &#39;co_await&#39; expression while the type of the promise is dependent.
Definition: ExprCXX.h:4735
Expr * getArrayIndex(const Designator &D) const
Definition: Expr.cpp:4413
bool getValue() const
Definition: ExprObjC.h:97
The receiver is an object instance.
Definition: ExprObjC.h:1101
Expr * getLHS() const
Definition: Expr.h:3780
bool hasExplicitTemplateArgs() const
Determines whether this expression had explicit template arguments.
Definition: ExprCXX.h:2995
unsigned getNumInputs() const
Definition: Stmt.h:2790
Expr * getSyntacticForm()
Return the syntactic form of this expression, i.e.
Definition: Expr.h:5759
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:2976
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:2375
CompoundStmt * getBlock() const
Definition: Stmt.h:3269
Smart pointer class that efficiently represents Objective-C method names.
A (possibly-)qualified type.
Definition: Type.h:654
ArrayRef< TemplateArgumentLoc > template_arguments() const
Definition: ExprCXX.h:3267
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
Definition: Expr.h:2919
ArrayRef< OMPClause * > clauses()
Definition: StmtOpenMP.h:325
unsigned SuppressInitializers
Suppress printing of variable initializers.
Expr * getCond() const
Definition: Expr.h:4175
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
Definition: Expr.h:2702
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:2275
Expr * getExpr(unsigned Index)
getExpr - Return the Expr at the specified index.
Definition: Expr.h:4039
unsigned getNumSubExprs() const
getNumSubExprs - Return the size of the SubExprs array.
Definition: Expr.h:4033
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
ArrayRef< ParmVarDecl * > getLocalParameters() const
Definition: ExprConcepts.h:507
VarDecl * getParameterPack() const
Get the parameter pack which this expression refers to.
Definition: ExprCXX.h:4366
CompoundStmt * getSubStmt()
Definition: Expr.h:3970
BinaryOperatorKind Opcode
The original opcode, prior to rewriting.
Definition: ExprCXX.h:298
const Expr * getInit(unsigned Init) const
Definition: Expr.h:4451
Expr * getControllingExpr()
Return the controlling expression of this generic selection expression.
Definition: Expr.h:5417
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:2689
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:3422
CXXCatchStmt * getHandler(unsigned i)
Definition: StmtCXX.h:107
IfStmt - This represents an if/then/else.
Definition: Stmt.h:1834
C Language Family Type Representation.
bool param_empty() const
Definition: Decl.h:4134
unsigned getNumOutputs() const
Definition: Stmt.h:2768
static CharSourceRange getTokenRange(SourceRange R)
This represents &#39;#pragma omp for simd&#39; directive.
Definition: StmtOpenMP.h:1337
bool isRecordType() const
Definition: Type.h:6594
Expr * getBase() const
Definition: Expr.h:2913
const StringLiteral * getAsmString() const
Definition: Stmt.h:2906
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:4171
Expr * getImplicitObjectArgument() const
Retrieve the implicit object argument for the member call.
Definition: ExprCXX.cpp:719
Stmt * getHandlerBlock() const
Definition: StmtCXX.h:51
arg_iterator arg_begin()
Definition: ExprCXX.h:1559
llvm::APFloat getValue() const
Definition: Expr.h:1597
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:5082
param_iterator param_end()
Definition: Decl.h:4136
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:4262
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:3469
StringRef P
This represents &#39;#pragma omp parallel master&#39; directive.
Definition: StmtOpenMP.h:1863
CapturedStmt * getInnermostCapturedStmt()
Get innermost captured statement for the construct.
Definition: StmtOpenMP.h:283
Represents an attribute applied to a statement.
Definition: Stmt.h:1776
ParenExpr - This represents a parethesized expression, e.g.
Definition: Expr.h:1994
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:4310
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:1328
llvm::iterator_range< child_iterator > child_range
Definition: Stmt.h:1180
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:3355
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:3311
A container of type source information.
Definition: Type.h:6227
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:1715
MS property subscript expression.
Definition: ExprCXX.h:937
IdentKind getIdentKind() const
Definition: Expr.h:1951
This represents &#39;#pragma omp target teams distribute parallel for&#39; combined directive.
Definition: StmtOpenMP.h:4379
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:4131
void printExceptionSpecification(raw_ostream &OS, const PrintingPolicy &Policy) const
const Expr * getSubExpr() const
Definition: Expr.h:1674
Expr * getIndexExpr(unsigned Idx)
Definition: Expr.h:2330
This represents &#39;#pragma omp target exit data&#39; directive.
Definition: StmtOpenMP.h:2690
Stmt * getSubStmt()
Definition: Stmt.h:1667
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:3077
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:63
bool isArrow() const
Definition: ExprObjC.h:1520
Expr * getVal1() const
Definition: Expr.h:5891
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:352
Stmt * getThen()
Definition: Stmt.h:1921
unsigned getNumPlacementArgs() const
Definition: ExprCXX.h:2236
Describes how types, statements, expressions, and declarations should be printed. ...
Definition: PrettyPrinter.h:47
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
Represents a parameter to a function.
Definition: Decl.h:1595
Defines the clang::Expr interface and subclasses for C++ expressions.
StringRef getInputName(unsigned i) const
Definition: Stmt.h:2998
unsigned TerseOutput
Provide a &#39;terse&#39; output.
CXXRecordDecl * getLambdaClass() const
Retrieve the class that corresponds to the lambda.
Definition: ExprCXX.cpp:1283
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:1732
Represents a C99 designated initializer expression.
Definition: Expr.h:4639
NamedDecl * getFoundDecl() const
Definition: ASTConcept.h:150
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Definition: Decl.h:272
One of these records is kept for each identifier that is lexed.
Stmt * getBody()
Definition: Stmt.h:2379
Represents a function call to one of __builtin_LINE(), __builtin_COLUMN(), __builtin_FUNCTION(), or __builtin_FILE().
Definition: Expr.h:4295
An element in an Objective-C dictionary literal.
Definition: ExprObjC.h:261
C++2a [expr.prim.req]: A requires-expression provides a concise way to express requirements on templa...
Definition: ExprConcepts.h:470
This represents &#39;#pragma omp parallel&#39; directive.
Definition: StmtOpenMP.h:357
ShuffleVectorExpr - clang-specific builtin-in function __builtin_shufflevector.
Definition: Expr.h:3999
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:2160
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:168
A C++ nested-name-specifier augmented with source location information.
Expr * getInit() const
Retrieve the initializer value.
Definition: Expr.h:4877
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:2729
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:4937
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:1307
unsigned getArrayExprIndex() const
For an array element node, returns the index into the array of expressions.
Definition: Expr.h:2221
bool hasExplicitTemplateArgs() const
Determines whether the member name was followed by an explicit template argument list.
Definition: Expr.h:2980
GNUNullExpr - Implements the GNU __null extension, which is a name for a null pointer constant that h...
Definition: Expr.h:4210
QualType getDestroyedType() const
Retrieve the type being destroyed.
Definition: ExprCXX.cpp:369
This represents &#39;#pragma omp target simd&#39; directive.
Definition: StmtOpenMP.h:3895
Expr * getSourceExpr() const
The source expression of an opaque value expression is the expression which originally generated the ...
Definition: Expr.h:1133
bool isAsmGoto() const
Definition: Stmt.h:3023
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:5518
Expr * getSubExpr()
Definition: Expr.h:3202
This represents &#39;#pragma omp barrier&#39; directive.
Definition: StmtOpenMP.h:2101
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:1640
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:2991
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:2399
bool isUnarySelector() const
Represents Objective-C&#39;s @catch statement.
Definition: StmtObjC.h:77
Expr * getLHS() const
Definition: ExprCXX.h:4557
StringRef getOpcodeStr() const
Definition: Expr.h:3490
IndirectGotoStmt - This represents an indirect goto.
Definition: Stmt.h:2520
Describes an C or C++ initializer list.
Definition: Expr.h:4403
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:3606
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:4748
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:4100
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:2410
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:5881
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:2444
A builtin binary operation expression such as "x + y" or "x <= y".
Definition: Expr.h:3434
Stmt * getInit()
Definition: Stmt.h:2423
Expr * getOutputExpr(unsigned i)
Definition: Stmt.cpp:440
ArrayRef< TemplateArgumentLoc > template_arguments() const
Definition: Expr.h:3008
bool isClassReceiver() const
Definition: ExprObjC.h:777
const StringLiteral * getInputConstraintLiteral(unsigned i) const
Definition: Stmt.h:3007
static bool isPostfix(Opcode Op)
isPostfix - Return true if this is a postfix operation, like x++.
Definition: Expr.h:2093
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:3020
This represents &#39;#pragma omp cancellation point&#39; directive.
Definition: StmtOpenMP.h:2946
ObjCStringLiteral, used for Objective-C string literals i.e.
Definition: ExprObjC.h:50
Expr * getRHS() const
Definition: ExprCXX.h:4558
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:1500
TypoExpr - Internal placeholder for expressions where typo correction still needs to be performed and...
Definition: Expr.h:5978
Expr * getCond()
Definition: Stmt.h:2442
This represents &#39;#pragma omp teams&#39; directive.
Definition: StmtOpenMP.h:2888
NestedNameSpecifier * getQualifier() const
Fetches the nested-name qualifier, if one was given.
Definition: ExprCXX.h:2959
Helper class for OffsetOfExpr.
Definition: Expr.h:2163
Expr * getOperand() const
Definition: ExprCXX.h:4760
This represents &#39;#pragma omp teams distribute simd&#39; combined directive.
Definition: StmtOpenMP.h:4029
AssociationTy< false > Association
Definition: Expr.h:5393
Represents binding an expression to a temporary.
Definition: ExprCXX.h:1373
StringLiteral * getClobberStringLiteral(unsigned i)
Definition: Stmt.h:3087
StringRef getOutputName(unsigned i) const
Definition: Stmt.h:2970
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:5925
bool isInitCapture(const LambdaCapture *Capture) const
Determine whether one of this lambda&#39;s captures is an init-capture.
Definition: ExprCXX.cpp:1240
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:2115
A default argument (C++ [dcl.fct.default]).
Definition: ExprCXX.h:1202
Stmt * getInit()
Definition: Stmt.h:1977
bool isTypeOperand() const
Definition: ExprCXX.h:1029
const IdentifierInfo * getUDSuffix() const
Returns the ud-suffix specified for this literal.
Definition: ExprCXX.cpp:989
Expr * IgnoreImpCasts() LLVM_READONLY
Skip past any implicit casts which might surround this expression until reaching a fixed point...
Definition: Expr.cpp:2975
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:3825
QualType getTypeAsWritten() const
getTypeAsWritten - Returns the type that this expression is casting to, as written in the source code...
Definition: Expr.h:3360
OpenMP 4.0 [2.4, Array Sections].
Definition: ExprOpenMP.h:44
ConditionalOperator - The ?: ternary operator.
Definition: Expr.h:3732
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:1332
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Definition: Type.cpp:1690
Represents a prototype with parameter type info, e.g.
Definition: Type.h:3754
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:2193
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:2947
StringRef getBuiltinStr() const
Return a string representing the name of the specific builtin function.
Definition: Expr.cpp:2176
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand...
Definition: Expr.h:2372
arg_iterator arg_end()
Definition: ExprCXX.h:1560
InitListExpr * getUpdater() const
Definition: Expr.h:4995
ConstantExpr - An expression that occurs in a constant context and optionally the result of evaluatin...
Definition: Expr.h:978
Represents a call to the builtin function __builtin_va_arg.
Definition: Expr.h:4244
void outputString(raw_ostream &OS) const
Definition: Expr.cpp:1106
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:1564
This represents &#39;#pragma omp distribute&#39; directive.
Definition: StmtOpenMP.h:3480
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:5665
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:3769
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Definition: Decl.h:4037
llvm::MutableArrayRef< Designator > designators()
Definition: Expr.h:4842
This represents one expression.
Definition: Expr.h:108
bool isVariadic() const
Whether this function is variadic.
Definition: Decl.cpp:2827
IdentifierInfo * getFieldName() const
For a field or identifier offsetof node, returns the name of the field.
Definition: Expr.cpp:1596
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:1531
This represents &#39;#pragma omp master taskloop&#39; directive.
Definition: StmtOpenMP.h:3204
const T * castAs() const
Member-template castAs<specific type>.
Definition: Type.h:7067
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:5579
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:2663
unsigned getNumInits() const
Definition: Expr.h:4433
Expr * getSubExpr() const
Get the initializer to use for each array element.
Definition: Expr.h:5049
Defines an enumeration for C++ overloaded operators.
This represents &#39;#pragma omp target teams distribute parallel for simd&#39; combined directive.
Definition: StmtOpenMP.h:4463
QualType getArgumentType() const
Definition: Expr.h:2409
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:2287
Expr * getOrder() const
Definition: Expr.h:5884
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:1601
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:2309
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:5642
IdentifierInfo & getAccessor() const
Definition: Expr.h:5540
This represents &#39;#pragma omp target teams distribute simd&#39; combined directive.
Definition: StmtOpenMP.h:4536
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:1928
Kind getKind() const
Determine what kind of offsetof node this is.
Definition: Expr.h:2217
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:1259
LabelDecl * getLabel() const
Definition: Stmt.h:2494
const Stmt * getTryBody() const
Retrieve the @try body.
Definition: StmtObjC.h:208
Represents a folding of a pack over an operator.
Definition: ExprCXX.h:4529
QualType getEncodedType() const
Definition: ExprObjC.h:428
ReturnStmt - This represents a return, optionally of an expression: return; return 4;...
Definition: Stmt.h:2636
This represents &#39;#pragma omp target teams&#39; directive.
Definition: StmtOpenMP.h:4251
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:3101
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:2046
CXXMethodDecl * getMethodDecl() const
Retrieve the declaration of the called method.
Definition: ExprCXX.cpp:738
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:5913
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:2316
unsigned getNumArgs() const
This represents &#39;#pragma omp cancel&#39; directive.
Definition: StmtOpenMP.h:3005
Expr * getCond()
Definition: Stmt.h:1909
ValueDecl * getDecl()
Definition: Expr.h:1247
Selector getSelector() const
Definition: DeclObjC.h:322
const Expr * getSubExpr() const
Definition: Expr.h:2010
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:3371
CXXMethodDecl * getCallOperator() const
Retrieve the function call operator associated with this lambda expression.
Definition: ExprCXX.cpp:1287
bool isNull() const
Return true if this QualType doesn&#39;t point to a type yet.
Definition: Type.h:719
Expr * getLHS()
An array access can be written A[4] or 4[A] (both are equivalent).
Definition: Expr.h:2497
bool getValue() const
Definition: ExprCXX.h:657
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Definition: ASTConcept.h:158
This file defines OpenMP AST classes for clauses.
ImaginaryLiteral - We support imaginary integer and floating point literals, like "1...
Definition: Expr.h:1662
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
Definition: ExprObjC.h:1395
This represents &#39;#pragma omp flush&#39; directive.
Definition: StmtOpenMP.h:2267
ArrayRef< concepts::Requirement * > getRequirements() const
Definition: ExprConcepts.h:513
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:1796
DoStmt - This represents a &#39;do/while&#39; stmt.
Definition: Stmt.h:2354
StringRef getBridgeKindName() const
Retrieve the kind of bridge being performed as a string.
Definition: ExprObjC.cpp:385
param_iterator param_begin()
Definition: Decl.h:4135
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:3340
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:960
This represents &#39;#pragma omp target enter data&#39; directive.
Definition: StmtOpenMP.h:2631
This represents &#39;#pragma omp master taskloop simd&#39; directive.
Definition: StmtOpenMP.h:3272
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:1075
Expr * getBase() const
Definition: Expr.h:4992
ConvertVectorExpr - Clang builtin function __builtin_convertvector This AST node provides support for...
Definition: Expr.h:4067
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:649
Kind
This captures a statement into a function.
Definition: Stmt.h:3376
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:5715
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:5169
This represents &#39;#pragma omp single&#39; directive.
Definition: StmtOpenMP.h:1535
unsigned Indentation
The number of spaces to use to indent each line.
Definition: PrettyPrinter.h:76
const Expr * LHS
The original left-hand side.
Definition: ExprCXX.h:300
body_range body()
Definition: Stmt.h:1365
capture_iterator explicit_capture_begin() const
Retrieve an iterator pointing to the first explicit lambda capture.
Definition: ExprCXX.cpp:1257
Expr * getRetValue()
Definition: Stmt.h:2669
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:463
unsigned getNumHandlers() const
Definition: StmtCXX.h:106
Expr * getSubExpr() const
Definition: Expr.h:2076
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:1589
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:4812
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:1930
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:1225
DeclarationNameInfo getDirectiveName() const
Return name of the directive.
Definition: StmtOpenMP.h:1699
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:1931
std::string getValueAsString(unsigned Radix) const
Definition: Expr.cpp:958
Expr * getCond()
Definition: Stmt.h:2103
StmtVisitor - This class implements a simple visitor for Stmt subclasses.
Definition: StmtVisitor.h:183
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:2147
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:5849
UnaryExprOrTypeTrait getKind() const
Definition: Expr.h:2403
ArrayRef< NamedDecl * > getExplicitTemplateParameters() const
Get the template parameters were explicitly specified (as opposed to being invented by use of an auto...
Definition: ExprCXX.cpp:1302
Expr * getExpr(unsigned Init)
Definition: Expr.h:5171
ObjCProtocolExpr used for protocol expression in Objective-C.
Definition: ExprObjC.h:503
const StringLiteral * getOutputConstraintLiteral(unsigned i) const
Definition: Stmt.h:2979
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
Definition: Expr.h:3274
Stmt * getCapturedStmt()
Retrieve the statement being captured.
Definition: Stmt.h:3477
bool hasTemplateKeyword() const
Determines whether the member name was preceded by the template keyword.
Definition: ExprCXX.h:3688
CharacterKind getKind() const
Definition: Expr.h:1557
This represents &#39;#pragma omp target&#39; directive.
Definition: StmtOpenMP.h:2514
Expr * getInputExpr(unsigned i)
Definition: Stmt.cpp:451
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:4418
Expr * getSubExpr()
Definition: ExprObjC.h:142
An expression trait intrinsic.
Definition: ExprCXX.h:2785
A static requirement that can be used in a requires-expression to check properties of types and expre...
Definition: ExprConcepts.h:145
DeclStmt * getConditionVariableDeclStmt()
If this WhileStmt has a condition variable, return the faux DeclStmt associated with the creation of ...
Definition: Stmt.h:2315
This represents &#39;#pragma omp ordered&#39; directive.
Definition: StmtOpenMP.h:2323
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
Definition: Expr.h:3954
This represents &#39;#pragma omp target update&#39; directive.
Definition: StmtOpenMP.h:3547
ObjCBoxedExpr - used for generalized expression boxing.
Definition: ExprObjC.h:124
bool isArgumentType() const
Definition: Expr.h:2408
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
This represents &#39;#pragma omp parallel master taskloop simd&#39; directive.
Definition: StmtOpenMP.h:3411
Representation of a Microsoft __if_exists or __if_not_exists statement with a dependent name...
Definition: StmtCXX.h:252
bool hasTemplateKeyword() const
Determines whether the name in this declaration reference was preceded by the template keyword...
Definition: Expr.h:1324
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:3103
InitializationStyle getInitializationStyle() const
The kind of initializer this new-expression has.
Definition: ExprCXX.h:2267
Expr * getLHS() const
Definition: Expr.h:3474
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:3654
Represents a C11 generic selection.
Definition: Expr.h:5234
StringRef getName() const
Return the actual identifier string.
const Expr * getBase() const
Definition: Expr.h:5536
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:3910
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:3867
NullStmt - This is the null statement ";": C99 6.8.3p3.
Definition: Stmt.h:1297
bool isMutable() const
Determine whether the lambda is mutable, meaning that any captures values can be modified.
Definition: ExprCXX.cpp:1318
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:2755
[C99 6.4.2.2] - A predefined identifier such as func.
Definition: Expr.h:1903
DeclarationNameInfo getMemberNameInfo() const
Retrieve the member declaration name info.
Definition: Expr.h:3013
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:1812
Parameter for Objective-C &#39;self&#39; argument.
Definition: Decl.h:1540
This represents &#39;#pragma omp section&#39; directive.
Definition: StmtOpenMP.h:1472
This represents &#39;#pragma omp teams distribute&#39; directive.
Definition: StmtOpenMP.h:3961
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:1194
Represents a &#39;co_yield&#39; expression.
Definition: ExprCXX.h:4786
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:1142
const NestedNameSpecifierLoc & getNestedNameSpecifierLoc() const
Definition: ASTConcept.h:138
const Expr * getSynchExpr() const
Definition: StmtObjC.h:305
void printName(raw_ostream &OS, PrintingPolicy Policy) const
printName - Print the human-readable name to a stream.
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:1297
Expr * getPlacementArg(unsigned I)
Definition: ExprCXX.h:2245
This represents &#39;#pragma omp atomic&#39; directive.
Definition: StmtOpenMP.h:2379
DeclStmt * getConditionVariableDeclStmt()
If this IfStmt has a condition variable, return the faux DeclStmt associated with the creation of tha...
Definition: Stmt.h:1965
TypeSourceInfo * getTypeOperandSourceInfo() const
Retrieve source information for the type operand.
Definition: ExprCXX.h:811
Expr * getArrayRangeEnd(const Designator &D) const
Definition: Expr.cpp:4424
llvm::APInt getValue() const
Definition: Expr.h:1430
Represents a __leave statement.
Definition: Stmt.h:3337
LabelDecl * getLabel() const
Definition: Expr.h:3932
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:2043
Capturing variable-length array type.
Definition: Lambda.h:38
Expr * getOrderFail() const
Definition: Expr.h:5897
DeclarationNameInfo getNameInfo() const
Definition: Expr.h:1251
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:2462
This file defines OpenMP AST classes for executable directives and clauses.
bool hasBraces() const
Definition: Stmt.h:3129
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:2175
Represents a call to a CUDA kernel function.
Definition: ExprCXX.h:224
Represents a &#39;co_await&#39; expression.
Definition: ExprCXX.h:4699
Stmt * getInit()
Definition: Stmt.h:2124
Opcode getOpcode() const
Definition: Expr.h:2071
Expr * getArg(unsigned Arg)
Return the specified argument.
Definition: ExprCXX.h:1573
decl_range decls()
Definition: Stmt.h:1273
Represents Objective-C&#39;s @finally statement.
Definition: StmtObjC.h:127
StringRef getAsmString() const
Definition: Stmt.h:3135
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
unsigned getNumClobbers() const
Definition: Stmt.h:2800
ObjCIvarRefExpr - A reference to an ObjC instance variable.
Definition: ExprObjC.h:546
SourceManager & getSourceManager()
Definition: ASTContext.h:679
Expr * getRHS() const
Definition: Expr.h:4179
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:1146
GotoStmt - This represents a direct goto.
Definition: Stmt.h:2481
A use of a default initializer in a constructor or in aggregate initialization.
Definition: ExprCXX.h:1279
Expr * getTarget()
Definition: Stmt.h:2540
A template argument list.
Definition: DeclTemplate.h:239
Expr * getSrcExpr() const
getSrcExpr - Return the Expr to be converted.
Definition: Expr.h:4091
ArrayRef< TemplateArgumentLoc > template_arguments() const
Definition: Expr.h:1354
CapturedDecl * getCapturedDecl()
Retrieve the outlined function declaration.
Definition: Stmt.cpp:1298
Expr * getCond()
Definition: Stmt.h:2372
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:2836
Defines the clang::SourceLocation class and associated facilities.
This represents &#39;#pragma omp target parallel&#39; directive.
Definition: StmtOpenMP.h:2748
ContinueStmt - This represents a continue.
Definition: Stmt.h:2569
Represents a loop initializing the elements of an array.
Definition: Expr.h:5027
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
Definition: Expr.h:4130
Expr * getFilterExpr() const
Definition: Stmt.h:3228
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
Definition: Expr.h:3808
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:2168
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:4720
Expr * getRHS() const
Definition: Expr.h:3781
WhileStmt - This represents a &#39;while&#39; stmt.
Definition: Stmt.h:2226
Capturing by reference.
Definition: Lambda.h:37
Represents the specialization of a concept - evaluates to a prvalue of type bool. ...
Definition: ExprConcepts.h:40
SourceLocation getLParenLoc() const
Definition: ExprCXX.h:1719
This class is used for builtin types like &#39;int&#39;.
Definition: Type.h:2465
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
SourceLocation getTemplateKWLoc() const
Definition: ASTConcept.h:148
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
Definition: Stmt.cpp:263
bool isGlobalDelete() const
Definition: ExprCXX.h:2385
This represents &#39;#pragma omp taskloop simd&#39; directive.
Definition: StmtOpenMP.h:3137
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:1711
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:2546
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:250
Expr * getLHS() const
Definition: Expr.h:4177
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:947
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:1403
ObjCBoolLiteralExpr - Objective-C Boolean Literal.
Definition: ExprObjC.h:85
bool isObjectReceiver() const
Definition: ExprObjC.h:775
unsigned getNumComponents() const
Definition: Expr.h:2326
This represents &#39;#pragma omp target data&#39; directive.
Definition: StmtOpenMP.h:2573
OpenMPDirectiveKind getCancelRegion() const
Get cancellation region for the current cancellation point.
Definition: StmtOpenMP.h:3055
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:1171
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:3476
unsigned IncludeNewlines
When true, include newlines after statements like "break", etc.
BreakStmt - This represents a break.
Definition: Stmt.h:2599
const VarDecl * getCatchParamDecl() const
Definition: StmtObjC.h:97
static bool isImplicitSelf(const Expr *E)
unsigned getNumLabels() const
Definition: Stmt.h:3027
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:764
Expr * getOperand() const
Definition: ExprCXX.h:4799
Stmt * getSubStmt()
Definition: Stmt.h:1753
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:630
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:1294
This represents &#39;#pragma omp taskyield&#39; directive.
Definition: StmtOpenMP.h:2055
This represents &#39;#pragma omp distribute parallel for simd&#39; composite directive.
Definition: StmtOpenMP.h:3688
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:1274
OffsetOfExpr - [C99 7.17] - This represents an expression of the form offsetof(record-type, member-designator).
Definition: Expr.h:2267
Expr * getQueriedExpression() const
Definition: ExprCXX.h:2824
This represents &#39;#pragma omp parallel sections&#39; directive.
Definition: StmtOpenMP.h:1914
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:3848
The receiver is a superclass.
Definition: ExprObjC.h:1104
Expr * getSubExpr() const
Retrieve the temporary-generating subexpression whose value will be materialized into a glvalue...
Definition: ExprCXX.h:4436
BinaryOperatorKind getOperator() const
Definition: ExprCXX.h:4575
const LangOptions & getLangOpts() const
Definition: ASTContext.h:724
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:3313
Stmt * getSubStmt()
Definition: Stmt.h:1816
InitListExpr * getSyntacticForm() const
Definition: Expr.h:4562
Expr * getBaseExpr() const
Definition: ExprCXX.h:919
Represents an implicitly-generated value initialization of an object of a given type.
Definition: Expr.h:5117
CompoundStmt * getBlock() const
Definition: Stmt.h:3232
Expr * getWeak() const
Definition: Expr.h:5907
This represents &#39;#pragma omp target parallel for&#39; directive.
Definition: StmtOpenMP.h:2808
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: Type.h:6238
TypeTrait getTrait() const
Determine which type trait this expression uses.
Definition: ExprCXX.h:2666
association_range associations()
Definition: Expr.h:5463
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:981
Expr * getBase()
An array section can be written only as Base[LowerBound:Length].
Definition: ExprOpenMP.h:81
Stmt * getSubStmt()
Definition: Stmt.h:1619
This represents &#39;#pragma omp taskloop&#39; directive.
Definition: StmtOpenMP.h:3071