clang  15.0.0git
StmtPrinter.cpp
Go to the documentation of this file.
1 //===- StmtPrinter.cpp - Printing implementation for Stmt ASTs ------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements the Stmt::dumpPretty/Stmt::printPretty methods, which
10 // pretty print the AST back out to C code.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "clang/AST/ASTContext.h"
15 #include "clang/AST/Attr.h"
16 #include "clang/AST/Decl.h"
17 #include "clang/AST/DeclBase.h"
18 #include "clang/AST/DeclCXX.h"
19 #include "clang/AST/DeclObjC.h"
20 #include "clang/AST/DeclOpenMP.h"
21 #include "clang/AST/DeclTemplate.h"
22 #include "clang/AST/Expr.h"
23 #include "clang/AST/ExprCXX.h"
24 #include "clang/AST/ExprObjC.h"
25 #include "clang/AST/ExprOpenMP.h"
27 #include "clang/AST/OpenMPClause.h"
29 #include "clang/AST/Stmt.h"
30 #include "clang/AST/StmtCXX.h"
31 #include "clang/AST/StmtObjC.h"
32 #include "clang/AST/StmtOpenMP.h"
33 #include "clang/AST/StmtVisitor.h"
34 #include "clang/AST/TemplateBase.h"
35 #include "clang/AST/Type.h"
36 #include "clang/Basic/CharInfo.h"
40 #include "clang/Basic/LLVM.h"
41 #include "clang/Basic/Lambda.h"
45 #include "clang/Basic/TypeTraits.h"
46 #include "clang/Lex/Lexer.h"
47 #include "llvm/ADT/ArrayRef.h"
48 #include "llvm/ADT/SmallString.h"
49 #include "llvm/ADT/SmallVector.h"
50 #include "llvm/ADT/StringExtras.h"
51 #include "llvm/ADT/StringRef.h"
52 #include "llvm/Support/Casting.h"
53 #include "llvm/Support/Compiler.h"
54 #include "llvm/Support/ErrorHandling.h"
55 #include "llvm/Support/raw_ostream.h"
56 #include <cassert>
57 #include <string>
58 
59 using namespace clang;
60 
61 //===----------------------------------------------------------------------===//
62 // StmtPrinter Visitor
63 //===----------------------------------------------------------------------===//
64 
65 namespace {
66 
67  class StmtPrinter : public StmtVisitor<StmtPrinter> {
68  raw_ostream &OS;
69  unsigned IndentLevel;
70  PrinterHelper* Helper;
71  PrintingPolicy Policy;
72  std::string NL;
73  const ASTContext *Context;
74 
75  public:
76  StmtPrinter(raw_ostream &os, PrinterHelper *helper,
77  const PrintingPolicy &Policy, unsigned Indentation = 0,
78  StringRef NL = "\n", const ASTContext *Context = nullptr)
79  : OS(os), IndentLevel(Indentation), Helper(helper), Policy(Policy),
80  NL(NL), Context(Context) {}
81 
82  void PrintStmt(Stmt *S) { PrintStmt(S, Policy.Indentation); }
83 
84  void PrintStmt(Stmt *S, int SubIndent) {
85  IndentLevel += SubIndent;
86  if (S && isa<Expr>(S)) {
87  // If this is an expr used in a stmt context, indent and newline it.
88  Indent();
89  Visit(S);
90  OS << ";" << NL;
91  } else if (S) {
92  Visit(S);
93  } else {
94  Indent() << "<<<NULL STATEMENT>>>" << NL;
95  }
96  IndentLevel -= SubIndent;
97  }
98 
99  void PrintInitStmt(Stmt *S, unsigned PrefixWidth) {
100  // FIXME: Cope better with odd prefix widths.
101  IndentLevel += (PrefixWidth + 1) / 2;
102  if (auto *DS = dyn_cast<DeclStmt>(S))
103  PrintRawDeclStmt(DS);
104  else
105  PrintExpr(cast<Expr>(S));
106  OS << "; ";
107  IndentLevel -= (PrefixWidth + 1) / 2;
108  }
109 
110  void PrintControlledStmt(Stmt *S) {
111  if (auto *CS = dyn_cast<CompoundStmt>(S)) {
112  OS << " ";
113  PrintRawCompoundStmt(CS);
114  OS << NL;
115  } else {
116  OS << NL;
117  PrintStmt(S);
118  }
119  }
120 
121  void PrintRawCompoundStmt(CompoundStmt *S);
122  void PrintRawDecl(Decl *D);
123  void PrintRawDeclStmt(const DeclStmt *S);
124  void PrintRawIfStmt(IfStmt *If);
125  void PrintRawCXXCatchStmt(CXXCatchStmt *Catch);
126  void PrintCallArgs(CallExpr *E);
127  void PrintRawSEHExceptHandler(SEHExceptStmt *S);
128  void PrintRawSEHFinallyStmt(SEHFinallyStmt *S);
129  void PrintOMPExecutableDirective(OMPExecutableDirective *S,
130  bool ForceNoStmt = false);
131 
132  void PrintExpr(Expr *E) {
133  if (E)
134  Visit(E);
135  else
136  OS << "<null expr>";
137  }
138 
139  raw_ostream &Indent(int Delta = 0) {
140  for (int i = 0, e = IndentLevel+Delta; i < e; ++i)
141  OS << " ";
142  return OS;
143  }
144 
145  void Visit(Stmt* S) {
146  if (Helper && Helper->handledStmt(S,OS))
147  return;
149  }
150 
151  void VisitStmt(Stmt *Node) LLVM_ATTRIBUTE_UNUSED {
152  Indent() << "<<unknown stmt type>>" << NL;
153  }
154 
155  void VisitExpr(Expr *Node) LLVM_ATTRIBUTE_UNUSED {
156  OS << "<<unknown expr type>>";
157  }
158 
159  void VisitCXXNamedCastExpr(CXXNamedCastExpr *Node);
160 
161 #define ABSTRACT_STMT(CLASS)
162 #define STMT(CLASS, PARENT) \
163  void Visit##CLASS(CLASS *Node);
164 #include "clang/AST/StmtNodes.inc"
165  };
166 
167 } // namespace
168 
169 //===----------------------------------------------------------------------===//
170 // Stmt printing methods.
171 //===----------------------------------------------------------------------===//
172 
173 /// PrintRawCompoundStmt - Print a compound stmt without indenting the {, and
174 /// with no newline after the }.
175 void StmtPrinter::PrintRawCompoundStmt(CompoundStmt *Node) {
176  OS << "{" << NL;
177  for (auto *I : Node->body())
178  PrintStmt(I);
179 
180  Indent() << "}";
181 }
182 
183 void StmtPrinter::PrintRawDecl(Decl *D) {
184  D->print(OS, Policy, IndentLevel);
185 }
186 
187 void StmtPrinter::PrintRawDeclStmt(const DeclStmt *S) {
188  SmallVector<Decl *, 2> Decls(S->decls());
189  Decl::printGroup(Decls.data(), Decls.size(), OS, Policy, IndentLevel);
190 }
191 
192 void StmtPrinter::VisitNullStmt(NullStmt *Node) {
193  Indent() << ";" << NL;
194 }
195 
196 void StmtPrinter::VisitDeclStmt(DeclStmt *Node) {
197  Indent();
198  PrintRawDeclStmt(Node);
199  OS << ";" << NL;
200 }
201 
202 void StmtPrinter::VisitCompoundStmt(CompoundStmt *Node) {
203  Indent();
204  PrintRawCompoundStmt(Node);
205  OS << "" << NL;
206 }
207 
208 void StmtPrinter::VisitCaseStmt(CaseStmt *Node) {
209  Indent(-1) << "case ";
210  PrintExpr(Node->getLHS());
211  if (Node->getRHS()) {
212  OS << " ... ";
213  PrintExpr(Node->getRHS());
214  }
215  OS << ":" << NL;
216 
217  PrintStmt(Node->getSubStmt(), 0);
218 }
219 
220 void StmtPrinter::VisitDefaultStmt(DefaultStmt *Node) {
221  Indent(-1) << "default:" << NL;
222  PrintStmt(Node->getSubStmt(), 0);
223 }
224 
225 void StmtPrinter::VisitLabelStmt(LabelStmt *Node) {
226  Indent(-1) << Node->getName() << ":" << NL;
227  PrintStmt(Node->getSubStmt(), 0);
228 }
229 
230 void StmtPrinter::VisitAttributedStmt(AttributedStmt *Node) {
231  for (const auto *Attr : Node->getAttrs()) {
232  Attr->printPretty(OS, Policy);
233  }
234 
235  PrintStmt(Node->getSubStmt(), 0);
236 }
237 
238 void StmtPrinter::PrintRawIfStmt(IfStmt *If) {
239  if (If->isConsteval()) {
240  OS << "if ";
241  if (If->isNegatedConsteval())
242  OS << "!";
243  OS << "consteval";
244  OS << NL;
245  PrintStmt(If->getThen());
246  if (Stmt *Else = If->getElse()) {
247  Indent();
248  OS << "else";
249  PrintStmt(Else);
250  OS << NL;
251  }
252  return;
253  }
254 
255  OS << "if (";
256  if (If->getInit())
257  PrintInitStmt(If->getInit(), 4);
258  if (const DeclStmt *DS = If->getConditionVariableDeclStmt())
259  PrintRawDeclStmt(DS);
260  else
261  PrintExpr(If->getCond());
262  OS << ')';
263 
264  if (auto *CS = dyn_cast<CompoundStmt>(If->getThen())) {
265  OS << ' ';
266  PrintRawCompoundStmt(CS);
267  OS << (If->getElse() ? " " : NL);
268  } else {
269  OS << NL;
270  PrintStmt(If->getThen());
271  if (If->getElse()) Indent();
272  }
273 
274  if (Stmt *Else = If->getElse()) {
275  OS << "else";
276 
277  if (auto *CS = dyn_cast<CompoundStmt>(Else)) {
278  OS << ' ';
279  PrintRawCompoundStmt(CS);
280  OS << NL;
281  } else if (auto *ElseIf = dyn_cast<IfStmt>(Else)) {
282  OS << ' ';
283  PrintRawIfStmt(ElseIf);
284  } else {
285  OS << NL;
286  PrintStmt(If->getElse());
287  }
288  }
289 }
290 
291 void StmtPrinter::VisitIfStmt(IfStmt *If) {
292  Indent();
293  PrintRawIfStmt(If);
294 }
295 
296 void StmtPrinter::VisitSwitchStmt(SwitchStmt *Node) {
297  Indent() << "switch (";
298  if (Node->getInit())
299  PrintInitStmt(Node->getInit(), 8);
300  if (const DeclStmt *DS = Node->getConditionVariableDeclStmt())
301  PrintRawDeclStmt(DS);
302  else
303  PrintExpr(Node->getCond());
304  OS << ")";
305  PrintControlledStmt(Node->getBody());
306 }
307 
308 void StmtPrinter::VisitWhileStmt(WhileStmt *Node) {
309  Indent() << "while (";
310  if (const DeclStmt *DS = Node->getConditionVariableDeclStmt())
311  PrintRawDeclStmt(DS);
312  else
313  PrintExpr(Node->getCond());
314  OS << ")" << NL;
315  PrintStmt(Node->getBody());
316 }
317 
318 void StmtPrinter::VisitDoStmt(DoStmt *Node) {
319  Indent() << "do ";
320  if (auto *CS = dyn_cast<CompoundStmt>(Node->getBody())) {
321  PrintRawCompoundStmt(CS);
322  OS << " ";
323  } else {
324  OS << NL;
325  PrintStmt(Node->getBody());
326  Indent();
327  }
328 
329  OS << "while (";
330  PrintExpr(Node->getCond());
331  OS << ");" << NL;
332 }
333 
334 void StmtPrinter::VisitForStmt(ForStmt *Node) {
335  Indent() << "for (";
336  if (Node->getInit())
337  PrintInitStmt(Node->getInit(), 5);
338  else
339  OS << (Node->getCond() ? "; " : ";");
340  if (Node->getCond())
341  PrintExpr(Node->getCond());
342  OS << ";";
343  if (Node->getInc()) {
344  OS << " ";
345  PrintExpr(Node->getInc());
346  }
347  OS << ")";
348  PrintControlledStmt(Node->getBody());
349 }
350 
351 void StmtPrinter::VisitObjCForCollectionStmt(ObjCForCollectionStmt *Node) {
352  Indent() << "for (";
353  if (auto *DS = dyn_cast<DeclStmt>(Node->getElement()))
354  PrintRawDeclStmt(DS);
355  else
356  PrintExpr(cast<Expr>(Node->getElement()));
357  OS << " in ";
358  PrintExpr(Node->getCollection());
359  OS << ")";
360  PrintControlledStmt(Node->getBody());
361 }
362 
363 void StmtPrinter::VisitCXXForRangeStmt(CXXForRangeStmt *Node) {
364  Indent() << "for (";
365  if (Node->getInit())
366  PrintInitStmt(Node->getInit(), 5);
367  PrintingPolicy SubPolicy(Policy);
368  SubPolicy.SuppressInitializers = true;
369  Node->getLoopVariable()->print(OS, SubPolicy, IndentLevel);
370  OS << " : ";
371  PrintExpr(Node->getRangeInit());
372  OS << ")";
373  PrintControlledStmt(Node->getBody());
374 }
375 
376 void StmtPrinter::VisitMSDependentExistsStmt(MSDependentExistsStmt *Node) {
377  Indent();
378  if (Node->isIfExists())
379  OS << "__if_exists (";
380  else
381  OS << "__if_not_exists (";
382 
383  if (NestedNameSpecifier *Qualifier
384  = Node->getQualifierLoc().getNestedNameSpecifier())
385  Qualifier->print(OS, Policy);
386 
387  OS << Node->getNameInfo() << ") ";
388 
389  PrintRawCompoundStmt(Node->getSubStmt());
390 }
391 
392 void StmtPrinter::VisitGotoStmt(GotoStmt *Node) {
393  Indent() << "goto " << Node->getLabel()->getName() << ";";
394  if (Policy.IncludeNewlines) OS << NL;
395 }
396 
397 void StmtPrinter::VisitIndirectGotoStmt(IndirectGotoStmt *Node) {
398  Indent() << "goto *";
399  PrintExpr(Node->getTarget());
400  OS << ";";
401  if (Policy.IncludeNewlines) OS << NL;
402 }
403 
404 void StmtPrinter::VisitContinueStmt(ContinueStmt *Node) {
405  Indent() << "continue;";
406  if (Policy.IncludeNewlines) OS << NL;
407 }
408 
409 void StmtPrinter::VisitBreakStmt(BreakStmt *Node) {
410  Indent() << "break;";
411  if (Policy.IncludeNewlines) OS << NL;
412 }
413 
414 void StmtPrinter::VisitReturnStmt(ReturnStmt *Node) {
415  Indent() << "return";
416  if (Node->getRetValue()) {
417  OS << " ";
418  PrintExpr(Node->getRetValue());
419  }
420  OS << ";";
421  if (Policy.IncludeNewlines) OS << NL;
422 }
423 
424 void StmtPrinter::VisitGCCAsmStmt(GCCAsmStmt *Node) {
425  Indent() << "asm ";
426 
427  if (Node->isVolatile())
428  OS << "volatile ";
429 
430  if (Node->isAsmGoto())
431  OS << "goto ";
432 
433  OS << "(";
434  VisitStringLiteral(Node->getAsmString());
435 
436  // Outputs
437  if (Node->getNumOutputs() != 0 || Node->getNumInputs() != 0 ||
438  Node->getNumClobbers() != 0 || Node->getNumLabels() != 0)
439  OS << " : ";
440 
441  for (unsigned i = 0, e = Node->getNumOutputs(); i != e; ++i) {
442  if (i != 0)
443  OS << ", ";
444 
445  if (!Node->getOutputName(i).empty()) {
446  OS << '[';
447  OS << Node->getOutputName(i);
448  OS << "] ";
449  }
450 
451  VisitStringLiteral(Node->getOutputConstraintLiteral(i));
452  OS << " (";
453  Visit(Node->getOutputExpr(i));
454  OS << ")";
455  }
456 
457  // Inputs
458  if (Node->getNumInputs() != 0 || Node->getNumClobbers() != 0 ||
459  Node->getNumLabels() != 0)
460  OS << " : ";
461 
462  for (unsigned i = 0, e = Node->getNumInputs(); i != e; ++i) {
463  if (i != 0)
464  OS << ", ";
465 
466  if (!Node->getInputName(i).empty()) {
467  OS << '[';
468  OS << Node->getInputName(i);
469  OS << "] ";
470  }
471 
472  VisitStringLiteral(Node->getInputConstraintLiteral(i));
473  OS << " (";
474  Visit(Node->getInputExpr(i));
475  OS << ")";
476  }
477 
478  // Clobbers
479  if (Node->getNumClobbers() != 0 || Node->getNumLabels())
480  OS << " : ";
481 
482  for (unsigned i = 0, e = Node->getNumClobbers(); i != e; ++i) {
483  if (i != 0)
484  OS << ", ";
485 
486  VisitStringLiteral(Node->getClobberStringLiteral(i));
487  }
488 
489  // Labels
490  if (Node->getNumLabels() != 0)
491  OS << " : ";
492 
493  for (unsigned i = 0, e = Node->getNumLabels(); i != e; ++i) {
494  if (i != 0)
495  OS << ", ";
496  OS << Node->getLabelName(i);
497  }
498 
499  OS << ");";
500  if (Policy.IncludeNewlines) OS << NL;
501 }
502 
503 void StmtPrinter::VisitMSAsmStmt(MSAsmStmt *Node) {
504  // FIXME: Implement MS style inline asm statement printer.
505  Indent() << "__asm ";
506  if (Node->hasBraces())
507  OS << "{" << NL;
508  OS << Node->getAsmString() << NL;
509  if (Node->hasBraces())
510  Indent() << "}" << NL;
511 }
512 
513 void StmtPrinter::VisitCapturedStmt(CapturedStmt *Node) {
514  PrintStmt(Node->getCapturedDecl()->getBody());
515 }
516 
517 void StmtPrinter::VisitObjCAtTryStmt(ObjCAtTryStmt *Node) {
518  Indent() << "@try";
519  if (auto *TS = dyn_cast<CompoundStmt>(Node->getTryBody())) {
520  PrintRawCompoundStmt(TS);
521  OS << NL;
522  }
523 
524  for (ObjCAtCatchStmt *catchStmt : Node->catch_stmts()) {
525  Indent() << "@catch(";
526  if (Decl *DS = catchStmt->getCatchParamDecl())
527  PrintRawDecl(DS);
528  OS << ")";
529  if (auto *CS = dyn_cast<CompoundStmt>(catchStmt->getCatchBody())) {
530  PrintRawCompoundStmt(CS);
531  OS << NL;
532  }
533  }
534 
535  if (auto *FS = static_cast<ObjCAtFinallyStmt *>(Node->getFinallyStmt())) {
536  Indent() << "@finally";
537  PrintRawCompoundStmt(dyn_cast<CompoundStmt>(FS->getFinallyBody()));
538  OS << NL;
539  }
540 }
541 
542 void StmtPrinter::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *Node) {
543 }
544 
545 void StmtPrinter::VisitObjCAtCatchStmt (ObjCAtCatchStmt *Node) {
546  Indent() << "@catch (...) { /* todo */ } " << NL;
547 }
548 
549 void StmtPrinter::VisitObjCAtThrowStmt(ObjCAtThrowStmt *Node) {
550  Indent() << "@throw";
551  if (Node->getThrowExpr()) {
552  OS << " ";
553  PrintExpr(Node->getThrowExpr());
554  }
555  OS << ";" << NL;
556 }
557 
558 void StmtPrinter::VisitObjCAvailabilityCheckExpr(
560  OS << "@available(...)";
561 }
562 
563 void StmtPrinter::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *Node) {
564  Indent() << "@synchronized (";
565  PrintExpr(Node->getSynchExpr());
566  OS << ")";
567  PrintRawCompoundStmt(Node->getSynchBody());
568  OS << NL;
569 }
570 
571 void StmtPrinter::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *Node) {
572  Indent() << "@autoreleasepool";
573  PrintRawCompoundStmt(dyn_cast<CompoundStmt>(Node->getSubStmt()));
574  OS << NL;
575 }
576 
577 void StmtPrinter::PrintRawCXXCatchStmt(CXXCatchStmt *Node) {
578  OS << "catch (";
579  if (Decl *ExDecl = Node->getExceptionDecl())
580  PrintRawDecl(ExDecl);
581  else
582  OS << "...";
583  OS << ") ";
584  PrintRawCompoundStmt(cast<CompoundStmt>(Node->getHandlerBlock()));
585 }
586 
587 void StmtPrinter::VisitCXXCatchStmt(CXXCatchStmt *Node) {
588  Indent();
589  PrintRawCXXCatchStmt(Node);
590  OS << NL;
591 }
592 
593 void StmtPrinter::VisitCXXTryStmt(CXXTryStmt *Node) {
594  Indent() << "try ";
595  PrintRawCompoundStmt(Node->getTryBlock());
596  for (unsigned i = 0, e = Node->getNumHandlers(); i < e; ++i) {
597  OS << " ";
598  PrintRawCXXCatchStmt(Node->getHandler(i));
599  }
600  OS << NL;
601 }
602 
603 void StmtPrinter::VisitSEHTryStmt(SEHTryStmt *Node) {
604  Indent() << (Node->getIsCXXTry() ? "try " : "__try ");
605  PrintRawCompoundStmt(Node->getTryBlock());
606  SEHExceptStmt *E = Node->getExceptHandler();
607  SEHFinallyStmt *F = Node->getFinallyHandler();
608  if(E)
609  PrintRawSEHExceptHandler(E);
610  else {
611  assert(F && "Must have a finally block...");
612  PrintRawSEHFinallyStmt(F);
613  }
614  OS << NL;
615 }
616 
617 void StmtPrinter::PrintRawSEHFinallyStmt(SEHFinallyStmt *Node) {
618  OS << "__finally ";
619  PrintRawCompoundStmt(Node->getBlock());
620  OS << NL;
621 }
622 
623 void StmtPrinter::PrintRawSEHExceptHandler(SEHExceptStmt *Node) {
624  OS << "__except (";
625  VisitExpr(Node->getFilterExpr());
626  OS << ")" << NL;
627  PrintRawCompoundStmt(Node->getBlock());
628  OS << NL;
629 }
630 
631 void StmtPrinter::VisitSEHExceptStmt(SEHExceptStmt *Node) {
632  Indent();
633  PrintRawSEHExceptHandler(Node);
634  OS << NL;
635 }
636 
637 void StmtPrinter::VisitSEHFinallyStmt(SEHFinallyStmt *Node) {
638  Indent();
639  PrintRawSEHFinallyStmt(Node);
640  OS << NL;
641 }
642 
643 void StmtPrinter::VisitSEHLeaveStmt(SEHLeaveStmt *Node) {
644  Indent() << "__leave;";
645  if (Policy.IncludeNewlines) OS << NL;
646 }
647 
648 //===----------------------------------------------------------------------===//
649 // OpenMP directives printing methods
650 //===----------------------------------------------------------------------===//
651 
652 void StmtPrinter::VisitOMPCanonicalLoop(OMPCanonicalLoop *Node) {
653  PrintStmt(Node->getLoopStmt());
654 }
655 
656 void StmtPrinter::PrintOMPExecutableDirective(OMPExecutableDirective *S,
657  bool ForceNoStmt) {
658  OMPClausePrinter Printer(OS, Policy);
659  ArrayRef<OMPClause *> Clauses = S->clauses();
660  for (auto *Clause : Clauses)
661  if (Clause && !Clause->isImplicit()) {
662  OS << ' ';
663  Printer.Visit(Clause);
664  }
665  OS << NL;
666  if (!ForceNoStmt && S->hasAssociatedStmt())
667  PrintStmt(S->getRawStmt());
668 }
669 
670 void StmtPrinter::VisitOMPMetaDirective(OMPMetaDirective *Node) {
671  Indent() << "#pragma omp metadirective";
672  PrintOMPExecutableDirective(Node);
673 }
674 
675 void StmtPrinter::VisitOMPParallelDirective(OMPParallelDirective *Node) {
676  Indent() << "#pragma omp parallel";
677  PrintOMPExecutableDirective(Node);
678 }
679 
680 void StmtPrinter::VisitOMPSimdDirective(OMPSimdDirective *Node) {
681  Indent() << "#pragma omp simd";
682  PrintOMPExecutableDirective(Node);
683 }
684 
685 void StmtPrinter::VisitOMPTileDirective(OMPTileDirective *Node) {
686  Indent() << "#pragma omp tile";
687  PrintOMPExecutableDirective(Node);
688 }
689 
690 void StmtPrinter::VisitOMPUnrollDirective(OMPUnrollDirective *Node) {
691  Indent() << "#pragma omp unroll";
692  PrintOMPExecutableDirective(Node);
693 }
694 
695 void StmtPrinter::VisitOMPForDirective(OMPForDirective *Node) {
696  Indent() << "#pragma omp for";
697  PrintOMPExecutableDirective(Node);
698 }
699 
700 void StmtPrinter::VisitOMPForSimdDirective(OMPForSimdDirective *Node) {
701  Indent() << "#pragma omp for simd";
702  PrintOMPExecutableDirective(Node);
703 }
704 
705 void StmtPrinter::VisitOMPSectionsDirective(OMPSectionsDirective *Node) {
706  Indent() << "#pragma omp sections";
707  PrintOMPExecutableDirective(Node);
708 }
709 
710 void StmtPrinter::VisitOMPSectionDirective(OMPSectionDirective *Node) {
711  Indent() << "#pragma omp section";
712  PrintOMPExecutableDirective(Node);
713 }
714 
715 void StmtPrinter::VisitOMPSingleDirective(OMPSingleDirective *Node) {
716  Indent() << "#pragma omp single";
717  PrintOMPExecutableDirective(Node);
718 }
719 
720 void StmtPrinter::VisitOMPMasterDirective(OMPMasterDirective *Node) {
721  Indent() << "#pragma omp master";
722  PrintOMPExecutableDirective(Node);
723 }
724 
725 void StmtPrinter::VisitOMPCriticalDirective(OMPCriticalDirective *Node) {
726  Indent() << "#pragma omp critical";
727  if (Node->getDirectiveName().getName()) {
728  OS << " (";
729  Node->getDirectiveName().printName(OS, Policy);
730  OS << ")";
731  }
732  PrintOMPExecutableDirective(Node);
733 }
734 
735 void StmtPrinter::VisitOMPParallelForDirective(OMPParallelForDirective *Node) {
736  Indent() << "#pragma omp parallel for";
737  PrintOMPExecutableDirective(Node);
738 }
739 
740 void StmtPrinter::VisitOMPParallelForSimdDirective(
742  Indent() << "#pragma omp parallel for simd";
743  PrintOMPExecutableDirective(Node);
744 }
745 
746 void StmtPrinter::VisitOMPParallelMasterDirective(
748  Indent() << "#pragma omp parallel master";
749  PrintOMPExecutableDirective(Node);
750 }
751 
752 void StmtPrinter::VisitOMPParallelSectionsDirective(
754  Indent() << "#pragma omp parallel sections";
755  PrintOMPExecutableDirective(Node);
756 }
757 
758 void StmtPrinter::VisitOMPTaskDirective(OMPTaskDirective *Node) {
759  Indent() << "#pragma omp task";
760  PrintOMPExecutableDirective(Node);
761 }
762 
763 void StmtPrinter::VisitOMPTaskyieldDirective(OMPTaskyieldDirective *Node) {
764  Indent() << "#pragma omp taskyield";
765  PrintOMPExecutableDirective(Node);
766 }
767 
768 void StmtPrinter::VisitOMPBarrierDirective(OMPBarrierDirective *Node) {
769  Indent() << "#pragma omp barrier";
770  PrintOMPExecutableDirective(Node);
771 }
772 
773 void StmtPrinter::VisitOMPTaskwaitDirective(OMPTaskwaitDirective *Node) {
774  Indent() << "#pragma omp taskwait";
775  PrintOMPExecutableDirective(Node);
776 }
777 
778 void StmtPrinter::VisitOMPTaskgroupDirective(OMPTaskgroupDirective *Node) {
779  Indent() << "#pragma omp taskgroup";
780  PrintOMPExecutableDirective(Node);
781 }
782 
783 void StmtPrinter::VisitOMPFlushDirective(OMPFlushDirective *Node) {
784  Indent() << "#pragma omp flush";
785  PrintOMPExecutableDirective(Node);
786 }
787 
788 void StmtPrinter::VisitOMPDepobjDirective(OMPDepobjDirective *Node) {
789  Indent() << "#pragma omp depobj";
790  PrintOMPExecutableDirective(Node);
791 }
792 
793 void StmtPrinter::VisitOMPScanDirective(OMPScanDirective *Node) {
794  Indent() << "#pragma omp scan";
795  PrintOMPExecutableDirective(Node);
796 }
797 
798 void StmtPrinter::VisitOMPOrderedDirective(OMPOrderedDirective *Node) {
799  Indent() << "#pragma omp ordered";
800  PrintOMPExecutableDirective(Node, Node->hasClausesOfKind<OMPDependClause>());
801 }
802 
803 void StmtPrinter::VisitOMPAtomicDirective(OMPAtomicDirective *Node) {
804  Indent() << "#pragma omp atomic";
805  PrintOMPExecutableDirective(Node);
806 }
807 
808 void StmtPrinter::VisitOMPTargetDirective(OMPTargetDirective *Node) {
809  Indent() << "#pragma omp target";
810  PrintOMPExecutableDirective(Node);
811 }
812 
813 void StmtPrinter::VisitOMPTargetDataDirective(OMPTargetDataDirective *Node) {
814  Indent() << "#pragma omp target data";
815  PrintOMPExecutableDirective(Node);
816 }
817 
818 void StmtPrinter::VisitOMPTargetEnterDataDirective(
820  Indent() << "#pragma omp target enter data";
821  PrintOMPExecutableDirective(Node, /*ForceNoStmt=*/true);
822 }
823 
824 void StmtPrinter::VisitOMPTargetExitDataDirective(
826  Indent() << "#pragma omp target exit data";
827  PrintOMPExecutableDirective(Node, /*ForceNoStmt=*/true);
828 }
829 
830 void StmtPrinter::VisitOMPTargetParallelDirective(
832  Indent() << "#pragma omp target parallel";
833  PrintOMPExecutableDirective(Node);
834 }
835 
836 void StmtPrinter::VisitOMPTargetParallelForDirective(
838  Indent() << "#pragma omp target parallel for";
839  PrintOMPExecutableDirective(Node);
840 }
841 
842 void StmtPrinter::VisitOMPTeamsDirective(OMPTeamsDirective *Node) {
843  Indent() << "#pragma omp teams";
844  PrintOMPExecutableDirective(Node);
845 }
846 
847 void StmtPrinter::VisitOMPCancellationPointDirective(
849  Indent() << "#pragma omp cancellation point "
850  << getOpenMPDirectiveName(Node->getCancelRegion());
851  PrintOMPExecutableDirective(Node);
852 }
853 
854 void StmtPrinter::VisitOMPCancelDirective(OMPCancelDirective *Node) {
855  Indent() << "#pragma omp cancel "
856  << getOpenMPDirectiveName(Node->getCancelRegion());
857  PrintOMPExecutableDirective(Node);
858 }
859 
860 void StmtPrinter::VisitOMPTaskLoopDirective(OMPTaskLoopDirective *Node) {
861  Indent() << "#pragma omp taskloop";
862  PrintOMPExecutableDirective(Node);
863 }
864 
865 void StmtPrinter::VisitOMPTaskLoopSimdDirective(
867  Indent() << "#pragma omp taskloop simd";
868  PrintOMPExecutableDirective(Node);
869 }
870 
871 void StmtPrinter::VisitOMPMasterTaskLoopDirective(
873  Indent() << "#pragma omp master taskloop";
874  PrintOMPExecutableDirective(Node);
875 }
876 
877 void StmtPrinter::VisitOMPMasterTaskLoopSimdDirective(
879  Indent() << "#pragma omp master taskloop simd";
880  PrintOMPExecutableDirective(Node);
881 }
882 
883 void StmtPrinter::VisitOMPParallelMasterTaskLoopDirective(
885  Indent() << "#pragma omp parallel master taskloop";
886  PrintOMPExecutableDirective(Node);
887 }
888 
889 void StmtPrinter::VisitOMPParallelMasterTaskLoopSimdDirective(
891  Indent() << "#pragma omp parallel master taskloop simd";
892  PrintOMPExecutableDirective(Node);
893 }
894 
895 void StmtPrinter::VisitOMPDistributeDirective(OMPDistributeDirective *Node) {
896  Indent() << "#pragma omp distribute";
897  PrintOMPExecutableDirective(Node);
898 }
899 
900 void StmtPrinter::VisitOMPTargetUpdateDirective(
902  Indent() << "#pragma omp target update";
903  PrintOMPExecutableDirective(Node, /*ForceNoStmt=*/true);
904 }
905 
906 void StmtPrinter::VisitOMPDistributeParallelForDirective(
908  Indent() << "#pragma omp distribute parallel for";
909  PrintOMPExecutableDirective(Node);
910 }
911 
912 void StmtPrinter::VisitOMPDistributeParallelForSimdDirective(
914  Indent() << "#pragma omp distribute parallel for simd";
915  PrintOMPExecutableDirective(Node);
916 }
917 
918 void StmtPrinter::VisitOMPDistributeSimdDirective(
920  Indent() << "#pragma omp distribute simd";
921  PrintOMPExecutableDirective(Node);
922 }
923 
924 void StmtPrinter::VisitOMPTargetParallelForSimdDirective(
926  Indent() << "#pragma omp target parallel for simd";
927  PrintOMPExecutableDirective(Node);
928 }
929 
930 void StmtPrinter::VisitOMPTargetSimdDirective(OMPTargetSimdDirective *Node) {
931  Indent() << "#pragma omp target simd";
932  PrintOMPExecutableDirective(Node);
933 }
934 
935 void StmtPrinter::VisitOMPTeamsDistributeDirective(
937  Indent() << "#pragma omp teams distribute";
938  PrintOMPExecutableDirective(Node);
939 }
940 
941 void StmtPrinter::VisitOMPTeamsDistributeSimdDirective(
943  Indent() << "#pragma omp teams distribute simd";
944  PrintOMPExecutableDirective(Node);
945 }
946 
947 void StmtPrinter::VisitOMPTeamsDistributeParallelForSimdDirective(
949  Indent() << "#pragma omp teams distribute parallel for simd";
950  PrintOMPExecutableDirective(Node);
951 }
952 
953 void StmtPrinter::VisitOMPTeamsDistributeParallelForDirective(
955  Indent() << "#pragma omp teams distribute parallel for";
956  PrintOMPExecutableDirective(Node);
957 }
958 
959 void StmtPrinter::VisitOMPTargetTeamsDirective(OMPTargetTeamsDirective *Node) {
960  Indent() << "#pragma omp target teams";
961  PrintOMPExecutableDirective(Node);
962 }
963 
964 void StmtPrinter::VisitOMPTargetTeamsDistributeDirective(
966  Indent() << "#pragma omp target teams distribute";
967  PrintOMPExecutableDirective(Node);
968 }
969 
970 void StmtPrinter::VisitOMPTargetTeamsDistributeParallelForDirective(
972  Indent() << "#pragma omp target teams distribute parallel for";
973  PrintOMPExecutableDirective(Node);
974 }
975 
976 void StmtPrinter::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
978  Indent() << "#pragma omp target teams distribute parallel for simd";
979  PrintOMPExecutableDirective(Node);
980 }
981 
982 void StmtPrinter::VisitOMPTargetTeamsDistributeSimdDirective(
984  Indent() << "#pragma omp target teams distribute simd";
985  PrintOMPExecutableDirective(Node);
986 }
987 
988 void StmtPrinter::VisitOMPInteropDirective(OMPInteropDirective *Node) {
989  Indent() << "#pragma omp interop";
990  PrintOMPExecutableDirective(Node);
991 }
992 
993 void StmtPrinter::VisitOMPDispatchDirective(OMPDispatchDirective *Node) {
994  Indent() << "#pragma omp dispatch";
995  PrintOMPExecutableDirective(Node);
996 }
997 
998 void StmtPrinter::VisitOMPMaskedDirective(OMPMaskedDirective *Node) {
999  Indent() << "#pragma omp masked";
1000  PrintOMPExecutableDirective(Node);
1001 }
1002 
1003 void StmtPrinter::VisitOMPGenericLoopDirective(OMPGenericLoopDirective *Node) {
1004  Indent() << "#pragma omp loop";
1005  PrintOMPExecutableDirective(Node);
1006 }
1007 
1008 void StmtPrinter::VisitOMPTeamsGenericLoopDirective(
1010  Indent() << "#pragma omp teams loop";
1011  PrintOMPExecutableDirective(Node);
1012 }
1013 
1014 void StmtPrinter::VisitOMPTargetTeamsGenericLoopDirective(
1016  Indent() << "#pragma omp target teams loop";
1017  PrintOMPExecutableDirective(Node);
1018 }
1019 
1020 void StmtPrinter::VisitOMPParallelGenericLoopDirective(
1022  Indent() << "#pragma omp parallel loop";
1023  PrintOMPExecutableDirective(Node);
1024 }
1025 
1026 void StmtPrinter::VisitOMPTargetParallelGenericLoopDirective(
1028  Indent() << "#pragma omp target parallel loop";
1029  PrintOMPExecutableDirective(Node);
1030 }
1031 
1032 //===----------------------------------------------------------------------===//
1033 // Expr printing methods.
1034 //===----------------------------------------------------------------------===//
1035 
1036 void StmtPrinter::VisitSourceLocExpr(SourceLocExpr *Node) {
1037  OS << Node->getBuiltinStr() << "()";
1038 }
1039 
1040 void StmtPrinter::VisitConstantExpr(ConstantExpr *Node) {
1041  PrintExpr(Node->getSubExpr());
1042 }
1043 
1044 void StmtPrinter::VisitDeclRefExpr(DeclRefExpr *Node) {
1045  if (const auto *OCED = dyn_cast<OMPCapturedExprDecl>(Node->getDecl())) {
1046  OCED->getInit()->IgnoreImpCasts()->printPretty(OS, nullptr, Policy);
1047  return;
1048  }
1049  if (const auto *TPOD = dyn_cast<TemplateParamObjectDecl>(Node->getDecl())) {
1050  TPOD->printAsExpr(OS, Policy);
1051  return;
1052  }
1053  if (NestedNameSpecifier *Qualifier = Node->getQualifier())
1054  Qualifier->print(OS, Policy);
1055  if (Node->hasTemplateKeyword())
1056  OS << "template ";
1057  if (Policy.CleanUglifiedParameters &&
1058  isa<ParmVarDecl, NonTypeTemplateParmDecl>(Node->getDecl()) &&
1059  Node->getDecl()->getIdentifier())
1060  OS << Node->getDecl()->getIdentifier()->deuglifiedName();
1061  else
1062  Node->getNameInfo().printName(OS, Policy);
1063  if (Node->hasExplicitTemplateArgs()) {
1064  const TemplateParameterList *TPL = nullptr;
1065  if (!Node->hadMultipleCandidates())
1066  if (auto *TD = dyn_cast<TemplateDecl>(Node->getDecl()))
1067  TPL = TD->getTemplateParameters();
1068  printTemplateArgumentList(OS, Node->template_arguments(), Policy, TPL);
1069  }
1070 }
1071 
1072 void StmtPrinter::VisitDependentScopeDeclRefExpr(
1074  if (NestedNameSpecifier *Qualifier = Node->getQualifier())
1075  Qualifier->print(OS, Policy);
1076  if (Node->hasTemplateKeyword())
1077  OS << "template ";
1078  OS << Node->getNameInfo();
1079  if (Node->hasExplicitTemplateArgs())
1080  printTemplateArgumentList(OS, Node->template_arguments(), Policy);
1081 }
1082 
1083 void StmtPrinter::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *Node) {
1084  if (Node->getQualifier())
1085  Node->getQualifier()->print(OS, Policy);
1086  if (Node->hasTemplateKeyword())
1087  OS << "template ";
1088  OS << Node->getNameInfo();
1089  if (Node->hasExplicitTemplateArgs())
1090  printTemplateArgumentList(OS, Node->template_arguments(), Policy);
1091 }
1092 
1093 static bool isImplicitSelf(const Expr *E) {
1094  if (const auto *DRE = dyn_cast<DeclRefExpr>(E)) {
1095  if (const auto *PD = dyn_cast<ImplicitParamDecl>(DRE->getDecl())) {
1096  if (PD->getParameterKind() == ImplicitParamDecl::ObjCSelf &&
1097  DRE->getBeginLoc().isInvalid())
1098  return true;
1099  }
1100  }
1101  return false;
1102 }
1103 
1104 void StmtPrinter::VisitObjCIvarRefExpr(ObjCIvarRefExpr *Node) {
1105  if (Node->getBase()) {
1106  if (!Policy.SuppressImplicitBase ||
1107  !isImplicitSelf(Node->getBase()->IgnoreImpCasts())) {
1108  PrintExpr(Node->getBase());
1109  OS << (Node->isArrow() ? "->" : ".");
1110  }
1111  }
1112  OS << *Node->getDecl();
1113 }
1114 
1115 void StmtPrinter::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *Node) {
1116  if (Node->isSuperReceiver())
1117  OS << "super.";
1118  else if (Node->isObjectReceiver() && Node->getBase()) {
1119  PrintExpr(Node->getBase());
1120  OS << ".";
1121  } else if (Node->isClassReceiver() && Node->getClassReceiver()) {
1122  OS << Node->getClassReceiver()->getName() << ".";
1123  }
1124 
1125  if (Node->isImplicitProperty()) {
1126  if (const auto *Getter = Node->getImplicitPropertyGetter())
1127  Getter->getSelector().print(OS);
1128  else
1130  Node->getImplicitPropertySetter()->getSelector());
1131  } else
1132  OS << Node->getExplicitProperty()->getName();
1133 }
1134 
1135 void StmtPrinter::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *Node) {
1136  PrintExpr(Node->getBaseExpr());
1137  OS << "[";
1138  PrintExpr(Node->getKeyExpr());
1139  OS << "]";
1140 }
1141 
1142 void StmtPrinter::VisitSYCLUniqueStableNameExpr(
1144  OS << "__builtin_sycl_unique_stable_name(";
1145  Node->getTypeSourceInfo()->getType().print(OS, Policy);
1146  OS << ")";
1147 }
1148 
1149 void StmtPrinter::VisitPredefinedExpr(PredefinedExpr *Node) {
1150  OS << PredefinedExpr::getIdentKindName(Node->getIdentKind());
1151 }
1152 
1153 void StmtPrinter::VisitCharacterLiteral(CharacterLiteral *Node) {
1154  CharacterLiteral::print(Node->getValue(), Node->getKind(), OS);
1155 }
1156 
1157 /// Prints the given expression using the original source text. Returns true on
1158 /// success, false otherwise.
1159 static bool printExprAsWritten(raw_ostream &OS, Expr *E,
1160  const ASTContext *Context) {
1161  if (!Context)
1162  return false;
1163  bool Invalid = false;
1164  StringRef Source = Lexer::getSourceText(
1166  Context->getSourceManager(), Context->getLangOpts(), &Invalid);
1167  if (!Invalid) {
1168  OS << Source;
1169  return true;
1170  }
1171  return false;
1172 }
1173 
1174 void StmtPrinter::VisitIntegerLiteral(IntegerLiteral *Node) {
1175  if (Policy.ConstantsAsWritten && printExprAsWritten(OS, Node, Context))
1176  return;
1177  bool isSigned = Node->getType()->isSignedIntegerType();
1178  OS << toString(Node->getValue(), 10, isSigned);
1179 
1180  if (isa<BitIntType>(Node->getType())) {
1181  OS << (isSigned ? "wb" : "uwb");
1182  return;
1183  }
1184 
1185  // Emit suffixes. Integer literals are always a builtin integer type.
1186  switch (Node->getType()->castAs<BuiltinType>()->getKind()) {
1187  default: llvm_unreachable("Unexpected type for integer literal!");
1188  case BuiltinType::Char_S:
1189  case BuiltinType::Char_U: OS << "i8"; break;
1190  case BuiltinType::UChar: OS << "Ui8"; break;
1191  case BuiltinType::Short: OS << "i16"; break;
1192  case BuiltinType::UShort: OS << "Ui16"; break;
1193  case BuiltinType::Int: break; // no suffix.
1194  case BuiltinType::UInt: OS << 'U'; break;
1195  case BuiltinType::Long: OS << 'L'; break;
1196  case BuiltinType::ULong: OS << "UL"; break;
1197  case BuiltinType::LongLong: OS << "LL"; break;
1198  case BuiltinType::ULongLong: OS << "ULL"; break;
1199  case BuiltinType::Int128:
1200  break; // no suffix.
1201  case BuiltinType::UInt128:
1202  break; // no suffix.
1203  }
1204 }
1205 
1206 void StmtPrinter::VisitFixedPointLiteral(FixedPointLiteral *Node) {
1207  if (Policy.ConstantsAsWritten && printExprAsWritten(OS, Node, Context))
1208  return;
1209  OS << Node->getValueAsString(/*Radix=*/10);
1210 
1211  switch (Node->getType()->castAs<BuiltinType>()->getKind()) {
1212  default: llvm_unreachable("Unexpected type for fixed point literal!");
1213  case BuiltinType::ShortFract: OS << "hr"; break;
1214  case BuiltinType::ShortAccum: OS << "hk"; break;
1215  case BuiltinType::UShortFract: OS << "uhr"; break;
1216  case BuiltinType::UShortAccum: OS << "uhk"; break;
1217  case BuiltinType::Fract: OS << "r"; break;
1218  case BuiltinType::Accum: OS << "k"; break;
1219  case BuiltinType::UFract: OS << "ur"; break;
1220  case BuiltinType::UAccum: OS << "uk"; break;
1221  case BuiltinType::LongFract: OS << "lr"; break;
1222  case BuiltinType::LongAccum: OS << "lk"; break;
1223  case BuiltinType::ULongFract: OS << "ulr"; break;
1224  case BuiltinType::ULongAccum: OS << "ulk"; break;
1225  }
1226 }
1227 
1228 static void PrintFloatingLiteral(raw_ostream &OS, FloatingLiteral *Node,
1229  bool PrintSuffix) {
1230  SmallString<16> Str;
1231  Node->getValue().toString(Str);
1232  OS << Str;
1233  if (Str.find_first_not_of("-0123456789") == StringRef::npos)
1234  OS << '.'; // Trailing dot in order to separate from ints.
1235 
1236  if (!PrintSuffix)
1237  return;
1238 
1239  // Emit suffixes. Float literals are always a builtin float type.
1240  switch (Node->getType()->castAs<BuiltinType>()->getKind()) {
1241  default: llvm_unreachable("Unexpected type for float literal!");
1242  case BuiltinType::Half: break; // FIXME: suffix?
1243  case BuiltinType::Ibm128: break; // FIXME: No suffix for ibm128 literal
1244  case BuiltinType::Double: break; // no suffix.
1245  case BuiltinType::Float16: OS << "F16"; break;
1246  case BuiltinType::Float: OS << 'F'; break;
1247  case BuiltinType::LongDouble: OS << 'L'; break;
1248  case BuiltinType::Float128: OS << 'Q'; break;
1249  }
1250 }
1251 
1252 void StmtPrinter::VisitFloatingLiteral(FloatingLiteral *Node) {
1253  if (Policy.ConstantsAsWritten && printExprAsWritten(OS, Node, Context))
1254  return;
1255  PrintFloatingLiteral(OS, Node, /*PrintSuffix=*/true);
1256 }
1257 
1258 void StmtPrinter::VisitImaginaryLiteral(ImaginaryLiteral *Node) {
1259  PrintExpr(Node->getSubExpr());
1260  OS << "i";
1261 }
1262 
1263 void StmtPrinter::VisitStringLiteral(StringLiteral *Str) {
1264  Str->outputString(OS);
1265 }
1266 
1267 void StmtPrinter::VisitParenExpr(ParenExpr *Node) {
1268  OS << "(";
1269  PrintExpr(Node->getSubExpr());
1270  OS << ")";
1271 }
1272 
1273 void StmtPrinter::VisitUnaryOperator(UnaryOperator *Node) {
1274  if (!Node->isPostfix()) {
1275  OS << UnaryOperator::getOpcodeStr(Node->getOpcode());
1276 
1277  // Print a space if this is an "identifier operator" like __real, or if
1278  // it might be concatenated incorrectly like '+'.
1279  switch (Node->getOpcode()) {
1280  default: break;
1281  case UO_Real:
1282  case UO_Imag:
1283  case UO_Extension:
1284  OS << ' ';
1285  break;
1286  case UO_Plus:
1287  case UO_Minus:
1288  if (isa<UnaryOperator>(Node->getSubExpr()))
1289  OS << ' ';
1290  break;
1291  }
1292  }
1293  PrintExpr(Node->getSubExpr());
1294 
1295  if (Node->isPostfix())
1296  OS << UnaryOperator::getOpcodeStr(Node->getOpcode());
1297 }
1298 
1299 void StmtPrinter::VisitOffsetOfExpr(OffsetOfExpr *Node) {
1300  OS << "__builtin_offsetof(";
1301  Node->getTypeSourceInfo()->getType().print(OS, Policy);
1302  OS << ", ";
1303  bool PrintedSomething = false;
1304  for (unsigned i = 0, n = Node->getNumComponents(); i < n; ++i) {
1305  OffsetOfNode ON = Node->getComponent(i);
1306  if (ON.getKind() == OffsetOfNode::Array) {
1307  // Array node
1308  OS << "[";
1309  PrintExpr(Node->getIndexExpr(ON.getArrayExprIndex()));
1310  OS << "]";
1311  PrintedSomething = true;
1312  continue;
1313  }
1314 
1315  // Skip implicit base indirections.
1316  if (ON.getKind() == OffsetOfNode::Base)
1317  continue;
1318 
1319  // Field or identifier node.
1320  IdentifierInfo *Id = ON.getFieldName();
1321  if (!Id)
1322  continue;
1323 
1324  if (PrintedSomething)
1325  OS << ".";
1326  else
1327  PrintedSomething = true;
1328  OS << Id->getName();
1329  }
1330  OS << ")";
1331 }
1332 
1333 void StmtPrinter::VisitUnaryExprOrTypeTraitExpr(
1335  const char *Spelling = getTraitSpelling(Node->getKind());
1336  if (Node->getKind() == UETT_AlignOf) {
1337  if (Policy.Alignof)
1338  Spelling = "alignof";
1339  else if (Policy.UnderscoreAlignof)
1340  Spelling = "_Alignof";
1341  else
1342  Spelling = "__alignof";
1343  }
1344 
1345  OS << Spelling;
1346 
1347  if (Node->isArgumentType()) {
1348  OS << '(';
1349  Node->getArgumentType().print(OS, Policy);
1350  OS << ')';
1351  } else {
1352  OS << " ";
1353  PrintExpr(Node->getArgumentExpr());
1354  }
1355 }
1356 
1357 void StmtPrinter::VisitGenericSelectionExpr(GenericSelectionExpr *Node) {
1358  OS << "_Generic(";
1359  PrintExpr(Node->getControllingExpr());
1360  for (const GenericSelectionExpr::Association Assoc : Node->associations()) {
1361  OS << ", ";
1362  QualType T = Assoc.getType();
1363  if (T.isNull())
1364  OS << "default";
1365  else
1366  T.print(OS, Policy);
1367  OS << ": ";
1368  PrintExpr(Assoc.getAssociationExpr());
1369  }
1370  OS << ")";
1371 }
1372 
1373 void StmtPrinter::VisitArraySubscriptExpr(ArraySubscriptExpr *Node) {
1374  PrintExpr(Node->getLHS());
1375  OS << "[";
1376  PrintExpr(Node->getRHS());
1377  OS << "]";
1378 }
1379 
1380 void StmtPrinter::VisitMatrixSubscriptExpr(MatrixSubscriptExpr *Node) {
1381  PrintExpr(Node->getBase());
1382  OS << "[";
1383  PrintExpr(Node->getRowIdx());
1384  OS << "]";
1385  OS << "[";
1386  PrintExpr(Node->getColumnIdx());
1387  OS << "]";
1388 }
1389 
1390 void StmtPrinter::VisitOMPArraySectionExpr(OMPArraySectionExpr *Node) {
1391  PrintExpr(Node->getBase());
1392  OS << "[";
1393  if (Node->getLowerBound())
1394  PrintExpr(Node->getLowerBound());
1395  if (Node->getColonLocFirst().isValid()) {
1396  OS << ":";
1397  if (Node->getLength())
1398  PrintExpr(Node->getLength());
1399  }
1400  if (Node->getColonLocSecond().isValid()) {
1401  OS << ":";
1402  if (Node->getStride())
1403  PrintExpr(Node->getStride());
1404  }
1405  OS << "]";
1406 }
1407 
1408 void StmtPrinter::VisitOMPArrayShapingExpr(OMPArrayShapingExpr *Node) {
1409  OS << "(";
1410  for (Expr *E : Node->getDimensions()) {
1411  OS << "[";
1412  PrintExpr(E);
1413  OS << "]";
1414  }
1415  OS << ")";
1416  PrintExpr(Node->getBase());
1417 }
1418 
1419 void StmtPrinter::VisitOMPIteratorExpr(OMPIteratorExpr *Node) {
1420  OS << "iterator(";
1421  for (unsigned I = 0, E = Node->numOfIterators(); I < E; ++I) {
1422  auto *VD = cast<ValueDecl>(Node->getIteratorDecl(I));
1423  VD->getType().print(OS, Policy);
1424  const OMPIteratorExpr::IteratorRange Range = Node->getIteratorRange(I);
1425  OS << " " << VD->getName() << " = ";
1426  PrintExpr(Range.Begin);
1427  OS << ":";
1428  PrintExpr(Range.End);
1429  if (Range.Step) {
1430  OS << ":";
1431  PrintExpr(Range.Step);
1432  }
1433  if (I < E - 1)
1434  OS << ", ";
1435  }
1436  OS << ")";
1437 }
1438 
1439 void StmtPrinter::PrintCallArgs(CallExpr *Call) {
1440  for (unsigned i = 0, e = Call->getNumArgs(); i != e; ++i) {
1441  if (isa<CXXDefaultArgExpr>(Call->getArg(i))) {
1442  // Don't print any defaulted arguments
1443  break;
1444  }
1445 
1446  if (i) OS << ", ";
1447  PrintExpr(Call->getArg(i));
1448  }
1449 }
1450 
1451 void StmtPrinter::VisitCallExpr(CallExpr *Call) {
1452  PrintExpr(Call->getCallee());
1453  OS << "(";
1454  PrintCallArgs(Call);
1455  OS << ")";
1456 }
1457 
1458 static bool isImplicitThis(const Expr *E) {
1459  if (const auto *TE = dyn_cast<CXXThisExpr>(E))
1460  return TE->isImplicit();
1461  return false;
1462 }
1463 
1464 void StmtPrinter::VisitMemberExpr(MemberExpr *Node) {
1465  if (!Policy.SuppressImplicitBase || !isImplicitThis(Node->getBase())) {
1466  PrintExpr(Node->getBase());
1467 
1468  auto *ParentMember = dyn_cast<MemberExpr>(Node->getBase());
1469  FieldDecl *ParentDecl =
1470  ParentMember ? dyn_cast<FieldDecl>(ParentMember->getMemberDecl())
1471  : nullptr;
1472 
1473  if (!ParentDecl || !ParentDecl->isAnonymousStructOrUnion())
1474  OS << (Node->isArrow() ? "->" : ".");
1475  }
1476 
1477  if (auto *FD = dyn_cast<FieldDecl>(Node->getMemberDecl()))
1478  if (FD->isAnonymousStructOrUnion())
1479  return;
1480 
1481  if (NestedNameSpecifier *Qualifier = Node->getQualifier())
1482  Qualifier->print(OS, Policy);
1483  if (Node->hasTemplateKeyword())
1484  OS << "template ";
1485  OS << Node->getMemberNameInfo();
1486  const TemplateParameterList *TPL = nullptr;
1487  if (auto *FD = dyn_cast<FunctionDecl>(Node->getMemberDecl())) {
1488  if (!Node->hadMultipleCandidates())
1489  if (auto *FTD = FD->getPrimaryTemplate())
1490  TPL = FTD->getTemplateParameters();
1491  } else if (auto *VTSD =
1492  dyn_cast<VarTemplateSpecializationDecl>(Node->getMemberDecl()))
1493  TPL = VTSD->getSpecializedTemplate()->getTemplateParameters();
1494  if (Node->hasExplicitTemplateArgs())
1495  printTemplateArgumentList(OS, Node->template_arguments(), Policy, TPL);
1496 }
1497 
1498 void StmtPrinter::VisitObjCIsaExpr(ObjCIsaExpr *Node) {
1499  PrintExpr(Node->getBase());
1500  OS << (Node->isArrow() ? "->isa" : ".isa");
1501 }
1502 
1503 void StmtPrinter::VisitExtVectorElementExpr(ExtVectorElementExpr *Node) {
1504  PrintExpr(Node->getBase());
1505  OS << ".";
1506  OS << Node->getAccessor().getName();
1507 }
1508 
1509 void StmtPrinter::VisitCStyleCastExpr(CStyleCastExpr *Node) {
1510  OS << '(';
1511  Node->getTypeAsWritten().print(OS, Policy);
1512  OS << ')';
1513  PrintExpr(Node->getSubExpr());
1514 }
1515 
1516 void StmtPrinter::VisitCompoundLiteralExpr(CompoundLiteralExpr *Node) {
1517  OS << '(';
1518  Node->getType().print(OS, Policy);
1519  OS << ')';
1520  PrintExpr(Node->getInitializer());
1521 }
1522 
1523 void StmtPrinter::VisitImplicitCastExpr(ImplicitCastExpr *Node) {
1524  // No need to print anything, simply forward to the subexpression.
1525  PrintExpr(Node->getSubExpr());
1526 }
1527 
1528 void StmtPrinter::VisitBinaryOperator(BinaryOperator *Node) {
1529  PrintExpr(Node->getLHS());
1530  OS << " " << BinaryOperator::getOpcodeStr(Node->getOpcode()) << " ";
1531  PrintExpr(Node->getRHS());
1532 }
1533 
1534 void StmtPrinter::VisitCompoundAssignOperator(CompoundAssignOperator *Node) {
1535  PrintExpr(Node->getLHS());
1536  OS << " " << BinaryOperator::getOpcodeStr(Node->getOpcode()) << " ";
1537  PrintExpr(Node->getRHS());
1538 }
1539 
1540 void StmtPrinter::VisitConditionalOperator(ConditionalOperator *Node) {
1541  PrintExpr(Node->getCond());
1542  OS << " ? ";
1543  PrintExpr(Node->getLHS());
1544  OS << " : ";
1545  PrintExpr(Node->getRHS());
1546 }
1547 
1548 // GNU extensions.
1549 
1550 void
1551 StmtPrinter::VisitBinaryConditionalOperator(BinaryConditionalOperator *Node) {
1552  PrintExpr(Node->getCommon());
1553  OS << " ?: ";
1554  PrintExpr(Node->getFalseExpr());
1555 }
1556 
1557 void StmtPrinter::VisitAddrLabelExpr(AddrLabelExpr *Node) {
1558  OS << "&&" << Node->getLabel()->getName();
1559 }
1560 
1561 void StmtPrinter::VisitStmtExpr(StmtExpr *E) {
1562  OS << "(";
1563  PrintRawCompoundStmt(E->getSubStmt());
1564  OS << ")";
1565 }
1566 
1567 void StmtPrinter::VisitChooseExpr(ChooseExpr *Node) {
1568  OS << "__builtin_choose_expr(";
1569  PrintExpr(Node->getCond());
1570  OS << ", ";
1571  PrintExpr(Node->getLHS());
1572  OS << ", ";
1573  PrintExpr(Node->getRHS());
1574  OS << ")";
1575 }
1576 
1577 void StmtPrinter::VisitGNUNullExpr(GNUNullExpr *) {
1578  OS << "__null";
1579 }
1580 
1581 void StmtPrinter::VisitShuffleVectorExpr(ShuffleVectorExpr *Node) {
1582  OS << "__builtin_shufflevector(";
1583  for (unsigned i = 0, e = Node->getNumSubExprs(); i != e; ++i) {
1584  if (i) OS << ", ";
1585  PrintExpr(Node->getExpr(i));
1586  }
1587  OS << ")";
1588 }
1589 
1590 void StmtPrinter::VisitConvertVectorExpr(ConvertVectorExpr *Node) {
1591  OS << "__builtin_convertvector(";
1592  PrintExpr(Node->getSrcExpr());
1593  OS << ", ";
1594  Node->getType().print(OS, Policy);
1595  OS << ")";
1596 }
1597 
1598 void StmtPrinter::VisitInitListExpr(InitListExpr* Node) {
1599  if (Node->getSyntacticForm()) {
1600  Visit(Node->getSyntacticForm());
1601  return;
1602  }
1603 
1604  OS << "{";
1605  for (unsigned i = 0, e = Node->getNumInits(); i != e; ++i) {
1606  if (i) OS << ", ";
1607  if (Node->getInit(i))
1608  PrintExpr(Node->getInit(i));
1609  else
1610  OS << "{}";
1611  }
1612  OS << "}";
1613 }
1614 
1615 void StmtPrinter::VisitArrayInitLoopExpr(ArrayInitLoopExpr *Node) {
1616  // There's no way to express this expression in any of our supported
1617  // languages, so just emit something terse and (hopefully) clear.
1618  OS << "{";
1619  PrintExpr(Node->getSubExpr());
1620  OS << "}";
1621 }
1622 
1623 void StmtPrinter::VisitArrayInitIndexExpr(ArrayInitIndexExpr *Node) {
1624  OS << "*";
1625 }
1626 
1627 void StmtPrinter::VisitParenListExpr(ParenListExpr* Node) {
1628  OS << "(";
1629  for (unsigned i = 0, e = Node->getNumExprs(); i != e; ++i) {
1630  if (i) OS << ", ";
1631  PrintExpr(Node->getExpr(i));
1632  }
1633  OS << ")";
1634 }
1635 
1636 void StmtPrinter::VisitDesignatedInitExpr(DesignatedInitExpr *Node) {
1637  bool NeedsEquals = true;
1638  for (const DesignatedInitExpr::Designator &D : Node->designators()) {
1639  if (D.isFieldDesignator()) {
1640  if (D.getDotLoc().isInvalid()) {
1641  if (IdentifierInfo *II = D.getFieldName()) {
1642  OS << II->getName() << ":";
1643  NeedsEquals = false;
1644  }
1645  } else {
1646  OS << "." << D.getFieldName()->getName();
1647  }
1648  } else {
1649  OS << "[";
1650  if (D.isArrayDesignator()) {
1651  PrintExpr(Node->getArrayIndex(D));
1652  } else {
1653  PrintExpr(Node->getArrayRangeStart(D));
1654  OS << " ... ";
1655  PrintExpr(Node->getArrayRangeEnd(D));
1656  }
1657  OS << "]";
1658  }
1659  }
1660 
1661  if (NeedsEquals)
1662  OS << " = ";
1663  else
1664  OS << " ";
1665  PrintExpr(Node->getInit());
1666 }
1667 
1668 void StmtPrinter::VisitDesignatedInitUpdateExpr(
1670  OS << "{";
1671  OS << "/*base*/";
1672  PrintExpr(Node->getBase());
1673  OS << ", ";
1674 
1675  OS << "/*updater*/";
1676  PrintExpr(Node->getUpdater());
1677  OS << "}";
1678 }
1679 
1680 void StmtPrinter::VisitNoInitExpr(NoInitExpr *Node) {
1681  OS << "/*no init*/";
1682 }
1683 
1684 void StmtPrinter::VisitImplicitValueInitExpr(ImplicitValueInitExpr *Node) {
1685  if (Node->getType()->getAsCXXRecordDecl()) {
1686  OS << "/*implicit*/";
1687  Node->getType().print(OS, Policy);
1688  OS << "()";
1689  } else {
1690  OS << "/*implicit*/(";
1691  Node->getType().print(OS, Policy);
1692  OS << ')';
1693  if (Node->getType()->isRecordType())
1694  OS << "{}";
1695  else
1696  OS << 0;
1697  }
1698 }
1699 
1700 void StmtPrinter::VisitVAArgExpr(VAArgExpr *Node) {
1701  OS << "__builtin_va_arg(";
1702  PrintExpr(Node->getSubExpr());
1703  OS << ", ";
1704  Node->getType().print(OS, Policy);
1705  OS << ")";
1706 }
1707 
1708 void StmtPrinter::VisitPseudoObjectExpr(PseudoObjectExpr *Node) {
1709  PrintExpr(Node->getSyntacticForm());
1710 }
1711 
1712 void StmtPrinter::VisitAtomicExpr(AtomicExpr *Node) {
1713  const char *Name = nullptr;
1714  switch (Node->getOp()) {
1715 #define BUILTIN(ID, TYPE, ATTRS)
1716 #define ATOMIC_BUILTIN(ID, TYPE, ATTRS) \
1717  case AtomicExpr::AO ## ID: \
1718  Name = #ID "("; \
1719  break;
1720 #include "clang/Basic/Builtins.def"
1721  }
1722  OS << Name;
1723 
1724  // AtomicExpr stores its subexpressions in a permuted order.
1725  PrintExpr(Node->getPtr());
1726  if (Node->getOp() != AtomicExpr::AO__c11_atomic_load &&
1727  Node->getOp() != AtomicExpr::AO__atomic_load_n &&
1728  Node->getOp() != AtomicExpr::AO__opencl_atomic_load &&
1729  Node->getOp() != AtomicExpr::AO__hip_atomic_load) {
1730  OS << ", ";
1731  PrintExpr(Node->getVal1());
1732  }
1733  if (Node->getOp() == AtomicExpr::AO__atomic_exchange ||
1734  Node->isCmpXChg()) {
1735  OS << ", ";
1736  PrintExpr(Node->getVal2());
1737  }
1738  if (Node->getOp() == AtomicExpr::AO__atomic_compare_exchange ||
1739  Node->getOp() == AtomicExpr::AO__atomic_compare_exchange_n) {
1740  OS << ", ";
1741  PrintExpr(Node->getWeak());
1742  }
1743  if (Node->getOp() != AtomicExpr::AO__c11_atomic_init &&
1744  Node->getOp() != AtomicExpr::AO__opencl_atomic_init) {
1745  OS << ", ";
1746  PrintExpr(Node->getOrder());
1747  }
1748  if (Node->isCmpXChg()) {
1749  OS << ", ";
1750  PrintExpr(Node->getOrderFail());
1751  }
1752  OS << ")";
1753 }
1754 
1755 // C++
1756 void StmtPrinter::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *Node) {
1757  OverloadedOperatorKind Kind = Node->getOperator();
1758  if (Kind == OO_PlusPlus || Kind == OO_MinusMinus) {
1759  if (Node->getNumArgs() == 1) {
1760  OS << getOperatorSpelling(Kind) << ' ';
1761  PrintExpr(Node->getArg(0));
1762  } else {
1763  PrintExpr(Node->getArg(0));
1764  OS << ' ' << getOperatorSpelling(Kind);
1765  }
1766  } else if (Kind == OO_Arrow) {
1767  PrintExpr(Node->getArg(0));
1768  } else if (Kind == OO_Call || Kind == OO_Subscript) {
1769  PrintExpr(Node->getArg(0));
1770  OS << (Kind == OO_Call ? '(' : '[');
1771  for (unsigned ArgIdx = 1; ArgIdx < Node->getNumArgs(); ++ArgIdx) {
1772  if (ArgIdx > 1)
1773  OS << ", ";
1774  if (!isa<CXXDefaultArgExpr>(Node->getArg(ArgIdx)))
1775  PrintExpr(Node->getArg(ArgIdx));
1776  }
1777  OS << (Kind == OO_Call ? ')' : ']');
1778  } else if (Node->getNumArgs() == 1) {
1779  OS << getOperatorSpelling(Kind) << ' ';
1780  PrintExpr(Node->getArg(0));
1781  } else if (Node->getNumArgs() == 2) {
1782  PrintExpr(Node->getArg(0));
1783  OS << ' ' << getOperatorSpelling(Kind) << ' ';
1784  PrintExpr(Node->getArg(1));
1785  } else {
1786  llvm_unreachable("unknown overloaded operator");
1787  }
1788 }
1789 
1790 void StmtPrinter::VisitCXXMemberCallExpr(CXXMemberCallExpr *Node) {
1791  // If we have a conversion operator call only print the argument.
1792  CXXMethodDecl *MD = Node->getMethodDecl();
1793  if (MD && isa<CXXConversionDecl>(MD)) {
1794  PrintExpr(Node->getImplicitObjectArgument());
1795  return;
1796  }
1797  VisitCallExpr(cast<CallExpr>(Node));
1798 }
1799 
1800 void StmtPrinter::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *Node) {
1801  PrintExpr(Node->getCallee());
1802  OS << "<<<";
1803  PrintCallArgs(Node->getConfig());
1804  OS << ">>>(";
1805  PrintCallArgs(Node);
1806  OS << ")";
1807 }
1808 
1809 void StmtPrinter::VisitCXXRewrittenBinaryOperator(
1812  Node->getDecomposedForm();
1813  PrintExpr(const_cast<Expr*>(Decomposed.LHS));
1814  OS << ' ' << BinaryOperator::getOpcodeStr(Decomposed.Opcode) << ' ';
1815  PrintExpr(const_cast<Expr*>(Decomposed.RHS));
1816 }
1817 
1818 void StmtPrinter::VisitCXXNamedCastExpr(CXXNamedCastExpr *Node) {
1819  OS << Node->getCastName() << '<';
1820  Node->getTypeAsWritten().print(OS, Policy);
1821  OS << ">(";
1822  PrintExpr(Node->getSubExpr());
1823  OS << ")";
1824 }
1825 
1826 void StmtPrinter::VisitCXXStaticCastExpr(CXXStaticCastExpr *Node) {
1827  VisitCXXNamedCastExpr(Node);
1828 }
1829 
1830 void StmtPrinter::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *Node) {
1831  VisitCXXNamedCastExpr(Node);
1832 }
1833 
1834 void StmtPrinter::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *Node) {
1835  VisitCXXNamedCastExpr(Node);
1836 }
1837 
1838 void StmtPrinter::VisitCXXConstCastExpr(CXXConstCastExpr *Node) {
1839  VisitCXXNamedCastExpr(Node);
1840 }
1841 
1842 void StmtPrinter::VisitBuiltinBitCastExpr(BuiltinBitCastExpr *Node) {
1843  OS << "__builtin_bit_cast(";
1844  Node->getTypeInfoAsWritten()->getType().print(OS, Policy);
1845  OS << ", ";
1846  PrintExpr(Node->getSubExpr());
1847  OS << ")";
1848 }
1849 
1850 void StmtPrinter::VisitCXXAddrspaceCastExpr(CXXAddrspaceCastExpr *Node) {
1851  VisitCXXNamedCastExpr(Node);
1852 }
1853 
1854 void StmtPrinter::VisitCXXTypeidExpr(CXXTypeidExpr *Node) {
1855  OS << "typeid(";
1856  if (Node->isTypeOperand()) {
1857  Node->getTypeOperandSourceInfo()->getType().print(OS, Policy);
1858  } else {
1859  PrintExpr(Node->getExprOperand());
1860  }
1861  OS << ")";
1862 }
1863 
1864 void StmtPrinter::VisitCXXUuidofExpr(CXXUuidofExpr *Node) {
1865  OS << "__uuidof(";
1866  if (Node->isTypeOperand()) {
1867  Node->getTypeOperandSourceInfo()->getType().print(OS, Policy);
1868  } else {
1869  PrintExpr(Node->getExprOperand());
1870  }
1871  OS << ")";
1872 }
1873 
1874 void StmtPrinter::VisitMSPropertyRefExpr(MSPropertyRefExpr *Node) {
1875  PrintExpr(Node->getBaseExpr());
1876  if (Node->isArrow())
1877  OS << "->";
1878  else
1879  OS << ".";
1880  if (NestedNameSpecifier *Qualifier =
1881  Node->getQualifierLoc().getNestedNameSpecifier())
1882  Qualifier->print(OS, Policy);
1883  OS << Node->getPropertyDecl()->getDeclName();
1884 }
1885 
1886 void StmtPrinter::VisitMSPropertySubscriptExpr(MSPropertySubscriptExpr *Node) {
1887  PrintExpr(Node->getBase());
1888  OS << "[";
1889  PrintExpr(Node->getIdx());
1890  OS << "]";
1891 }
1892 
1893 void StmtPrinter::VisitUserDefinedLiteral(UserDefinedLiteral *Node) {
1894  switch (Node->getLiteralOperatorKind()) {
1896  OS << cast<StringLiteral>(Node->getArg(0)->IgnoreImpCasts())->getString();
1897  break;
1899  const auto *DRE = cast<DeclRefExpr>(Node->getCallee()->IgnoreImpCasts());
1900  const TemplateArgumentList *Args =
1901  cast<FunctionDecl>(DRE->getDecl())->getTemplateSpecializationArgs();
1902  assert(Args);
1903 
1904  if (Args->size() != 1) {
1905  const TemplateParameterList *TPL = nullptr;
1906  if (!DRE->hadMultipleCandidates())
1907  if (const auto *TD = dyn_cast<TemplateDecl>(DRE->getDecl()))
1908  TPL = TD->getTemplateParameters();
1909  OS << "operator\"\"" << Node->getUDSuffix()->getName();
1910  printTemplateArgumentList(OS, Args->asArray(), Policy, TPL);
1911  OS << "()";
1912  return;
1913  }
1914 
1915  const TemplateArgument &Pack = Args->get(0);
1916  for (const auto &P : Pack.pack_elements()) {
1917  char C = (char)P.getAsIntegral().getZExtValue();
1918  OS << C;
1919  }
1920  break;
1921  }
1923  // Print integer literal without suffix.
1924  const auto *Int = cast<IntegerLiteral>(Node->getCookedLiteral());
1925  OS << toString(Int->getValue(), 10, /*isSigned*/false);
1926  break;
1927  }
1929  // Print floating literal without suffix.
1930  auto *Float = cast<FloatingLiteral>(Node->getCookedLiteral());
1931  PrintFloatingLiteral(OS, Float, /*PrintSuffix=*/false);
1932  break;
1933  }
1936  PrintExpr(Node->getCookedLiteral());
1937  break;
1938  }
1939  OS << Node->getUDSuffix()->getName();
1940 }
1941 
1942 void StmtPrinter::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *Node) {
1943  OS << (Node->getValue() ? "true" : "false");
1944 }
1945 
1946 void StmtPrinter::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *Node) {
1947  OS << "nullptr";
1948 }
1949 
1950 void StmtPrinter::VisitCXXThisExpr(CXXThisExpr *Node) {
1951  OS << "this";
1952 }
1953 
1954 void StmtPrinter::VisitCXXThrowExpr(CXXThrowExpr *Node) {
1955  if (!Node->getSubExpr())
1956  OS << "throw";
1957  else {
1958  OS << "throw ";
1959  PrintExpr(Node->getSubExpr());
1960  }
1961 }
1962 
1963 void StmtPrinter::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *Node) {
1964  // Nothing to print: we picked up the default argument.
1965 }
1966 
1967 void StmtPrinter::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *Node) {
1968  // Nothing to print: we picked up the default initializer.
1969 }
1970 
1971 void StmtPrinter::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *Node) {
1972  auto TargetType = Node->getType();
1973  auto *Auto = TargetType->getContainedDeducedType();
1974  bool Bare = Auto && Auto->isDeduced();
1975 
1976  // Parenthesize deduced casts.
1977  if (Bare)
1978  OS << '(';
1979  TargetType.print(OS, Policy);
1980  if (Bare)
1981  OS << ')';
1982 
1983  // No extra braces surrounding the inner construct.
1984  if (!Node->isListInitialization())
1985  OS << '(';
1986  PrintExpr(Node->getSubExpr());
1987  if (!Node->isListInitialization())
1988  OS << ')';
1989 }
1990 
1991 void StmtPrinter::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *Node) {
1992  PrintExpr(Node->getSubExpr());
1993 }
1994 
1995 void StmtPrinter::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *Node) {
1996  Node->getType().print(OS, Policy);
1997  if (Node->isStdInitListInitialization())
1998  /* Nothing to do; braces are part of creating the std::initializer_list. */;
1999  else if (Node->isListInitialization())
2000  OS << "{";
2001  else
2002  OS << "(";
2003  for (CXXTemporaryObjectExpr::arg_iterator Arg = Node->arg_begin(),
2004  ArgEnd = Node->arg_end();
2005  Arg != ArgEnd; ++Arg) {
2006  if ((*Arg)->isDefaultArgument())
2007  break;
2008  if (Arg != Node->arg_begin())
2009  OS << ", ";
2010  PrintExpr(*Arg);
2011  }
2012  if (Node->isStdInitListInitialization())
2013  /* See above. */;
2014  else if (Node->isListInitialization())
2015  OS << "}";
2016  else
2017  OS << ")";
2018 }
2019 
2020 void StmtPrinter::VisitLambdaExpr(LambdaExpr *Node) {
2021  OS << '[';
2022  bool NeedComma = false;
2023  switch (Node->getCaptureDefault()) {
2024  case LCD_None:
2025  break;
2026 
2027  case LCD_ByCopy:
2028  OS << '=';
2029  NeedComma = true;
2030  break;
2031 
2032  case LCD_ByRef:
2033  OS << '&';
2034  NeedComma = true;
2035  break;
2036  }
2037  for (LambdaExpr::capture_iterator C = Node->explicit_capture_begin(),
2038  CEnd = Node->explicit_capture_end();
2039  C != CEnd;
2040  ++C) {
2041  if (C->capturesVLAType())
2042  continue;
2043 
2044  if (NeedComma)
2045  OS << ", ";
2046  NeedComma = true;
2047 
2048  switch (C->getCaptureKind()) {
2049  case LCK_This:
2050  OS << "this";
2051  break;
2052 
2053  case LCK_StarThis:
2054  OS << "*this";
2055  break;
2056 
2057  case LCK_ByRef:
2058  if (Node->getCaptureDefault() != LCD_ByRef || Node->isInitCapture(C))
2059  OS << '&';
2060  OS << C->getCapturedVar()->getName();
2061  break;
2062 
2063  case LCK_ByCopy:
2064  OS << C->getCapturedVar()->getName();
2065  break;
2066 
2067  case LCK_VLAType:
2068  llvm_unreachable("VLA type in explicit captures.");
2069  }
2070 
2071  if (C->isPackExpansion())
2072  OS << "...";
2073 
2074  if (Node->isInitCapture(C)) {
2075  VarDecl *D = C->getCapturedVar();
2076 
2077  llvm::StringRef Pre;
2078  llvm::StringRef Post;
2079  if (D->getInitStyle() == VarDecl::CallInit &&
2080  !isa<ParenListExpr>(D->getInit())) {
2081  Pre = "(";
2082  Post = ")";
2083  } else if (D->getInitStyle() == VarDecl::CInit) {
2084  Pre = " = ";
2085  }
2086 
2087  OS << Pre;
2088  PrintExpr(D->getInit());
2089  OS << Post;
2090  }
2091  }
2092  OS << ']';
2093 
2094  if (!Node->getExplicitTemplateParameters().empty()) {
2095  Node->getTemplateParameterList()->print(
2096  OS, Node->getLambdaClass()->getASTContext(),
2097  /*OmitTemplateKW*/true);
2098  }
2099 
2100  if (Node->hasExplicitParameters()) {
2101  OS << '(';
2102  CXXMethodDecl *Method = Node->getCallOperator();
2103  NeedComma = false;
2104  for (const auto *P : Method->parameters()) {
2105  if (NeedComma) {
2106  OS << ", ";
2107  } else {
2108  NeedComma = true;
2109  }
2110  std::string ParamStr =
2111  (Policy.CleanUglifiedParameters && P->getIdentifier())
2112  ? P->getIdentifier()->deuglifiedName().str()
2113  : P->getNameAsString();
2114  P->getOriginalType().print(OS, Policy, ParamStr);
2115  }
2116  if (Method->isVariadic()) {
2117  if (NeedComma)
2118  OS << ", ";
2119  OS << "...";
2120  }
2121  OS << ')';
2122 
2123  if (Node->isMutable())
2124  OS << " mutable";
2125 
2126  auto *Proto = Method->getType()->castAs<FunctionProtoType>();
2127  Proto->printExceptionSpecification(OS, Policy);
2128 
2129  // FIXME: Attributes
2130 
2131  // Print the trailing return type if it was specified in the source.
2132  if (Node->hasExplicitResultType()) {
2133  OS << " -> ";
2134  Proto->getReturnType().print(OS, Policy);
2135  }
2136  }
2137 
2138  // Print the body.
2139  OS << ' ';
2140  if (Policy.TerseOutput)
2141  OS << "{}";
2142  else
2143  PrintRawCompoundStmt(Node->getCompoundStmtBody());
2144 }
2145 
2146 void StmtPrinter::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *Node) {
2147  if (TypeSourceInfo *TSInfo = Node->getTypeSourceInfo())
2148  TSInfo->getType().print(OS, Policy);
2149  else
2150  Node->getType().print(OS, Policy);
2151  OS << "()";
2152 }
2153 
2154 void StmtPrinter::VisitCXXNewExpr(CXXNewExpr *E) {
2155  if (E->isGlobalNew())
2156  OS << "::";
2157  OS << "new ";
2158  unsigned NumPlace = E->getNumPlacementArgs();
2159  if (NumPlace > 0 && !isa<CXXDefaultArgExpr>(E->getPlacementArg(0))) {
2160  OS << "(";
2161  PrintExpr(E->getPlacementArg(0));
2162  for (unsigned i = 1; i < NumPlace; ++i) {
2163  if (isa<CXXDefaultArgExpr>(E->getPlacementArg(i)))
2164  break;
2165  OS << ", ";
2166  PrintExpr(E->getPlacementArg(i));
2167  }
2168  OS << ") ";
2169  }
2170  if (E->isParenTypeId())
2171  OS << "(";
2172  std::string TypeS;
2173  if (E->isArray()) {
2174  llvm::raw_string_ostream s(TypeS);
2175  s << '[';
2176  if (Optional<Expr *> Size = E->getArraySize())
2177  (*Size)->printPretty(s, Helper, Policy);
2178  s << ']';
2179  }
2180  E->getAllocatedType().print(OS, Policy, TypeS);
2181  if (E->isParenTypeId())
2182  OS << ")";
2183 
2185  if (InitStyle != CXXNewExpr::NoInit) {
2186  bool Bare = InitStyle == CXXNewExpr::CallInit &&
2187  !isa<ParenListExpr>(E->getInitializer());
2188  if (Bare)
2189  OS << "(";
2190  PrintExpr(E->getInitializer());
2191  if (Bare)
2192  OS << ")";
2193  }
2194 }
2195 
2196 void StmtPrinter::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
2197  if (E->isGlobalDelete())
2198  OS << "::";
2199  OS << "delete ";
2200  if (E->isArrayForm())
2201  OS << "[] ";
2202  PrintExpr(E->getArgument());
2203 }
2204 
2205 void StmtPrinter::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
2206  PrintExpr(E->getBase());
2207  if (E->isArrow())
2208  OS << "->";
2209  else
2210  OS << '.';
2211  if (E->getQualifier())
2212  E->getQualifier()->print(OS, Policy);
2213  OS << "~";
2214 
2216  OS << II->getName();
2217  else
2218  E->getDestroyedType().print(OS, Policy);
2219 }
2220 
2221 void StmtPrinter::VisitCXXConstructExpr(CXXConstructExpr *E) {
2223  OS << "{";
2224 
2225  for (unsigned i = 0, e = E->getNumArgs(); i != e; ++i) {
2226  if (isa<CXXDefaultArgExpr>(E->getArg(i))) {
2227  // Don't print any defaulted arguments
2228  break;
2229  }
2230 
2231  if (i) OS << ", ";
2232  PrintExpr(E->getArg(i));
2233  }
2234 
2236  OS << "}";
2237 }
2238 
2239 void StmtPrinter::VisitCXXInheritedCtorInitExpr(CXXInheritedCtorInitExpr *E) {
2240  // Parens are printed by the surrounding context.
2241  OS << "<forwarded>";
2242 }
2243 
2244 void StmtPrinter::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E) {
2245  PrintExpr(E->getSubExpr());
2246 }
2247 
2248 void StmtPrinter::VisitExprWithCleanups(ExprWithCleanups *E) {
2249  // Just forward to the subexpression.
2250  PrintExpr(E->getSubExpr());
2251 }
2252 
2253 void StmtPrinter::VisitCXXUnresolvedConstructExpr(
2255  Node->getTypeAsWritten().print(OS, Policy);
2256  if (!Node->isListInitialization())
2257  OS << '(';
2258  for (auto Arg = Node->arg_begin(), ArgEnd = Node->arg_end(); Arg != ArgEnd;
2259  ++Arg) {
2260  if (Arg != Node->arg_begin())
2261  OS << ", ";
2262  PrintExpr(*Arg);
2263  }
2264  if (!Node->isListInitialization())
2265  OS << ')';
2266 }
2267 
2268 void StmtPrinter::VisitCXXDependentScopeMemberExpr(
2270  if (!Node->isImplicitAccess()) {
2271  PrintExpr(Node->getBase());
2272  OS << (Node->isArrow() ? "->" : ".");
2273  }
2274  if (NestedNameSpecifier *Qualifier = Node->getQualifier())
2275  Qualifier->print(OS, Policy);
2276  if (Node->hasTemplateKeyword())
2277  OS << "template ";
2278  OS << Node->getMemberNameInfo();
2279  if (Node->hasExplicitTemplateArgs())
2280  printTemplateArgumentList(OS, Node->template_arguments(), Policy);
2281 }
2282 
2283 void StmtPrinter::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *Node) {
2284  if (!Node->isImplicitAccess()) {
2285  PrintExpr(Node->getBase());
2286  OS << (Node->isArrow() ? "->" : ".");
2287  }
2288  if (NestedNameSpecifier *Qualifier = Node->getQualifier())
2289  Qualifier->print(OS, Policy);
2290  if (Node->hasTemplateKeyword())
2291  OS << "template ";
2292  OS << Node->getMemberNameInfo();
2293  if (Node->hasExplicitTemplateArgs())
2294  printTemplateArgumentList(OS, Node->template_arguments(), Policy);
2295 }
2296 
2297 void StmtPrinter::VisitTypeTraitExpr(TypeTraitExpr *E) {
2298  OS << getTraitSpelling(E->getTrait()) << "(";
2299  for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) {
2300  if (I > 0)
2301  OS << ", ";
2302  E->getArg(I)->getType().print(OS, Policy);
2303  }
2304  OS << ")";
2305 }
2306 
2307 void StmtPrinter::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
2308  OS << getTraitSpelling(E->getTrait()) << '(';
2309  E->getQueriedType().print(OS, Policy);
2310  OS << ')';
2311 }
2312 
2313 void StmtPrinter::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
2314  OS << getTraitSpelling(E->getTrait()) << '(';
2315  PrintExpr(E->getQueriedExpression());
2316  OS << ')';
2317 }
2318 
2319 void StmtPrinter::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
2320  OS << "noexcept(";
2321  PrintExpr(E->getOperand());
2322  OS << ")";
2323 }
2324 
2325 void StmtPrinter::VisitPackExpansionExpr(PackExpansionExpr *E) {
2326  PrintExpr(E->getPattern());
2327  OS << "...";
2328 }
2329 
2330 void StmtPrinter::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
2331  OS << "sizeof...(" << *E->getPack() << ")";
2332 }
2333 
2334 void StmtPrinter::VisitSubstNonTypeTemplateParmPackExpr(
2336  OS << *Node->getParameterPack();
2337 }
2338 
2339 void StmtPrinter::VisitSubstNonTypeTemplateParmExpr(
2341  Visit(Node->getReplacement());
2342 }
2343 
2344 void StmtPrinter::VisitFunctionParmPackExpr(FunctionParmPackExpr *E) {
2345  OS << *E->getParameterPack();
2346 }
2347 
2348 void StmtPrinter::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *Node){
2349  PrintExpr(Node->getSubExpr());
2350 }
2351 
2352 void StmtPrinter::VisitCXXFoldExpr(CXXFoldExpr *E) {
2353  OS << "(";
2354  if (E->getLHS()) {
2355  PrintExpr(E->getLHS());
2356  OS << " " << BinaryOperator::getOpcodeStr(E->getOperator()) << " ";
2357  }
2358  OS << "...";
2359  if (E->getRHS()) {
2360  OS << " " << BinaryOperator::getOpcodeStr(E->getOperator()) << " ";
2361  PrintExpr(E->getRHS());
2362  }
2363  OS << ")";
2364 }
2365 
2366 void StmtPrinter::VisitConceptSpecializationExpr(ConceptSpecializationExpr *E) {
2368  if (NNS)
2369  NNS.getNestedNameSpecifier()->print(OS, Policy);
2370  if (E->getTemplateKWLoc().isValid())
2371  OS << "template ";
2372  OS << E->getFoundDecl()->getName();
2374  Policy,
2376 }
2377 
2378 void StmtPrinter::VisitRequiresExpr(RequiresExpr *E) {
2379  OS << "requires ";
2380  auto LocalParameters = E->getLocalParameters();
2381  if (!LocalParameters.empty()) {
2382  OS << "(";
2383  for (ParmVarDecl *LocalParam : LocalParameters) {
2384  PrintRawDecl(LocalParam);
2385  if (LocalParam != LocalParameters.back())
2386  OS << ", ";
2387  }
2388 
2389  OS << ") ";
2390  }
2391  OS << "{ ";
2392  auto Requirements = E->getRequirements();
2393  for (concepts::Requirement *Req : Requirements) {
2394  if (auto *TypeReq = dyn_cast<concepts::TypeRequirement>(Req)) {
2395  if (TypeReq->isSubstitutionFailure())
2396  OS << "<<error-type>>";
2397  else
2398  TypeReq->getType()->getType().print(OS, Policy);
2399  } else if (auto *ExprReq = dyn_cast<concepts::ExprRequirement>(Req)) {
2400  if (ExprReq->isCompound())
2401  OS << "{ ";
2402  if (ExprReq->isExprSubstitutionFailure())
2403  OS << "<<error-expression>>";
2404  else
2405  PrintExpr(ExprReq->getExpr());
2406  if (ExprReq->isCompound()) {
2407  OS << " }";
2408  if (ExprReq->getNoexceptLoc().isValid())
2409  OS << " noexcept";
2410  const auto &RetReq = ExprReq->getReturnTypeRequirement();
2411  if (!RetReq.isEmpty()) {
2412  OS << " -> ";
2413  if (RetReq.isSubstitutionFailure())
2414  OS << "<<error-type>>";
2415  else if (RetReq.isTypeConstraint())
2416  RetReq.getTypeConstraint()->print(OS, Policy);
2417  }
2418  }
2419  } else {
2420  auto *NestedReq = cast<concepts::NestedRequirement>(Req);
2421  OS << "requires ";
2422  if (NestedReq->isSubstitutionFailure())
2423  OS << "<<error-expression>>";
2424  else
2425  PrintExpr(NestedReq->getConstraintExpr());
2426  }
2427  OS << "; ";
2428  }
2429  OS << "}";
2430 }
2431 
2432 // C++ Coroutines TS
2433 
2434 void StmtPrinter::VisitCoroutineBodyStmt(CoroutineBodyStmt *S) {
2435  Visit(S->getBody());
2436 }
2437 
2438 void StmtPrinter::VisitCoreturnStmt(CoreturnStmt *S) {
2439  OS << "co_return";
2440  if (S->getOperand()) {
2441  OS << " ";
2442  Visit(S->getOperand());
2443  }
2444  OS << ";";
2445 }
2446 
2447 void StmtPrinter::VisitCoawaitExpr(CoawaitExpr *S) {
2448  OS << "co_await ";
2449  PrintExpr(S->getOperand());
2450 }
2451 
2452 void StmtPrinter::VisitDependentCoawaitExpr(DependentCoawaitExpr *S) {
2453  OS << "co_await ";
2454  PrintExpr(S->getOperand());
2455 }
2456 
2457 void StmtPrinter::VisitCoyieldExpr(CoyieldExpr *S) {
2458  OS << "co_yield ";
2459  PrintExpr(S->getOperand());
2460 }
2461 
2462 // Obj-C
2463 
2464 void StmtPrinter::VisitObjCStringLiteral(ObjCStringLiteral *Node) {
2465  OS << "@";
2466  VisitStringLiteral(Node->getString());
2467 }
2468 
2469 void StmtPrinter::VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
2470  OS << "@";
2471  Visit(E->getSubExpr());
2472 }
2473 
2474 void StmtPrinter::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
2475  OS << "@[ ";
2477  for (auto I = Ch.begin(), E = Ch.end(); I != E; ++I) {
2478  if (I != Ch.begin())
2479  OS << ", ";
2480  Visit(*I);
2481  }
2482  OS << " ]";
2483 }
2484 
2485 void StmtPrinter::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
2486  OS << "@{ ";
2487  for (unsigned I = 0, N = E->getNumElements(); I != N; ++I) {
2488  if (I > 0)
2489  OS << ", ";
2490 
2491  ObjCDictionaryElement Element = E->getKeyValueElement(I);
2492  Visit(Element.Key);
2493  OS << " : ";
2494  Visit(Element.Value);
2495  if (Element.isPackExpansion())
2496  OS << "...";
2497  }
2498  OS << " }";
2499 }
2500 
2501 void StmtPrinter::VisitObjCEncodeExpr(ObjCEncodeExpr *Node) {
2502  OS << "@encode(";
2503  Node->getEncodedType().print(OS, Policy);
2504  OS << ')';
2505 }
2506 
2507 void StmtPrinter::VisitObjCSelectorExpr(ObjCSelectorExpr *Node) {
2508  OS << "@selector(";
2509  Node->getSelector().print(OS);
2510  OS << ')';
2511 }
2512 
2513 void StmtPrinter::VisitObjCProtocolExpr(ObjCProtocolExpr *Node) {
2514  OS << "@protocol(" << *Node->getProtocol() << ')';
2515 }
2516 
2517 void StmtPrinter::VisitObjCMessageExpr(ObjCMessageExpr *Mess) {
2518  OS << "[";
2519  switch (Mess->getReceiverKind()) {
2521  PrintExpr(Mess->getInstanceReceiver());
2522  break;
2523 
2525  Mess->getClassReceiver().print(OS, Policy);
2526  break;
2527 
2530  OS << "Super";
2531  break;
2532  }
2533 
2534  OS << ' ';
2535  Selector selector = Mess->getSelector();
2536  if (selector.isUnarySelector()) {
2537  OS << selector.getNameForSlot(0);
2538  } else {
2539  for (unsigned i = 0, e = Mess->getNumArgs(); i != e; ++i) {
2540  if (i < selector.getNumArgs()) {
2541  if (i > 0) OS << ' ';
2542  if (selector.getIdentifierInfoForSlot(i))
2543  OS << selector.getIdentifierInfoForSlot(i)->getName() << ':';
2544  else
2545  OS << ":";
2546  }
2547  else OS << ", "; // Handle variadic methods.
2548 
2549  PrintExpr(Mess->getArg(i));
2550  }
2551  }
2552  OS << "]";
2553 }
2554 
2555 void StmtPrinter::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *Node) {
2556  OS << (Node->getValue() ? "__objc_yes" : "__objc_no");
2557 }
2558 
2559 void
2560 StmtPrinter::VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
2561  PrintExpr(E->getSubExpr());
2562 }
2563 
2564 void
2565 StmtPrinter::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
2566  OS << '(' << E->getBridgeKindName();
2567  E->getType().print(OS, Policy);
2568  OS << ')';
2569  PrintExpr(E->getSubExpr());
2570 }
2571 
2572 void StmtPrinter::VisitBlockExpr(BlockExpr *Node) {
2573  BlockDecl *BD = Node->getBlockDecl();
2574  OS << "^";
2575 
2576  const FunctionType *AFT = Node->getFunctionType();
2577 
2578  if (isa<FunctionNoProtoType>(AFT)) {
2579  OS << "()";
2580  } else if (!BD->param_empty() || cast<FunctionProtoType>(AFT)->isVariadic()) {
2581  OS << '(';
2582  for (BlockDecl::param_iterator AI = BD->param_begin(),
2583  E = BD->param_end(); AI != E; ++AI) {
2584  if (AI != BD->param_begin()) OS << ", ";
2585  std::string ParamStr = (*AI)->getNameAsString();
2586  (*AI)->getType().print(OS, Policy, ParamStr);
2587  }
2588 
2589  const auto *FT = cast<FunctionProtoType>(AFT);
2590  if (FT->isVariadic()) {
2591  if (!BD->param_empty()) OS << ", ";
2592  OS << "...";
2593  }
2594  OS << ')';
2595  }
2596  OS << "{ }";
2597 }
2598 
2599 void StmtPrinter::VisitOpaqueValueExpr(OpaqueValueExpr *Node) {
2600  PrintExpr(Node->getSourceExpr());
2601 }
2602 
2603 void StmtPrinter::VisitTypoExpr(TypoExpr *Node) {
2604  // TODO: Print something reasonable for a TypoExpr, if necessary.
2605  llvm_unreachable("Cannot print TypoExpr nodes");
2606 }
2607 
2608 void StmtPrinter::VisitRecoveryExpr(RecoveryExpr *Node) {
2609  OS << "<recovery-expr>(";
2610  const char *Sep = "";
2611  for (Expr *E : Node->subExpressions()) {
2612  OS << Sep;
2613  PrintExpr(E);
2614  Sep = ", ";
2615  }
2616  OS << ')';
2617 }
2618 
2619 void StmtPrinter::VisitAsTypeExpr(AsTypeExpr *Node) {
2620  OS << "__builtin_astype(";
2621  PrintExpr(Node->getSrcExpr());
2622  OS << ", ";
2623  Node->getType().print(OS, Policy);
2624  OS << ")";
2625 }
2626 
2627 //===----------------------------------------------------------------------===//
2628 // Stmt method implementations
2629 //===----------------------------------------------------------------------===//
2630 
2631 void Stmt::dumpPretty(const ASTContext &Context) const {
2632  printPretty(llvm::errs(), nullptr, PrintingPolicy(Context.getLangOpts()));
2633 }
2634 
2635 void Stmt::printPretty(raw_ostream &Out, PrinterHelper *Helper,
2636  const PrintingPolicy &Policy, unsigned Indentation,
2637  StringRef NL, const ASTContext *Context) const {
2638  StmtPrinter P(Out, Helper, Policy, Indentation, NL, Context);
2639  P.Visit(const_cast<Stmt *>(this));
2640 }
2641 
2642 void Stmt::printPrettyControlled(raw_ostream &Out, PrinterHelper *Helper,
2643  const PrintingPolicy &Policy,
2644  unsigned Indentation, StringRef NL,
2645  const ASTContext *Context) const {
2646  StmtPrinter P(Out, Helper, Policy, Indentation, NL, Context);
2647  P.PrintControlledStmt(const_cast<Stmt *>(this));
2648 }
2649 
2650 void Stmt::printJson(raw_ostream &Out, PrinterHelper *Helper,
2651  const PrintingPolicy &Policy, bool AddQuotes) const {
2652  std::string Buf;
2653  llvm::raw_string_ostream TempOut(Buf);
2654 
2655  printPretty(TempOut, Helper, Policy);
2656 
2657  Out << JsonFormat(TempOut.str(), AddQuotes);
2658 }
2659 
2660 //===----------------------------------------------------------------------===//
2661 // PrinterHelper
2662 //===----------------------------------------------------------------------===//
2663 
2664 // Implement virtual destructor.
2665 PrinterHelper::~PrinterHelper() = default;
clang::StmtVisitor
StmtVisitor - This class implements a simple visitor for Stmt subclasses.
Definition: StmtVisitor.h:183
clang::ArrayInitIndexExpr
Represents the index of the current element of an array being initialized by an ArrayInitLoopExpr.
Definition: Expr.h:5474
clang::BuiltinType
This class is used for builtin types like 'int'.
Definition: Type.h:2504
clang::CXXPseudoDestructorExpr::getDestroyedType
QualType getDestroyedType() const
Retrieve the type being destroyed.
Definition: ExprCXX.cpp:334
clang::IndirectGotoStmt
IndirectGotoStmt - This represents an indirect goto.
Definition: Stmt.h:2648
clang::LabelStmt
LabelStmt - Represents a label, which has a substatement.
Definition: Stmt.h:1803
clang::PackExpansionExpr::getPattern
Expr * getPattern()
Retrieve the pattern of the pack expansion.
Definition: ExprCXX.h:4097
clang::ExpressionTraitExpr
An expression trait intrinsic.
Definition: ExprCXX.h:2840
clang::ObjCMessageExpr::SuperInstance
@ SuperInstance
The receiver is the instance of the superclass object.
Definition: ExprObjC.h:1097
clang::OMPForDirective
This represents '#pragma omp for' directive.
Definition: StmtOpenMP.h:1628
clang::OMPIteratorExpr
OpenMP 5.0 [2.1.6 Iterators] Iterators are identifiers that expand to multiple values in the clause o...
Definition: ExprOpenMP.h:272
clang::MatrixSubscriptExpr
MatrixSubscriptExpr - Matrix subscript expression for the MatrixType extension.
Definition: Expr.h:2723
clang::SubstNonTypeTemplateParmExpr
Represents a reference to a non-type template parameter that has been substituted with a template arg...
Definition: ExprCXX.h:4262
clang::TypeTraitExpr::getArg
TypeSourceInfo * getArg(unsigned I) const
Retrieve the Ith argument.
Definition: ExprCXX.h:2734
clang::CXXNewExpr::getInitializationStyle
InitializationStyle getInitializationStyle() const
The kind of initializer this new-expression has.
Definition: ExprCXX.h:2323
clang::AtomicExpr
AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*, __atomic_load,...
Definition: Expr.h:6234
clang::OMPMasterTaskLoopSimdDirective
This represents '#pragma omp master taskloop simd' directive.
Definition: StmtOpenMP.h:3786
clang::CaseStmt
CaseStmt - Represent a case statement.
Definition: Stmt.h:1571
clang::ObjCBridgedCastExpr::getBridgeKindName
StringRef getBridgeKindName() const
Retrieve the kind of bridge being performed as a string.
Definition: ExprObjC.cpp:341
clang::OMPTaskyieldDirective
This represents '#pragma omp taskyield' directive.
Definition: StmtOpenMP.h:2459
clang::ImaginaryLiteral
ImaginaryLiteral - We support imaginary integer and floating point literals, like "1....
Definition: Expr.h:1718
clang::SizeOfPackExpr::getPack
NamedDecl * getPack() const
Retrieve the parameter pack.
Definition: ExprCXX.h:4215
clang::ArrayTypeTraitExpr
An Embarcadero array type trait, as used in the implementation of __array_rank and __array_extent.
Definition: ExprCXX.h:2770
clang::ObjCBoxedExpr
ObjCBoxedExpr - used for generalized expression boxing.
Definition: ExprObjC.h:128
clang::CXXBoolLiteralExpr
A boolean literal, per ([C++ lex.bool] Boolean literals).
Definition: ExprCXX.h:721
clang::PrintingPolicy::CleanUglifiedParameters
unsigned CleanUglifiedParameters
Whether to strip underscores when printing reserved parameter names.
Definition: PrettyPrinter.h:288
clang::AsTypeExpr
AsTypeExpr - Clang builtin function __builtin_astype [OpenCL 6.2.4.2] This AST node provides support ...
Definition: Expr.h:6031
clang::OffsetOfExpr
OffsetOfExpr - [C99 7.17] - This represents an expression of the form offsetof(record-type,...
Definition: Expr.h:2444
clang::CXXPseudoDestructorExpr
Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
Definition: ExprCXX.h:2534
clang::TypeSourceInfo::getType
QualType getType() const
Return the type wrapped by this type source info.
Definition: Type.h:6482
clang::CXXRewrittenBinaryOperator::DecomposedForm
Definition: ExprCXX.h:305
clang::ObjCDictionaryElement
An element in an Objective-C dictionary literal.
Definition: ExprObjC.h:263
clang::CXXRewrittenBinaryOperator::DecomposedForm::LHS
const Expr * LHS
The original left-hand side.
Definition: ExprCXX.h:309
clang::OMPTileDirective
This represents the '#pragma omp tile' loop transformation directive.
Definition: StmtOpenMP.h:5118
clang::SwitchStmt
SwitchStmt - This represents a 'switch' stmt.
Definition: Stmt.h:2154
clang::ObjCDictionaryLiteral::getNumElements
unsigned getNumElements() const
getNumElements - Return number of elements of objective-c dictionary literal.
Definition: ExprObjC.h:360
clang::OMPMaskedDirective
This represents '#pragma omp masked' directive.
Definition: StmtOpenMP.h:5445
clang::Stmt::dumpPretty
void dumpPretty(const ASTContext &Context) const
dumpPretty/printPretty - These two methods do a "pretty print" of the AST back to its original source...
Definition: StmtPrinter.cpp:2631
string
string(SUBSTRING ${CMAKE_CURRENT_BINARY_DIR} 0 ${PATH_LIB_START} PATH_HEAD) string(SUBSTRING $
Definition: CMakeLists.txt:22
clang::WhileStmt
WhileStmt - This represents a 'while' stmt.
Definition: Stmt.h:2345
clang::NullStmt
NullStmt - This is the null statement ";": C99 6.8.3p3.
Definition: Stmt.h:1366
clang::LambdaCapture
Describes the capture of a variable or of this, or of a C++1y init-capture.
Definition: LambdaCapture.h:25
clang::CXXReinterpretCastExpr
A C++ reinterpret_cast expression (C++ [expr.reinterpret.cast]).
Definition: ExprCXX.h:521
clang::TemplateArgument::pack_elements
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
Definition: TemplateBase.h:365
clang::TypeTraitExpr::getNumArgs
unsigned getNumArgs() const
Determine the number of arguments to this type trait.
Definition: ExprCXX.h:2731
clang::CXXConstructExpr::getNumArgs
unsigned getNumArgs() const
Return the number of arguments to the constructor call.
Definition: ExprCXX.h:1608
clang::ObjCMessageExpr::getSelector
Selector getSelector() const
Definition: ExprObjC.cpp:293
clang::OMPParallelMasterTaskLoopDirective
This represents '#pragma omp parallel master taskloop' directive.
Definition: StmtOpenMP.h:3852
clang::OMPTargetParallelGenericLoopDirective
This represents '#pragma omp target parallel loop' directive.
Definition: StmtOpenMP.h:5793
clang::PrintingPolicy::IncludeNewlines
unsigned IncludeNewlines
When true, include newlines after statements like "break", etc.
Definition: PrettyPrinter.h:237
clang::RequiresExpr::getRequirements
ArrayRef< concepts::Requirement * > getRequirements() const
Definition: ExprConcepts.h:518
clang::BlockDecl::param_empty
bool param_empty() const
Definition: Decl.h:4298
clang::DesignatedInitExpr
Represents a C99 designated initializer expression.
Definition: Expr.h:5029
clang::OMPTargetTeamsDistributeDirective
This represents '#pragma omp target teams distribute' combined directive.
Definition: StmtOpenMP.h:4825
clang::SubstNonTypeTemplateParmPackExpr
Represents a reference to a non-type template parameter pack that has been substituted with a non-tem...
Definition: ExprCXX.h:4329
clang::FunctionParmPackExpr::getParameterPack
VarDecl * getParameterPack() const
Get the parameter pack which this expression refers to.
Definition: ExprCXX.h:4426
clang::OMPTargetTeamsDistributeSimdDirective
This represents '#pragma omp target teams distribute simd' combined directive.
Definition: StmtOpenMP.h:5060
llvm::SmallVector
Definition: LLVM.h:38
clang::OMPCanonicalLoop
Representation of an OpenMP canonical loop.
Definition: StmtOpenMP.h:142
clang::MSPropertyRefExpr
A member reference to an MSPropertyDecl.
Definition: ExprCXX.h:923
clang::CXXNewExpr::CallInit
@ CallInit
New-expression has a C++98 paren-delimited initializer.
Definition: ExprCXX.h:2196
clang::ParenListExpr
Definition: Expr.h:5537
clang::OffsetOfNode::getKind
Kind getKind() const
Determine what kind of offsetof node this is.
Definition: Expr.h:2394
clang::OMPMasterDirective
This represents '#pragma omp master' directive.
Definition: StmtOpenMP.h:1971
clang::CXXNewExpr::getNumPlacementArgs
unsigned getNumPlacementArgs() const
Definition: ExprCXX.h:2292
clang::CastExpr::getSubExpr
Expr * getSubExpr()
Definition: Expr.h:3525
clang::NoInitExpr
Represents a place-holder for an object not to be initialized by anything.
Definition: Expr.h:5330
clang::CXXDeleteExpr::isArrayForm
bool isArrayForm() const
Definition: ExprCXX.h:2441
clang::OffsetOfNode::Array
@ Array
An index into an array.
Definition: Expr.h:2345
clang::OMPTaskwaitDirective
This represents '#pragma omp taskwait' directive.
Definition: StmtOpenMP.h:2551
ExpressionTraits.h
clang::Stmt::getSourceRange
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
Definition: Stmt.cpp:324
clang::ConceptReference::getNamedConcept
ConceptDecl * getNamedConcept() const
Definition: ASTConcept.h:152
clang::UnresolvedMemberExpr
Represents a C++ member access expression for which lookup produced a set of overloaded functions.
Definition: ExprCXX.h:3827
clang::QualType
A (possibly-)qualified type.
Definition: Type.h:675
Attr.h
clang::Selector::isUnarySelector
bool isUnarySelector() const
Definition: IdentifierTable.h:829
clang::ObjCBridgedCastExpr
An Objective-C "bridged" cast expression, which casts between Objective-C pointers and C pointers,...
Definition: ExprObjC.h:1625
AttributeLangSupport::C
@ C
Definition: SemaDeclAttr.cpp:55
clang::NestedNameSpecifier
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
Definition: NestedNameSpecifier.h:50
clang::CXXNewExpr::isArray
bool isArray() const
Definition: ExprCXX.h:2262
clang::OMPSectionDirective
This represents '#pragma omp section' directive.
Definition: StmtOpenMP.h:1858
clang::ento::ObjCMessageVisitKind::Pre
@ Pre
clang::TypeTraitExpr
A type trait used in the implementation of various C++11 and Library TR1 trait templates.
Definition: ExprCXX.h:2682
clang::GenericSelectionExpr::Association
AssociationTy< false > Association
Definition: Expr.h:5785
clang::CXXTypeidExpr
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
Definition: ExprCXX.h:839
clang::FieldDecl
Represents a member of a struct/union/class.
Definition: Decl.h:2855
clang::RequiresExpr
C++2a [expr.prim.req]: A requires-expression provides a concise way to express requirements on templa...
Definition: ExprConcepts.h:475
clang::PrinterHelper::~PrinterHelper
virtual ~PrinterHelper()
clang::ParmVarDecl
Represents a parameter to a function.
Definition: Decl.h:1680
DeclCXX.h
clang::OMPTeamsDistributeSimdDirective
This represents '#pragma omp teams distribute simd' combined directive.
Definition: StmtOpenMP.h:4542
clang::BinaryOperator::getOpcodeStr
StringRef getOpcodeStr() const
Definition: Expr.h:3872
clang::CXXNewExpr
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)".
Definition: ExprCXX.h:2139
clang::IfStmt
IfStmt - This represents an if/then/else.
Definition: Stmt.h:1908
clang::ObjCAtTryStmt
Represents Objective-C's @try ... @catch ... @finally statement.
Definition: StmtObjC.h:165
DeclOpenMP.h
clang::RecoveryExpr
Frontend produces RecoveryExprs on semantic errors that prevent creating other well-formed expression...
Definition: Expr.h:6421
clang::GotoStmt
GotoStmt - This represents a direct goto.
Definition: Stmt.h:2609
clang::StmtExpr::getSubStmt
CompoundStmt * getSubStmt()
Definition: Expr.h:4366
clang::InitListExpr
Describes an C or C++ initializer list.
Definition: Expr.h:4791
clang::ObjCMessageExpr::getInstanceReceiver
Expr * getInstanceReceiver()
Returns the object expression (receiver) for an instance message, or null for a message that is not a...
Definition: ExprObjC.h:1250
llvm::Optional
Definition: LLVM.h:40
clang::OffsetOfNode::getFieldName
IdentifierInfo * getFieldName() const
For a field or identifier offsetof node, returns the name of the field.
Definition: Expr.cpp:1585
clang::ExpressionTraitExpr::getTrait
ExpressionTrait getTrait() const
Definition: ExprCXX.h:2875
clang::Lexer::getSourceText
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:962
clang::UnaryOperator
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Definition: Expr.h:2163
clang::printTemplateArgumentList
void printTemplateArgumentList(raw_ostream &OS, ArrayRef< TemplateArgument > Args, const PrintingPolicy &Policy, const TemplateParameterList *TPL=nullptr)
Print a template argument list, including the '<' and '>' enclosing the template arguments.
Definition: TypePrinter.cpp:2122
clang::CoreturnStmt
Represents a 'co_return' statement in the C++ Coroutines TS.
Definition: StmtCXX.h:458
ExprOpenMP.h
clang::CXXStaticCastExpr
A C++ static_cast expression (C++ [expr.static.cast]).
Definition: ExprCXX.h:431
clang::ObjCForCollectionStmt
Represents Objective-C's collection statement.
Definition: StmtObjC.h:23
clang::PrintingPolicy
Describes how types, statements, expressions, and declarations should be printed.
Definition: PrettyPrinter.h:57
clang::index::SymbolRole::Call
@ Call
clang::ArrayInitLoopExpr
Represents a loop initializing the elements of an array.
Definition: Expr.h:5421
clang::FunctionType
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition: Type.h:3559
clang::CXXNewExpr::getAllocatedType
QualType getAllocatedType() const
Definition: ExprCXX.h:2232
clang::BlockDecl::param_iterator
MutableArrayRef< ParmVarDecl * >::iterator param_iterator
Definition: Decl.h:4295
clang::ObjCMessageExpr::SuperClass
@ SuperClass
The receiver is a superclass.
Definition: ExprObjC.h:1094
clang::CXXPseudoDestructorExpr::getDestroyedTypeIdentifier
IdentifierInfo * getDestroyedTypeIdentifier() const
In a dependent pseudo-destructor expression for which we do not have full type information on the des...
Definition: ExprCXX.h:2634
clang::ASTContext::getSourceManager
SourceManager & getSourceManager()
Definition: ASTContext.h:716
clang::ObjCMessageExpr::getArg
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
Definition: ExprObjC.h:1385
clang::ASTTemplateArgumentListInfo::arguments
llvm::ArrayRef< TemplateArgumentLoc > arguments() const
Definition: TemplateBase.h:640
isImplicitThis
static bool isImplicitThis(const Expr *E)
Definition: StmtPrinter.cpp:1458
clang::OMPTargetTeamsDistributeParallelForDirective
This represents '#pragma omp target teams distribute parallel for' combined directive.
Definition: StmtOpenMP.h:4891
clang::getTraitSpelling
const char * getTraitSpelling(ExpressionTrait T) LLVM_READONLY
Return the spelling of the type trait TT. Never null.
Definition: ExpressionTraits.cpp:33
clang::OpaqueValueExpr
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.
Definition: Expr.h:1135
clang::ObjCDictionaryElement::isPackExpansion
bool isPackExpansion() const
Determines whether this dictionary element is a pack expansion.
Definition: ExprObjC.h:278
clang::SEHTryStmt
Definition: Stmt.h:3412
clang::CXXRewrittenBinaryOperator::DecomposedForm::Opcode
BinaryOperatorKind Opcode
The original opcode, prior to rewriting.
Definition: ExprCXX.h:307
clang::CXXFoldExpr
Represents a folding of a pack over an operator.
Definition: ExprCXX.h:4591
clang::ObjCSubscriptRefExpr
ObjCSubscriptRefExpr - used for array and dictionary subscripting.
Definition: ExprObjC.h:841
clang::ObjCBoolLiteralExpr
ObjCBoolLiteralExpr - Objective-C Boolean Literal.
Definition: ExprObjC.h:88
clang::OMPTaskgroupDirective
This represents '#pragma omp taskgroup' directive.
Definition: StmtOpenMP.h:2602
Decl.h
clang::ObjCIndirectCopyRestoreExpr
ObjCIndirectCopyRestoreExpr - Represents the passing of a function argument by indirect copy-restore ...
Definition: ExprObjC.h:1566
clang::ConditionalOperator
ConditionalOperator - The ?: ternary operator.
Definition: Expr.h:4145
clang::FunctionProtoType::printExceptionSpecification
void printExceptionSpecification(raw_ostream &OS, const PrintingPolicy &Policy) const
Definition: TypePrinter.cpp:802
clang::CXXThrowExpr
A C++ throw-expression (C++ [except.throw]).
Definition: ExprCXX.h:1181
clang::ObjCArrayLiteral
ObjCArrayLiteral - used for objective-c array containers; as in: @["Hello", NSApp,...
Definition: ExprObjC.h:190
DeclObjC.h
clang::ArrayTypeTraitExpr::getTrait
ArrayTypeTrait getTrait() const
Definition: ExprCXX.h:2809
clang::UserDefinedLiteral::LOK_Template
@ LOK_Template
Raw form: operator "" X<cs...> ()
Definition: ExprCXX.h:671
clang::ObjCPropertyRefExpr
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
Definition: ExprObjC.h:614
clang::CXXTemporaryObjectExpr
Represents a C++ functional cast expression that builds a temporary object.
Definition: ExprCXX.h:1797
clang::FunctionParmPackExpr
Represents a reference to a function parameter pack or init-capture pack that has been substituted bu...
Definition: ExprCXX.h:4397
clang::TemplateArgumentList::get
const TemplateArgument & get(unsigned Idx) const
Retrieve the template argument at a given index.
Definition: DeclTemplate.h:282
clang::FixedPointLiteral
Definition: Expr.h:1537
PrettyPrinter.h
clang::OMPTargetExitDataDirective
This represents '#pragma omp target exit data' directive.
Definition: StmtOpenMP.h:3171
clang::OMPForSimdDirective
This represents '#pragma omp for simd' directive.
Definition: StmtOpenMP.h:1718
JsonSupport.h
clang::AttributedStmt
Represents an attribute applied to a statement.
Definition: Stmt.h:1850
clang::OMPParallelGenericLoopDirective
This represents '#pragma omp parallel loop' directive.
Definition: StmtOpenMP.h:5728
TemplateBase.h
clang::IntegerLiteral
Definition: Expr.h:1494
clang::ObjCAtCatchStmt
Represents Objective-C's @catch statement.
Definition: StmtObjC.h:77
clang::ConceptReference::getTemplateArgsAsWritten
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Definition: ASTConcept.h:156
clang::UnaryExprOrTypeTraitExpr
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand.
Definition: Expr.h:2549
clang::FloatingLiteral
Definition: Expr.h:1639
clang::ObjCArrayLiteral::children
child_range children()
Definition: ExprObjC.h:246
clang::CompoundStmt
CompoundStmt - This represents a group of statements like { stmt stmt }.
Definition: Stmt.h:1401
clang::ConvertVectorExpr
ConvertVectorExpr - Clang builtin function __builtin_convertvector This AST node provides support for...
Definition: Expr.h:4465
clang::ObjCSelectorExpr
ObjCSelectorExpr used for @selector in Objective-C.
Definition: ExprObjC.h:454
DeclTemplate.h
clang::MSPropertySubscriptExpr
MS property subscript expression.
Definition: ExprCXX.h:994
clang::CXXAddrspaceCastExpr
A C++ addrspace_cast expression (currently only enabled for OpenCL).
Definition: ExprCXX.h:600
clang::OMPParallelMasterDirective
This represents '#pragma omp parallel master' directive.
Definition: StmtOpenMP.h:2252
clang::UnresolvedLookupExpr
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
Definition: ExprCXX.h:3090
clang::Selector::getNameForSlot
StringRef getNameForSlot(unsigned argIndex) const
Retrieve the name at a given position in the selector.
Definition: IdentifierTable.cpp:514
clang::CXXRewrittenBinaryOperator
A rewritten comparison expression that was originally written using operator syntax.
Definition: ExprCXX.h:284
clang::UserDefinedLiteral::LOK_Character
@ LOK_Character
operator "" X (CharT)
Definition: ExprCXX.h:683
StmtOpenMP.h
clang::DependentCoawaitExpr
Represents a 'co_await' expression while the type of the promise is dependent.
Definition: ExprCXX.h:4821
clang::SizeOfPackExpr
Represents an expression that computes the length of a parameter pack.
Definition: ExprCXX.h:4144
clang::Stmt::printPretty
void printPretty(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation=0, StringRef NewlineSymbol="\n", const ASTContext *Context=nullptr) const
Definition: StmtPrinter.cpp:2635
Node
DynTypedNode Node
Definition: ASTMatchFinder.cpp:68
clang::CXXBindTemporaryExpr
Represents binding an expression to a temporary.
Definition: ExprCXX.h:1412
clang::BlockDecl
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Definition: Decl.h:4201
clang::BinaryOperator
A builtin binary operation expression such as "x + y" or "x <= y".
Definition: Expr.h:3807
clang::Decl::printGroup
static void printGroup(Decl **Begin, unsigned NumDecls, raw_ostream &Out, const PrintingPolicy &Policy, unsigned Indentation=0)
Definition: DeclPrinter.cpp:186
Id
int Id
Definition: ASTDiff.cpp:191
DeclBase.h
clang::CXXNewExpr::getInitializer
Expr * getInitializer()
The initializer of this new-expression.
Definition: ExprCXX.h:2331
clang::OMPTeamsDirective
This represents '#pragma omp teams' directive.
Definition: StmtOpenMP.h:3400
clang::LambdaExpr
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
Definition: ExprCXX.h:1865
clang::ObjCAtThrowStmt
Represents Objective-C's @throw statement.
Definition: StmtObjC.h:357
OperatorKinds.h
clang::ObjCStringLiteral
ObjCStringLiteral, used for Objective-C string literals i.e.
Definition: ExprObjC.h:52
clang::threadSafety::sx::toString
std::string toString(const til::SExpr *E)
Definition: ThreadSafetyCommon.h:90
clang::ObjCDictionaryElement::Key
Expr * Key
The key for the dictionary element.
Definition: ExprObjC.h:265
clang::CXXFoldExpr::getLHS
Expr * getLHS() const
Definition: ExprCXX.h:4625
clang::ConceptSpecializationExpr
Represents the specialization of a concept - evaluates to a prvalue of type bool.
Definition: ExprConcepts.h:40
clang::OMPScanDirective
This represents '#pragma omp scan' directive.
Definition: StmtOpenMP.h:5274
clang::MaterializeTemporaryExpr
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
Definition: ExprCXX.h:4479
clang::ASTContext
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:208
clang::ObjCDictionaryLiteral
ObjCDictionaryLiteral - AST node to represent objective-c dictionary literals; as in:"name" : NSUserN...
Definition: ExprObjC.h:306
clang::OMPMetaDirective
This represents '#pragma omp metadirective' directive.
Definition: StmtOpenMP.h:5496
NestedNameSpecifier.h
clang::UnaryOperator::getOpcodeStr
static StringRef getOpcodeStr(Opcode Op)
getOpcodeStr - Turn an Opcode enum value into the punctuation char it corresponds to,...
Definition: Expr.cpp:1305
clang::syntax::NodeRole::Qualifier
@ Qualifier
clang::CXXConstructExpr::arg_iterator
ExprIterator arg_iterator
Definition: ExprCXX.h:1587
clang::Selector::getNumArgs
unsigned getNumArgs() const
Definition: IdentifierTable.cpp:492
TypeTraits.h
clang::IfStmt::getConditionVariableDeclStmt
DeclStmt * getConditionVariableDeclStmt()
If this IfStmt has a condition variable, return the faux DeclStmt associated with the creation of tha...
Definition: Stmt.h:2043
clang::BuiltinBitCastExpr
Represents a C++2a __builtin_bit_cast(T, v) expression.
Definition: ExprCXX.h:4894
clang::TemplateArgument
Represents a template argument.
Definition: TemplateBase.h:61
clang::ConceptReference::getTemplateKWLoc
SourceLocation getTemplateKWLoc() const
Definition: ASTConcept.h:146
OpenMPKinds.h
clang::concepts::Requirement
A static requirement that can be used in a requires-expression to check properties of types and expre...
Definition: ExprConcepts.h:149
clang::OMPDistributeParallelForSimdDirective
This represents '#pragma omp distribute parallel for simd' composite directive.
Definition: StmtOpenMP.h:4213
clang::ForStmt
ForStmt - This represents a 'for (init;cond;inc)' stmt.
Definition: Stmt.h:2538
clang::ObjCAvailabilityCheckExpr
A runtime availability query.
Definition: ExprObjC.h:1686
clang::CXXNewExpr::InitializationStyle
InitializationStyle
Definition: ExprCXX.h:2191
clang::StmtVisitorBase< std::add_pointer, ImplClass, void, ParamTys... >::Visit
void Visit(PTR(Stmt) S, ParamTys... P)
Definition: StmtVisitor.h:43
clang::OMPDepobjDirective
This represents '#pragma omp depobj' directive.
Definition: StmtOpenMP.h:2721
clang::PseudoObjectExpr
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
Definition: Expr.h:6100
clang::ObjCAtSynchronizedStmt
Represents Objective-C's @synchronized statement.
Definition: StmtObjC.h:302
clang::ObjCMessageExpr::getReceiverKind
ReceiverKind getReceiverKind() const
Determine the kind of receiver that this message is being sent to.
Definition: ExprObjC.h:1224
clang::BinaryConditionalOperator
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
Definition: Expr.h:4207
clang::CXXPseudoDestructorExpr::getQualifier
NestedNameSpecifier * getQualifier() const
If the member name was qualified, retrieves the nested-name-specifier that precedes the member name.
Definition: ExprCXX.h:2591
IdentifierTable.h
clang::ArrayTypeTraitExpr::getQueriedType
QualType getQueriedType() const
Definition: ExprCXX.h:2811
clang::CXXStdInitializerListExpr::getSubExpr
Expr * getSubExpr()
Definition: ExprCXX.h:807
Type.h
clang::ObjCMessageExpr::Class
@ Class
The receiver is a class.
Definition: ExprObjC.h:1088
clang::UserDefinedLiteral::LOK_Integer
@ LOK_Integer
operator "" X (unsigned long long)
Definition: ExprCXX.h:674
Expr.h
llvm::SmallString< 16 >
clang::ImplicitValueInitExpr
Represents an implicitly-generated value initialization of an object of a given type.
Definition: Expr.h:5510
clang::OMPParallelDirective
This represents '#pragma omp parallel' directive.
Definition: StmtOpenMP.h:611
ASTContext.h
clang::LCD_ByCopy
@ LCD_ByCopy
Definition: Lambda.h:24
clang::CXXDynamicCastExpr
A C++ dynamic_cast expression (C++ [expr.dynamic.cast]).
Definition: ExprCXX.h:477
clang::OMPParallelForSimdDirective
This represents '#pragma omp parallel for simd' directive.
Definition: StmtOpenMP.h:2187
clang::VarDecl
Represents a variable declaration or definition.
Definition: Decl.h:874
clang::OMPTaskDirective
This represents '#pragma omp task' directive.
Definition: StmtOpenMP.h:2397
clang::PrinterHelper
Definition: PrettyPrinter.h:25
clang::ConceptReference::getFoundDecl
NamedDecl * getFoundDecl() const
Definition: ASTConcept.h:148
clang::PrintingPolicy::ConstantsAsWritten
unsigned ConstantsAsWritten
Whether we should print the constant expressions as written in the sources.
Definition: PrettyPrinter.h:260
clang::TemplateParameterList
Stores a list of template parameters for a TemplateDecl and its derived classes.
Definition: DeclTemplate.h:69
clang::StringLiteral
StringLiteral - This represents a string literal expression, e.g.
Definition: Expr.h:1767
clang::OMPTargetParallelDirective
This represents '#pragma omp target parallel' directive.
Definition: StmtOpenMP.h:3225
clang::ExprWithCleanups
Represents an expression – generally a full-expression – that introduces cleanups to be run at the en...
Definition: ExprCXX.h:3359
clang::CapturedStmt
This captures a statement into a function.
Definition: Stmt.h:3504
clang::ObjCAtFinallyStmt
Represents Objective-C's @finally statement.
Definition: StmtObjC.h:127
clang::OMPParallelForDirective
This represents '#pragma omp parallel for' directive.
Definition: StmtOpenMP.h:2090
clang::getOperatorSpelling
const char * getOperatorSpelling(OverloadedOperatorKind Operator)
Retrieve the spelling of the given overloaded operator, without the preceding "operator" keyword.
Definition: IdentifierTable.cpp:747
clang::IfStmt::getElse
Stmt * getElse()
Definition: Stmt.h:2008
clang::CXXTryStmt
CXXTryStmt - A C++ try block, including all handlers.
Definition: StmtCXX.h:68
ExprObjC.h
clang::NestedNameSpecifierLoc
A C++ nested-name-specifier augmented with source location information.
Definition: NestedNameSpecifier.h:243
ExprCXX.h
clang::LCD_None
@ LCD_None
Definition: Lambda.h:23
clang::RequiresExpr::getLocalParameters
ArrayRef< ParmVarDecl * > getLocalParameters() const
Definition: ExprConcepts.h:512
clang::ObjCEncodeExpr
ObjCEncodeExpr, used for @encode in Objective-C.
Definition: ExprObjC.h:409
clang::Stmt::child_range
llvm::iterator_range< child_iterator > child_range
Definition: Stmt.h:1249
clang::CXXInheritedCtorInitExpr
Represents a call to an inherited base class constructor from an inheriting constructor.
Definition: ExprCXX.h:1651
clang::CXXDefaultArgExpr
A default argument (C++ [dcl.fct.default]).
Definition: ExprCXX.h:1241
clang::PackExpansionExpr
Represents a C++11 pack expansion that produces a sequence of expressions.
Definition: ExprCXX.h:4068
clang::OMPCriticalDirective
This represents '#pragma omp critical' directive.
Definition: StmtOpenMP.h:2019
clang::OMPTargetTeamsGenericLoopDirective
This represents '#pragma omp target teams loop' directive.
Definition: StmtOpenMP.h:5662
clang::OMPTargetParallelForSimdDirective
This represents '#pragma omp target parallel for simd' directive.
Definition: StmtOpenMP.h:4344
clang::OMPMasterTaskLoopDirective
This represents '#pragma omp master taskloop' directive.
Definition: StmtOpenMP.h:3710
clang::ConstantExpr
ConstantExpr - An expression that occurs in a constant context and optionally the result of evaluatin...
Definition: Expr.h:1032
getKind
static Decl::Kind getKind(const Decl *D)
Definition: DeclBase.cpp:1008
clang::ento::ObjCMessageVisitKind::Post
@ Post
clang::ObjCMessageExpr
An expression that sends a message to the given Objective-C object or class.
Definition: ExprObjC.h:940
clang::OMPTeamsDistributeDirective
This represents '#pragma omp teams distribute' directive.
Definition: StmtOpenMP.h:4476
clang::OffsetOfNode
Helper class for OffsetOfExpr.
Definition: Expr.h:2340
clang::PrintingPolicy::TerseOutput
unsigned TerseOutput
Provide a 'terse' output.
Definition: PrettyPrinter.h:221
clang::OverloadedOperatorKind
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
Definition: OperatorKinds.h:21
StmtObjC.h
clang::ChooseExpr
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
Definition: Expr.h:4524
clang::PrinterHelper::handledStmt
virtual bool handledStmt(Stmt *E, raw_ostream &OS)=0
clang::CXXFoldExpr::getOperator
BinaryOperatorKind getOperator() const
Definition: ExprCXX.h:4645
clang::SEHExceptStmt
Definition: Stmt.h:3333
clang::CXXFoldExpr::getRHS
Expr * getRHS() const
Definition: ExprCXX.h:4626
clang::ExpressionTraitExpr::getQueriedExpression
Expr * getQueriedExpression() const
Definition: ExprCXX.h:2877
clang::TemplateDecl::getTemplateParameters
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Definition: DeclTemplate.h:419
clang::OMPArrayShapingExpr
An explicit cast in C or a C-style cast in C++, which uses the syntax ([s1][s2]......
Definition: ExprOpenMP.h:146
clang::SelectorTable::getPropertyNameFromSetterSelector
static std::string getPropertyNameFromSetterSelector(Selector Sel)
Return the property name for the given setter selector.
Definition: IdentifierTable.cpp:702
clang::TemplateArgumentList::asArray
ArrayRef< TemplateArgument > asArray() const
Produce this as an array ref.
Definition: DeclTemplate.h:291
clang::FullExpr::getSubExpr
const Expr * getSubExpr() const
Definition: Expr.h:1017
clang::PredefinedExpr::getIdentKindName
StringRef getIdentKindName() const
Definition: Expr.h:2027
clang::CharacterLiteral
Definition: Expr.h:1584
clang::UserDefinedLiteral
A call to a literal operator (C++11 [over.literal]) written as a user-defined literal (C++11 [lit....
Definition: ExprCXX.h:638
clang::OffsetOfNode::getArrayExprIndex
unsigned getArrayExprIndex() const
For an array element node, returns the index into the array of expressions.
Definition: Expr.h:2398
clang::Type::castAs
const T * castAs() const
Member-template castAs<specific type>.
Definition: Type.h:7310
clang::transformer::EditKind::Range
@ Range
clang::OMPCancelDirective
This represents '#pragma omp cancel' directive.
Definition: StmtOpenMP.h:3511
clang::CompoundLiteralExpr
CompoundLiteralExpr - [C99 6.5.2.5].
Definition: Expr.h:3405
clang::ObjCDictionaryLiteral::getKeyValueElement
ObjCDictionaryElement getKeyValueElement(unsigned Index) const
Definition: ExprObjC.h:362
clang::OMPSectionsDirective
This represents '#pragma omp sections' directive.
Definition: StmtOpenMP.h:1781
clang::OMPTargetTeamsDistributeParallelForSimdDirective
This represents '#pragma omp target teams distribute parallel for simd' combined directive.
Definition: StmtOpenMP.h:4989
clang::CStyleCastExpr
CStyleCastExpr - An explicit cast in C (C99 6.5.4) or a C-style cast in C++ (C++ [expr....
Definition: Expr.h:3735
clang::GCCAsmStmt
This represents a GCC inline-assembly statement extension.
Definition: Stmt.h:3006
SourceLocation.h
clang::OMPDependClause
This represents implicit clause 'depend' for the '#pragma omp task' directive.
Definition: OpenMPClause.h:4742
clang::OMPFlushDirective
This represents '#pragma omp flush' directive.
Definition: StmtOpenMP.h:2669
clang::Indent
raw_ostream & Indent(raw_ostream &Out, const unsigned int Space, bool IsDot)
Definition: JsonSupport.h:21
clang::UserDefinedLiteral::LOK_String
@ LOK_String
operator "" X (const CharT *, size_t)
Definition: ExprCXX.h:680
P
StringRef P
Definition: ASTMatchersInternal.cpp:563
clang::OMPTargetEnterDataDirective
This represents '#pragma omp target enter data' directive.
Definition: StmtOpenMP.h:3116
clang::DesignatedInitUpdateExpr
Definition: Expr.h:5367
clang::IfStmt::isNegatedConsteval
bool isNegatedConsteval() const
Definition: Stmt.h:2094
clang::LCD_ByRef
@ LCD_ByRef
Definition: Lambda.h:25
clang::NestedNameSpecifier::print
void print(raw_ostream &OS, const PrintingPolicy &Policy, bool ResolveTemplateArguments=false) const
Print this nested name specifier to the given output stream.
Definition: NestedNameSpecifier.cpp:252
clang::PrintingPolicy::Alignof
unsigned Alignof
Whether we can use 'alignof' rather than '__alignof'.
Definition: PrettyPrinter.h:203
CharInfo.h
PrintFloatingLiteral
static void PrintFloatingLiteral(raw_ostream &OS, FloatingLiteral *Node, bool PrintSuffix)
Definition: StmtPrinter.cpp:1228
clang::OMPIteratorExpr::IteratorRange
Iterator range representation begin:end[:step].
Definition: ExprOpenMP.h:278
clang::OMPInteropDirective
This represents '#pragma omp interop' directive.
Definition: StmtOpenMP.h:5327
clang::OMPDistributeDirective
This represents '#pragma omp distribute' directive.
Definition: StmtOpenMP.h:3995
clang::PrintingPolicy::Indentation
unsigned Indentation
The number of spaces to use to indent each line.
Definition: PrettyPrinter.h:91
clang::OMPTeamsGenericLoopDirective
This represents '#pragma omp teams loop' directive.
Definition: StmtOpenMP.h:5597
clang::LCK_ByRef
@ LCK_ByRef
Capturing by reference.
Definition: Lambda.h:37
clang::OMPSingleDirective
This represents '#pragma omp single' directive.
Definition: StmtOpenMP.h:1920
clang::IfStmt::isConsteval
bool isConsteval() const
Definition: Stmt.h:2085
clang::ParenExpr
ParenExpr - This represents a parethesized expression, e.g.
Definition: Expr.h:2112
clang::CoyieldExpr
Represents a 'co_yield' expression.
Definition: ExprCXX.h:4870
clang::FunctionProtoType
Represents a prototype with parameter type info, e.g.
Definition: Type.h:3898
clang::ObjCProtocolExpr
ObjCProtocolExpr used for protocol expression in Objective-C.
Definition: ExprObjC.h:504
clang::CharSourceRange::getTokenRange
static CharSourceRange getTokenRange(SourceRange R)
Definition: SourceLocation.h:261
clang::DynTypedNode::print
void print(llvm::raw_ostream &OS, const PrintingPolicy &PP) const
Prints the node to the given output stream.
Definition: ASTTypeTraits.cpp:171
clang::CXXDeleteExpr
Represents a delete expression for memory deallocation and destructor calls, e.g.
Definition: ExprCXX.h:2415
clang::Stmt::printJson
void printJson(raw_ostream &Out, PrinterHelper *Helper, const PrintingPolicy &Policy, bool AddQuotes) const
Pretty-prints in JSON format.
Definition: StmtPrinter.cpp:2650
clang::QualType::isNull
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Definition: Type.h:740
clang::BlockExpr
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Definition: Expr.h:5970
clang::StmtExpr
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
Definition: Expr.h:4349
llvm::ArrayRef
Definition: LLVM.h:34
clang::OMPTaskLoopDirective
This represents '#pragma omp taskloop' directive.
Definition: StmtOpenMP.h:3571
Lexer.h
clang::Decl
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:83
clang::OffsetOfNode::Base
@ Base
An implicit indirection through a C++ base class, when the field found is in a base class.
Definition: Expr.h:2352
OpenMPClause.h
clang::AddrLabelExpr
AddrLabelExpr - The GNU address of label extension, representing &&label.
Definition: Expr.h:4304
clang::CXXFunctionalCastExpr
Represents an explicit C++ type conversion that uses "functional" notation (C++ [expr....
Definition: ExprCXX.h:1726
clang::DesignatedInitExpr::Designator
Represents a single C99 designator.
Definition: Expr.h:5104
clang::LCK_StarThis
@ LCK_StarThis
Capturing the *this object by copy.
Definition: Lambda.h:35
clang::ArraySubscriptExpr
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
Definition: Expr.h:2645
clang::CXXUuidofExpr
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
Definition: ExprCXX.h:1056
clang::DependentScopeDeclRefExpr
A qualified reference to a name whose declaration cannot yet be resolved.
Definition: ExprCXX.h:3208
clang::DoStmt
DoStmt - This represents a 'do/while' stmt.
Definition: Stmt.h:2482
clang::RISCV::Float
@ Float
Definition: RISCVVIntrinsicUtils.h:147
StmtVisitor.h
LLVM.h
clang::CXXNullPtrLiteralExpr
The null pointer literal (C++11 [lex.nullptr])
Definition: ExprCXX.h:759
clang::CoroutineBodyStmt
Represents the body of a coroutine.
Definition: StmtCXX.h:317
clang::Selector::getIdentifierInfoForSlot
IdentifierInfo * getIdentifierInfoForSlot(unsigned argIndex) const
Retrieve the identifier at a given position in the selector.
Definition: IdentifierTable.cpp:503
clang::CoawaitExpr
Represents a 'co_await' expression.
Definition: ExprCXX.h:4789
clang::BreakStmt
BreakStmt - This represents a break.
Definition: Stmt.h:2727
clang::PrintingPolicy::SuppressImplicitBase
unsigned SuppressImplicitBase
When true, don't print the implicit 'self' or 'this' expressions.
Definition: PrettyPrinter.h:263
clang::OMPCancellationPointDirective
This represents '#pragma omp cancellation point' directive.
Definition: StmtOpenMP.h:3453
clang::UserDefinedLiteral::LOK_Raw
@ LOK_Raw
Raw form: operator "" X (const char *)
Definition: ExprCXX.h:668
clang::OMPDispatchDirective
This represents '#pragma omp dispatch' directive.
Definition: StmtOpenMP.h:5380
clang::TemplateArgumentList
A template argument list.
Definition: DeclTemplate.h:237
clang::CXXDependentScopeMemberExpr
Represents a C++ member access expression where the actual member referenced could not be resolved be...
Definition: ExprCXX.h:3567
clang::ImplicitParamDecl::ObjCSelf
@ ObjCSelf
Parameter for Objective-C 'self' argument.
Definition: Decl.h:1622
clang::CompoundAssignOperator
CompoundAssignOperator - For compound assignments (e.g.
Definition: Expr.h:4054
clang::CXXRewrittenBinaryOperator::DecomposedForm::RHS
const Expr * RHS
The original right-hand side.
Definition: ExprCXX.h:311
clang::VarDecl::getInit
const Expr * getInit() const
Definition: Decl.h:1283
clang::AutoTypeKeyword::Auto
@ Auto
auto
clang::CXXNoexceptExpr
Represents a C++11 noexcept expression (C++ [expr.unary.noexcept]).
Definition: ExprCXX.h:4014
clang::CXXUnresolvedConstructExpr
Describes an explicit type conversion that uses functional notion but could not be resolved because o...
Definition: ExprCXX.h:3445
clang::IdentifierInfo
One of these records is kept for each identifier that is lexed.
Definition: IdentifierTable.h:84
clang::PrintingPolicy::UnderscoreAlignof
unsigned UnderscoreAlignof
Whether we can use '_Alignof' rather than '__alignof'.
Definition: PrettyPrinter.h:206
clang::IfStmt::getInit
Stmt * getInit()
Definition: Stmt.h:2055
clang::OMPExecutableDirective
This is a basic class for representing single OpenMP executable directive.
Definition: StmtOpenMP.h:266
clang::CXXForRangeStmt
CXXForRangeStmt - This represents C++0x [stmt.ranged]'s ranged for statement, represented as 'for (ra...
Definition: StmtCXX.h:134
Lambda.h
clang::ObjCPropertyAttribute::Kind
Kind
Definition: DeclObjCCommon.h:22
clang::DeclStmt
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
Definition: Stmt.h:1294
clang::ContinueStmt
ContinueStmt - This represents a continue.
Definition: Stmt.h:2697
clang::BuiltinType::getKind
Kind getKind() const
Definition: Type.h:2539
clang::LCK_ByCopy
@ LCK_ByCopy
Capturing by copy (a.k.a., by value)
Definition: Lambda.h:36
clang::IfStmt::getCond
Expr * getCond()
Definition: Stmt.h:1987
clang::LCK_VLAType
@ LCK_VLAType
Capturing variable-length array type.
Definition: Lambda.h:38
clang::CXXConstCastExpr
A C++ const_cast expression (C++ [expr.const.cast]).
Definition: ExprCXX.h:562
clang::CXXThisExpr
Represents the this expression in C++.
Definition: ExprCXX.h:1142
clang::ExtVectorElementExpr
ExtVectorElementExpr - This represents access to specific elements of a vector, and may occur on the ...
Definition: Expr.h:5910
clang::OMPTeamsDistributeParallelForDirective
This represents '#pragma omp teams distribute parallel for' composite directive.
Definition: StmtOpenMP.h:4676
clang::TypoExpr
TypoExpr - Internal placeholder for expressions where typo correction still needs to be performed and...
Definition: Expr.h:6367
clang::PredefinedExpr
[C99 6.4.2.2] - A predefined identifier such as func.
Definition: Expr.h:1959
clang::MSDependentExistsStmt
Representation of a Microsoft __if_exists or __if_not_exists statement with a dependent name.
Definition: StmtCXX.h:252
clang::SEHFinallyStmt
Definition: Stmt.h:3377
clang::CUDAKernelCallExpr
Represents a call to a CUDA kernel function.
Definition: ExprCXX.h:232
clang::ObjCMessageExpr::Instance
@ Instance
The receiver is an object instance.
Definition: ExprObjC.h:1091
clang::VarDecl::CInit
@ CInit
C-style initialization with assignment.
Definition: Decl.h:879
clang::OMPSimdDirective
This represents '#pragma omp simd' directive.
Definition: StmtOpenMP.h:1565
clang::IdentifierInfo::getName
StringRef getName() const
Return the actual identifier string.
Definition: IdentifierTable.h:195
printExprAsWritten
static bool printExprAsWritten(raw_ostream &OS, Expr *E, const ASTContext *Context)
Prints the given expression using the original source text.
Definition: StmtPrinter.cpp:1159
isImplicitSelf
static bool isImplicitSelf(const Expr *E)
Definition: StmtPrinter.cpp:1093
clang::OMPArraySectionExpr
OpenMP 5.0 [2.1.5, Array Sections].
Definition: ExprOpenMP.h:56
clang
Definition: CalledOnceCheck.h:17
clang::Selector
Smart pointer class that efficiently represents Objective-C method names.
Definition: IdentifierTable.h:752
clang::BlockDecl::param_end
param_iterator param_end()
Definition: Decl.h:4300
clang::OMPTargetTeamsDirective
This represents '#pragma omp target teams' directive.
Definition: StmtOpenMP.h:4769
clang::Stmt
Stmt - This represents one statement.
Definition: Stmt.h:69
clang::OMPDistributeParallelForDirective
This represents '#pragma omp distribute parallel for' composite directive.
Definition: StmtOpenMP.h:4117
clang::DefaultStmt
Definition: Stmt.h:1727
clang::ObjCAutoreleasePoolStmt
Represents Objective-C's @autoreleasepool Statement.
Definition: StmtObjC.h:393
clang::CXXNewExpr::isParenTypeId
bool isParenTypeId() const
Definition: ExprCXX.h:2309
clang::CXXCatchStmt
CXXCatchStmt - This represents a C++ catch block.
Definition: StmtCXX.h:28
clang::Decl::print
void print(raw_ostream &Out, unsigned Indentation=0, bool PrintInstantiation=false) const
Definition: DeclPrinter.cpp:124
clang::CXXNewExpr::isGlobalNew
bool isGlobalNew() const
Definition: ExprCXX.h:2315
clang::GenericSelectionExpr
Represents a C11 generic selection.
Definition: Expr.h:5628
clang::CXXScalarValueInitExpr
An expression "T()" which creates a value-initialized rvalue of type T, which is a non-class type.
Definition: ExprCXX.h:2093
clang::ObjCIsaExpr
ObjCIsaExpr - Represent X->isa and X.isa when X is an ObjC 'id' type.
Definition: ExprObjC.h:1482
clang::NestedNameSpecifierLoc::getNestedNameSpecifier
NestedNameSpecifier * getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
Definition: NestedNameSpecifier.h:274
clang::Expr::getType
QualType getType() const
Definition: Expr.h:141
clang::SourceLocation::isValid
bool isValid() const
Return true if this is a valid SourceLocation object.
Definition: SourceLocation.h:110
clang::Attr
Attr - This represents one attribute.
Definition: Attr.h:41
clang::TypeSourceInfo
A container of type source information.
Definition: Type.h:6471
clang::OMPUnrollDirective
This represents the '#pragma omp unroll' loop transformation directive.
Definition: StmtOpenMP.h:5200
s
__device__ __2f16 float bool s
Definition: __clang_hip_libdevice_declares.h:315
clang::JsonFormat
std::string JsonFormat(StringRef RawSR, bool AddQuotes)
Definition: JsonSupport.h:28
clang::CXXNamedCastExpr
Abstract class common to all of the C++ "named"/"keyword" casts.
Definition: ExprCXX.h:373
clang::CXXPseudoDestructorExpr::getBase
Expr * getBase() const
Definition: ExprCXX.h:2577
clang::CXXDeleteExpr::getArgument
Expr * getArgument()
Definition: ExprCXX.h:2456
clang::IfStmt::getThen
Stmt * getThen()
Definition: Stmt.h:1999
clang::LCK_This
@ LCK_This
Capturing the *this object by reference.
Definition: Lambda.h:34
clang::CXXNewExpr::NoInit
@ NoInit
New-expression has no initializer as written.
Definition: ExprCXX.h:2193
clang::FunctionDecl::isVariadic
bool isVariadic() const
Whether this function is variadic.
Definition: Decl.cpp:2980
clang::OMPTargetDirective
This represents '#pragma omp target' directive.
Definition: StmtOpenMP.h:3008
clang::OMPGenericLoopDirective
This represents '#pragma omp loop' directive.
Definition: StmtOpenMP.h:5535
clang::OMPTargetUpdateDirective
This represents '#pragma omp target update' directive.
Definition: StmtOpenMP.h:4061
clang::CXXPseudoDestructorExpr::isArrow
bool isArrow() const
Determine whether this pseudo-destructor expression was written using an '->' (otherwise,...
Definition: ExprCXX.h:2597
clang::ImplicitCastExpr
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
Definition: Expr.h:3619
clang::VAArgExpr
Represents a call to the builtin function __builtin_va_arg.
Definition: Expr.h:4633
clang::OMPOrderedDirective
This represents '#pragma omp ordered' directive.
Definition: StmtOpenMP.h:2773
clang::SourceLocExpr
Represents a function call to one of __builtin_LINE(), __builtin_COLUMN(), __builtin_FUNCTION(),...
Definition: Expr.h:4682
clang::MemberExpr
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Definition: Expr.h:3164
clang::ConceptReference::getNestedNameSpecifierLoc
const NestedNameSpecifierLoc & getNestedNameSpecifierLoc() const
Definition: ASTConcept.h:136
clang::OMPDistributeSimdDirective
This represents '#pragma omp distribute simd' composite directive.
Definition: StmtOpenMP.h:4278
clang::CXXDeleteExpr::isGlobalDelete
bool isGlobalDelete() const
Definition: ExprCXX.h:2440
clang::UserDefinedLiteral::LOK_Floating
@ LOK_Floating
operator "" X (long double)
Definition: ExprCXX.h:677
Stmt.h
clang::QualType::print
void print(raw_ostream &OS, const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) const
Definition: TypePrinter.cpp:2288
clang::CXXConstructExpr::getArg
Expr * getArg(unsigned Arg)
Return the specified argument.
Definition: ExprCXX.h:1611
clang::StringLiteral::outputString
void outputString(raw_ostream &OS) const
Definition: Expr.cpp:1124
clang::OMPParallelMasterTaskLoopSimdDirective
This represents '#pragma omp parallel master taskloop simd' directive.
Definition: StmtOpenMP.h:3930
clang::GNUNullExpr
GNUNullExpr - Implements the GNU __null extension, which is a name for a null pointer constant that h...
Definition: Expr.h:4599
clang::CXXStdInitializerListExpr
Implicit construction of a std::initializer_list<T> object from an array temporary within list-initia...
Definition: ExprCXX.h:791
clang::CXXNewExpr::getArraySize
Optional< Expr * > getArraySize()
This might return None even if isArray() returns true, since there might not be an array size express...
Definition: ExprCXX.h:2267
clang::ObjCMessageExpr::getNumArgs
unsigned getNumArgs() const
Return the number of actual arguments in this message, not counting the receiver.
Definition: ExprObjC.h:1372
clang::ObjCMessageExpr::getClassReceiver
QualType getClassReceiver() const
Returns the type of a class message send, or NULL if the message is not a class message.
Definition: ExprObjC.h:1269
clang::VarDecl::getInitStyle
InitializationStyle getInitStyle() const
The style of initialization for this declaration.
Definition: Decl.h:1374
clang::ValueDecl::getType
QualType getType() const
Definition: Decl.h:685
clang::Expr
This represents one expression.
Definition: Expr.h:109
clang::OMPClausePrinter
Definition: OpenMPClause.h:8761
clang::CXXConstructExpr::isListInitialization
bool isListInitialization() const
Whether this constructor call was written as list-initialization.
Definition: ExprCXX.h:1551
clang::Stmt::printPrettyControlled
void printPrettyControlled(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation=0, StringRef NewlineSymbol="\n", const ASTContext *Context=nullptr) const
Definition: StmtPrinter.cpp:2642
clang::CXXNewExpr::getPlacementArg
Expr * getPlacementArg(unsigned I)
Definition: ExprCXX.h:2301
clang::OMPTargetDataDirective
This represents '#pragma omp target data' directive.
Definition: StmtOpenMP.h:3062
clang::CXXDefaultInitExpr
A use of a default initializer in a constructor or in aggregate initialization.
Definition: ExprCXX.h:1318
clang::ObjCDictionaryElement::Value
Expr * Value
The value of the dictionary element.
Definition: ExprObjC.h:268
clang::OMPTargetSimdDirective
This represents '#pragma omp target simd' directive.
Definition: StmtOpenMP.h:4411
clang::ObjCBoxedExpr::getSubExpr
Expr * getSubExpr()
Definition: ExprObjC.h:144
clang::FunctionDecl::parameters
ArrayRef< ParmVarDecl * > parameters() const
Definition: Decl.h:2503
clang::FieldDecl::isAnonymousStructOrUnion
bool isAnonymousStructOrUnion() const
Determines whether this field is a representative for an anonymous struct or union.
Definition: Decl.cpp:4248
clang::MSAsmStmt
This represents a Microsoft inline-assembly statement extension.
Definition: Stmt.h:3229
clang::TemplateArgumentList::size
unsigned size() const
Retrieve the number of template arguments in this template argument list.
Definition: DeclTemplate.h:297
clang::DeclRefExpr
A reference to a declared variable, function, enum, etc.
Definition: Expr.h:1223
clang::OMPTaskLoopSimdDirective
This represents '#pragma omp taskloop simd' directive.
Definition: StmtOpenMP.h:3644
clang::OMPTargetParallelForDirective
This represents '#pragma omp target parallel for' directive.
Definition: StmtOpenMP.h:3305
clang::CXXNoexceptExpr::getOperand
Expr * getOperand() const
Definition: ExprCXX.h:4031
clang::CallExpr
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition: Expr.h:2801
clang::OMPParallelSectionsDirective
This represents '#pragma omp parallel sections' directive.
Definition: StmtOpenMP.h:2316
clang::TypeTraitExpr::getTrait
TypeTrait getTrait() const
Determine which type trait this expression uses.
Definition: ExprCXX.h:2721
clang::CXXOperatorCallExpr
A call to an overloaded operator written using operator syntax.
Definition: ExprCXX.h:82
clang::ShuffleVectorExpr
ShuffleVectorExpr - clang-specific builtin-in function __builtin_shufflevector.
Definition: Expr.h:4397
StmtCXX.h
clang::CXXConstructExpr
Represents a call to a C++ constructor.
Definition: ExprCXX.h:1460
clang::ObjCIvarRefExpr
ObjCIvarRefExpr - A reference to an ObjC instance variable.
Definition: ExprObjC.h:548
clang::OMPAtomicDirective
This represents '#pragma omp atomic' directive.
Definition: StmtOpenMP.h:2827
clang::Attr::printPretty
void printPretty(raw_ostream &OS, const PrintingPolicy &Policy) const
clang::ASTContext::getLangOpts
const LangOptions & getLangOpts() const
Definition: ASTContext.h:786
clang::CXXMemberCallExpr
Represents a call to a member function that may be written either with member call syntax (e....
Definition: ExprCXX.h:177
clang::ObjCIndirectCopyRestoreExpr::getSubExpr
Expr * getSubExpr()
Definition: ExprObjC.h:1589
clang::ento::ObjKind::OS
@ OS
Indicates that the tracking object is a descendant of a referenced-counted OSObject,...
clang::ReturnStmt
ReturnStmt - This represents a return, optionally of an expression: return; return 4;.
Definition: Stmt.h:2764
clang::CXXConstructExpr::isStdInitListInitialization
bool isStdInitListInitialization() const
Whether this constructor call was written as list-initialization, but was interpreted as forming a st...
Definition: ExprCXX.h:1562
clang::BlockDecl::param_begin
param_iterator param_begin()
Definition: Decl.h:4299
clang::VarDecl::CallInit
@ CallInit
Call-style initialization (C++98)
Definition: Decl.h:882
clang::CharacterLiteral::print
static void print(unsigned val, CharacterKind Kind, raw_ostream &OS)
Definition: Expr.cpp:945
clang::SEHLeaveStmt
Represents a __leave statement.
Definition: Stmt.h:3465
clang::CXXMethodDecl
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:1968
clang::OMPTeamsDistributeParallelForSimdDirective
This represents '#pragma omp teams distribute parallel for simd' composite directive.
Definition: StmtOpenMP.h:4609
clang::OMPBarrierDirective
This represents '#pragma omp barrier' directive.
Definition: StmtOpenMP.h:2505
clang::SYCLUniqueStableNameExpr
Definition: Expr.h:2056
clang::NamedDecl::getName
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
Definition: Decl.h:274