47#include "llvm/ADT/ArrayRef.h"
48#include "llvm/ADT/STLExtras.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"
68 class StmtPrinter :
public StmtVisitor<StmtPrinter> {
79 StringRef NL =
"\n",
const ASTContext *Context =
nullptr)
80 : OS(os), IndentLevel(Indentation), Helper(helper), Policy(Policy),
81 NL(NL), Context(Context) {}
85 void PrintStmt(
Stmt *S,
int SubIndent) {
86 IndentLevel += SubIndent;
87 if (isa_and_nonnull<Expr>(S)) {
95 Indent() <<
"<<<NULL STATEMENT>>>" << NL;
97 IndentLevel -= SubIndent;
100 void PrintInitStmt(
Stmt *S,
unsigned PrefixWidth) {
102 IndentLevel += (PrefixWidth + 1) / 2;
103 if (
auto *DS = dyn_cast<DeclStmt>(S))
104 PrintRawDeclStmt(DS);
106 PrintExpr(cast<Expr>(S));
108 IndentLevel -= (PrefixWidth + 1) / 2;
111 void PrintControlledStmt(
Stmt *S) {
112 if (
auto *CS = dyn_cast<CompoundStmt>(S)) {
114 PrintRawCompoundStmt(CS);
123 void PrintRawDecl(
Decl *
D);
124 void PrintRawDeclStmt(
const DeclStmt *S);
131 bool ForceNoStmt =
false);
136 void PrintExpr(
Expr *
E) {
143 raw_ostream &Indent(
int Delta = 0) {
144 for (
int i = 0, e = IndentLevel+Delta; i < e; ++i)
155 void VisitStmt(
Stmt *
Node) LLVM_ATTRIBUTE_UNUSED {
156 Indent() <<
"<<unknown stmt type>>" << NL;
159 void VisitExpr(
Expr *
Node) LLVM_ATTRIBUTE_UNUSED {
160 OS <<
"<<unknown expr type>>";
165#define ABSTRACT_STMT(CLASS)
166#define STMT(CLASS, PARENT) \
167 void Visit##CLASS(CLASS *Node);
168#include "clang/AST/StmtNodes.inc"
180 assert(
Node &&
"Compound statement cannot be null");
182 PrintFPPragmas(
Node);
183 for (
auto *I :
Node->body())
190 if (!S->hasStoredFPFeatures())
193 bool FEnvAccess =
false;
194 if (FPO.hasAllowFEnvAccessOverride()) {
195 FEnvAccess = FPO.getAllowFEnvAccessOverride();
196 Indent() <<
"#pragma STDC FENV_ACCESS " << (FEnvAccess ?
"ON" :
"OFF")
199 if (FPO.hasSpecifiedExceptionModeOverride()) {
201 FPO.getSpecifiedExceptionModeOverride();
202 if (!FEnvAccess || EM != LangOptions::FPE_Strict) {
203 Indent() <<
"#pragma clang fp exceptions(";
204 switch (FPO.getSpecifiedExceptionModeOverride()) {
207 case LangOptions::FPE_Ignore:
210 case LangOptions::FPE_MayTrap:
213 case LangOptions::FPE_Strict:
220 if (FPO.hasConstRoundingModeOverride()) {
222 Indent() <<
"#pragma STDC FENV_ROUND ";
224 case llvm::RoundingMode::TowardZero:
225 OS <<
"FE_TOWARDZERO";
227 case llvm::RoundingMode::NearestTiesToEven:
228 OS <<
"FE_TONEAREST";
230 case llvm::RoundingMode::TowardPositive:
233 case llvm::RoundingMode::TowardNegative:
236 case llvm::RoundingMode::NearestTiesToAway:
237 OS <<
"FE_TONEARESTFROMZERO";
239 case llvm::RoundingMode::Dynamic:
243 llvm_unreachable(
"Invalid rounding mode");
249void StmtPrinter::PrintRawDecl(
Decl *
D) {
250 D->
print(OS, Policy, IndentLevel);
253void StmtPrinter::PrintRawDeclStmt(
const DeclStmt *S) {
259 Indent() <<
";" << NL;
264 PrintRawDeclStmt(
Node);
270 PrintRawCompoundStmt(
Node);
275 Indent(-1) <<
"case ";
276 PrintExpr(
Node->getLHS());
277 if (
Node->getRHS()) {
279 PrintExpr(
Node->getRHS());
283 PrintStmt(
Node->getSubStmt(), 0);
287 Indent(-1) <<
"default:" << NL;
288 PrintStmt(
Node->getSubStmt(), 0);
292 Indent(-1) <<
Node->getName() <<
":" << NL;
293 PrintStmt(
Node->getSubStmt(), 0);
298 for (
const auto *
Attr : Attrs) {
300 if (
Attr != Attrs.back())
304 PrintStmt(
Node->getSubStmt(), 0);
307void StmtPrinter::PrintRawIfStmt(
IfStmt *
If) {
308 if (
If->isConsteval()) {
310 if (
If->isNegatedConsteval())
314 PrintStmt(
If->getThen());
315 if (
Stmt *Else =
If->getElse()) {
326 PrintInitStmt(
If->getInit(), 4);
327 if (
const DeclStmt *DS =
If->getConditionVariableDeclStmt())
328 PrintRawDeclStmt(DS);
330 PrintExpr(
If->getCond());
333 if (
auto *CS = dyn_cast<CompoundStmt>(
If->getThen())) {
335 PrintRawCompoundStmt(CS);
336 OS << (
If->getElse() ?
" " : NL);
339 PrintStmt(
If->getThen());
340 if (
If->getElse()) Indent();
343 if (
Stmt *Else =
If->getElse()) {
346 if (
auto *CS = dyn_cast<CompoundStmt>(Else)) {
348 PrintRawCompoundStmt(CS);
350 }
else if (
auto *ElseIf = dyn_cast<IfStmt>(Else)) {
352 PrintRawIfStmt(ElseIf);
355 PrintStmt(
If->getElse());
360void StmtPrinter::VisitIfStmt(
IfStmt *
If) {
366 Indent() <<
"switch (";
368 PrintInitStmt(
Node->getInit(), 8);
369 if (
const DeclStmt *DS =
Node->getConditionVariableDeclStmt())
370 PrintRawDeclStmt(DS);
372 PrintExpr(
Node->getCond());
374 PrintControlledStmt(
Node->getBody());
378 Indent() <<
"while (";
379 if (
const DeclStmt *DS =
Node->getConditionVariableDeclStmt())
380 PrintRawDeclStmt(DS);
382 PrintExpr(
Node->getCond());
384 PrintStmt(
Node->getBody());
389 if (
auto *CS = dyn_cast<CompoundStmt>(
Node->getBody())) {
390 PrintRawCompoundStmt(CS);
394 PrintStmt(
Node->getBody());
399 PrintExpr(
Node->getCond());
406 PrintInitStmt(
Node->getInit(), 5);
408 OS << (
Node->getCond() ?
"; " :
";");
409 if (
const DeclStmt *DS =
Node->getConditionVariableDeclStmt())
410 PrintRawDeclStmt(DS);
411 else if (
Node->getCond())
412 PrintExpr(
Node->getCond());
414 if (
Node->getInc()) {
416 PrintExpr(
Node->getInc());
419 PrintControlledStmt(
Node->getBody());
424 if (
auto *DS = dyn_cast<DeclStmt>(
Node->getElement()))
425 PrintRawDeclStmt(DS);
427 PrintExpr(cast<Expr>(
Node->getElement()));
429 PrintExpr(
Node->getCollection());
431 PrintControlledStmt(
Node->getBody());
437 PrintInitStmt(
Node->getInit(), 5);
439 SubPolicy.SuppressInitializers =
true;
440 Node->getLoopVariable()->
print(OS, SubPolicy, IndentLevel);
442 PrintExpr(
Node->getRangeInit());
444 PrintControlledStmt(
Node->getBody());
449 if (
Node->isIfExists())
450 OS <<
"__if_exists (";
452 OS <<
"__if_not_exists (";
455 =
Node->getQualifierLoc().getNestedNameSpecifier())
458 OS <<
Node->getNameInfo() <<
") ";
460 PrintRawCompoundStmt(
Node->getSubStmt());
464 Indent() <<
"goto " <<
Node->getLabel()->getName() <<
";";
469 Indent() <<
"goto *";
470 PrintExpr(
Node->getTarget());
476 Indent() <<
"continue;";
481 Indent() <<
"break;";
486 Indent() <<
"return";
487 if (
Node->getRetValue()) {
489 PrintExpr(
Node->getRetValue());
498 if (
Node->isVolatile())
501 if (
Node->isAsmGoto())
505 VisitStringLiteral(
Node->getAsmString());
508 if (
Node->getNumOutputs() != 0 ||
Node->getNumInputs() != 0 ||
509 Node->getNumClobbers() != 0 ||
Node->getNumLabels() != 0)
512 for (
unsigned i = 0, e =
Node->getNumOutputs(); i != e; ++i) {
516 if (!
Node->getOutputName(i).empty()) {
518 OS <<
Node->getOutputName(i);
522 VisitStringLiteral(
Node->getOutputConstraintLiteral(i));
524 Visit(
Node->getOutputExpr(i));
529 if (
Node->getNumInputs() != 0 ||
Node->getNumClobbers() != 0 ||
530 Node->getNumLabels() != 0)
533 for (
unsigned i = 0, e =
Node->getNumInputs(); i != e; ++i) {
537 if (!
Node->getInputName(i).empty()) {
539 OS <<
Node->getInputName(i);
543 VisitStringLiteral(
Node->getInputConstraintLiteral(i));
545 Visit(
Node->getInputExpr(i));
550 if (
Node->getNumClobbers() != 0 ||
Node->getNumLabels())
553 for (
unsigned i = 0, e =
Node->getNumClobbers(); i != e; ++i) {
557 VisitStringLiteral(
Node->getClobberStringLiteral(i));
561 if (
Node->getNumLabels() != 0)
564 for (
unsigned i = 0, e =
Node->getNumLabels(); i != e; ++i) {
567 OS <<
Node->getLabelName(i);
576 Indent() <<
"__asm ";
577 if (
Node->hasBraces())
579 OS <<
Node->getAsmString() << NL;
580 if (
Node->hasBraces())
581 Indent() <<
"}" << NL;
585 PrintStmt(
Node->getCapturedDecl()->getBody());
589 PrintStmt(
Node->getOutlinedFunctionDecl()->getBody());
594 if (
auto *TS = dyn_cast<CompoundStmt>(
Node->getTryBody())) {
595 PrintRawCompoundStmt(TS);
600 Indent() <<
"@catch(";
601 if (
Decl *DS = catchStmt->getCatchParamDecl())
604 if (
auto *CS = dyn_cast<CompoundStmt>(catchStmt->getCatchBody())) {
605 PrintRawCompoundStmt(CS);
611 Indent() <<
"@finally";
612 if (
auto *CS = dyn_cast<CompoundStmt>(FS->getFinallyBody())) {
613 PrintRawCompoundStmt(CS);
623 Indent() <<
"@catch (...) { /* todo */ } " << NL;
627 Indent() <<
"@throw";
628 if (
Node->getThrowExpr()) {
630 PrintExpr(
Node->getThrowExpr());
635void StmtPrinter::VisitObjCAvailabilityCheckExpr(
637 OS <<
"@available(...)";
641 Indent() <<
"@synchronized (";
642 PrintExpr(
Node->getSynchExpr());
644 PrintRawCompoundStmt(
Node->getSynchBody());
649 Indent() <<
"@autoreleasepool";
650 PrintRawCompoundStmt(cast<CompoundStmt>(
Node->getSubStmt()));
656 if (
Decl *ExDecl =
Node->getExceptionDecl())
657 PrintRawDecl(ExDecl);
661 PrintRawCompoundStmt(cast<CompoundStmt>(
Node->getHandlerBlock()));
666 PrintRawCXXCatchStmt(
Node);
672 PrintRawCompoundStmt(
Node->getTryBlock());
673 for (
unsigned i = 0, e =
Node->getNumHandlers(); i < e; ++i) {
675 PrintRawCXXCatchStmt(
Node->getHandler(i));
681 Indent() << (
Node->getIsCXXTry() ?
"try " :
"__try ");
682 PrintRawCompoundStmt(
Node->getTryBlock());
686 PrintRawSEHExceptHandler(
E);
688 assert(F &&
"Must have a finally block...");
689 PrintRawSEHFinallyStmt(F);
696 PrintRawCompoundStmt(
Node->getBlock());
702 VisitExpr(
Node->getFilterExpr());
704 PrintRawCompoundStmt(
Node->getBlock());
710 PrintRawSEHExceptHandler(
Node);
716 PrintRawSEHFinallyStmt(
Node);
721 Indent() <<
"__leave;";
730 PrintStmt(
Node->getLoopStmt());
737 for (
auto *Clause : Clauses)
738 if (Clause && !Clause->isImplicit()) {
740 Printer.Visit(Clause);
743 if (!ForceNoStmt && S->hasAssociatedStmt())
744 PrintStmt(S->getRawStmt());
748 Indent() <<
"#pragma omp metadirective";
749 PrintOMPExecutableDirective(
Node);
753 Indent() <<
"#pragma omp parallel";
754 PrintOMPExecutableDirective(
Node);
758 Indent() <<
"#pragma omp simd";
759 PrintOMPExecutableDirective(
Node);
763 Indent() <<
"#pragma omp tile";
764 PrintOMPExecutableDirective(
Node);
768 Indent() <<
"#pragma omp unroll";
769 PrintOMPExecutableDirective(
Node);
773 Indent() <<
"#pragma omp reverse";
774 PrintOMPExecutableDirective(
Node);
778 Indent() <<
"#pragma omp interchange";
779 PrintOMPExecutableDirective(
Node);
783 Indent() <<
"#pragma omp for";
784 PrintOMPExecutableDirective(
Node);
788 Indent() <<
"#pragma omp for simd";
789 PrintOMPExecutableDirective(
Node);
793 Indent() <<
"#pragma omp sections";
794 PrintOMPExecutableDirective(
Node);
798 Indent() <<
"#pragma omp section";
799 PrintOMPExecutableDirective(
Node);
803 Indent() <<
"#pragma omp scope";
804 PrintOMPExecutableDirective(
Node);
808 Indent() <<
"#pragma omp single";
809 PrintOMPExecutableDirective(
Node);
813 Indent() <<
"#pragma omp master";
814 PrintOMPExecutableDirective(
Node);
818 Indent() <<
"#pragma omp critical";
819 if (
Node->getDirectiveName().getName()) {
821 Node->getDirectiveName().printName(OS, Policy);
824 PrintOMPExecutableDirective(
Node);
828 Indent() <<
"#pragma omp parallel for";
829 PrintOMPExecutableDirective(
Node);
832void StmtPrinter::VisitOMPParallelForSimdDirective(
834 Indent() <<
"#pragma omp parallel for simd";
835 PrintOMPExecutableDirective(
Node);
838void StmtPrinter::VisitOMPParallelMasterDirective(
840 Indent() <<
"#pragma omp parallel master";
841 PrintOMPExecutableDirective(
Node);
844void StmtPrinter::VisitOMPParallelMaskedDirective(
846 Indent() <<
"#pragma omp parallel masked";
847 PrintOMPExecutableDirective(
Node);
850void StmtPrinter::VisitOMPParallelSectionsDirective(
852 Indent() <<
"#pragma omp parallel sections";
853 PrintOMPExecutableDirective(
Node);
857 Indent() <<
"#pragma omp task";
858 PrintOMPExecutableDirective(
Node);
862 Indent() <<
"#pragma omp taskyield";
863 PrintOMPExecutableDirective(
Node);
867 Indent() <<
"#pragma omp barrier";
868 PrintOMPExecutableDirective(
Node);
872 Indent() <<
"#pragma omp taskwait";
873 PrintOMPExecutableDirective(
Node);
877 Indent() <<
"#pragma omp assume";
878 PrintOMPExecutableDirective(
Node);
882 Indent() <<
"#pragma omp error";
883 PrintOMPExecutableDirective(
Node);
887 Indent() <<
"#pragma omp taskgroup";
888 PrintOMPExecutableDirective(
Node);
892 Indent() <<
"#pragma omp flush";
893 PrintOMPExecutableDirective(
Node);
897 Indent() <<
"#pragma omp depobj";
898 PrintOMPExecutableDirective(
Node);
902 Indent() <<
"#pragma omp scan";
903 PrintOMPExecutableDirective(
Node);
907 Indent() <<
"#pragma omp ordered";
912 Indent() <<
"#pragma omp atomic";
913 PrintOMPExecutableDirective(
Node);
917 Indent() <<
"#pragma omp target";
918 PrintOMPExecutableDirective(
Node);
922 Indent() <<
"#pragma omp target data";
923 PrintOMPExecutableDirective(
Node);
926void StmtPrinter::VisitOMPTargetEnterDataDirective(
928 Indent() <<
"#pragma omp target enter data";
929 PrintOMPExecutableDirective(
Node,
true);
932void StmtPrinter::VisitOMPTargetExitDataDirective(
934 Indent() <<
"#pragma omp target exit data";
935 PrintOMPExecutableDirective(
Node,
true);
938void StmtPrinter::VisitOMPTargetParallelDirective(
940 Indent() <<
"#pragma omp target parallel";
941 PrintOMPExecutableDirective(
Node);
944void StmtPrinter::VisitOMPTargetParallelForDirective(
946 Indent() <<
"#pragma omp target parallel for";
947 PrintOMPExecutableDirective(
Node);
951 Indent() <<
"#pragma omp teams";
952 PrintOMPExecutableDirective(
Node);
955void StmtPrinter::VisitOMPCancellationPointDirective(
957 Indent() <<
"#pragma omp cancellation point "
958 << getOpenMPDirectiveName(
Node->getCancelRegion());
959 PrintOMPExecutableDirective(
Node);
963 Indent() <<
"#pragma omp cancel "
964 << getOpenMPDirectiveName(
Node->getCancelRegion());
965 PrintOMPExecutableDirective(
Node);
969 Indent() <<
"#pragma omp taskloop";
970 PrintOMPExecutableDirective(
Node);
973void StmtPrinter::VisitOMPTaskLoopSimdDirective(
975 Indent() <<
"#pragma omp taskloop simd";
976 PrintOMPExecutableDirective(
Node);
979void StmtPrinter::VisitOMPMasterTaskLoopDirective(
981 Indent() <<
"#pragma omp master taskloop";
982 PrintOMPExecutableDirective(
Node);
985void StmtPrinter::VisitOMPMaskedTaskLoopDirective(
987 Indent() <<
"#pragma omp masked taskloop";
988 PrintOMPExecutableDirective(
Node);
991void StmtPrinter::VisitOMPMasterTaskLoopSimdDirective(
993 Indent() <<
"#pragma omp master taskloop simd";
994 PrintOMPExecutableDirective(
Node);
997void StmtPrinter::VisitOMPMaskedTaskLoopSimdDirective(
999 Indent() <<
"#pragma omp masked taskloop simd";
1000 PrintOMPExecutableDirective(
Node);
1003void StmtPrinter::VisitOMPParallelMasterTaskLoopDirective(
1005 Indent() <<
"#pragma omp parallel master taskloop";
1006 PrintOMPExecutableDirective(
Node);
1009void StmtPrinter::VisitOMPParallelMaskedTaskLoopDirective(
1011 Indent() <<
"#pragma omp parallel masked taskloop";
1012 PrintOMPExecutableDirective(
Node);
1015void StmtPrinter::VisitOMPParallelMasterTaskLoopSimdDirective(
1017 Indent() <<
"#pragma omp parallel master taskloop simd";
1018 PrintOMPExecutableDirective(
Node);
1021void StmtPrinter::VisitOMPParallelMaskedTaskLoopSimdDirective(
1023 Indent() <<
"#pragma omp parallel masked taskloop simd";
1024 PrintOMPExecutableDirective(
Node);
1028 Indent() <<
"#pragma omp distribute";
1029 PrintOMPExecutableDirective(
Node);
1032void StmtPrinter::VisitOMPTargetUpdateDirective(
1034 Indent() <<
"#pragma omp target update";
1035 PrintOMPExecutableDirective(
Node,
true);
1038void StmtPrinter::VisitOMPDistributeParallelForDirective(
1040 Indent() <<
"#pragma omp distribute parallel for";
1041 PrintOMPExecutableDirective(
Node);
1044void StmtPrinter::VisitOMPDistributeParallelForSimdDirective(
1046 Indent() <<
"#pragma omp distribute parallel for simd";
1047 PrintOMPExecutableDirective(
Node);
1050void StmtPrinter::VisitOMPDistributeSimdDirective(
1052 Indent() <<
"#pragma omp distribute simd";
1053 PrintOMPExecutableDirective(
Node);
1056void StmtPrinter::VisitOMPTargetParallelForSimdDirective(
1058 Indent() <<
"#pragma omp target parallel for simd";
1059 PrintOMPExecutableDirective(
Node);
1063 Indent() <<
"#pragma omp target simd";
1064 PrintOMPExecutableDirective(
Node);
1067void StmtPrinter::VisitOMPTeamsDistributeDirective(
1069 Indent() <<
"#pragma omp teams distribute";
1070 PrintOMPExecutableDirective(
Node);
1073void StmtPrinter::VisitOMPTeamsDistributeSimdDirective(
1075 Indent() <<
"#pragma omp teams distribute simd";
1076 PrintOMPExecutableDirective(
Node);
1079void StmtPrinter::VisitOMPTeamsDistributeParallelForSimdDirective(
1081 Indent() <<
"#pragma omp teams distribute parallel for simd";
1082 PrintOMPExecutableDirective(
Node);
1085void StmtPrinter::VisitOMPTeamsDistributeParallelForDirective(
1087 Indent() <<
"#pragma omp teams distribute parallel for";
1088 PrintOMPExecutableDirective(
Node);
1092 Indent() <<
"#pragma omp target teams";
1093 PrintOMPExecutableDirective(
Node);
1096void StmtPrinter::VisitOMPTargetTeamsDistributeDirective(
1098 Indent() <<
"#pragma omp target teams distribute";
1099 PrintOMPExecutableDirective(
Node);
1102void StmtPrinter::VisitOMPTargetTeamsDistributeParallelForDirective(
1104 Indent() <<
"#pragma omp target teams distribute parallel for";
1105 PrintOMPExecutableDirective(
Node);
1108void StmtPrinter::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
1110 Indent() <<
"#pragma omp target teams distribute parallel for simd";
1111 PrintOMPExecutableDirective(
Node);
1114void StmtPrinter::VisitOMPTargetTeamsDistributeSimdDirective(
1116 Indent() <<
"#pragma omp target teams distribute simd";
1117 PrintOMPExecutableDirective(
Node);
1121 Indent() <<
"#pragma omp interop";
1122 PrintOMPExecutableDirective(
Node);
1126 Indent() <<
"#pragma omp dispatch";
1127 PrintOMPExecutableDirective(
Node);
1131 Indent() <<
"#pragma omp masked";
1132 PrintOMPExecutableDirective(
Node);
1136 Indent() <<
"#pragma omp loop";
1137 PrintOMPExecutableDirective(
Node);
1140void StmtPrinter::VisitOMPTeamsGenericLoopDirective(
1142 Indent() <<
"#pragma omp teams loop";
1143 PrintOMPExecutableDirective(
Node);
1146void StmtPrinter::VisitOMPTargetTeamsGenericLoopDirective(
1148 Indent() <<
"#pragma omp target teams loop";
1149 PrintOMPExecutableDirective(
Node);
1152void StmtPrinter::VisitOMPParallelGenericLoopDirective(
1154 Indent() <<
"#pragma omp parallel loop";
1155 PrintOMPExecutableDirective(
Node);
1158void StmtPrinter::VisitOMPTargetParallelGenericLoopDirective(
1160 Indent() <<
"#pragma omp target parallel loop";
1161 PrintOMPExecutableDirective(
Node);
1168 if (!S->clauses().empty()) {
1171 Printer.VisitClauseList(S->clauses());
1175 Indent() <<
"#pragma acc " << S->getDirectiveKind();
1176 PrintOpenACCClauseList(S);
1180 PrintOpenACCConstruct(S);
1181 PrintStmt(S->getStructuredBlock());
1185 PrintOpenACCConstruct(S);
1186 PrintStmt(S->getLoop());
1190 PrintOpenACCConstruct(S);
1191 PrintStmt(S->getLoop());
1195 PrintOpenACCConstruct(S);
1196 PrintStmt(S->getStructuredBlock());
1199 PrintOpenACCConstruct(S);
1200 PrintStmt(S->getStructuredBlock());
1203 PrintOpenACCConstruct(S);
1206 PrintOpenACCConstruct(S);
1209 PrintOpenACCConstruct(S);
1212 PrintOpenACCConstruct(S);
1215 PrintOpenACCConstruct(S);
1218 PrintOpenACCConstruct(S);
1222 Indent() <<
"#pragma acc wait";
1223 if (!S->getLParenLoc().isInvalid()) {
1225 if (S->hasDevNumExpr()) {
1227 S->getDevNumExpr()->printPretty(OS,
nullptr, Policy);
1231 if (S->hasQueuesTag())
1234 llvm::interleaveComma(S->getQueueIdExprs(), OS, [&](
const Expr *
E) {
1235 E->printPretty(OS, nullptr, Policy);
1241 PrintOpenACCClauseList(S);
1246 Indent() <<
"#pragma acc atomic";
1248 if (S->getAtomicKind() != OpenACCAtomicKind::None)
1249 OS <<
" " << S->getAtomicKind();
1252 PrintStmt(S->getAssociatedStmt());
1260 OS <<
Node->getBuiltinStr() <<
"()";
1264 llvm::report_fatal_error(
"Not implemented");
1268 PrintExpr(
Node->getSubExpr());
1273 if (
const auto *OCED = dyn_cast<OMPCapturedExprDecl>(VD)) {
1274 OCED->getInit()->IgnoreImpCasts()->printPretty(OS,
nullptr, Policy);
1277 if (
const auto *TPOD = dyn_cast<TemplateParamObjectDecl>(VD)) {
1278 TPOD->printAsExpr(OS, Policy);
1283 if (
Node->hasTemplateKeyword())
1289 isa<ParmVarDecl, NonTypeTemplateParmDecl>(VD) && ID)
1290 OS <<
ID->deuglifiedName();
1295 case Decl::NonTypeTemplateParm: {
1296 auto *TD = cast<NonTypeTemplateParmDecl>(VD);
1297 OS <<
"value-parameter-" << TD->getDepth() <<
'-' << TD->getIndex() <<
"";
1300 case Decl::ParmVar: {
1301 auto *PD = cast<ParmVarDecl>(VD);
1302 OS <<
"function-parameter-" << PD->getFunctionScopeDepth() <<
'-'
1303 << PD->getFunctionScopeIndex();
1306 case Decl::Decomposition:
1307 OS <<
"decomposition";
1308 for (
const auto &I : cast<DecompositionDecl>(VD)->bindings())
1309 OS <<
'-' << I->getName();
1316 if (
Node->hasExplicitTemplateArgs()) {
1318 if (!
Node->hadMultipleCandidates())
1319 if (
auto *TD = dyn_cast<TemplateDecl>(VD))
1320 TPL = TD->getTemplateParameters();
1325void StmtPrinter::VisitDependentScopeDeclRefExpr(
1329 if (
Node->hasTemplateKeyword())
1331 OS <<
Node->getNameInfo();
1332 if (
Node->hasExplicitTemplateArgs())
1337 if (
Node->getQualifier())
1338 Node->getQualifier()->
print(OS, Policy);
1339 if (
Node->hasTemplateKeyword())
1341 OS <<
Node->getNameInfo();
1342 if (
Node->hasExplicitTemplateArgs())
1347 if (
const auto *DRE = dyn_cast<DeclRefExpr>(
E)) {
1348 if (
const auto *PD = dyn_cast<ImplicitParamDecl>(DRE->getDecl())) {
1349 if (PD->getParameterKind() == ImplicitParamKind::ObjCSelf &&
1350 DRE->getBeginLoc().isInvalid())
1358 if (
Node->getBase()) {
1361 PrintExpr(
Node->getBase());
1362 OS << (
Node->isArrow() ?
"->" :
".");
1365 OS << *
Node->getDecl();
1369 if (
Node->isSuperReceiver())
1371 else if (
Node->isObjectReceiver() &&
Node->getBase()) {
1372 PrintExpr(
Node->getBase());
1374 }
else if (
Node->isClassReceiver() &&
Node->getClassReceiver()) {
1375 OS <<
Node->getClassReceiver()->getName() <<
".";
1378 if (
Node->isImplicitProperty()) {
1379 if (
const auto *Getter =
Node->getImplicitPropertyGetter())
1380 Getter->getSelector().
print(OS);
1383 Node->getImplicitPropertySetter()->getSelector());
1385 OS <<
Node->getExplicitProperty()->getName();
1389 PrintExpr(
Node->getBaseExpr());
1391 PrintExpr(
Node->getKeyExpr());
1395void StmtPrinter::VisitSYCLUniqueStableNameExpr(
1397 OS <<
"__builtin_sycl_unique_stable_name(";
1398 Node->getTypeSourceInfo()->getType().
print(OS, Policy);
1434 bool isSigned =
Node->getType()->isSignedIntegerType();
1437 if (isa<BitIntType>(
Node->getType())) {
1438 OS << (isSigned ?
"wb" :
"uwb");
1444 default: llvm_unreachable(
"Unexpected type for integer literal!");
1445 case BuiltinType::Char_S:
1446 case BuiltinType::Char_U: OS <<
"i8";
break;
1447 case BuiltinType::UChar: OS <<
"Ui8";
break;
1448 case BuiltinType::SChar: OS <<
"i8";
break;
1449 case BuiltinType::Short: OS <<
"i16";
break;
1450 case BuiltinType::UShort: OS <<
"Ui16";
break;
1451 case BuiltinType::Int:
break;
1452 case BuiltinType::UInt: OS <<
'U';
break;
1453 case BuiltinType::Long: OS <<
'L';
break;
1454 case BuiltinType::ULong: OS <<
"UL";
break;
1455 case BuiltinType::LongLong: OS <<
"LL";
break;
1456 case BuiltinType::ULongLong: OS <<
"ULL";
break;
1457 case BuiltinType::Int128:
1459 case BuiltinType::UInt128:
1461 case BuiltinType::WChar_S:
1462 case BuiltinType::WChar_U:
1470 OS <<
Node->getValueAsString(10);
1473 default: llvm_unreachable(
"Unexpected type for fixed point literal!");
1474 case BuiltinType::ShortFract: OS <<
"hr";
break;
1475 case BuiltinType::ShortAccum: OS <<
"hk";
break;
1476 case BuiltinType::UShortFract: OS <<
"uhr";
break;
1477 case BuiltinType::UShortAccum: OS <<
"uhk";
break;
1478 case BuiltinType::Fract: OS <<
"r";
break;
1479 case BuiltinType::Accum: OS <<
"k";
break;
1480 case BuiltinType::UFract: OS <<
"ur";
break;
1481 case BuiltinType::UAccum: OS <<
"uk";
break;
1482 case BuiltinType::LongFract: OS <<
"lr";
break;
1483 case BuiltinType::LongAccum: OS <<
"lk";
break;
1484 case BuiltinType::ULongFract: OS <<
"ulr";
break;
1485 case BuiltinType::ULongAccum: OS <<
"ulk";
break;
1492 Node->getValue().toString(Str);
1494 if (Str.find_first_not_of(
"-0123456789") == StringRef::npos)
1502 default: llvm_unreachable(
"Unexpected type for float literal!");
1503 case BuiltinType::Half:
break;
1504 case BuiltinType::Ibm128:
break;
1505 case BuiltinType::Double:
break;
1506 case BuiltinType::Float16: OS <<
"F16";
break;
1507 case BuiltinType::Float: OS <<
'F';
break;
1508 case BuiltinType::LongDouble: OS <<
'L';
break;
1509 case BuiltinType::Float128: OS <<
'Q';
break;
1520 PrintExpr(
Node->getSubExpr());
1530 PrintExpr(
Node->getSubExpr());
1535 if (!
Node->isPostfix()) {
1540 switch (
Node->getOpcode()) {
1549 if (isa<UnaryOperator>(
Node->getSubExpr()))
1554 PrintExpr(
Node->getSubExpr());
1556 if (
Node->isPostfix())
1561 OS <<
"__builtin_offsetof(";
1562 Node->getTypeSourceInfo()->getType().
print(OS, Policy);
1564 bool PrintedSomething =
false;
1565 for (
unsigned i = 0, n =
Node->getNumComponents(); i < n; ++i) {
1572 PrintedSomething =
true;
1585 if (PrintedSomething)
1588 PrintedSomething =
true;
1589 OS <<
Id->getName();
1594void StmtPrinter::VisitUnaryExprOrTypeTraitExpr(
1597 if (
Node->getKind() == UETT_AlignOf) {
1599 Spelling =
"alignof";
1601 Spelling =
"_Alignof";
1603 Spelling =
"__alignof";
1608 if (
Node->isArgumentType()) {
1610 Node->getArgumentType().
print(OS, Policy);
1614 PrintExpr(
Node->getArgumentExpr());
1620 if (
Node->isExprPredicate())
1621 PrintExpr(
Node->getControllingExpr());
1623 Node->getControllingType()->getType().
print(OS, Policy);
1631 T.print(OS, Policy);
1633 PrintExpr(Assoc.getAssociationExpr());
1639 PrintExpr(
Node->getLHS());
1641 PrintExpr(
Node->getRHS());
1646 PrintExpr(
Node->getBase());
1648 PrintExpr(
Node->getRowIdx());
1651 PrintExpr(
Node->getColumnIdx());
1656 PrintExpr(
Node->getBase());
1658 if (
Node->getLowerBound())
1659 PrintExpr(
Node->getLowerBound());
1660 if (
Node->getColonLocFirst().isValid()) {
1662 if (
Node->getLength())
1663 PrintExpr(
Node->getLength());
1665 if (
Node->isOMPArraySection() &&
Node->getColonLocSecond().isValid()) {
1667 if (
Node->getStride())
1668 PrintExpr(
Node->getStride());
1681 PrintExpr(
Node->getBase());
1686 for (
unsigned I = 0,
E =
Node->numOfIterators(); I <
E; ++I) {
1687 auto *VD = cast<ValueDecl>(
Node->getIteratorDecl(I));
1690 OS <<
" " << VD->
getName() <<
" = ";
1691 PrintExpr(
Range.Begin);
1693 PrintExpr(
Range.End);
1696 PrintExpr(
Range.Step);
1705 for (
unsigned i = 0, e =
Call->getNumArgs(); i != e; ++i) {
1706 if (isa<CXXDefaultArgExpr>(
Call->getArg(i))) {
1712 PrintExpr(
Call->getArg(i));
1717 PrintExpr(
Call->getCallee());
1719 PrintCallArgs(
Call);
1724 if (
const auto *TE = dyn_cast<CXXThisExpr>(
E))
1725 return TE->isImplicit();
1731 PrintExpr(
Node->getBase());
1733 auto *ParentMember = dyn_cast<MemberExpr>(
Node->getBase());
1735 ParentMember ? dyn_cast<FieldDecl>(ParentMember->getMemberDecl())
1739 OS << (
Node->isArrow() ?
"->" :
".");
1742 if (
auto *FD = dyn_cast<FieldDecl>(
Node->getMemberDecl()))
1743 if (FD->isAnonymousStructOrUnion())
1748 if (
Node->hasTemplateKeyword())
1750 OS <<
Node->getMemberNameInfo();
1752 if (
auto *FD = dyn_cast<FunctionDecl>(
Node->getMemberDecl())) {
1753 if (!
Node->hadMultipleCandidates())
1754 if (
auto *FTD = FD->getPrimaryTemplate())
1755 TPL = FTD->getTemplateParameters();
1756 }
else if (
auto *VTSD =
1757 dyn_cast<VarTemplateSpecializationDecl>(
Node->getMemberDecl()))
1758 TPL = VTSD->getSpecializedTemplate()->getTemplateParameters();
1759 if (
Node->hasExplicitTemplateArgs())
1764 PrintExpr(
Node->getBase());
1765 OS << (
Node->isArrow() ?
"->isa" :
".isa");
1769 PrintExpr(
Node->getBase());
1771 OS <<
Node->getAccessor().getName();
1776 Node->getTypeAsWritten().
print(OS, Policy);
1778 PrintExpr(
Node->getSubExpr());
1785 PrintExpr(
Node->getInitializer());
1790 PrintExpr(
Node->getSubExpr());
1794 PrintExpr(
Node->getLHS());
1796 PrintExpr(
Node->getRHS());
1800 PrintExpr(
Node->getLHS());
1802 PrintExpr(
Node->getRHS());
1806 PrintExpr(
Node->getCond());
1808 PrintExpr(
Node->getLHS());
1810 PrintExpr(
Node->getRHS());
1817 PrintExpr(
Node->getCommon());
1819 PrintExpr(
Node->getFalseExpr());
1823 OS <<
"&&" <<
Node->getLabel()->getName();
1826void StmtPrinter::VisitStmtExpr(
StmtExpr *
E) {
1828 PrintRawCompoundStmt(
E->getSubStmt());
1833 OS <<
"__builtin_choose_expr(";
1834 PrintExpr(
Node->getCond());
1836 PrintExpr(
Node->getLHS());
1838 PrintExpr(
Node->getRHS());
1842void StmtPrinter::VisitGNUNullExpr(
GNUNullExpr *) {
1847 OS <<
"__builtin_shufflevector(";
1848 for (
unsigned i = 0, e =
Node->getNumSubExprs(); i != e; ++i) {
1850 PrintExpr(
Node->getExpr(i));
1856 OS <<
"__builtin_convertvector(";
1857 PrintExpr(
Node->getSrcExpr());
1864 if (
Node->getSyntacticForm()) {
1865 Visit(
Node->getSyntacticForm());
1870 for (
unsigned i = 0, e =
Node->getNumInits(); i != e; ++i) {
1872 if (
Node->getInit(i))
1873 PrintExpr(
Node->getInit(i));
1884 PrintExpr(
Node->getSubExpr());
1894 for (
unsigned i = 0, e =
Node->getNumExprs(); i != e; ++i) {
1896 PrintExpr(
Node->getExpr(i));
1902 bool NeedsEquals =
true;
1904 if (
D.isFieldDesignator()) {
1905 if (
D.getDotLoc().isInvalid()) {
1907 OS << II->getName() <<
":";
1908 NeedsEquals =
false;
1911 OS <<
"." <<
D.getFieldName()->getName();
1915 if (
D.isArrayDesignator()) {
1916 PrintExpr(
Node->getArrayIndex(
D));
1918 PrintExpr(
Node->getArrayRangeStart(
D));
1920 PrintExpr(
Node->getArrayRangeEnd(
D));
1930 PrintExpr(
Node->getInit());
1933void StmtPrinter::VisitDesignatedInitUpdateExpr(
1937 PrintExpr(
Node->getBase());
1940 OS <<
"/*updater*/";
1941 PrintExpr(
Node->getUpdater());
1946 OS <<
"/*no init*/";
1950 if (
Node->getType()->getAsCXXRecordDecl()) {
1951 OS <<
"/*implicit*/";
1955 OS <<
"/*implicit*/(";
1958 if (
Node->getType()->isRecordType())
1966 OS <<
"__builtin_va_arg(";
1967 PrintExpr(
Node->getSubExpr());
1974 PrintExpr(
Node->getSyntacticForm());
1978 const char *Name =
nullptr;
1979 switch (
Node->getOp()) {
1980#define BUILTIN(ID, TYPE, ATTRS)
1981#define ATOMIC_BUILTIN(ID, TYPE, ATTRS) \
1982 case AtomicExpr::AO ## ID: \
1985#include "clang/Basic/Builtins.inc"
1990 PrintExpr(
Node->getPtr());
1991 if (
Node->getOp() != AtomicExpr::AO__c11_atomic_load &&
1992 Node->getOp() != AtomicExpr::AO__atomic_load_n &&
1993 Node->getOp() != AtomicExpr::AO__scoped_atomic_load_n &&
1994 Node->getOp() != AtomicExpr::AO__opencl_atomic_load &&
1995 Node->getOp() != AtomicExpr::AO__hip_atomic_load) {
1997 PrintExpr(
Node->getVal1());
1999 if (
Node->getOp() == AtomicExpr::AO__atomic_exchange ||
2000 Node->isCmpXChg()) {
2002 PrintExpr(
Node->getVal2());
2004 if (
Node->getOp() == AtomicExpr::AO__atomic_compare_exchange ||
2005 Node->getOp() == AtomicExpr::AO__atomic_compare_exchange_n) {
2007 PrintExpr(
Node->getWeak());
2009 if (
Node->getOp() != AtomicExpr::AO__c11_atomic_init &&
2010 Node->getOp() != AtomicExpr::AO__opencl_atomic_init) {
2012 PrintExpr(
Node->getOrder());
2014 if (
Node->isCmpXChg()) {
2016 PrintExpr(
Node->getOrderFail());
2024 if (Kind == OO_PlusPlus || Kind == OO_MinusMinus) {
2025 if (
Node->getNumArgs() == 1) {
2027 PrintExpr(
Node->getArg(0));
2029 PrintExpr(
Node->getArg(0));
2032 }
else if (Kind == OO_Arrow) {
2033 PrintExpr(
Node->getArg(0));
2034 }
else if (Kind == OO_Call || Kind == OO_Subscript) {
2035 PrintExpr(
Node->getArg(0));
2036 OS << (
Kind == OO_Call ?
'(' :
'[');
2037 for (
unsigned ArgIdx = 1; ArgIdx <
Node->getNumArgs(); ++ArgIdx) {
2040 if (!isa<CXXDefaultArgExpr>(
Node->getArg(ArgIdx)))
2041 PrintExpr(
Node->getArg(ArgIdx));
2043 OS << (
Kind == OO_Call ?
')' :
']');
2044 }
else if (
Node->getNumArgs() == 1) {
2046 PrintExpr(
Node->getArg(0));
2047 }
else if (
Node->getNumArgs() == 2) {
2048 PrintExpr(
Node->getArg(0));
2050 PrintExpr(
Node->getArg(1));
2052 llvm_unreachable(
"unknown overloaded operator");
2059 if (isa_and_nonnull<CXXConversionDecl>(MD)) {
2060 PrintExpr(
Node->getImplicitObjectArgument());
2063 VisitCallExpr(cast<CallExpr>(
Node));
2067 PrintExpr(
Node->getCallee());
2069 PrintCallArgs(
Node->getConfig());
2071 PrintCallArgs(
Node);
2075void StmtPrinter::VisitCXXRewrittenBinaryOperator(
2078 Node->getDecomposedForm();
2079 PrintExpr(
const_cast<Expr*
>(Decomposed.
LHS));
2081 PrintExpr(
const_cast<Expr*
>(Decomposed.
RHS));
2085 OS <<
Node->getCastName() <<
'<';
2086 Node->getTypeAsWritten().
print(OS, Policy);
2088 PrintExpr(
Node->getSubExpr());
2093 VisitCXXNamedCastExpr(
Node);
2097 VisitCXXNamedCastExpr(
Node);
2101 VisitCXXNamedCastExpr(
Node);
2105 VisitCXXNamedCastExpr(
Node);
2109 OS <<
"__builtin_bit_cast(";
2110 Node->getTypeInfoAsWritten()->getType().
print(OS, Policy);
2112 PrintExpr(
Node->getSubExpr());
2117 VisitCXXNamedCastExpr(
Node);
2122 if (
Node->isTypeOperand()) {
2123 Node->getTypeOperandSourceInfo()->getType().
print(OS, Policy);
2125 PrintExpr(
Node->getExprOperand());
2132 if (
Node->isTypeOperand()) {
2133 Node->getTypeOperandSourceInfo()->getType().
print(OS, Policy);
2135 PrintExpr(
Node->getExprOperand());
2141 PrintExpr(
Node->getBaseExpr());
2142 if (
Node->isArrow())
2147 Node->getQualifierLoc().getNestedNameSpecifier())
2149 OS <<
Node->getPropertyDecl()->getDeclName();
2153 PrintExpr(
Node->getBase());
2155 PrintExpr(
Node->getIdx());
2160 switch (
Node->getLiteralOperatorKind()) {
2162 OS << cast<StringLiteral>(
Node->getArg(0)->IgnoreImpCasts())->getString();
2165 const auto *DRE = cast<DeclRefExpr>(
Node->getCallee()->IgnoreImpCasts());
2167 cast<FunctionDecl>(DRE->getDecl())->getTemplateSpecializationArgs();
2172 if (!DRE->hadMultipleCandidates())
2173 if (
const auto *TD = dyn_cast<TemplateDecl>(DRE->getDecl()))
2174 TPL = TD->getTemplateParameters();
2175 OS <<
"operator\"\"" <<
Node->getUDSuffix()->getName();
2183 char C = (char)
P.getAsIntegral().getZExtValue();
2190 const auto *
Int = cast<IntegerLiteral>(
Node->getCookedLiteral());
2196 auto *
Float = cast<FloatingLiteral>(
Node->getCookedLiteral());
2202 PrintExpr(
Node->getCookedLiteral());
2205 OS <<
Node->getUDSuffix()->getName();
2209 OS << (
Node->getValue() ?
"true" :
"false");
2221 if (!
Node->getSubExpr())
2225 PrintExpr(
Node->getSubExpr());
2238 auto TargetType =
Node->getType();
2239 auto *
Auto = TargetType->getContainedDeducedType();
2240 bool Bare =
Auto &&
Auto->isDeduced();
2245 TargetType.print(OS, Policy);
2250 if (!
Node->isListInitialization())
2252 PrintExpr(
Node->getSubExpr());
2253 if (!
Node->isListInitialization())
2258 PrintExpr(
Node->getSubExpr());
2263 if (
Node->isStdInitListInitialization())
2265 else if (
Node->isListInitialization())
2270 ArgEnd =
Node->arg_end();
2271 Arg != ArgEnd; ++Arg) {
2272 if ((*Arg)->isDefaultArgument())
2274 if (Arg !=
Node->arg_begin())
2278 if (
Node->isStdInitListInitialization())
2280 else if (
Node->isListInitialization())
2288 bool NeedComma =
false;
2289 switch (
Node->getCaptureDefault()) {
2304 CEnd =
Node->explicit_capture_end();
2307 if (
C->capturesVLAType())
2314 switch (
C->getCaptureKind()) {
2326 OS <<
C->getCapturedVar()->getName();
2330 OS <<
C->getCapturedVar()->getName();
2334 llvm_unreachable(
"VLA type in explicit captures.");
2337 if (
C->isPackExpansion())
2340 if (
Node->isInitCapture(
C)) {
2342 auto *
D = cast<VarDecl>(
C->getCapturedVar());
2344 llvm::StringRef
Pre;
2345 llvm::StringRef
Post;
2347 !isa<ParenListExpr>(
D->getInit())) {
2355 PrintExpr(
D->getInit());
2361 if (!
Node->getExplicitTemplateParameters().empty()) {
2362 Node->getTemplateParameterList()->
print(
2363 OS,
Node->getLambdaClass()->getASTContext(),
2367 if (
Node->hasExplicitParameters()) {
2377 std::string ParamStr =
2379 ?
P->getIdentifier()->deuglifiedName().str()
2380 :
P->getNameAsString();
2381 P->getOriginalType().print(OS, Policy, ParamStr);
2390 if (
Node->isMutable())
2399 if (
Node->hasExplicitResultType()) {
2401 Proto->getReturnType().print(OS, Policy);
2410 PrintRawCompoundStmt(
Node->getCompoundStmtBody());
2415 TSInfo->getType().print(OS, Policy);
2422 if (
E->isGlobalNew())
2425 unsigned NumPlace =
E->getNumPlacementArgs();
2426 if (NumPlace > 0 && !isa<CXXDefaultArgExpr>(
E->getPlacementArg(0))) {
2428 PrintExpr(
E->getPlacementArg(0));
2429 for (
unsigned i = 1; i < NumPlace; ++i) {
2430 if (isa<CXXDefaultArgExpr>(
E->getPlacementArg(i)))
2433 PrintExpr(
E->getPlacementArg(i));
2437 if (
E->isParenTypeId())
2441 llvm::raw_string_ostream
s(TypeS);
2443 if (std::optional<Expr *> Size =
E->getArraySize())
2444 (*Size)->printPretty(
s, Helper, Policy);
2447 E->getAllocatedType().print(OS, Policy, TypeS);
2448 if (
E->isParenTypeId())
2452 if (InitStyle != CXXNewInitializationStyle::None) {
2453 bool Bare = InitStyle == CXXNewInitializationStyle::Parens &&
2454 !isa<ParenListExpr>(
E->getInitializer());
2457 PrintExpr(
E->getInitializer());
2464 if (
E->isGlobalDelete())
2467 if (
E->isArrayForm())
2469 PrintExpr(
E->getArgument());
2473 PrintExpr(
E->getBase());
2478 if (
E->getQualifier())
2479 E->getQualifier()->print(OS, Policy);
2483 OS << II->getName();
2485 E->getDestroyedType().print(OS, Policy);
2489 if (
E->isListInitialization() && !
E->isStdInitListInitialization())
2492 for (
unsigned i = 0, e =
E->getNumArgs(); i != e; ++i) {
2493 if (isa<CXXDefaultArgExpr>(
E->getArg(i))) {
2499 PrintExpr(
E->getArg(i));
2502 if (
E->isListInitialization() && !
E->isStdInitListInitialization())
2508 OS <<
"<forwarded>";
2512 PrintExpr(
E->getSubExpr());
2517 PrintExpr(
E->getSubExpr());
2520void StmtPrinter::VisitCXXUnresolvedConstructExpr(
2522 Node->getTypeAsWritten().
print(OS, Policy);
2523 if (!
Node->isListInitialization())
2525 for (
auto Arg =
Node->arg_begin(), ArgEnd =
Node->arg_end(); Arg != ArgEnd;
2527 if (Arg !=
Node->arg_begin())
2531 if (!
Node->isListInitialization())
2535void StmtPrinter::VisitCXXDependentScopeMemberExpr(
2537 if (!
Node->isImplicitAccess()) {
2538 PrintExpr(
Node->getBase());
2539 OS << (
Node->isArrow() ?
"->" :
".");
2543 if (
Node->hasTemplateKeyword())
2545 OS <<
Node->getMemberNameInfo();
2546 if (
Node->hasExplicitTemplateArgs())
2551 if (!
Node->isImplicitAccess()) {
2552 PrintExpr(
Node->getBase());
2553 OS << (
Node->isArrow() ?
"->" :
".");
2557 if (
Node->hasTemplateKeyword())
2559 OS <<
Node->getMemberNameInfo();
2560 if (
Node->hasExplicitTemplateArgs())
2566 for (
unsigned I = 0, N =
E->getNumArgs(); I != N; ++I) {
2576 E->getQueriedType().print(OS, Policy);
2582 PrintExpr(
E->getQueriedExpression());
2588 PrintExpr(
E->getOperand());
2593 PrintExpr(
E->getPattern());
2598 OS <<
"sizeof...(" << *
E->getPack() <<
")";
2602 PrintExpr(
E->getPackIdExpression());
2604 PrintExpr(
E->getIndexExpr());
2608void StmtPrinter::VisitResolvedUnexpandedPackExpr(
2610 OS <<
"<<resolved pack(";
2612 E->getExprs().begin(),
E->getExprs().end(),
2613 [
this](
auto *
X) { PrintExpr(X); }, [
this] { OS <<
", "; });
2617void StmtPrinter::VisitSubstNonTypeTemplateParmPackExpr(
2619 OS << *
Node->getParameterPack();
2622void StmtPrinter::VisitSubstNonTypeTemplateParmExpr(
2624 Visit(
Node->getReplacement());
2628 OS << *
E->getParameterPack();
2632 PrintExpr(
Node->getSubExpr());
2638 PrintExpr(
E->getLHS());
2644 PrintExpr(
E->getRHS());
2651 llvm::interleaveComma(
Node->getInitExprs(), OS,
2652 [&](
Expr *
E) { PrintExpr(E); });
2660 if (
E->getTemplateKWLoc().isValid())
2662 OS <<
E->getFoundDecl()->getName();
2665 E->getNamedConcept()->getTemplateParameters());
2670 auto LocalParameters =
E->getLocalParameters();
2671 if (!LocalParameters.empty()) {
2674 PrintRawDecl(LocalParam);
2675 if (LocalParam != LocalParameters.back())
2682 auto Requirements =
E->getRequirements();
2684 if (
auto *TypeReq = dyn_cast<concepts::TypeRequirement>(Req)) {
2685 if (TypeReq->isSubstitutionFailure())
2686 OS <<
"<<error-type>>";
2688 TypeReq->getType()->getType().print(OS, Policy);
2689 }
else if (
auto *ExprReq = dyn_cast<concepts::ExprRequirement>(Req)) {
2690 if (ExprReq->isCompound())
2692 if (ExprReq->isExprSubstitutionFailure())
2693 OS <<
"<<error-expression>>";
2695 PrintExpr(ExprReq->getExpr());
2696 if (ExprReq->isCompound()) {
2698 if (ExprReq->getNoexceptLoc().isValid())
2700 const auto &RetReq = ExprReq->getReturnTypeRequirement();
2701 if (!RetReq.isEmpty()) {
2703 if (RetReq.isSubstitutionFailure())
2704 OS <<
"<<error-type>>";
2705 else if (RetReq.isTypeConstraint())
2706 RetReq.getTypeConstraint()->print(OS, Policy);
2710 auto *NestedReq = cast<concepts::NestedRequirement>(Req);
2712 if (NestedReq->hasInvalidConstraint())
2713 OS <<
"<<error-expression>>";
2715 PrintExpr(NestedReq->getConstraintExpr());
2725 Visit(S->getBody());
2730 if (S->getOperand()) {
2732 Visit(S->getOperand());
2737void StmtPrinter::VisitCoawaitExpr(
CoawaitExpr *S) {
2739 PrintExpr(S->getOperand());
2744 PrintExpr(S->getOperand());
2747void StmtPrinter::VisitCoyieldExpr(
CoyieldExpr *S) {
2749 PrintExpr(S->getOperand());
2756 VisitStringLiteral(
Node->getString());
2761 Visit(
E->getSubExpr());
2767 for (
auto I = Ch.begin(),
E = Ch.end(); I !=
E; ++I) {
2768 if (I != Ch.begin())
2777 for (
unsigned I = 0, N =
E->getNumElements(); I != N; ++I) {
2784 Visit(Element.Value);
2785 if (Element.isPackExpansion())
2793 Node->getEncodedType().
print(OS, Policy);
2804 OS <<
"@protocol(" << *
Node->getProtocol() <<
')';
2829 for (
unsigned i = 0, e = Mess->
getNumArgs(); i != e; ++i) {
2831 if (i > 0) OS <<
' ';
2839 PrintExpr(Mess->
getArg(i));
2846 OS << (
Node->getValue() ?
"__objc_yes" :
"__objc_no");
2851 PrintExpr(
E->getSubExpr());
2856 OS <<
'(' <<
E->getBridgeKindName();
2859 PrintExpr(
E->getSubExpr());
2868 if (isa<FunctionNoProtoType>(AFT)) {
2870 }
else if (!BD->
param_empty() || cast<FunctionProtoType>(AFT)->isVariadic()) {
2875 std::string ParamStr = (*AI)->getNameAsString();
2876 (*AI)->getType().print(OS, Policy, ParamStr);
2879 const auto *FT = cast<FunctionProtoType>(AFT);
2880 if (FT->isVariadic()) {
2890 PrintExpr(
Node->getSourceExpr());
2895 llvm_unreachable(
"Cannot print TypoExpr nodes");
2899 OS <<
"<recovery-expr>(";
2900 const char *Sep =
"";
2901 for (
Expr *
E :
Node->subExpressions()) {
2910 OS <<
"__builtin_astype(";
2911 PrintExpr(
Node->getSrcExpr());
2918 PrintExpr(
Node->getArgLValue());
2931 StringRef NL,
const ASTContext *Context)
const {
2932 StmtPrinter
P(Out, Helper, Policy, Indentation, NL, Context);
2933 P.Visit(
const_cast<Stmt *
>(
this));
2938 unsigned Indentation, StringRef NL,
2940 StmtPrinter
P(Out, Helper, Policy, Indentation, NL, Context);
2941 P.PrintControlledStmt(
const_cast<Stmt *
>(
this));
2947 llvm::raw_string_ostream TempOut(Buf);
Defines the clang::ASTContext interface.
static Decl::Kind getKind(const Decl *D)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
This file defines OpenMP nodes for declarative directives.
Defines the C++ template declaration subclasses.
Defines the clang::Expr interface and subclasses for C++ expressions.
Defines enumerations for expression traits intrinsics.
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines several types used to describe C++ lambda expressions that are shared between the parser and ...
This file defines OpenMP AST classes for clauses.
Defines some OpenMP-specific enums and functions.
Defines an enumeration for C++ overloaded operators.
static std::string toString(const clang::SanitizerSet &Sanitizers)
Produce a string containing comma-separated names of sanitizers in Sanitizers set.
Defines the clang::SourceLocation class and associated facilities.
Defines the Objective-C statement AST node classes.
This file defines OpenMP AST classes for executable directives and clauses.
static bool isImplicitThis(const Expr *E)
static bool isImplicitSelf(const Expr *E)
static void PrintFloatingLiteral(raw_ostream &OS, FloatingLiteral *Node, bool PrintSuffix)
static bool printExprAsWritten(raw_ostream &OS, Expr *E, const ASTContext *Context)
Prints the given expression using the original source text.
This file defines SYCL AST classes used to represent calls to SYCL kernels.
Defines enumerations for the type traits support.
C Language Family Type Representation.
__device__ __2f16 float __ockl_bool s
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
SourceManager & getSourceManager()
const LangOptions & getLangOpts() const
AddrLabelExpr - The GNU address of label extension, representing &&label.
Represents the index of the current element of an array being initialized by an ArrayInitLoopExpr.
Represents a loop initializing the elements of an array.
This class represents BOTH the OpenMP Array Section and OpenACC 'subarray', with a boolean differenti...
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
An Embarcadero array type trait, as used in the implementation of __array_rank and __array_extent.
AsTypeExpr - Clang builtin function __builtin_astype [OpenCL 6.2.4.2] This AST node provides support ...
AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*, __atomic_load,...
Attr - This represents one attribute.
void printPretty(raw_ostream &OS, const PrintingPolicy &Policy) const
Represents an attribute applied to a statement.
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
A builtin binary operation expression such as "x + y" or "x <= y".
StringRef getOpcodeStr() const
Represents a block literal declaration, which is like an unnamed FunctionDecl.
param_iterator param_end()
MutableArrayRef< ParmVarDecl * >::iterator param_iterator
param_iterator param_begin()
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
BreakStmt - This represents a break.
Represents a C++2a __builtin_bit_cast(T, v) expression.
This class is used for builtin types like 'int'.
CStyleCastExpr - An explicit cast in C (C99 6.5.4) or a C-style cast in C++ (C++ [expr....
Represents a call to a CUDA kernel function.
A C++ addrspace_cast expression (currently only enabled for OpenCL).
Represents binding an expression to a temporary.
A boolean literal, per ([C++ lex.bool] Boolean literals).
CXXCatchStmt - This represents a C++ catch block.
A C++ const_cast expression (C++ [expr.const.cast]).
Represents a call to a C++ constructor.
A default argument (C++ [dcl.fct.default]).
A use of a default initializer in a constructor or in aggregate initialization.
Represents a delete expression for memory deallocation and destructor calls, e.g.
Represents a C++ member access expression where the actual member referenced could not be resolved be...
A C++ dynamic_cast expression (C++ [expr.dynamic.cast]).
Represents a folding of a pack over an operator.
CXXForRangeStmt - This represents C++0x [stmt.ranged]'s ranged for statement, represented as 'for (ra...
Represents an explicit C++ type conversion that uses "functional" notation (C++ [expr....
Represents a call to an inherited base class constructor from an inheriting constructor.
Represents a call to a member function that may be written either with member call syntax (e....
Represents a static or instance method of a struct/union/class.
Abstract class common to all of the C++ "named"/"keyword" casts.
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)".
Represents a C++11 noexcept expression (C++ [expr.unary.noexcept]).
The null pointer literal (C++11 [lex.nullptr])
A call to an overloaded operator written using operator syntax.
Represents a list-initialization with parenthesis.
Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
A C++ reinterpret_cast expression (C++ [expr.reinterpret.cast]).
A rewritten comparison expression that was originally written using operator syntax.
An expression "T()" which creates an rvalue of a non-class type T.
A C++ static_cast expression (C++ [expr.static.cast]).
Implicit construction of a std::initializer_list<T> object from an array temporary within list-initia...
Represents a C++ functional cast expression that builds a temporary object.
Represents the this expression in C++.
A C++ throw-expression (C++ [except.throw]).
CXXTryStmt - A C++ try block, including all handlers.
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
Describes an explicit type conversion that uses functional notion but could not be resolved because o...
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
This captures a statement into a function.
CaseStmt - Represent a case statement.
static CharSourceRange getTokenRange(SourceRange R)
static void print(unsigned val, CharacterLiteralKind Kind, raw_ostream &OS)
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
Represents a 'co_await' expression.
CompoundAssignOperator - For compound assignments (e.g.
CompoundLiteralExpr - [C99 6.5.2.5].
CompoundStmt - This represents a group of statements like { stmt stmt }.
Represents the specialization of a concept - evaluates to a prvalue of type bool.
ConditionalOperator - The ?: ternary operator.
ConstantExpr - An expression that occurs in a constant context and optionally the result of evaluatin...
ContinueStmt - This represents a continue.
ConvertVectorExpr - Clang builtin function __builtin_convertvector This AST node provides support for...
Represents a 'co_return' statement in the C++ Coroutines TS.
Represents the body of a coroutine.
Represents a 'co_yield' expression.
A reference to a declared variable, function, enum, etc.
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
Decl - This represents one declaration (or definition), e.g.
const char * getDeclKindName() const
static void printGroup(Decl **Begin, unsigned NumDecls, raw_ostream &Out, const PrintingPolicy &Policy, unsigned Indentation=0)
void print(raw_ostream &Out, unsigned Indentation=0, bool PrintInstantiation=false) const
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't...
NameKind getNameKind() const
Determine what kind of name this is.
Represents a 'co_await' expression while the type of the promise is dependent.
A qualified reference to a name whose declaration cannot yet be resolved.
Represents a single C99 designator.
Represents a C99 designated initializer expression.
DoStmt - This represents a 'do/while' stmt.
void print(llvm::raw_ostream &OS, const PrintingPolicy &PP) const
Prints the node to the given output stream.
Represents a reference to #emded data.
Represents an expression – generally a full-expression – that introduces cleanups to be run at the en...
This represents one expression.
An expression trait intrinsic.
ExtVectorElementExpr - This represents access to specific elements of a vector, and may occur on the ...
Represents difference between two FPOptions values.
Represents a member of a struct/union/class.
bool isAnonymousStructOrUnion() const
Determines whether this field is a representative for an anonymous struct or union.
ForStmt - This represents a 'for (init;cond;inc)' stmt.
ArrayRef< ParmVarDecl * > parameters() const
bool isVariadic() const
Whether this function is variadic.
Represents a reference to a function parameter pack or init-capture pack that has been substituted bu...
Represents a prototype with parameter type info, e.g.
void printExceptionSpecification(raw_ostream &OS, const PrintingPolicy &Policy) const
FunctionType - C99 6.7.5.3 - Function Declarators.
This represents a GCC inline-assembly statement extension.
GNUNullExpr - Implements the GNU __null extension, which is a name for a null pointer constant that h...
Represents a C11 generic selection.
AssociationTy< false > Association
GotoStmt - This represents a direct goto.
This class represents temporary values used to represent inout and out arguments in HLSL.
One of these records is kept for each identifier that is lexed.
StringRef getName() const
Return the actual identifier string.
IfStmt - This represents an if/then/else.
ImaginaryLiteral - We support imaginary integer and floating point literals, like "1....
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
Represents an implicitly-generated value initialization of an object of a given type.
IndirectGotoStmt - This represents an indirect goto.
Describes an C or C++ initializer list.
LabelStmt - Represents a label, which has a substatement.
Describes the capture of a variable or of this, or of a C++1y init-capture.
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
llvm::RoundingMode RoundingMode
FPExceptionModeKind
Possible floating point exception behavior.
static StringRef getSourceText(CharSourceRange Range, const SourceManager &SM, const LangOptions &LangOpts, bool *Invalid=nullptr)
Returns a string for the source that the range encompasses.
This represents a Microsoft inline-assembly statement extension.
Representation of a Microsoft __if_exists or __if_not_exists statement with a dependent name.
A member reference to an MSPropertyDecl.
MS property subscript expression.
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
MatrixSubscriptExpr - Matrix subscript expression for the MatrixType extension.
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
A C++ nested-name-specifier augmented with source location information.
NestedNameSpecifier * getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
void print(raw_ostream &OS, const PrintingPolicy &Policy, bool ResolveTemplateArguments=false) const
Print this nested name specifier to the given output stream.
Represents a place-holder for an object not to be initialized by anything.
NullStmt - This is the null statement ";": C99 6.8.3p3.
An explicit cast in C or a C-style cast in C++, which uses the syntax ([s1][s2]......
This represents '#pragma omp atomic' directive.
This represents '#pragma omp barrier' directive.
This represents '#pragma omp cancel' directive.
This represents '#pragma omp cancellation point' directive.
Representation of an OpenMP canonical loop.
This represents '#pragma omp critical' directive.
This represents implicit clause 'depend' for the '#pragma omp task' directive.
This represents '#pragma omp depobj' directive.
This represents '#pragma omp dispatch' directive.
This represents '#pragma omp distribute' directive.
This represents '#pragma omp distribute parallel for' composite directive.
This represents '#pragma omp distribute parallel for simd' composite directive.
This represents '#pragma omp distribute simd' composite directive.
This represents '#pragma omp error' directive.
This is a basic class for representing single OpenMP executable directive.
This represents '#pragma omp flush' directive.
This represents '#pragma omp for' directive.
This represents '#pragma omp for simd' directive.
This represents '#pragma omp loop' directive.
Represents the '#pragma omp interchange' loop transformation directive.
This represents '#pragma omp interop' directive.
OpenMP 5.0 [2.1.6 Iterators] Iterators are identifiers that expand to multiple values in the clause o...
This represents '#pragma omp masked' directive.
This represents '#pragma omp masked taskloop' directive.
This represents '#pragma omp masked taskloop simd' directive.
This represents '#pragma omp master' directive.
This represents '#pragma omp master taskloop' directive.
This represents '#pragma omp master taskloop simd' directive.
This represents '#pragma omp ordered' directive.
This represents '#pragma omp parallel' directive.
This represents '#pragma omp parallel for' directive.
This represents '#pragma omp parallel for simd' directive.
This represents '#pragma omp parallel loop' directive.
This represents '#pragma omp parallel masked' directive.
This represents '#pragma omp parallel masked taskloop' directive.
This represents '#pragma omp parallel masked taskloop simd' directive.
This represents '#pragma omp parallel master' directive.
This represents '#pragma omp parallel master taskloop' directive.
This represents '#pragma omp parallel master taskloop simd' directive.
This represents '#pragma omp parallel sections' directive.
Represents the '#pragma omp reverse' loop transformation directive.
This represents '#pragma omp scan' directive.
This represents '#pragma omp scope' directive.
This represents '#pragma omp section' directive.
This represents '#pragma omp sections' directive.
This represents '#pragma omp simd' directive.
This represents '#pragma omp single' directive.
This represents '#pragma omp target data' directive.
This represents '#pragma omp target' directive.
This represents '#pragma omp target enter data' directive.
This represents '#pragma omp target exit data' directive.
This represents '#pragma omp target parallel' directive.
This represents '#pragma omp target parallel for' directive.
This represents '#pragma omp target parallel for simd' directive.
This represents '#pragma omp target parallel loop' directive.
This represents '#pragma omp target simd' directive.
This represents '#pragma omp target teams' directive.
This represents '#pragma omp target teams distribute' combined directive.
This represents '#pragma omp target teams distribute parallel for' combined directive.
This represents '#pragma omp target teams distribute parallel for simd' combined directive.
This represents '#pragma omp target teams distribute simd' combined directive.
This represents '#pragma omp target teams loop' directive.
This represents '#pragma omp target update' directive.
This represents '#pragma omp task' directive.
This represents '#pragma omp taskloop' directive.
This represents '#pragma omp taskloop simd' directive.
This represents '#pragma omp taskgroup' directive.
This represents '#pragma omp taskwait' directive.
This represents '#pragma omp taskyield' directive.
This represents '#pragma omp teams' directive.
This represents '#pragma omp teams distribute' directive.
This represents '#pragma omp teams distribute parallel for' composite directive.
This represents '#pragma omp teams distribute parallel for simd' composite directive.
This represents '#pragma omp teams distribute simd' combined directive.
This represents '#pragma omp teams loop' directive.
This represents the '#pragma omp tile' loop transformation directive.
This represents the '#pragma omp unroll' loop transformation directive.
ObjCArrayLiteral - used for objective-c array containers; as in: @["Hello", NSApp,...
Represents Objective-C's @catch statement.
Represents Objective-C's @finally statement.
Represents Objective-C's @synchronized statement.
Represents Objective-C's @throw statement.
Represents Objective-C's @try ... @catch ... @finally statement.
Represents Objective-C's @autoreleasepool Statement.
A runtime availability query.
ObjCBoolLiteralExpr - Objective-C Boolean Literal.
ObjCBoxedExpr - used for generalized expression boxing.
An Objective-C "bridged" cast expression, which casts between Objective-C pointers and C pointers,...
ObjCDictionaryLiteral - AST node to represent objective-c dictionary literals; as in:"name" : NSUserN...
ObjCEncodeExpr, used for @encode in Objective-C.
Represents Objective-C's collection statement.
ObjCIndirectCopyRestoreExpr - Represents the passing of a function argument by indirect copy-restore ...
ObjCIsaExpr - Represent X->isa and X.isa when X is an ObjC 'id' type.
ObjCIvarRefExpr - A reference to an ObjC instance variable.
An expression that sends a message to the given Objective-C object or class.
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
Expr * getInstanceReceiver()
Returns the object expression (receiver) for an instance message, or null for a message that is not a...
Selector getSelector() const
@ SuperInstance
The receiver is the instance of the superclass object.
@ Instance
The receiver is an object instance.
@ SuperClass
The receiver is a superclass.
@ Class
The receiver is a class.
QualType getClassReceiver() const
Returns the type of a class message send, or NULL if the message is not a class message.
ReceiverKind getReceiverKind() const
Determine the kind of receiver that this message is being sent to.
unsigned getNumArgs() const
Return the number of actual arguments in this message, not counting the receiver.
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
ObjCProtocolExpr used for protocol expression in Objective-C.
ObjCSelectorExpr used for @selector in Objective-C.
ObjCStringLiteral, used for Objective-C string literals i.e.
ObjCSubscriptRefExpr - used for array and dictionary subscripting.
OffsetOfExpr - [C99 7.17] - This represents an expression of the form offsetof(record-type,...
Helper class for OffsetOfExpr.
unsigned getArrayExprIndex() const
For an array element node, returns the index into the array of expressions.
IdentifierInfo * getFieldName() const
For a field or identifier offsetof node, returns the name of the field.
@ Array
An index into an array.
@ Base
An implicit indirection through a C++ base class, when the field found is in a base class.
Kind getKind() const
Determine what kind of offsetof node this is.
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.
This expression type represents an asterisk in an OpenACC Size-Expr, used in the 'tile' and 'gang' cl...
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
This is the base class for an OpenACC statement-level construct, other construct types are expected t...
This class represents a 'loop' construct.
Represents a C++11 pack expansion that produces a sequence of expressions.
ParenExpr - This represents a parenthesized expression, e.g.
Represents a parameter to a function.
[C99 6.4.2.2] - A predefined identifier such as func.
StringRef getIdentKindName() const
virtual bool handledStmt(Stmt *E, raw_ostream &OS)=0
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
A (possibly-)qualified type.
void print(raw_ostream &OS, const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) const
Frontend produces RecoveryExprs on semantic errors that prevent creating other well-formed expression...
C++2a [expr.prim.req]: A requires-expression provides a concise way to express requirements on templa...
ReturnStmt - This represents a return, optionally of an expression: return; return 4;.
Represents a __leave statement.
SYCLKernelCallStmt represents the transformation that is applied to the body of a function declared w...
static std::string getPropertyNameFromSetterSelector(Selector Sel)
Return the property name for the given setter selector.
Smart pointer class that efficiently represents Objective-C method names.
StringRef getNameForSlot(unsigned argIndex) const
Retrieve the name at a given position in the selector.
const IdentifierInfo * getIdentifierInfoForSlot(unsigned argIndex) const
Retrieve the identifier at a given position in the selector.
bool isUnarySelector() const
unsigned getNumArgs() const
ShuffleVectorExpr - clang-specific builtin-in function __builtin_shufflevector.
Represents an expression that computes the length of a parameter pack.
Represents a function call to one of __builtin_LINE(), __builtin_COLUMN(), __builtin_FUNCTION(),...
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
RetTy Visit(PTR(Stmt) S, ParamTys... P)
StmtVisitor - This class implements a simple visitor for Stmt subclasses.
Stmt - This represents one statement.
void printPretty(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation=0, StringRef NewlineSymbol="\n", const ASTContext *Context=nullptr) const
void printJson(raw_ostream &Out, PrinterHelper *Helper, const PrintingPolicy &Policy, bool AddQuotes) const
Pretty-prints in JSON format.
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
void printPrettyControlled(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation=0, StringRef NewlineSymbol="\n", const ASTContext *Context=nullptr) const
llvm::iterator_range< child_iterator > child_range
void dumpPretty(const ASTContext &Context) const
dumpPretty/printPretty - These two methods do a "pretty print" of the AST back to its original source...
StringLiteral - This represents a string literal expression, e.g.
void outputString(raw_ostream &OS) const
Represents a reference to a non-type template parameter that has been substituted with a template arg...
Represents a reference to a non-type template parameter pack that has been substituted with a non-tem...
SwitchStmt - This represents a 'switch' stmt.
A template argument list.
unsigned size() const
Retrieve the number of template arguments in this template argument list.
const TemplateArgument & get(unsigned Idx) const
Retrieve the template argument at a given index.
ArrayRef< TemplateArgument > asArray() const
Produce this as an array ref.
Represents a template argument.
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
@ Pack
The template argument is actually a parameter pack.
ArgKind getKind() const
Return the kind of stored template argument.
Stores a list of template parameters for a TemplateDecl and its derived classes.
A container of type source information.
A type trait used in the implementation of various C++11 and Library TR1 trait templates.
const T * castAs() const
Member-template castAs<specific type>.
TypoExpr - Internal placeholder for expressions where typo correction still needs to be performed and...
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand.
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
static StringRef getOpcodeStr(Opcode Op)
getOpcodeStr - Turn an Opcode enum value into the punctuation char it corresponds to,...
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
Represents a C++ member access expression for which lookup produced a set of overloaded functions.
A call to a literal operator (C++11 [over.literal]) written as a user-defined literal (C++11 [lit....
@ LOK_String
operator "" X (const CharT *, size_t)
@ LOK_Raw
Raw form: operator "" X (const char *)
@ LOK_Floating
operator "" X (long double)
@ LOK_Integer
operator "" X (unsigned long long)
@ LOK_Template
Raw form: operator "" X<cs...> ()
@ LOK_Character
operator "" X (CharT)
Represents a call to the builtin function __builtin_va_arg.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
@ CInit
C-style initialization with assignment.
@ CallInit
Call-style initialization (C++98)
WhileStmt - This represents a 'while' stmt.
A static requirement that can be used in a requires-expression to check properties of types and expre...
The JSON file list parser is used to communicate input to InstallAPI.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
@ LCK_ByCopy
Capturing by copy (a.k.a., by value)
@ LCK_ByRef
Capturing by reference.
@ LCK_VLAType
Capturing variable-length array type.
@ LCK_StarThis
Capturing the *this object by copy.
@ LCK_This
Capturing the *this object by reference.
@ If
'if' clause, allowed on all the Compute Constructs, Data Constructs, Executable Constructs,...
std::string JsonFormat(StringRef RawSR, bool AddQuotes)
const char * getTraitSpelling(ExpressionTrait T) LLVM_READONLY
Return the spelling of the type trait TT. Never null.
const FunctionProtoType * T
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.
const char * getOperatorSpelling(OverloadedOperatorKind Operator)
Retrieve the spelling of the given overloaded operator, without the preceding "operator" keyword.
CXXNewInitializationStyle
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
DeclarationName getName() const
getName - Returns the embedded declaration name.
void printName(raw_ostream &OS, PrintingPolicy Policy) const
printName - Print the human-readable name to a stream.
Iterator range representation begin:end[:step].
An element in an Objective-C dictionary literal.
Describes how types, statements, expressions, and declarations should be printed.
unsigned Alignof
Whether we can use 'alignof' rather than '__alignof'.
unsigned CleanUglifiedParameters
Whether to strip underscores when printing reserved parameter names.
unsigned ConstantsAsWritten
Whether we should print the constant expressions as written in the sources.
unsigned IncludeNewlines
When true, include newlines after statements like "break", etc.
unsigned Indentation
The number of spaces to use to indent each line.
unsigned TerseOutput
Provide a 'terse' output.
unsigned UnderscoreAlignof
Whether we can use '_Alignof' rather than '__alignof'.
unsigned SuppressImplicitBase
When true, don't print the implicit 'self' or 'this' expressions.
Iterator for iterating over Stmt * arrays that contain only T *.