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