48#include "llvm/ADT/ArrayRef.h"
49#include "llvm/ADT/STLExtras.h"
50#include "llvm/ADT/StringExtras.h"
51#include "llvm/ADT/StringRef.h"
52#include "llvm/Support/Compiler.h"
53#include "llvm/Support/ErrorHandling.h"
54#include "llvm/Support/raw_ostream.h"
67 class StmtPrinter :
public StmtVisitor<StmtPrinter> {
78 StringRef NL =
"\n",
const ASTContext *Context =
nullptr)
79 : OS(os), IndentLevel(Indentation), Helper(helper), Policy(Policy),
80 NL(NL), Context(Context) {}
84 void PrintStmt(
Stmt *S,
int SubIndent) {
85 IndentLevel += SubIndent;
86 if (isa_and_nonnull<Expr>(S)) {
94 Indent() <<
"<<<NULL STATEMENT>>>" << NL;
96 IndentLevel -= SubIndent;
99 void PrintInitStmt(
Stmt *S,
unsigned PrefixWidth) {
101 IndentLevel += (PrefixWidth + 1) / 2;
102 if (
auto *DS = dyn_cast<DeclStmt>(S))
103 PrintRawDeclStmt(DS);
105 PrintExpr(cast<Expr>(S));
107 IndentLevel -= (PrefixWidth + 1) / 2;
110 void PrintControlledStmt(
Stmt *S) {
111 if (
auto *CS = dyn_cast<CompoundStmt>(S)) {
113 PrintRawCompoundStmt(CS);
122 void PrintRawDecl(
Decl *
D);
123 void PrintRawDeclStmt(
const DeclStmt *S);
130 bool ForceNoStmt =
false);
135 void PrintExpr(
Expr *
E) {
142 raw_ostream &Indent(
int Delta = 0) {
143 for (
int i = 0, e = IndentLevel+Delta; i < e; ++i)
154 void VisitStmt(
Stmt *
Node) LLVM_ATTRIBUTE_UNUSED {
155 Indent() <<
"<<unknown stmt type>>" << NL;
158 void VisitExpr(
Expr *
Node) LLVM_ATTRIBUTE_UNUSED {
159 OS <<
"<<unknown expr type>>";
164#define ABSTRACT_STMT(CLASS)
165#define STMT(CLASS, PARENT) \
166 void Visit##CLASS(CLASS *Node);
167#include "clang/AST/StmtNodes.inc"
179 assert(
Node &&
"Compound statement cannot be null");
181 PrintFPPragmas(
Node);
182 for (
auto *I :
Node->body())
189 if (!S->hasStoredFPFeatures())
192 bool FEnvAccess =
false;
193 if (FPO.hasAllowFEnvAccessOverride()) {
194 FEnvAccess = FPO.getAllowFEnvAccessOverride();
195 Indent() <<
"#pragma STDC FENV_ACCESS " << (FEnvAccess ?
"ON" :
"OFF")
198 if (FPO.hasSpecifiedExceptionModeOverride()) {
200 FPO.getSpecifiedExceptionModeOverride();
201 if (!FEnvAccess || EM != LangOptions::FPE_Strict) {
202 Indent() <<
"#pragma clang fp exceptions(";
203 switch (FPO.getSpecifiedExceptionModeOverride()) {
206 case LangOptions::FPE_Ignore:
209 case LangOptions::FPE_MayTrap:
212 case LangOptions::FPE_Strict:
219 if (FPO.hasConstRoundingModeOverride()) {
221 Indent() <<
"#pragma STDC FENV_ROUND ";
223 case llvm::RoundingMode::TowardZero:
224 OS <<
"FE_TOWARDZERO";
226 case llvm::RoundingMode::NearestTiesToEven:
227 OS <<
"FE_TONEAREST";
229 case llvm::RoundingMode::TowardPositive:
232 case llvm::RoundingMode::TowardNegative:
235 case llvm::RoundingMode::NearestTiesToAway:
236 OS <<
"FE_TONEARESTFROMZERO";
238 case llvm::RoundingMode::Dynamic:
242 llvm_unreachable(
"Invalid rounding mode");
248void StmtPrinter::PrintRawDecl(
Decl *
D) {
249 D->
print(OS, Policy, IndentLevel);
252void StmtPrinter::PrintRawDeclStmt(
const DeclStmt *S) {
258 Indent() <<
";" << NL;
263 PrintRawDeclStmt(
Node);
265 if (!
Node->isSingleDecl() ||
266 !isa<OpenACCDeclareDecl, OpenACCRoutineDecl>(
Node->getSingleDecl()))
273 PrintRawCompoundStmt(
Node);
278 Indent(-1) <<
"case ";
279 PrintExpr(
Node->getLHS());
280 if (
Node->getRHS()) {
282 PrintExpr(
Node->getRHS());
286 PrintStmt(
Node->getSubStmt(), 0);
290 Indent(-1) <<
"default:" << NL;
291 PrintStmt(
Node->getSubStmt(), 0);
295 Indent(-1) <<
Node->getName() <<
":" << NL;
296 PrintStmt(
Node->getSubStmt(), 0);
301 for (
const auto *
Attr : Attrs) {
303 if (
Attr != Attrs.back())
307 PrintStmt(
Node->getSubStmt(), 0);
310void StmtPrinter::PrintRawIfStmt(
IfStmt *
If) {
311 if (
If->isConsteval()) {
313 if (
If->isNegatedConsteval())
317 PrintStmt(
If->getThen());
318 if (
Stmt *Else =
If->getElse()) {
329 PrintInitStmt(
If->getInit(), 4);
330 if (
const DeclStmt *DS =
If->getConditionVariableDeclStmt())
331 PrintRawDeclStmt(DS);
333 PrintExpr(
If->getCond());
336 if (
auto *CS = dyn_cast<CompoundStmt>(
If->getThen())) {
338 PrintRawCompoundStmt(CS);
339 OS << (
If->getElse() ?
" " : NL);
342 PrintStmt(
If->getThen());
343 if (
If->getElse()) Indent();
346 if (
Stmt *Else =
If->getElse()) {
349 if (
auto *CS = dyn_cast<CompoundStmt>(Else)) {
351 PrintRawCompoundStmt(CS);
353 }
else if (
auto *ElseIf = dyn_cast<IfStmt>(Else)) {
355 PrintRawIfStmt(ElseIf);
358 PrintStmt(
If->getElse());
363void StmtPrinter::VisitIfStmt(
IfStmt *
If) {
369 Indent() <<
"switch (";
371 PrintInitStmt(
Node->getInit(), 8);
372 if (
const DeclStmt *DS =
Node->getConditionVariableDeclStmt())
373 PrintRawDeclStmt(DS);
375 PrintExpr(
Node->getCond());
377 PrintControlledStmt(
Node->getBody());
381 Indent() <<
"while (";
382 if (
const DeclStmt *DS =
Node->getConditionVariableDeclStmt())
383 PrintRawDeclStmt(DS);
385 PrintExpr(
Node->getCond());
387 PrintStmt(
Node->getBody());
392 if (
auto *CS = dyn_cast<CompoundStmt>(
Node->getBody())) {
393 PrintRawCompoundStmt(CS);
397 PrintStmt(
Node->getBody());
402 PrintExpr(
Node->getCond());
409 PrintInitStmt(
Node->getInit(), 5);
411 OS << (
Node->getCond() ?
"; " :
";");
412 if (
const DeclStmt *DS =
Node->getConditionVariableDeclStmt())
413 PrintRawDeclStmt(DS);
414 else if (
Node->getCond())
415 PrintExpr(
Node->getCond());
417 if (
Node->getInc()) {
419 PrintExpr(
Node->getInc());
422 PrintControlledStmt(
Node->getBody());
427 if (
auto *DS = dyn_cast<DeclStmt>(
Node->getElement()))
428 PrintRawDeclStmt(DS);
430 PrintExpr(cast<Expr>(
Node->getElement()));
432 PrintExpr(
Node->getCollection());
434 PrintControlledStmt(
Node->getBody());
440 PrintInitStmt(
Node->getInit(), 5);
442 SubPolicy.SuppressInitializers =
true;
443 Node->getLoopVariable()->
print(OS, SubPolicy, IndentLevel);
445 PrintExpr(
Node->getRangeInit());
447 PrintControlledStmt(
Node->getBody());
452 if (
Node->isIfExists())
453 OS <<
"__if_exists (";
455 OS <<
"__if_not_exists (";
457 Node->getQualifierLoc().getNestedNameSpecifier().
print(OS, Policy);
458 OS <<
Node->getNameInfo() <<
") ";
460 PrintRawCompoundStmt(
Node->getSubStmt());
464 Indent() <<
"goto " <<
Node->getLabel()->getName() <<
";";
469 Indent() <<
"goto *";
470 PrintExpr(
Node->getTarget());
477 if (
Node->hasLabelTarget())
478 OS <<
"continue " <<
Node->getLabelDecl()->getIdentifier()->getName()
487 if (
Node->hasLabelTarget())
488 OS <<
"break " <<
Node->getLabelDecl()->getIdentifier()->getName() <<
';';
495 Indent() <<
"return";
496 if (
Node->getRetValue()) {
498 PrintExpr(
Node->getRetValue());
507 if (
Node->isVolatile())
510 if (
Node->isAsmGoto())
514 Visit(
Node->getAsmStringExpr());
517 if (
Node->getNumOutputs() != 0 ||
Node->getNumInputs() != 0 ||
518 Node->getNumClobbers() != 0 ||
Node->getNumLabels() != 0)
521 for (
unsigned i = 0, e =
Node->getNumOutputs(); i != e; ++i) {
525 if (!
Node->getOutputName(i).empty()) {
527 OS <<
Node->getOutputName(i);
531 Visit(
Node->getOutputConstraintExpr(i));
533 Visit(
Node->getOutputExpr(i));
538 if (
Node->getNumInputs() != 0 ||
Node->getNumClobbers() != 0 ||
539 Node->getNumLabels() != 0)
542 for (
unsigned i = 0, e =
Node->getNumInputs(); i != e; ++i) {
546 if (!
Node->getInputName(i).empty()) {
548 OS <<
Node->getInputName(i);
552 Visit(
Node->getInputConstraintExpr(i));
554 Visit(
Node->getInputExpr(i));
559 if (
Node->getNumClobbers() != 0 ||
Node->getNumLabels())
562 for (
unsigned i = 0, e =
Node->getNumClobbers(); i != e; ++i) {
566 Visit(
Node->getClobberExpr(i));
570 if (
Node->getNumLabels() != 0)
573 for (
unsigned i = 0, e =
Node->getNumLabels(); i != e; ++i) {
576 OS <<
Node->getLabelName(i);
585 Indent() <<
"__asm ";
586 if (
Node->hasBraces())
588 OS <<
Node->getAsmString() << NL;
589 if (
Node->hasBraces())
590 Indent() <<
"}" << NL;
594 PrintStmt(
Node->getCapturedDecl()->getBody());
598 PrintStmt(
Node->getOutlinedFunctionDecl()->getBody());
603 if (
auto *TS = dyn_cast<CompoundStmt>(
Node->getTryBody())) {
604 PrintRawCompoundStmt(TS);
609 Indent() <<
"@catch(";
610 if (
Decl *DS = catchStmt->getCatchParamDecl())
613 if (
auto *CS = dyn_cast<CompoundStmt>(catchStmt->getCatchBody())) {
614 PrintRawCompoundStmt(CS);
620 Indent() <<
"@finally";
621 if (
auto *CS = dyn_cast<CompoundStmt>(FS->getFinallyBody())) {
622 PrintRawCompoundStmt(CS);
632 Indent() <<
"@catch (...) { /* todo */ } " << NL;
636 Indent() <<
"@throw";
637 if (
Node->getThrowExpr()) {
639 PrintExpr(
Node->getThrowExpr());
644void StmtPrinter::VisitObjCAvailabilityCheckExpr(
646 OS <<
"@available(...)";
650 Indent() <<
"@synchronized (";
651 PrintExpr(
Node->getSynchExpr());
653 PrintRawCompoundStmt(
Node->getSynchBody());
658 Indent() <<
"@autoreleasepool";
659 PrintRawCompoundStmt(cast<CompoundStmt>(
Node->getSubStmt()));
665 if (
Decl *ExDecl =
Node->getExceptionDecl())
666 PrintRawDecl(ExDecl);
670 PrintRawCompoundStmt(cast<CompoundStmt>(
Node->getHandlerBlock()));
675 PrintRawCXXCatchStmt(
Node);
681 PrintRawCompoundStmt(
Node->getTryBlock());
682 for (
unsigned i = 0, e =
Node->getNumHandlers(); i < e; ++i) {
684 PrintRawCXXCatchStmt(
Node->getHandler(i));
690 Indent() << (
Node->getIsCXXTry() ?
"try " :
"__try ");
691 PrintRawCompoundStmt(
Node->getTryBlock());
695 PrintRawSEHExceptHandler(
E);
697 assert(F &&
"Must have a finally block...");
698 PrintRawSEHFinallyStmt(F);
705 PrintRawCompoundStmt(
Node->getBlock());
711 VisitExpr(
Node->getFilterExpr());
713 PrintRawCompoundStmt(
Node->getBlock());
719 PrintRawSEHExceptHandler(
Node);
725 PrintRawSEHFinallyStmt(
Node);
730 Indent() <<
"__leave;";
739 PrintStmt(
Node->getLoopStmt());
744 unsigned OpenMPVersion =
745 Context ? Context->
getLangOpts().OpenMP : llvm::omp::FallbackVersion;
748 for (
auto *Clause : Clauses)
749 if (Clause && !Clause->isImplicit()) {
751 Printer.Visit(Clause);
754 if (!ForceNoStmt && S->hasAssociatedStmt())
755 PrintStmt(S->getRawStmt());
759 Indent() <<
"#pragma omp metadirective";
760 PrintOMPExecutableDirective(
Node);
764 Indent() <<
"#pragma omp parallel";
765 PrintOMPExecutableDirective(
Node);
769 Indent() <<
"#pragma omp simd";
770 PrintOMPExecutableDirective(
Node);
774 Indent() <<
"#pragma omp tile";
775 PrintOMPExecutableDirective(
Node);
779 Indent() <<
"#pragma omp stripe";
780 PrintOMPExecutableDirective(
Node);
784 Indent() <<
"#pragma omp unroll";
785 PrintOMPExecutableDirective(
Node);
789 Indent() <<
"#pragma omp reverse";
790 PrintOMPExecutableDirective(
Node);
794 Indent() <<
"#pragma omp interchange";
795 PrintOMPExecutableDirective(
Node);
799 Indent() <<
"#pragma omp for";
800 PrintOMPExecutableDirective(
Node);
804 Indent() <<
"#pragma omp for simd";
805 PrintOMPExecutableDirective(
Node);
809 Indent() <<
"#pragma omp sections";
810 PrintOMPExecutableDirective(
Node);
814 Indent() <<
"#pragma omp section";
815 PrintOMPExecutableDirective(
Node);
819 Indent() <<
"#pragma omp scope";
820 PrintOMPExecutableDirective(
Node);
824 Indent() <<
"#pragma omp single";
825 PrintOMPExecutableDirective(
Node);
829 Indent() <<
"#pragma omp master";
830 PrintOMPExecutableDirective(
Node);
834 Indent() <<
"#pragma omp critical";
835 if (
Node->getDirectiveName().getName()) {
837 Node->getDirectiveName().printName(OS, Policy);
840 PrintOMPExecutableDirective(
Node);
844 Indent() <<
"#pragma omp parallel for";
845 PrintOMPExecutableDirective(
Node);
848void StmtPrinter::VisitOMPParallelForSimdDirective(
850 Indent() <<
"#pragma omp parallel for simd";
851 PrintOMPExecutableDirective(
Node);
854void StmtPrinter::VisitOMPParallelMasterDirective(
856 Indent() <<
"#pragma omp parallel master";
857 PrintOMPExecutableDirective(
Node);
860void StmtPrinter::VisitOMPParallelMaskedDirective(
862 Indent() <<
"#pragma omp parallel masked";
863 PrintOMPExecutableDirective(
Node);
866void StmtPrinter::VisitOMPParallelSectionsDirective(
868 Indent() <<
"#pragma omp parallel sections";
869 PrintOMPExecutableDirective(
Node);
873 Indent() <<
"#pragma omp task";
874 PrintOMPExecutableDirective(
Node);
878 Indent() <<
"#pragma omp taskyield";
879 PrintOMPExecutableDirective(
Node);
883 Indent() <<
"#pragma omp barrier";
884 PrintOMPExecutableDirective(
Node);
888 Indent() <<
"#pragma omp taskwait";
889 PrintOMPExecutableDirective(
Node);
893 Indent() <<
"#pragma omp assume";
894 PrintOMPExecutableDirective(
Node);
898 Indent() <<
"#pragma omp error";
899 PrintOMPExecutableDirective(
Node);
903 Indent() <<
"#pragma omp taskgroup";
904 PrintOMPExecutableDirective(
Node);
908 Indent() <<
"#pragma omp flush";
909 PrintOMPExecutableDirective(
Node);
913 Indent() <<
"#pragma omp depobj";
914 PrintOMPExecutableDirective(
Node);
918 Indent() <<
"#pragma omp scan";
919 PrintOMPExecutableDirective(
Node);
923 Indent() <<
"#pragma omp ordered";
928 Indent() <<
"#pragma omp atomic";
929 PrintOMPExecutableDirective(
Node);
933 Indent() <<
"#pragma omp target";
934 PrintOMPExecutableDirective(
Node);
938 Indent() <<
"#pragma omp target data";
939 PrintOMPExecutableDirective(
Node);
942void StmtPrinter::VisitOMPTargetEnterDataDirective(
944 Indent() <<
"#pragma omp target enter data";
945 PrintOMPExecutableDirective(
Node,
true);
948void StmtPrinter::VisitOMPTargetExitDataDirective(
950 Indent() <<
"#pragma omp target exit data";
951 PrintOMPExecutableDirective(
Node,
true);
954void StmtPrinter::VisitOMPTargetParallelDirective(
956 Indent() <<
"#pragma omp target parallel";
957 PrintOMPExecutableDirective(
Node);
960void StmtPrinter::VisitOMPTargetParallelForDirective(
962 Indent() <<
"#pragma omp target parallel for";
963 PrintOMPExecutableDirective(
Node);
967 Indent() <<
"#pragma omp teams";
968 PrintOMPExecutableDirective(
Node);
971void StmtPrinter::VisitOMPCancellationPointDirective(
973 unsigned OpenMPVersion =
974 Context ? Context->
getLangOpts().OpenMP : llvm::omp::FallbackVersion;
975 Indent() <<
"#pragma omp cancellation point "
976 << getOpenMPDirectiveName(
Node->getCancelRegion(), OpenMPVersion);
977 PrintOMPExecutableDirective(
Node);
981 unsigned OpenMPVersion =
982 Context ? Context->
getLangOpts().OpenMP : llvm::omp::FallbackVersion;
983 Indent() <<
"#pragma omp cancel "
984 << getOpenMPDirectiveName(
Node->getCancelRegion(), OpenMPVersion);
985 PrintOMPExecutableDirective(
Node);
989 Indent() <<
"#pragma omp taskloop";
990 PrintOMPExecutableDirective(
Node);
993void StmtPrinter::VisitOMPTaskLoopSimdDirective(
995 Indent() <<
"#pragma omp taskloop simd";
996 PrintOMPExecutableDirective(
Node);
999void StmtPrinter::VisitOMPMasterTaskLoopDirective(
1001 Indent() <<
"#pragma omp master taskloop";
1002 PrintOMPExecutableDirective(
Node);
1005void StmtPrinter::VisitOMPMaskedTaskLoopDirective(
1007 Indent() <<
"#pragma omp masked taskloop";
1008 PrintOMPExecutableDirective(
Node);
1011void StmtPrinter::VisitOMPMasterTaskLoopSimdDirective(
1013 Indent() <<
"#pragma omp master taskloop simd";
1014 PrintOMPExecutableDirective(
Node);
1017void StmtPrinter::VisitOMPMaskedTaskLoopSimdDirective(
1019 Indent() <<
"#pragma omp masked taskloop simd";
1020 PrintOMPExecutableDirective(
Node);
1023void StmtPrinter::VisitOMPParallelMasterTaskLoopDirective(
1025 Indent() <<
"#pragma omp parallel master taskloop";
1026 PrintOMPExecutableDirective(
Node);
1029void StmtPrinter::VisitOMPParallelMaskedTaskLoopDirective(
1031 Indent() <<
"#pragma omp parallel masked taskloop";
1032 PrintOMPExecutableDirective(
Node);
1035void StmtPrinter::VisitOMPParallelMasterTaskLoopSimdDirective(
1037 Indent() <<
"#pragma omp parallel master taskloop simd";
1038 PrintOMPExecutableDirective(
Node);
1041void StmtPrinter::VisitOMPParallelMaskedTaskLoopSimdDirective(
1043 Indent() <<
"#pragma omp parallel masked taskloop simd";
1044 PrintOMPExecutableDirective(
Node);
1048 Indent() <<
"#pragma omp distribute";
1049 PrintOMPExecutableDirective(
Node);
1052void StmtPrinter::VisitOMPTargetUpdateDirective(
1054 Indent() <<
"#pragma omp target update";
1055 PrintOMPExecutableDirective(
Node,
true);
1058void StmtPrinter::VisitOMPDistributeParallelForDirective(
1060 Indent() <<
"#pragma omp distribute parallel for";
1061 PrintOMPExecutableDirective(
Node);
1064void StmtPrinter::VisitOMPDistributeParallelForSimdDirective(
1066 Indent() <<
"#pragma omp distribute parallel for simd";
1067 PrintOMPExecutableDirective(
Node);
1070void StmtPrinter::VisitOMPDistributeSimdDirective(
1072 Indent() <<
"#pragma omp distribute simd";
1073 PrintOMPExecutableDirective(
Node);
1076void StmtPrinter::VisitOMPTargetParallelForSimdDirective(
1078 Indent() <<
"#pragma omp target parallel for simd";
1079 PrintOMPExecutableDirective(
Node);
1083 Indent() <<
"#pragma omp target simd";
1084 PrintOMPExecutableDirective(
Node);
1087void StmtPrinter::VisitOMPTeamsDistributeDirective(
1089 Indent() <<
"#pragma omp teams distribute";
1090 PrintOMPExecutableDirective(
Node);
1093void StmtPrinter::VisitOMPTeamsDistributeSimdDirective(
1095 Indent() <<
"#pragma omp teams distribute simd";
1096 PrintOMPExecutableDirective(
Node);
1099void StmtPrinter::VisitOMPTeamsDistributeParallelForSimdDirective(
1101 Indent() <<
"#pragma omp teams distribute parallel for simd";
1102 PrintOMPExecutableDirective(
Node);
1105void StmtPrinter::VisitOMPTeamsDistributeParallelForDirective(
1107 Indent() <<
"#pragma omp teams distribute parallel for";
1108 PrintOMPExecutableDirective(
Node);
1112 Indent() <<
"#pragma omp target teams";
1113 PrintOMPExecutableDirective(
Node);
1116void StmtPrinter::VisitOMPTargetTeamsDistributeDirective(
1118 Indent() <<
"#pragma omp target teams distribute";
1119 PrintOMPExecutableDirective(
Node);
1122void StmtPrinter::VisitOMPTargetTeamsDistributeParallelForDirective(
1124 Indent() <<
"#pragma omp target teams distribute parallel for";
1125 PrintOMPExecutableDirective(
Node);
1128void StmtPrinter::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
1130 Indent() <<
"#pragma omp target teams distribute parallel for simd";
1131 PrintOMPExecutableDirective(
Node);
1134void StmtPrinter::VisitOMPTargetTeamsDistributeSimdDirective(
1136 Indent() <<
"#pragma omp target teams distribute simd";
1137 PrintOMPExecutableDirective(
Node);
1141 Indent() <<
"#pragma omp interop";
1142 PrintOMPExecutableDirective(
Node);
1146 Indent() <<
"#pragma omp dispatch";
1147 PrintOMPExecutableDirective(
Node);
1151 Indent() <<
"#pragma omp masked";
1152 PrintOMPExecutableDirective(
Node);
1156 Indent() <<
"#pragma omp loop";
1157 PrintOMPExecutableDirective(
Node);
1160void StmtPrinter::VisitOMPTeamsGenericLoopDirective(
1162 Indent() <<
"#pragma omp teams loop";
1163 PrintOMPExecutableDirective(
Node);
1166void StmtPrinter::VisitOMPTargetTeamsGenericLoopDirective(
1168 Indent() <<
"#pragma omp target teams loop";
1169 PrintOMPExecutableDirective(
Node);
1172void StmtPrinter::VisitOMPParallelGenericLoopDirective(
1174 Indent() <<
"#pragma omp parallel loop";
1175 PrintOMPExecutableDirective(
Node);
1178void StmtPrinter::VisitOMPTargetParallelGenericLoopDirective(
1180 Indent() <<
"#pragma omp target parallel loop";
1181 PrintOMPExecutableDirective(
Node);
1188 if (!S->clauses().empty()) {
1191 Printer.VisitClauseList(S->clauses());
1195 Indent() <<
"#pragma acc " << S->getDirectiveKind();
1196 PrintOpenACCClauseList(S);
1200 PrintOpenACCConstruct(S);
1201 PrintStmt(S->getStructuredBlock());
1205 PrintOpenACCConstruct(S);
1206 PrintStmt(S->getLoop());
1210 PrintOpenACCConstruct(S);
1211 PrintStmt(S->getLoop());
1215 PrintOpenACCConstruct(S);
1216 PrintStmt(S->getStructuredBlock());
1219 PrintOpenACCConstruct(S);
1220 PrintStmt(S->getStructuredBlock());
1223 PrintOpenACCConstruct(S);
1226 PrintOpenACCConstruct(S);
1229 PrintOpenACCConstruct(S);
1232 PrintOpenACCConstruct(S);
1235 PrintOpenACCConstruct(S);
1238 PrintOpenACCConstruct(S);
1242 Indent() <<
"#pragma acc wait";
1243 if (!S->getLParenLoc().isInvalid()) {
1245 if (S->hasDevNumExpr()) {
1247 S->getDevNumExpr()->printPretty(OS,
nullptr, Policy);
1251 if (S->hasQueuesTag())
1254 llvm::interleaveComma(S->getQueueIdExprs(), OS, [&](
const Expr *
E) {
1255 E->printPretty(OS, nullptr, Policy);
1261 PrintOpenACCClauseList(S);
1266 Indent() <<
"#pragma acc atomic";
1268 if (S->getAtomicKind() != OpenACCAtomicKind::None)
1269 OS <<
" " << S->getAtomicKind();
1271 PrintOpenACCClauseList(S);
1273 PrintStmt(S->getAssociatedStmt());
1277 Indent() <<
"#pragma acc cache(";
1278 if (S->hasReadOnly())
1281 llvm::interleaveComma(S->getVarList(), OS, [&](
const Expr *
E) {
1282 E->printPretty(OS, nullptr, Policy);
1293 OS <<
Node->getBuiltinStr() <<
"()";
1300 OS <<
Node->getFileName();
1305 PrintExpr(
Node->getSubExpr());
1310 if (
const auto *OCED = dyn_cast<OMPCapturedExprDecl>(VD)) {
1311 OCED->getInit()->IgnoreImpCasts()->printPretty(OS,
nullptr, Policy);
1314 if (
const auto *TPOD = dyn_cast<TemplateParamObjectDecl>(VD)) {
1315 TPOD->printAsExpr(OS, Policy);
1319 if (
Node->hasTemplateKeyword())
1322 bool ForceAnonymous =
1329 isa<ParmVarDecl, NonTypeTemplateParmDecl>(VD) && ID)
1330 OS <<
ID->deuglifiedName();
1335 case Decl::NonTypeTemplateParm: {
1336 auto *TD = cast<NonTypeTemplateParmDecl>(VD);
1337 OS <<
"value-parameter-" << TD->getDepth() <<
'-' << TD->getIndex() <<
"";
1340 case Decl::ParmVar: {
1341 auto *PD = cast<ParmVarDecl>(VD);
1342 OS <<
"function-parameter-" << PD->getFunctionScopeDepth() <<
'-'
1343 << PD->getFunctionScopeIndex();
1346 case Decl::Decomposition:
1347 OS <<
"decomposition";
1348 for (
const auto &I : cast<DecompositionDecl>(VD)->bindings())
1349 OS <<
'-' << I->getName();
1356 if (
Node->hasExplicitTemplateArgs()) {
1358 if (!
Node->hadMultipleCandidates())
1359 if (
auto *TD = dyn_cast<TemplateDecl>(VD))
1360 TPL = TD->getTemplateParameters();
1365void StmtPrinter::VisitDependentScopeDeclRefExpr(
1368 if (
Node->hasTemplateKeyword())
1370 OS <<
Node->getNameInfo();
1371 if (
Node->hasExplicitTemplateArgs())
1377 if (
Node->hasTemplateKeyword())
1379 OS <<
Node->getNameInfo();
1380 if (
Node->hasExplicitTemplateArgs())
1385 if (
const auto *DRE = dyn_cast<DeclRefExpr>(
E)) {
1386 if (
const auto *PD = dyn_cast<ImplicitParamDecl>(DRE->getDecl())) {
1387 if (PD->getParameterKind() == ImplicitParamKind::ObjCSelf &&
1388 DRE->getBeginLoc().isInvalid())
1396 if (
Node->getBase()) {
1399 PrintExpr(
Node->getBase());
1400 OS << (
Node->isArrow() ?
"->" :
".");
1403 OS << *
Node->getDecl();
1407 if (
Node->isSuperReceiver())
1409 else if (
Node->isObjectReceiver() &&
Node->getBase()) {
1410 PrintExpr(
Node->getBase());
1412 }
else if (
Node->isClassReceiver() &&
Node->getClassReceiver()) {
1413 OS <<
Node->getClassReceiver()->getName() <<
".";
1416 if (
Node->isImplicitProperty()) {
1417 if (
const auto *Getter =
Node->getImplicitPropertyGetter())
1418 Getter->getSelector().
print(OS);
1421 Node->getImplicitPropertySetter()->getSelector());
1423 OS <<
Node->getExplicitProperty()->getName();
1427 PrintExpr(
Node->getBaseExpr());
1429 PrintExpr(
Node->getKeyExpr());
1433void StmtPrinter::VisitSYCLUniqueStableNameExpr(
1435 OS <<
"__builtin_sycl_unique_stable_name(";
1436 Node->getTypeSourceInfo()->getType().
print(OS, Policy);
1472 bool isSigned =
Node->getType()->isSignedIntegerType();
1475 if (isa<BitIntType>(
Node->getType())) {
1476 OS << (isSigned ?
"wb" :
"uwb");
1482 default: llvm_unreachable(
"Unexpected type for integer literal!");
1483 case BuiltinType::Char_S:
1484 case BuiltinType::Char_U: OS <<
"i8";
break;
1485 case BuiltinType::UChar: OS <<
"Ui8";
break;
1486 case BuiltinType::SChar: OS <<
"i8";
break;
1487 case BuiltinType::Short: OS <<
"i16";
break;
1488 case BuiltinType::UShort: OS <<
"Ui16";
break;
1489 case BuiltinType::Int:
break;
1490 case BuiltinType::UInt: OS <<
'U';
break;
1491 case BuiltinType::Long: OS <<
'L';
break;
1492 case BuiltinType::ULong: OS <<
"UL";
break;
1493 case BuiltinType::LongLong: OS <<
"LL";
break;
1494 case BuiltinType::ULongLong: OS <<
"ULL";
break;
1495 case BuiltinType::Int128:
1497 case BuiltinType::UInt128:
1499 case BuiltinType::WChar_S:
1500 case BuiltinType::WChar_U:
1508 OS <<
Node->getValueAsString(10);
1511 default: llvm_unreachable(
"Unexpected type for fixed point literal!");
1512 case BuiltinType::ShortFract: OS <<
"hr";
break;
1513 case BuiltinType::ShortAccum: OS <<
"hk";
break;
1514 case BuiltinType::UShortFract: OS <<
"uhr";
break;
1515 case BuiltinType::UShortAccum: OS <<
"uhk";
break;
1516 case BuiltinType::Fract: OS <<
"r";
break;
1517 case BuiltinType::Accum: OS <<
"k";
break;
1518 case BuiltinType::UFract: OS <<
"ur";
break;
1519 case BuiltinType::UAccum: OS <<
"uk";
break;
1520 case BuiltinType::LongFract: OS <<
"lr";
break;
1521 case BuiltinType::LongAccum: OS <<
"lk";
break;
1522 case BuiltinType::ULongFract: OS <<
"ulr";
break;
1523 case BuiltinType::ULongAccum: OS <<
"ulk";
break;
1530 Node->getValue().toString(Str);
1532 if (Str.find_first_not_of(
"-0123456789") == StringRef::npos)
1540 default: llvm_unreachable(
"Unexpected type for float literal!");
1541 case BuiltinType::Half:
break;
1542 case BuiltinType::Ibm128:
break;
1543 case BuiltinType::Double:
break;
1544 case BuiltinType::Float16: OS <<
"F16";
break;
1545 case BuiltinType::Float: OS <<
'F';
break;
1546 case BuiltinType::LongDouble: OS <<
'L';
break;
1547 case BuiltinType::Float128: OS <<
'Q';
break;
1558 PrintExpr(
Node->getSubExpr());
1568 PrintExpr(
Node->getSubExpr());
1573 if (!
Node->isPostfix()) {
1578 switch (
Node->getOpcode()) {
1587 if (isa<UnaryOperator>(
Node->getSubExpr()))
1592 PrintExpr(
Node->getSubExpr());
1594 if (
Node->isPostfix())
1599 OS <<
"__builtin_offsetof(";
1600 Node->getTypeSourceInfo()->getType().
print(OS, Policy);
1602 bool PrintedSomething =
false;
1603 for (
unsigned i = 0, n =
Node->getNumComponents(); i < n; ++i) {
1610 PrintedSomething =
true;
1623 if (PrintedSomething)
1626 PrintedSomething =
true;
1627 OS <<
Id->getName();
1632void StmtPrinter::VisitUnaryExprOrTypeTraitExpr(
1635 if (
Node->getKind() == UETT_AlignOf) {
1637 Spelling =
"alignof";
1639 Spelling =
"_Alignof";
1641 Spelling =
"__alignof";
1646 if (
Node->isArgumentType()) {
1648 Node->getArgumentType().
print(OS, Policy);
1652 PrintExpr(
Node->getArgumentExpr());
1658 if (
Node->isExprPredicate())
1659 PrintExpr(
Node->getControllingExpr());
1661 Node->getControllingType()->getType().
print(OS, Policy);
1669 T.print(OS, Policy);
1671 PrintExpr(Assoc.getAssociationExpr());
1677 PrintExpr(
Node->getLHS());
1679 PrintExpr(
Node->getRHS());
1684 PrintExpr(
Node->getBase());
1686 PrintExpr(
Node->getRowIdx());
1689 PrintExpr(
Node->getColumnIdx());
1694 PrintExpr(
Node->getBase());
1696 if (
Node->getLowerBound())
1697 PrintExpr(
Node->getLowerBound());
1698 if (
Node->getColonLocFirst().isValid()) {
1700 if (
Node->getLength())
1701 PrintExpr(
Node->getLength());
1703 if (
Node->isOMPArraySection() &&
Node->getColonLocSecond().isValid()) {
1705 if (
Node->getStride())
1706 PrintExpr(
Node->getStride());
1719 PrintExpr(
Node->getBase());
1724 for (
unsigned I = 0,
E =
Node->numOfIterators(); I <
E; ++I) {
1725 auto *VD = cast<ValueDecl>(
Node->getIteratorDecl(I));
1728 OS <<
" " << VD->
getName() <<
" = ";
1729 PrintExpr(
Range.Begin);
1731 PrintExpr(
Range.End);
1734 PrintExpr(
Range.Step);
1743 for (
unsigned i = 0, e =
Call->getNumArgs(); i != e; ++i) {
1744 if (isa<CXXDefaultArgExpr>(
Call->getArg(i))) {
1750 PrintExpr(
Call->getArg(i));
1755 PrintExpr(
Call->getCallee());
1757 PrintCallArgs(
Call);
1762 if (
const auto *TE = dyn_cast<CXXThisExpr>(
E))
1763 return TE->isImplicit();
1769 PrintExpr(
Node->getBase());
1771 auto *ParentMember = dyn_cast<MemberExpr>(
Node->getBase());
1773 ParentMember ? dyn_cast<FieldDecl>(ParentMember->getMemberDecl())
1777 OS << (
Node->isArrow() ?
"->" :
".");
1780 if (
auto *FD = dyn_cast<FieldDecl>(
Node->getMemberDecl()))
1781 if (FD->isAnonymousStructOrUnion())
1785 if (
Node->hasTemplateKeyword())
1787 OS <<
Node->getMemberNameInfo();
1789 if (
auto *FD = dyn_cast<FunctionDecl>(
Node->getMemberDecl())) {
1790 if (!
Node->hadMultipleCandidates())
1791 if (
auto *FTD = FD->getPrimaryTemplate())
1792 TPL = FTD->getTemplateParameters();
1793 }
else if (
auto *VTSD =
1794 dyn_cast<VarTemplateSpecializationDecl>(
Node->getMemberDecl()))
1795 TPL = VTSD->getSpecializedTemplate()->getTemplateParameters();
1796 if (
Node->hasExplicitTemplateArgs())
1801 PrintExpr(
Node->getBase());
1802 OS << (
Node->isArrow() ?
"->isa" :
".isa");
1806 PrintExpr(
Node->getBase());
1808 OS <<
Node->getAccessor().getName();
1813 Node->getTypeAsWritten().
print(OS, Policy);
1815 PrintExpr(
Node->getSubExpr());
1822 PrintExpr(
Node->getInitializer());
1827 PrintExpr(
Node->getSubExpr());
1831 PrintExpr(
Node->getLHS());
1833 PrintExpr(
Node->getRHS());
1837 PrintExpr(
Node->getLHS());
1839 PrintExpr(
Node->getRHS());
1843 PrintExpr(
Node->getCond());
1845 PrintExpr(
Node->getLHS());
1847 PrintExpr(
Node->getRHS());
1854 PrintExpr(
Node->getCommon());
1856 PrintExpr(
Node->getFalseExpr());
1860 OS <<
"&&" <<
Node->getLabel()->getName();
1863void StmtPrinter::VisitStmtExpr(
StmtExpr *
E) {
1865 PrintRawCompoundStmt(
E->getSubStmt());
1870 OS <<
"__builtin_choose_expr(";
1871 PrintExpr(
Node->getCond());
1873 PrintExpr(
Node->getLHS());
1875 PrintExpr(
Node->getRHS());
1879void StmtPrinter::VisitGNUNullExpr(
GNUNullExpr *) {
1884 OS <<
"__builtin_shufflevector(";
1885 for (
unsigned i = 0, e =
Node->getNumSubExprs(); i != e; ++i) {
1887 PrintExpr(
Node->getExpr(i));
1893 OS <<
"__builtin_convertvector(";
1894 PrintExpr(
Node->getSrcExpr());
1901 if (
Node->getSyntacticForm()) {
1902 Visit(
Node->getSyntacticForm());
1907 for (
unsigned i = 0, e =
Node->getNumInits(); i != e; ++i) {
1909 if (
Node->getInit(i))
1910 PrintExpr(
Node->getInit(i));
1921 PrintExpr(
Node->getSubExpr());
1931 for (
unsigned i = 0, e =
Node->getNumExprs(); i != e; ++i) {
1933 PrintExpr(
Node->getExpr(i));
1939 bool NeedsEquals =
true;
1941 if (
D.isFieldDesignator()) {
1942 if (
D.getDotLoc().isInvalid()) {
1944 OS << II->getName() <<
":";
1945 NeedsEquals =
false;
1948 OS <<
"." <<
D.getFieldName()->getName();
1952 if (
D.isArrayDesignator()) {
1953 PrintExpr(
Node->getArrayIndex(
D));
1955 PrintExpr(
Node->getArrayRangeStart(
D));
1957 PrintExpr(
Node->getArrayRangeEnd(
D));
1967 PrintExpr(
Node->getInit());
1970void StmtPrinter::VisitDesignatedInitUpdateExpr(
1974 PrintExpr(
Node->getBase());
1977 OS <<
"/*updater*/";
1978 PrintExpr(
Node->getUpdater());
1983 OS <<
"/*no init*/";
1987 if (
Node->getType()->getAsCXXRecordDecl()) {
1988 OS <<
"/*implicit*/";
1992 OS <<
"/*implicit*/(";
1995 if (
Node->getType()->isRecordType())
2003 OS <<
"__builtin_va_arg(";
2004 PrintExpr(
Node->getSubExpr());
2011 PrintExpr(
Node->getSyntacticForm());
2015 const char *Name =
nullptr;
2016 switch (
Node->getOp()) {
2017#define ATOMIC_BUILTIN(ID, TYPE, ATTRS) \
2018 case AtomicExpr::AO ## ID: \
2021#include "clang/Basic/Builtins.inc"
2026 PrintExpr(
Node->getPtr());
2027 if (
Node->getOp() != AtomicExpr::AO__c11_atomic_load &&
2028 Node->getOp() != AtomicExpr::AO__atomic_load_n &&
2029 Node->getOp() != AtomicExpr::AO__scoped_atomic_load_n &&
2030 Node->getOp() != AtomicExpr::AO__opencl_atomic_load &&
2031 Node->getOp() != AtomicExpr::AO__hip_atomic_load) {
2033 PrintExpr(
Node->getVal1());
2035 if (
Node->getOp() == AtomicExpr::AO__atomic_exchange ||
2036 Node->isCmpXChg()) {
2038 PrintExpr(
Node->getVal2());
2040 if (
Node->getOp() == AtomicExpr::AO__atomic_compare_exchange ||
2041 Node->getOp() == AtomicExpr::AO__atomic_compare_exchange_n) {
2043 PrintExpr(
Node->getWeak());
2045 if (
Node->getOp() != AtomicExpr::AO__c11_atomic_init &&
2046 Node->getOp() != AtomicExpr::AO__opencl_atomic_init) {
2048 PrintExpr(
Node->getOrder());
2050 if (
Node->isCmpXChg()) {
2052 PrintExpr(
Node->getOrderFail());
2060 if (Kind == OO_PlusPlus || Kind == OO_MinusMinus) {
2061 if (
Node->getNumArgs() == 1) {
2063 PrintExpr(
Node->getArg(0));
2065 PrintExpr(
Node->getArg(0));
2068 }
else if (Kind == OO_Arrow) {
2069 PrintExpr(
Node->getArg(0));
2070 }
else if (Kind == OO_Call || Kind == OO_Subscript) {
2071 PrintExpr(
Node->getArg(0));
2072 OS << (
Kind == OO_Call ?
'(' :
'[');
2073 for (
unsigned ArgIdx = 1; ArgIdx <
Node->getNumArgs(); ++ArgIdx) {
2076 if (!isa<CXXDefaultArgExpr>(
Node->getArg(ArgIdx)))
2077 PrintExpr(
Node->getArg(ArgIdx));
2079 OS << (
Kind == OO_Call ?
')' :
']');
2080 }
else if (
Node->getNumArgs() == 1) {
2082 PrintExpr(
Node->getArg(0));
2083 }
else if (
Node->getNumArgs() == 2) {
2084 PrintExpr(
Node->getArg(0));
2086 PrintExpr(
Node->getArg(1));
2088 llvm_unreachable(
"unknown overloaded operator");
2095 if (isa_and_nonnull<CXXConversionDecl>(MD)) {
2096 PrintExpr(
Node->getImplicitObjectArgument());
2099 VisitCallExpr(cast<CallExpr>(
Node));
2103 PrintExpr(
Node->getCallee());
2105 PrintCallArgs(
Node->getConfig());
2107 PrintCallArgs(
Node);
2111void StmtPrinter::VisitCXXRewrittenBinaryOperator(
2114 Node->getDecomposedForm();
2115 PrintExpr(
const_cast<Expr*
>(Decomposed.
LHS));
2117 PrintExpr(
const_cast<Expr*
>(Decomposed.
RHS));
2121 OS <<
Node->getCastName() <<
'<';
2122 Node->getTypeAsWritten().
print(OS, Policy);
2124 PrintExpr(
Node->getSubExpr());
2129 VisitCXXNamedCastExpr(
Node);
2133 VisitCXXNamedCastExpr(
Node);
2137 VisitCXXNamedCastExpr(
Node);
2141 VisitCXXNamedCastExpr(
Node);
2145 OS <<
"__builtin_bit_cast(";
2146 Node->getTypeInfoAsWritten()->getType().
print(OS, Policy);
2148 PrintExpr(
Node->getSubExpr());
2153 VisitCXXNamedCastExpr(
Node);
2158 if (
Node->isTypeOperand()) {
2159 Node->getTypeOperandSourceInfo()->getType().
print(OS, Policy);
2161 PrintExpr(
Node->getExprOperand());
2168 if (
Node->isTypeOperand()) {
2169 Node->getTypeOperandSourceInfo()->getType().
print(OS, Policy);
2171 PrintExpr(
Node->getExprOperand());
2177 PrintExpr(
Node->getBaseExpr());
2178 if (
Node->isArrow())
2182 Node->getQualifierLoc().getNestedNameSpecifier().
print(OS, Policy);
2183 OS <<
Node->getPropertyDecl()->getDeclName();
2187 PrintExpr(
Node->getBase());
2189 PrintExpr(
Node->getIdx());
2194 switch (
Node->getLiteralOperatorKind()) {
2196 OS << cast<StringLiteral>(
Node->getArg(0)->IgnoreImpCasts())->getString();
2199 const auto *DRE = cast<DeclRefExpr>(
Node->getCallee()->IgnoreImpCasts());
2201 cast<FunctionDecl>(DRE->getDecl())->getTemplateSpecializationArgs();
2206 if (!DRE->hadMultipleCandidates())
2207 if (
const auto *TD = dyn_cast<TemplateDecl>(DRE->getDecl()))
2208 TPL = TD->getTemplateParameters();
2209 OS <<
"operator\"\"" <<
Node->getUDSuffix()->getName();
2217 char C = (char)
P.getAsIntegral().getZExtValue();
2224 const auto *
Int = cast<IntegerLiteral>(
Node->getCookedLiteral());
2230 auto *
Float = cast<FloatingLiteral>(
Node->getCookedLiteral());
2236 PrintExpr(
Node->getCookedLiteral());
2239 OS <<
Node->getUDSuffix()->getName();
2243 OS << (
Node->getValue() ?
"true" :
"false");
2255 if (!
Node->getSubExpr())
2259 PrintExpr(
Node->getSubExpr());
2272 auto TargetType =
Node->getType();
2273 auto *
Auto = TargetType->getContainedDeducedType();
2274 bool Bare =
Auto &&
Auto->isDeduced();
2279 TargetType.print(OS, Policy);
2284 if (!
Node->isListInitialization())
2286 PrintExpr(
Node->getSubExpr());
2287 if (!
Node->isListInitialization())
2292 PrintExpr(
Node->getSubExpr());
2297 if (
Node->isStdInitListInitialization())
2299 else if (
Node->isListInitialization())
2304 ArgEnd =
Node->arg_end();
2305 Arg != ArgEnd; ++Arg) {
2306 if ((*Arg)->isDefaultArgument())
2308 if (Arg !=
Node->arg_begin())
2312 if (
Node->isStdInitListInitialization())
2314 else if (
Node->isListInitialization())
2322 bool NeedComma =
false;
2323 switch (
Node->getCaptureDefault()) {
2338 CEnd =
Node->explicit_capture_end();
2341 if (
C->capturesVLAType())
2348 switch (
C->getCaptureKind()) {
2360 OS <<
C->getCapturedVar()->getName();
2364 OS <<
C->getCapturedVar()->getName();
2368 llvm_unreachable(
"VLA type in explicit captures.");
2371 if (
C->isPackExpansion())
2374 if (
Node->isInitCapture(
C)) {
2376 auto *
D = cast<VarDecl>(
C->getCapturedVar());
2378 llvm::StringRef
Pre;
2379 llvm::StringRef
Post;
2381 !isa<ParenListExpr>(
D->getInit())) {
2389 PrintExpr(
D->getInit());
2395 if (!
Node->getExplicitTemplateParameters().empty()) {
2396 Node->getTemplateParameterList()->
print(
2397 OS,
Node->getLambdaClass()->getASTContext(),
2401 if (
Node->hasExplicitParameters()) {
2405 for (
const auto *
P :
Method->parameters()) {
2411 std::string ParamStr =
2413 ?
P->getIdentifier()->deuglifiedName().str()
2414 :
P->getNameAsString();
2415 P->getOriginalType().print(OS, Policy, ParamStr);
2417 if (
Method->isVariadic()) {
2424 if (
Node->isMutable())
2433 if (
Node->hasExplicitResultType()) {
2435 Proto->getReturnType().print(OS, Policy);
2444 PrintRawCompoundStmt(
Node->getCompoundStmtBody());
2449 TSInfo->getType().print(OS, Policy);
2456 if (
E->isGlobalNew())
2459 unsigned NumPlace =
E->getNumPlacementArgs();
2460 if (NumPlace > 0 && !isa<CXXDefaultArgExpr>(
E->getPlacementArg(0))) {
2462 PrintExpr(
E->getPlacementArg(0));
2463 for (
unsigned i = 1; i < NumPlace; ++i) {
2464 if (isa<CXXDefaultArgExpr>(
E->getPlacementArg(i)))
2467 PrintExpr(
E->getPlacementArg(i));
2471 if (
E->isParenTypeId())
2475 llvm::raw_string_ostream
s(TypeS);
2477 if (std::optional<Expr *> Size =
E->getArraySize())
2478 (*Size)->printPretty(
s, Helper, Policy);
2481 E->getAllocatedType().print(OS, Policy, TypeS);
2482 if (
E->isParenTypeId())
2486 if (InitStyle != CXXNewInitializationStyle::None) {
2487 bool Bare = InitStyle == CXXNewInitializationStyle::Parens &&
2488 !isa<ParenListExpr>(
E->getInitializer());
2491 PrintExpr(
E->getInitializer());
2498 if (
E->isGlobalDelete())
2501 if (
E->isArrayForm())
2503 PrintExpr(
E->getArgument());
2507 PrintExpr(
E->getBase());
2512 E->getQualifier().print(OS, Policy);
2516 OS << II->getName();
2518 E->getDestroyedType().print(OS, Policy);
2522 if (
E->isListInitialization() && !
E->isStdInitListInitialization())
2525 for (
unsigned i = 0, e =
E->getNumArgs(); i != e; ++i) {
2526 if (isa<CXXDefaultArgExpr>(
E->getArg(i))) {
2532 PrintExpr(
E->getArg(i));
2535 if (
E->isListInitialization() && !
E->isStdInitListInitialization())
2541 OS <<
"<forwarded>";
2545 PrintExpr(
E->getSubExpr());
2550 PrintExpr(
E->getSubExpr());
2553void StmtPrinter::VisitCXXUnresolvedConstructExpr(
2555 Node->getTypeAsWritten().
print(OS, Policy);
2556 if (!
Node->isListInitialization())
2558 for (
auto Arg =
Node->arg_begin(), ArgEnd =
Node->arg_end(); Arg != ArgEnd;
2560 if (Arg !=
Node->arg_begin())
2564 if (!
Node->isListInitialization())
2568void StmtPrinter::VisitCXXDependentScopeMemberExpr(
2570 if (!
Node->isImplicitAccess()) {
2571 PrintExpr(
Node->getBase());
2572 OS << (
Node->isArrow() ?
"->" :
".");
2575 if (
Node->hasTemplateKeyword())
2577 OS <<
Node->getMemberNameInfo();
2578 if (
Node->hasExplicitTemplateArgs())
2583 if (!
Node->isImplicitAccess()) {
2584 PrintExpr(
Node->getBase());
2585 OS << (
Node->isArrow() ?
"->" :
".");
2588 if (
Node->hasTemplateKeyword())
2590 OS <<
Node->getMemberNameInfo();
2591 if (
Node->hasExplicitTemplateArgs())
2597 for (
unsigned I = 0, N =
E->getNumArgs(); I != N; ++I) {
2607 E->getQueriedType().print(OS, Policy);
2613 PrintExpr(
E->getQueriedExpression());
2619 PrintExpr(
E->getOperand());
2624 PrintExpr(
E->getPattern());
2629 OS <<
"sizeof...(" << *
E->getPack() <<
")";
2633 PrintExpr(
E->getPackIdExpression());
2635 PrintExpr(
E->getIndexExpr());
2639void StmtPrinter::VisitSubstNonTypeTemplateParmPackExpr(
2641 OS << *
Node->getParameterPack();
2644void StmtPrinter::VisitSubstNonTypeTemplateParmExpr(
2646 Visit(
Node->getReplacement());
2650 OS << *
E->getParameterPack();
2654 PrintExpr(
Node->getSubExpr());
2660 PrintExpr(
E->getLHS());
2666 PrintExpr(
E->getRHS());
2672 llvm::interleaveComma(
Node->getUserSpecifiedInitExprs(), OS,
2673 [&](
Expr *
E) { PrintExpr(E); });
2679 if (
E->getTemplateKWLoc().isValid())
2681 OS <<
E->getFoundDecl()->getName();
2684 E->getNamedConcept()->getTemplateParameters());
2689 auto LocalParameters =
E->getLocalParameters();
2690 if (!LocalParameters.empty()) {
2693 PrintRawDecl(LocalParam);
2694 if (LocalParam != LocalParameters.back())
2701 auto Requirements =
E->getRequirements();
2703 if (
auto *TypeReq = dyn_cast<concepts::TypeRequirement>(Req)) {
2704 if (TypeReq->isSubstitutionFailure())
2705 OS <<
"<<error-type>>";
2707 TypeReq->getType()->getType().print(OS, Policy);
2708 }
else if (
auto *ExprReq = dyn_cast<concepts::ExprRequirement>(Req)) {
2709 if (ExprReq->isCompound())
2711 if (ExprReq->isExprSubstitutionFailure())
2712 OS <<
"<<error-expression>>";
2714 PrintExpr(ExprReq->getExpr());
2715 if (ExprReq->isCompound()) {
2717 if (ExprReq->getNoexceptLoc().isValid())
2719 const auto &RetReq = ExprReq->getReturnTypeRequirement();
2720 if (!RetReq.isEmpty()) {
2722 if (RetReq.isSubstitutionFailure())
2723 OS <<
"<<error-type>>";
2724 else if (RetReq.isTypeConstraint())
2725 RetReq.getTypeConstraint()->print(OS, Policy);
2729 auto *NestedReq = cast<concepts::NestedRequirement>(Req);
2731 if (NestedReq->hasInvalidConstraint())
2732 OS <<
"<<error-expression>>";
2734 PrintExpr(NestedReq->getConstraintExpr());
2744 Visit(S->getBody());
2749 if (S->getOperand()) {
2751 Visit(S->getOperand());
2756void StmtPrinter::VisitCoawaitExpr(
CoawaitExpr *S) {
2758 PrintExpr(S->getOperand());
2763 PrintExpr(S->getOperand());
2766void StmtPrinter::VisitCoyieldExpr(
CoyieldExpr *S) {
2768 PrintExpr(S->getOperand());
2775 VisitStringLiteral(
Node->getString());
2780 Visit(
E->getSubExpr());
2786 for (
auto I = Ch.begin(),
E = Ch.end(); I !=
E; ++I) {
2787 if (I != Ch.begin())
2796 for (
unsigned I = 0, N =
E->getNumElements(); I != N; ++I) {
2803 Visit(Element.Value);
2804 if (Element.isPackExpansion())
2812 Node->getEncodedType().
print(OS, Policy);
2823 OS <<
"@protocol(" << *
Node->getProtocol() <<
')';
2848 for (
unsigned i = 0, e = Mess->
getNumArgs(); i != e; ++i) {
2850 if (i > 0) OS <<
' ';
2858 PrintExpr(Mess->
getArg(i));
2865 OS << (
Node->getValue() ?
"__objc_yes" :
"__objc_no");
2870 PrintExpr(
E->getSubExpr());
2875 OS <<
'(' <<
E->getBridgeKindName();
2878 PrintExpr(
E->getSubExpr());
2887 if (isa<FunctionNoProtoType>(AFT)) {
2889 }
else if (!BD->
param_empty() || cast<FunctionProtoType>(AFT)->isVariadic()) {
2894 std::string ParamStr = (*AI)->getNameAsString();
2895 (*AI)->getType().print(OS, Policy, ParamStr);
2898 const auto *FT = cast<FunctionProtoType>(AFT);
2899 if (FT->isVariadic()) {
2909 PrintExpr(
Node->getSourceExpr());
2913 OS <<
"<recovery-expr>(";
2914 const char *Sep =
"";
2915 for (
Expr *
E :
Node->subExpressions()) {
2924 OS <<
"__builtin_astype(";
2925 PrintExpr(
Node->getSrcExpr());
2932 PrintExpr(
Node->getArgLValue());
2945 StringRef NL,
const ASTContext *Context)
const {
2946 StmtPrinter
P(Out, Helper, Policy, Indentation, NL, Context);
2947 P.Visit(
const_cast<Stmt *
>(
this));
2952 unsigned Indentation, StringRef NL,
2954 StmtPrinter
P(Out, Helper, Policy, Indentation, NL, Context);
2955 P.PrintControlledStmt(
const_cast<Stmt *
>(
this));
2961 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 OpenACC nodes for declarative directives.
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.
Represents a reference to a function parameter pack, init-capture pack, or binding pack that has been...
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.
void print(raw_ostream &OS, const PrintingPolicy &Policy, bool ResolveTemplateArguments=false, bool PrintFinalScopeResOp=true) 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 the '#pragma omp stripe' loop transformation 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.
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 PrintAsCanonical
Whether to print entities as written or canonically.
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 *.