47#include "llvm/ADT/ArrayRef.h"
48#include "llvm/ADT/STLExtras.h"
49#include "llvm/ADT/Sequence.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> {
70 PrinterHelper* Helper;
71 PrintingPolicy Policy;
73 const ASTContext *Context;
76 StmtPrinter(raw_ostream &os, PrinterHelper *helper,
77 const PrintingPolicy &Policy,
unsigned Indentation = 0,
78 StringRef NL =
"\n",
const ASTContext *Context =
nullptr)
79 : OS(os), IndentLevel(Indentation), Helper(helper), Policy(Policy),
80 NL(NL), Context(Context) {}
82 void PrintStmt(Stmt *S) { PrintStmt(S, Policy.Indentation); }
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);
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);
124 void PrintRawIfStmt(IfStmt *
If);
125 void PrintRawCXXCatchStmt(CXXCatchStmt *Catch);
126 void PrintCallArgs(CallExpr *E);
127 void PrintRawSEHExceptHandler(SEHExceptStmt *S);
128 void PrintRawSEHFinallyStmt(SEHFinallyStmt *S);
129 void PrintOMPExecutableDirective(OMPExecutableDirective *S,
130 bool ForceNoStmt =
false);
132 void PrintOpenACCClauseList(OpenACCConstructStmt *S);
133 void PrintOpenACCConstruct(OpenACCConstructStmt *S);
135 void PrintExpr(Expr *E) {
142 raw_ostream &
Indent(
int Delta = 0) {
143 for (
int i = 0, e = IndentLevel+Delta; i < e; ++i)
148 void Visit(Stmt* S) {
149 if (Helper && Helper->handledStmt(S,OS))
151 else StmtVisitor<StmtPrinter>::Visit(S);
154 [[maybe_unused]]
void VisitStmt(Stmt *Node) {
155 Indent() <<
"<<unknown stmt type>>" << NL;
158 [[maybe_unused]]
void VisitExpr(Expr *Node) {
159 OS <<
"<<unknown expr type>>";
162 void VisitCXXNamedCastExpr(CXXNamedCastExpr *Node);
164 void VisitBinComma(BinaryOperator *Node);
166#define ABSTRACT_STMT(CLASS)
167#define STMT(CLASS, PARENT) \
168 void Visit##CLASS(CLASS *Node);
169#include "clang/AST/StmtNodes.inc"
180void StmtPrinter::PrintRawCompoundStmt(
CompoundStmt *Node) {
181 assert(Node &&
"Compound statement cannot be null");
183 PrintFPPragmas(Node);
184 for (
auto *I : Node->
body())
194 bool FEnvAccess =
false;
195 if (FPO.hasAllowFEnvAccessOverride()) {
196 FEnvAccess = FPO.getAllowFEnvAccessOverride();
197 Indent() <<
"#pragma STDC FENV_ACCESS " << (FEnvAccess ?
"ON" :
"OFF")
200 if (FPO.hasSpecifiedExceptionModeOverride()) {
201 LangOptions::FPExceptionModeKind EM =
202 FPO.getSpecifiedExceptionModeOverride();
203 if (!FEnvAccess || EM != LangOptions::FPE_Strict) {
204 Indent() <<
"#pragma clang fp exceptions(";
205 switch (FPO.getSpecifiedExceptionModeOverride()) {
208 case LangOptions::FPE_Ignore:
211 case LangOptions::FPE_MayTrap:
214 case LangOptions::FPE_Strict:
221 if (FPO.hasConstRoundingModeOverride()) {
222 LangOptions::RoundingMode RM = FPO.getConstRoundingModeOverride();
223 Indent() <<
"#pragma STDC FENV_ROUND ";
225 case llvm::RoundingMode::TowardZero:
226 OS <<
"FE_TOWARDZERO";
228 case llvm::RoundingMode::NearestTiesToEven:
229 OS <<
"FE_TONEAREST";
231 case llvm::RoundingMode::TowardPositive:
234 case llvm::RoundingMode::TowardNegative:
237 case llvm::RoundingMode::NearestTiesToAway:
238 OS <<
"FE_TONEARESTFROMZERO";
240 case llvm::RoundingMode::Dynamic:
244 llvm_unreachable(
"Invalid rounding mode");
250void StmtPrinter::PrintRawDecl(Decl *D) {
254void StmtPrinter::PrintRawDeclStmt(
const DeclStmt *S) {
255 SmallVector<Decl *, 2> Decls(S->
decls());
259void StmtPrinter::VisitNullStmt(NullStmt *Node) {
263void StmtPrinter::VisitDeclStmt(DeclStmt *Node) {
265 PrintRawDeclStmt(Node);
274void StmtPrinter::VisitCompoundStmt(
CompoundStmt *Node) {
276 PrintRawCompoundStmt(Node);
280void StmtPrinter::VisitCaseStmt(CaseStmt *Node) {
282 PrintExpr(Node->
getLHS());
285 PrintExpr(Node->
getRHS());
292void StmtPrinter::VisitDefaultStmt(DefaultStmt *Node) {
293 Indent(-1) <<
"default:" << NL;
297void StmtPrinter::VisitLabelStmt(LabelStmt *Node) {
302void StmtPrinter::VisitAttributedStmt(AttributedStmt *Node) {
303 ArrayRef<const Attr *> Attrs = Node->
getAttrs();
304 for (
const auto *Attr : Attrs) {
305 Attr->printPretty(OS, Policy);
306 if (Attr != Attrs.back())
313void StmtPrinter::PrintRawIfStmt(IfStmt *
If) {
314 if (
If->isConsteval()) {
316 if (
If->isNegatedConsteval())
320 PrintStmt(
If->getThen());
321 if (Stmt *Else =
If->getElse()) {
332 PrintInitStmt(
If->getInit(), 4);
333 if (
const DeclStmt *DS =
If->getConditionVariableDeclStmt())
334 PrintRawDeclStmt(DS);
336 PrintExpr(
If->getCond());
339 if (
auto *CS = dyn_cast<CompoundStmt>(
If->getThen())) {
341 PrintRawCompoundStmt(CS);
342 OS << (
If->getElse() ?
" " : NL);
345 PrintStmt(
If->getThen());
349 if (Stmt *Else =
If->getElse()) {
352 if (
auto *CS = dyn_cast<CompoundStmt>(Else)) {
354 PrintRawCompoundStmt(CS);
356 }
else if (
auto *ElseIf = dyn_cast<IfStmt>(Else)) {
358 PrintRawIfStmt(ElseIf);
361 PrintStmt(
If->getElse());
366void StmtPrinter::VisitIfStmt(IfStmt *
If) {
371void StmtPrinter::VisitSwitchStmt(SwitchStmt *Node) {
374 PrintInitStmt(Node->
getInit(), 8);
376 PrintRawDeclStmt(DS);
380 PrintControlledStmt(Node->
getBody());
383void StmtPrinter::VisitWhileStmt(WhileStmt *Node) {
386 PrintRawDeclStmt(DS);
393void StmtPrinter::VisitDoStmt(DoStmt *Node) {
395 if (
auto *CS = dyn_cast<CompoundStmt>(Node->
getBody())) {
396 PrintRawCompoundStmt(CS);
409void StmtPrinter::VisitForStmt(ForStmt *Node) {
412 PrintInitStmt(Node->
getInit(), 5);
416 PrintRawDeclStmt(DS);
422 PrintExpr(Node->
getInc());
425 PrintControlledStmt(Node->
getBody());
428void StmtPrinter::VisitObjCForCollectionStmt(ObjCForCollectionStmt *Node) {
430 if (
auto *DS = dyn_cast<DeclStmt>(Node->
getElement()))
431 PrintRawDeclStmt(DS);
437 PrintControlledStmt(Node->
getBody());
440void StmtPrinter::VisitCXXForRangeStmt(CXXForRangeStmt *Node) {
443 PrintInitStmt(Node->
getInit(), 5);
444 PrintingPolicy SubPolicy(Policy);
445 SubPolicy.SuppressInitializers =
true;
450 PrintControlledStmt(Node->
getBody());
453void StmtPrinter::VisitCXXExpansionStmtPattern(CXXExpansionStmtPattern *Node) {
454 OS <<
"template for (";
456 PrintInitStmt(Node->
getInit(), 14);
457 PrintingPolicy SubPolicy(Policy);
458 SubPolicy.SuppressInitializers =
true;
472 PrintControlledStmt(Node->
getBody());
475void StmtPrinter::VisitCXXExpansionStmtInstantiation(
476 CXXExpansionStmtInstantiation *) {
477 llvm_unreachable(
"should never be printed");
480void StmtPrinter::VisitCXXExpansionSelectExpr(CXXExpansionSelectExpr *Node) {
484void StmtPrinter::VisitMSDependentExistsStmt(MSDependentExistsStmt *Node) {
487 OS <<
"__if_exists (";
489 OS <<
"__if_not_exists (";
497void StmtPrinter::VisitGotoStmt(GotoStmt *Node) {
502void StmtPrinter::VisitIndirectGotoStmt(IndirectGotoStmt *Node) {
509void StmtPrinter::VisitContinueStmt(ContinueStmt *Node) {
519void StmtPrinter::VisitBreakStmt(BreakStmt *Node) {
528void StmtPrinter::VisitDeferStmt(DeferStmt *Node) {
530 PrintControlledStmt(Node->
getBody());
533void StmtPrinter::VisitReturnStmt(ReturnStmt *Node) {
543void StmtPrinter::VisitGCCAsmStmt(GCCAsmStmt *Node) {
560 for (
unsigned i = 0, e = Node->
getNumOutputs(); i != e; ++i) {
581 for (
unsigned i = 0, e = Node->
getNumInputs(); i != e; ++i) {
612 for (
unsigned i = 0, e = Node->
getNumLabels(); i != e; ++i) {
622void StmtPrinter::VisitMSAsmStmt(MSAsmStmt *Node) {
632void StmtPrinter::VisitCapturedStmt(CapturedStmt *Node) {
636void StmtPrinter::VisitSYCLKernelCallStmt(SYCLKernelCallStmt *Node) {
640void StmtPrinter::VisitObjCAtTryStmt(ObjCAtTryStmt *Node) {
642 if (
auto *TS = dyn_cast<CompoundStmt>(Node->
getTryBody())) {
643 PrintRawCompoundStmt(TS);
647 for (ObjCAtCatchStmt *catchStmt : Node->
catch_stmts()) {
649 if (Decl *DS = catchStmt->getCatchParamDecl())
652 if (
auto *CS = dyn_cast<CompoundStmt>(catchStmt->getCatchBody())) {
653 PrintRawCompoundStmt(CS);
660 if (
auto *CS = dyn_cast<CompoundStmt>(FS->getFinallyBody())) {
661 PrintRawCompoundStmt(CS);
667void StmtPrinter::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *Node) {
670void StmtPrinter::VisitObjCAtCatchStmt (ObjCAtCatchStmt *Node) {
671 Indent() <<
"@catch (...) { /* todo */ } " << NL;
674void StmtPrinter::VisitObjCAtThrowStmt(ObjCAtThrowStmt *Node) {
683void StmtPrinter::VisitObjCAvailabilityCheckExpr(
684 ObjCAvailabilityCheckExpr *Node) {
685 OS <<
"@available(...)";
688void StmtPrinter::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *Node) {
689 Indent() <<
"@synchronized (";
696void StmtPrinter::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *Node) {
697 Indent() <<
"@autoreleasepool";
702void StmtPrinter::PrintRawCXXCatchStmt(CXXCatchStmt *Node) {
705 PrintRawDecl(ExDecl);
712void StmtPrinter::VisitCXXCatchStmt(CXXCatchStmt *Node) {
714 PrintRawCXXCatchStmt(Node);
718void StmtPrinter::VisitCXXTryStmt(CXXTryStmt *Node) {
728void StmtPrinter::VisitSEHTryStmt(SEHTryStmt *Node) {
734 PrintRawSEHExceptHandler(E);
736 assert(F &&
"Must have a finally block...");
737 PrintRawSEHFinallyStmt(F);
742void StmtPrinter::PrintRawSEHFinallyStmt(SEHFinallyStmt *Node) {
744 PrintRawCompoundStmt(Node->
getBlock());
748void StmtPrinter::PrintRawSEHExceptHandler(SEHExceptStmt *Node) {
752 PrintRawCompoundStmt(Node->
getBlock());
756void StmtPrinter::VisitSEHExceptStmt(SEHExceptStmt *Node) {
758 PrintRawSEHExceptHandler(Node);
762void StmtPrinter::VisitSEHFinallyStmt(SEHFinallyStmt *Node) {
764 PrintRawSEHFinallyStmt(Node);
768void StmtPrinter::VisitSEHLeaveStmt(SEHLeaveStmt *Node) {
777void StmtPrinter::VisitOMPCanonicalLoop(OMPCanonicalLoop *Node) {
778 PrintStmt(Node->getLoopStmt());
781void StmtPrinter::PrintOMPExecutableDirective(OMPExecutableDirective *S,
783 llvm::omp::Version OpenMPVersion =
785 : llvm::omp::FallbackVersion;
786 OMPClausePrinter Printer(OS, Policy, OpenMPVersion);
787 ArrayRef<OMPClause *> Clauses = S->clauses();
788 for (
auto *Clause : Clauses)
789 if (Clause && !Clause->isImplicit()) {
791 Printer.Visit(Clause);
794 if (!ForceNoStmt && S->hasAssociatedStmt())
795 PrintStmt(S->getRawStmt());
798void StmtPrinter::VisitOMPMetaDirective(OMPMetaDirective *Node) {
799 Indent() <<
"#pragma omp metadirective";
800 llvm::omp::Version OpenMPVersion =
802 : llvm::omp::FallbackVersion;
803 OMPClausePrinter Printer(OS, Policy, OpenMPVersion);
804 ArrayRef<Stmt *> Variants = Node->
variants();
805 ArrayRef<OMPTraitInfo *> TraitInfos = Node->
traitInfos();
806 unsigned NumClauses =
808 for (
unsigned I : llvm::seq<unsigned>(NumClauses)) {
809 if (TraitInfos[I]->Sets.empty()) {
810 OS << (OpenMPVersion < 52 ?
" default(" :
" otherwise(");
813 TraitInfos[I]->print(OS, Policy);
816 if (
auto *D = dyn_cast<OMPExecutableDirective>(Variants[I])) {
817 OS << getOpenMPDirectiveName(D->getDirectiveKind(), OpenMPVersion);
818 for (OMPClause *
C : D->clauses()) {
819 if (
C && !
C->isImplicit()) {
829 Stmt *Body = Variants.front();
830 if (
auto *D = dyn_cast<OMPExecutableDirective>(Body))
831 Body = D->getRawStmt();
835void StmtPrinter::VisitOMPParallelDirective(OMPParallelDirective *Node) {
836 Indent() <<
"#pragma omp parallel";
837 PrintOMPExecutableDirective(Node);
840void StmtPrinter::VisitOMPSimdDirective(OMPSimdDirective *Node) {
841 Indent() <<
"#pragma omp simd";
842 PrintOMPExecutableDirective(Node);
845void StmtPrinter::VisitOMPTileDirective(OMPTileDirective *Node) {
846 Indent() <<
"#pragma omp tile";
847 PrintOMPExecutableDirective(Node);
850void StmtPrinter::VisitOMPStripeDirective(OMPStripeDirective *Node) {
851 Indent() <<
"#pragma omp stripe";
852 PrintOMPExecutableDirective(Node);
855void StmtPrinter::VisitOMPUnrollDirective(OMPUnrollDirective *Node) {
856 Indent() <<
"#pragma omp unroll";
857 PrintOMPExecutableDirective(Node);
860void StmtPrinter::VisitOMPReverseDirective(OMPReverseDirective *Node) {
861 Indent() <<
"#pragma omp reverse";
862 PrintOMPExecutableDirective(Node);
865void StmtPrinter::VisitOMPInterchangeDirective(OMPInterchangeDirective *Node) {
866 Indent() <<
"#pragma omp interchange";
867 PrintOMPExecutableDirective(Node);
870void StmtPrinter::VisitOMPFlattenDirective(OMPFlattenDirective *Node) {
871 Indent() <<
"#pragma omp flatten";
872 PrintOMPExecutableDirective(Node);
875void StmtPrinter::VisitOMPSplitDirective(OMPSplitDirective *Node) {
876 Indent() <<
"#pragma omp split";
877 PrintOMPExecutableDirective(Node);
880void StmtPrinter::VisitOMPFuseDirective(OMPFuseDirective *Node) {
881 Indent() <<
"#pragma omp fuse";
882 PrintOMPExecutableDirective(Node);
885void StmtPrinter::VisitOMPForDirective(OMPForDirective *Node) {
886 Indent() <<
"#pragma omp for";
887 PrintOMPExecutableDirective(Node);
890void StmtPrinter::VisitOMPForSimdDirective(OMPForSimdDirective *Node) {
891 Indent() <<
"#pragma omp for simd";
892 PrintOMPExecutableDirective(Node);
895void StmtPrinter::VisitOMPSectionsDirective(OMPSectionsDirective *Node) {
896 Indent() <<
"#pragma omp sections";
897 PrintOMPExecutableDirective(Node);
900void StmtPrinter::VisitOMPSectionDirective(OMPSectionDirective *Node) {
901 Indent() <<
"#pragma omp section";
902 PrintOMPExecutableDirective(Node);
905void StmtPrinter::VisitOMPScopeDirective(OMPScopeDirective *Node) {
906 Indent() <<
"#pragma omp scope";
907 PrintOMPExecutableDirective(Node);
910void StmtPrinter::VisitOMPSingleDirective(OMPSingleDirective *Node) {
911 Indent() <<
"#pragma omp single";
912 PrintOMPExecutableDirective(Node);
915void StmtPrinter::VisitOMPMasterDirective(OMPMasterDirective *Node) {
916 Indent() <<
"#pragma omp master";
917 PrintOMPExecutableDirective(Node);
920void StmtPrinter::VisitOMPCriticalDirective(OMPCriticalDirective *Node) {
921 Indent() <<
"#pragma omp critical";
927 PrintOMPExecutableDirective(Node);
930void StmtPrinter::VisitOMPParallelForDirective(OMPParallelForDirective *Node) {
931 Indent() <<
"#pragma omp parallel for";
932 PrintOMPExecutableDirective(Node);
935void StmtPrinter::VisitOMPParallelForSimdDirective(
936 OMPParallelForSimdDirective *Node) {
937 Indent() <<
"#pragma omp parallel for simd";
938 PrintOMPExecutableDirective(Node);
941void StmtPrinter::VisitOMPParallelMasterDirective(
942 OMPParallelMasterDirective *Node) {
943 Indent() <<
"#pragma omp parallel master";
944 PrintOMPExecutableDirective(Node);
947void StmtPrinter::VisitOMPParallelMaskedDirective(
948 OMPParallelMaskedDirective *Node) {
949 Indent() <<
"#pragma omp parallel masked";
950 PrintOMPExecutableDirective(Node);
953void StmtPrinter::VisitOMPParallelSectionsDirective(
954 OMPParallelSectionsDirective *Node) {
955 Indent() <<
"#pragma omp parallel sections";
956 PrintOMPExecutableDirective(Node);
959void StmtPrinter::VisitOMPTaskDirective(OMPTaskDirective *Node) {
960 Indent() <<
"#pragma omp task";
961 PrintOMPExecutableDirective(Node);
964void StmtPrinter::VisitOMPTaskyieldDirective(OMPTaskyieldDirective *Node) {
965 Indent() <<
"#pragma omp taskyield";
966 PrintOMPExecutableDirective(Node);
969void StmtPrinter::VisitOMPBarrierDirective(OMPBarrierDirective *Node) {
970 Indent() <<
"#pragma omp barrier";
971 PrintOMPExecutableDirective(Node);
974void StmtPrinter::VisitOMPTaskwaitDirective(OMPTaskwaitDirective *Node) {
975 Indent() <<
"#pragma omp taskwait";
976 PrintOMPExecutableDirective(Node);
979void StmtPrinter::VisitOMPAssumeDirective(OMPAssumeDirective *Node) {
980 Indent() <<
"#pragma omp assume";
981 PrintOMPExecutableDirective(Node);
984void StmtPrinter::VisitOMPErrorDirective(OMPErrorDirective *Node) {
985 Indent() <<
"#pragma omp error";
986 PrintOMPExecutableDirective(Node);
989void StmtPrinter::VisitOMPTaskgroupDirective(OMPTaskgroupDirective *Node) {
990 Indent() <<
"#pragma omp taskgroup";
991 PrintOMPExecutableDirective(Node);
994void StmtPrinter::VisitOMPFlushDirective(OMPFlushDirective *Node) {
995 Indent() <<
"#pragma omp flush";
996 PrintOMPExecutableDirective(Node);
999void StmtPrinter::VisitOMPDepobjDirective(OMPDepobjDirective *Node) {
1000 Indent() <<
"#pragma omp depobj";
1001 PrintOMPExecutableDirective(Node);
1004void StmtPrinter::VisitOMPScanDirective(OMPScanDirective *Node) {
1005 Indent() <<
"#pragma omp scan";
1006 PrintOMPExecutableDirective(Node);
1009void StmtPrinter::VisitOMPOrderedStandaloneDirective(
1010 OMPOrderedStandaloneDirective *Node) {
1011 Indent() <<
"#pragma omp ordered";
1012 PrintOMPExecutableDirective(Node,
true);
1015void StmtPrinter::VisitOMPOrderedBlockAssocDirective(
1016 OMPOrderedBlockAssocDirective *Node) {
1017 Indent() <<
"#pragma omp ordered";
1018 PrintOMPExecutableDirective(Node);
1021void StmtPrinter::VisitOMPAtomicDirective(OMPAtomicDirective *Node) {
1022 Indent() <<
"#pragma omp atomic";
1023 PrintOMPExecutableDirective(Node);
1026void StmtPrinter::VisitOMPTargetDirective(OMPTargetDirective *Node) {
1027 Indent() <<
"#pragma omp target";
1028 PrintOMPExecutableDirective(Node);
1031void StmtPrinter::VisitOMPTargetDataDirective(OMPTargetDataDirective *Node) {
1032 Indent() <<
"#pragma omp target data";
1033 PrintOMPExecutableDirective(Node);
1036void StmtPrinter::VisitOMPTargetEnterDataDirective(
1037 OMPTargetEnterDataDirective *Node) {
1038 Indent() <<
"#pragma omp target enter data";
1039 PrintOMPExecutableDirective(Node,
true);
1042void StmtPrinter::VisitOMPTargetExitDataDirective(
1043 OMPTargetExitDataDirective *Node) {
1044 Indent() <<
"#pragma omp target exit data";
1045 PrintOMPExecutableDirective(Node,
true);
1048void StmtPrinter::VisitOMPTargetParallelDirective(
1049 OMPTargetParallelDirective *Node) {
1050 Indent() <<
"#pragma omp target parallel";
1051 PrintOMPExecutableDirective(Node);
1054void StmtPrinter::VisitOMPTargetParallelForDirective(
1055 OMPTargetParallelForDirective *Node) {
1056 Indent() <<
"#pragma omp target parallel for";
1057 PrintOMPExecutableDirective(Node);
1060void StmtPrinter::VisitOMPTeamsDirective(OMPTeamsDirective *Node) {
1061 Indent() <<
"#pragma omp teams";
1062 PrintOMPExecutableDirective(Node);
1065void StmtPrinter::VisitOMPCancellationPointDirective(
1066 OMPCancellationPointDirective *Node) {
1067 llvm::omp::Version OpenMPVersion =
1069 : llvm::omp::FallbackVersion;
1070 Indent() <<
"#pragma omp cancellation point "
1072 PrintOMPExecutableDirective(Node);
1075void StmtPrinter::VisitOMPCancelDirective(OMPCancelDirective *Node) {
1076 llvm::omp::Version OpenMPVersion =
1078 : llvm::omp::FallbackVersion;
1079 Indent() <<
"#pragma omp cancel "
1081 PrintOMPExecutableDirective(Node);
1084void StmtPrinter::VisitOMPTaskLoopDirective(OMPTaskLoopDirective *Node) {
1085 Indent() <<
"#pragma omp taskloop";
1086 PrintOMPExecutableDirective(Node);
1089void StmtPrinter::VisitOMPTaskLoopSimdDirective(
1090 OMPTaskLoopSimdDirective *Node) {
1091 Indent() <<
"#pragma omp taskloop simd";
1092 PrintOMPExecutableDirective(Node);
1095void StmtPrinter::VisitOMPMasterTaskLoopDirective(
1096 OMPMasterTaskLoopDirective *Node) {
1097 Indent() <<
"#pragma omp master taskloop";
1098 PrintOMPExecutableDirective(Node);
1101void StmtPrinter::VisitOMPMaskedTaskLoopDirective(
1102 OMPMaskedTaskLoopDirective *Node) {
1103 Indent() <<
"#pragma omp masked taskloop";
1104 PrintOMPExecutableDirective(Node);
1107void StmtPrinter::VisitOMPMasterTaskLoopSimdDirective(
1108 OMPMasterTaskLoopSimdDirective *Node) {
1109 Indent() <<
"#pragma omp master taskloop simd";
1110 PrintOMPExecutableDirective(Node);
1113void StmtPrinter::VisitOMPMaskedTaskLoopSimdDirective(
1114 OMPMaskedTaskLoopSimdDirective *Node) {
1115 Indent() <<
"#pragma omp masked taskloop simd";
1116 PrintOMPExecutableDirective(Node);
1119void StmtPrinter::VisitOMPParallelMasterTaskLoopDirective(
1120 OMPParallelMasterTaskLoopDirective *Node) {
1121 Indent() <<
"#pragma omp parallel master taskloop";
1122 PrintOMPExecutableDirective(Node);
1125void StmtPrinter::VisitOMPParallelMaskedTaskLoopDirective(
1126 OMPParallelMaskedTaskLoopDirective *Node) {
1127 Indent() <<
"#pragma omp parallel masked taskloop";
1128 PrintOMPExecutableDirective(Node);
1131void StmtPrinter::VisitOMPParallelMasterTaskLoopSimdDirective(
1132 OMPParallelMasterTaskLoopSimdDirective *Node) {
1133 Indent() <<
"#pragma omp parallel master taskloop simd";
1134 PrintOMPExecutableDirective(Node);
1137void StmtPrinter::VisitOMPParallelMaskedTaskLoopSimdDirective(
1138 OMPParallelMaskedTaskLoopSimdDirective *Node) {
1139 Indent() <<
"#pragma omp parallel masked taskloop simd";
1140 PrintOMPExecutableDirective(Node);
1143void StmtPrinter::VisitOMPDistributeDirective(OMPDistributeDirective *Node) {
1144 Indent() <<
"#pragma omp distribute";
1145 PrintOMPExecutableDirective(Node);
1148void StmtPrinter::VisitOMPTargetUpdateDirective(
1149 OMPTargetUpdateDirective *Node) {
1150 Indent() <<
"#pragma omp target update";
1151 PrintOMPExecutableDirective(Node,
true);
1154void StmtPrinter::VisitOMPDistributeParallelForDirective(
1155 OMPDistributeParallelForDirective *Node) {
1156 Indent() <<
"#pragma omp distribute parallel for";
1157 PrintOMPExecutableDirective(Node);
1160void StmtPrinter::VisitOMPDistributeParallelForSimdDirective(
1161 OMPDistributeParallelForSimdDirective *Node) {
1162 Indent() <<
"#pragma omp distribute parallel for simd";
1163 PrintOMPExecutableDirective(Node);
1166void StmtPrinter::VisitOMPDistributeSimdDirective(
1167 OMPDistributeSimdDirective *Node) {
1168 Indent() <<
"#pragma omp distribute simd";
1169 PrintOMPExecutableDirective(Node);
1172void StmtPrinter::VisitOMPTargetParallelForSimdDirective(
1173 OMPTargetParallelForSimdDirective *Node) {
1174 Indent() <<
"#pragma omp target parallel for simd";
1175 PrintOMPExecutableDirective(Node);
1178void StmtPrinter::VisitOMPTargetSimdDirective(OMPTargetSimdDirective *Node) {
1179 Indent() <<
"#pragma omp target simd";
1180 PrintOMPExecutableDirective(Node);
1183void StmtPrinter::VisitOMPTeamsDistributeDirective(
1184 OMPTeamsDistributeDirective *Node) {
1185 Indent() <<
"#pragma omp teams distribute";
1186 PrintOMPExecutableDirective(Node);
1189void StmtPrinter::VisitOMPTeamsDistributeSimdDirective(
1190 OMPTeamsDistributeSimdDirective *Node) {
1191 Indent() <<
"#pragma omp teams distribute simd";
1192 PrintOMPExecutableDirective(Node);
1195void StmtPrinter::VisitOMPTeamsDistributeParallelForSimdDirective(
1196 OMPTeamsDistributeParallelForSimdDirective *Node) {
1197 Indent() <<
"#pragma omp teams distribute parallel for simd";
1198 PrintOMPExecutableDirective(Node);
1201void StmtPrinter::VisitOMPTeamsDistributeParallelForDirective(
1202 OMPTeamsDistributeParallelForDirective *Node) {
1203 Indent() <<
"#pragma omp teams distribute parallel for";
1204 PrintOMPExecutableDirective(Node);
1207void StmtPrinter::VisitOMPTargetTeamsDirective(OMPTargetTeamsDirective *Node) {
1208 Indent() <<
"#pragma omp target teams";
1209 PrintOMPExecutableDirective(Node);
1212void StmtPrinter::VisitOMPTargetTeamsDistributeDirective(
1213 OMPTargetTeamsDistributeDirective *Node) {
1214 Indent() <<
"#pragma omp target teams distribute";
1215 PrintOMPExecutableDirective(Node);
1218void StmtPrinter::VisitOMPTargetTeamsDistributeParallelForDirective(
1219 OMPTargetTeamsDistributeParallelForDirective *Node) {
1220 Indent() <<
"#pragma omp target teams distribute parallel for";
1221 PrintOMPExecutableDirective(Node);
1224void StmtPrinter::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
1225 OMPTargetTeamsDistributeParallelForSimdDirective *Node) {
1226 Indent() <<
"#pragma omp target teams distribute parallel for simd";
1227 PrintOMPExecutableDirective(Node);
1230void StmtPrinter::VisitOMPTargetTeamsDistributeSimdDirective(
1231 OMPTargetTeamsDistributeSimdDirective *Node) {
1232 Indent() <<
"#pragma omp target teams distribute simd";
1233 PrintOMPExecutableDirective(Node);
1236void StmtPrinter::VisitOMPInteropDirective(OMPInteropDirective *Node) {
1237 Indent() <<
"#pragma omp interop";
1238 PrintOMPExecutableDirective(Node);
1241void StmtPrinter::VisitOMPDispatchDirective(OMPDispatchDirective *Node) {
1242 Indent() <<
"#pragma omp dispatch";
1243 PrintOMPExecutableDirective(Node);
1246void StmtPrinter::VisitOMPMaskedDirective(OMPMaskedDirective *Node) {
1247 Indent() <<
"#pragma omp masked";
1248 PrintOMPExecutableDirective(Node);
1251void StmtPrinter::VisitOMPGenericLoopDirective(OMPGenericLoopDirective *Node) {
1252 Indent() <<
"#pragma omp loop";
1253 PrintOMPExecutableDirective(Node);
1256void StmtPrinter::VisitOMPTeamsGenericLoopDirective(
1257 OMPTeamsGenericLoopDirective *Node) {
1258 Indent() <<
"#pragma omp teams loop";
1259 PrintOMPExecutableDirective(Node);
1262void StmtPrinter::VisitOMPTargetTeamsGenericLoopDirective(
1263 OMPTargetTeamsGenericLoopDirective *Node) {
1264 Indent() <<
"#pragma omp target teams loop";
1265 PrintOMPExecutableDirective(Node);
1268void StmtPrinter::VisitOMPParallelGenericLoopDirective(
1269 OMPParallelGenericLoopDirective *Node) {
1270 Indent() <<
"#pragma omp parallel loop";
1271 PrintOMPExecutableDirective(Node);
1274void StmtPrinter::VisitOMPTargetParallelGenericLoopDirective(
1275 OMPTargetParallelGenericLoopDirective *Node) {
1276 Indent() <<
"#pragma omp target parallel loop";
1277 PrintOMPExecutableDirective(Node);
1283void StmtPrinter::PrintOpenACCClauseList(OpenACCConstructStmt *S) {
1286 OpenACCClausePrinter Printer(OS, Policy);
1287 Printer.VisitClauseList(S->
clauses());
1290void StmtPrinter::PrintOpenACCConstruct(OpenACCConstructStmt *S) {
1292 PrintOpenACCClauseList(S);
1296 PrintOpenACCConstruct(S);
1297 PrintStmt(S->getStructuredBlock());
1300void StmtPrinter::VisitOpenACCLoopConstruct(OpenACCLoopConstruct *S) {
1301 PrintOpenACCConstruct(S);
1305void StmtPrinter::VisitOpenACCCombinedConstruct(OpenACCCombinedConstruct *S) {
1306 PrintOpenACCConstruct(S);
1310void StmtPrinter::VisitOpenACCDataConstruct(OpenACCDataConstruct *S) {
1311 PrintOpenACCConstruct(S);
1314void StmtPrinter::VisitOpenACCHostDataConstruct(OpenACCHostDataConstruct *S) {
1315 PrintOpenACCConstruct(S);
1318void StmtPrinter::VisitOpenACCEnterDataConstruct(OpenACCEnterDataConstruct *S) {
1319 PrintOpenACCConstruct(S);
1321void StmtPrinter::VisitOpenACCExitDataConstruct(OpenACCExitDataConstruct *S) {
1322 PrintOpenACCConstruct(S);
1324void StmtPrinter::VisitOpenACCInitConstruct(OpenACCInitConstruct *S) {
1325 PrintOpenACCConstruct(S);
1327void StmtPrinter::VisitOpenACCShutdownConstruct(OpenACCShutdownConstruct *S) {
1328 PrintOpenACCConstruct(S);
1330void StmtPrinter::VisitOpenACCSetConstruct(OpenACCSetConstruct *S) {
1331 PrintOpenACCConstruct(S);
1333void StmtPrinter::VisitOpenACCUpdateConstruct(OpenACCUpdateConstruct *S) {
1334 PrintOpenACCConstruct(S);
1337void StmtPrinter::VisitOpenACCWaitConstruct(OpenACCWaitConstruct *S) {
1338 Indent() <<
"#pragma acc wait";
1351 E->printPretty(OS, nullptr, Policy);
1357 PrintOpenACCClauseList(S);
1361void StmtPrinter::VisitOpenACCAtomicConstruct(OpenACCAtomicConstruct *S) {
1362 Indent() <<
"#pragma acc atomic";
1367 PrintOpenACCClauseList(S);
1372void StmtPrinter::VisitOpenACCCacheConstruct(OpenACCCacheConstruct *S) {
1373 Indent() <<
"#pragma acc cache(";
1377 llvm::interleaveComma(S->
getVarList(), OS, [&](
const Expr *E) {
1378 E->printPretty(OS, nullptr, Policy);
1388void StmtPrinter::VisitSourceLocExpr(SourceLocExpr *Node) {
1392void StmtPrinter::VisitEmbedExpr(EmbedExpr *Node) {
1400void StmtPrinter::VisitConstantExpr(ConstantExpr *Node) {
1404void StmtPrinter::VisitDeclRefExpr(DeclRefExpr *Node) {
1405 ValueDecl *VD = Node->
getDecl();
1406 if (
const auto *OCED = dyn_cast<OMPCapturedExprDecl>(VD)) {
1407 OCED->getInit()->IgnoreImpCasts()->printPretty(OS,
nullptr, Policy);
1410 if (
const auto *TPOD = dyn_cast<TemplateParamObjectDecl>(VD)) {
1411 TPOD->printAsExpr(OS, Policy);
1414 bool ForceAnonymous =
1415 Policy.PrintAsCanonical && VD->
getKind() == Decl::NonTypeTemplateParm;
1416 bool CleanUglifiedParameter = Policy.CleanUglifiedParameters &&
1419 if (Policy.FullyQualifiedName && !ForceAnonymous && !CleanUglifiedParameter &&
1427 DeclarationNameInfo NameInfo = Node->
getNameInfo();
1431 if (CleanUglifiedParameter && ID)
1432 OS <<
ID->deuglifiedName();
1437 case Decl::NonTypeTemplateParm: {
1439 OS <<
"value-parameter-" << TD->getDepth() <<
'-' << TD->getIndex()
1443 case Decl::ParmVar: {
1445 OS <<
"function-parameter-" << PD->getFunctionScopeDepth() <<
'-'
1446 << PD->getFunctionScopeIndex();
1449 case Decl::Decomposition:
1450 OS <<
"decomposition";
1452 OS <<
'-' << I->getName();
1461 const TemplateParameterList *TPL =
nullptr;
1463 if (
auto *TD = dyn_cast<TemplateDecl>(VD))
1464 TPL = TD->getTemplateParameters();
1469void StmtPrinter::VisitDependentScopeDeclRefExpr(
1470 DependentScopeDeclRefExpr *Node) {
1479void StmtPrinter::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *Node) {
1489 if (
const auto *DRE = dyn_cast<DeclRefExpr>(E)) {
1490 if (
const auto *PD = dyn_cast<ImplicitParamDecl>(DRE->getDecl())) {
1492 DRE->getBeginLoc().isInvalid())
1499void StmtPrinter::VisitObjCIvarRefExpr(ObjCIvarRefExpr *Node) {
1501 if (!Policy.SuppressImplicitBase ||
1510void StmtPrinter::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *Node) {
1522 Getter->getSelector().print(OS);
1530void StmtPrinter::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *Node) {
1537void StmtPrinter::VisitSYCLUniqueStableNameExpr(
1538 SYCLUniqueStableNameExpr *Node) {
1539 OS <<
"__builtin_sycl_unique_stable_name(";
1544void StmtPrinter::VisitUnresolvedSYCLKernelCallStmt(
1545 UnresolvedSYCLKernelCallStmt *Node) {
1549void StmtPrinter::VisitPredefinedExpr(PredefinedExpr *Node) {
1553void StmtPrinter::VisitOpenACCAsteriskSizeExpr(OpenACCAsteriskSizeExpr *Node) {
1557void StmtPrinter::VisitCharacterLiteral(CharacterLiteral *Node) {
1570 Context->getSourceManager(), Context->getLangOpts(), &
Invalid);
1578void StmtPrinter::VisitIntegerLiteral(IntegerLiteral *Node) {
1585 OS << (isSigned ?
"wb" :
"uwb");
1590 switch (Node->
getType()->
castAs<BuiltinType>()->getKind()) {
1591 default: llvm_unreachable(
"Unexpected type for integer literal!");
1592 case BuiltinType::Char_S:
1593 case BuiltinType::Char_U:
OS <<
"i8";
break;
1594 case BuiltinType::UChar:
OS <<
"Ui8";
break;
1595 case BuiltinType::SChar:
OS <<
"i8";
break;
1596 case BuiltinType::Short:
OS <<
"i16";
break;
1597 case BuiltinType::UShort:
OS <<
"Ui16";
break;
1598 case BuiltinType::Int:
break;
1599 case BuiltinType::UInt:
OS <<
'U';
break;
1600 case BuiltinType::Long:
OS <<
'L';
break;
1601 case BuiltinType::ULong:
OS <<
"UL";
break;
1602 case BuiltinType::LongLong:
OS <<
"LL";
break;
1603 case BuiltinType::ULongLong:
OS <<
"ULL";
break;
1604 case BuiltinType::Int128:
1606 case BuiltinType::UInt128:
1608 case BuiltinType::WChar_S:
1609 case BuiltinType::WChar_U:
1614void StmtPrinter::VisitFixedPointLiteral(FixedPointLiteral *Node) {
1619 switch (Node->
getType()->
castAs<BuiltinType>()->getKind()) {
1620 default: llvm_unreachable(
"Unexpected type for fixed point literal!");
1621 case BuiltinType::ShortFract:
OS <<
"hr";
break;
1622 case BuiltinType::ShortAccum:
OS <<
"hk";
break;
1623 case BuiltinType::UShortFract:
OS <<
"uhr";
break;
1624 case BuiltinType::UShortAccum:
OS <<
"uhk";
break;
1625 case BuiltinType::Fract:
OS <<
"r";
break;
1626 case BuiltinType::Accum:
OS <<
"k";
break;
1627 case BuiltinType::UFract:
OS <<
"ur";
break;
1628 case BuiltinType::UAccum:
OS <<
"uk";
break;
1629 case BuiltinType::LongFract:
OS <<
"lr";
break;
1630 case BuiltinType::LongAccum:
OS <<
"lk";
break;
1631 case BuiltinType::ULongFract:
OS <<
"ulr";
break;
1632 case BuiltinType::ULongAccum:
OS <<
"ulk";
break;
1639 Node->
getValue().toStringShortest(Str);
1641 if (Str.find_first_not_of(
"-0123456789") == StringRef::npos)
1649 default: llvm_unreachable(
"Unexpected type for float literal!");
1650 case BuiltinType::Half:
break;
1651 case BuiltinType::Ibm128:
break;
1652 case BuiltinType::Double:
break;
1653 case BuiltinType::Float16: OS <<
"F16";
break;
1654 case BuiltinType::Float: OS <<
'F';
break;
1655 case BuiltinType::LongDouble: OS <<
'L';
break;
1656 case BuiltinType::Float128: OS <<
'Q';
break;
1660void StmtPrinter::VisitFloatingLiteral(FloatingLiteral *Node) {
1666void StmtPrinter::VisitImaginaryLiteral(ImaginaryLiteral *Node) {
1671void StmtPrinter::VisitStringLiteral(StringLiteral *Str) {
1675void StmtPrinter::VisitParenExpr(ParenExpr *Node) {
1681void StmtPrinter::VisitUnaryOperator(UnaryOperator *Node) {
1707void StmtPrinter::VisitOffsetOfExpr(OffsetOfExpr *Node) {
1708 OS <<
"__builtin_offsetof(";
1711 bool PrintedSomething =
false;
1719 PrintedSomething =
true;
1732 if (PrintedSomething)
1735 PrintedSomething =
true;
1741void StmtPrinter::VisitUnaryExprOrTypeTraitExpr(
1742 UnaryExprOrTypeTraitExpr *Node) {
1744 if (Node->
getKind() == UETT_AlignOf) {
1746 Spelling =
"alignof";
1748 Spelling =
"_Alignof";
1750 Spelling =
"__alignof";
1765void StmtPrinter::VisitGenericSelectionExpr(GenericSelectionExpr *Node) {
1774 QualType
T = Assoc.getType();
1778 T.print(OS, Policy);
1780 PrintExpr(Assoc.getAssociationExpr());
1785void StmtPrinter::VisitArraySubscriptExpr(ArraySubscriptExpr *Node) {
1786 PrintExpr(Node->
getLHS());
1788 PrintExpr(Node->
getRHS());
1792void StmtPrinter::VisitMatrixSingleSubscriptExpr(
1793 MatrixSingleSubscriptExpr *Node) {
1800void StmtPrinter::VisitMatrixSubscriptExpr(MatrixSubscriptExpr *Node) {
1810void StmtPrinter::VisitArraySectionExpr(ArraySectionExpr *Node) {
1828void StmtPrinter::VisitOMPArrayShapingExpr(OMPArrayShapingExpr *Node) {
1839void StmtPrinter::VisitOMPIteratorExpr(OMPIteratorExpr *Node) {
1846 PrintExpr(
Range.Begin);
1848 PrintExpr(
Range.End);
1851 PrintExpr(
Range.Step);
1859void StmtPrinter::PrintCallArgs(CallExpr *
Call) {
1860 for (
unsigned i = 0, e =
Call->getNumArgs(); i != e; ++i) {
1867 PrintExpr(
Call->getArg(i));
1871void StmtPrinter::VisitCallExpr(CallExpr *
Call) {
1872 PrintExpr(
Call->getCallee());
1874 PrintCallArgs(
Call);
1879 if (
const auto *TE = dyn_cast<CXXThisExpr>(E))
1880 return TE->isImplicit();
1884void StmtPrinter::VisitMemberExpr(MemberExpr *Node) {
1888 auto *ParentMember = dyn_cast<MemberExpr>(Node->
getBase());
1889 FieldDecl *ParentDecl =
1890 ParentMember ? dyn_cast<FieldDecl>(ParentMember->getMemberDecl())
1898 if (FD->isAnonymousStructOrUnion())
1905 const TemplateParameterList *TPL =
nullptr;
1906 if (
auto *FD = dyn_cast<FunctionDecl>(Node->
getMemberDecl())) {
1908 if (
auto *FTD = FD->getPrimaryTemplate())
1909 TPL = FTD->getTemplateParameters();
1910 }
else if (
auto *VTSD =
1911 dyn_cast<VarTemplateSpecializationDecl>(Node->
getMemberDecl()))
1912 TPL = VTSD->getSpecializedTemplate()->getTemplateParameters();
1917void StmtPrinter::VisitObjCIsaExpr(ObjCIsaExpr *Node) {
1919 OS << (Node->
isArrow() ?
"->isa" :
".isa");
1922void StmtPrinter::VisitExtVectorElementExpr(ExtVectorElementExpr *Node) {
1928void StmtPrinter::VisitMatrixElementExpr(MatrixElementExpr *Node) {
1934void StmtPrinter::VisitCStyleCastExpr(CStyleCastExpr *Node) {
1939 const auto *IL = dyn_cast<IntegerLiteral>(Node->
getSubExpr());
1942 llvm::APInt Val = IL->getValue();
1944 llvm::find_if(ED->enumerators(), [&](
const EnumConstantDecl *ECD) {
1945 return llvm::APInt::isSameValue(ECD->getInitVal(), Val);
1947 if (ECD != ED->enumerator_end()) {
1948 ECD->printQualifiedName(OS, Policy);
1959void StmtPrinter::VisitCompoundLiteralExpr(CompoundLiteralExpr *Node) {
1966void StmtPrinter::VisitImplicitCastExpr(ImplicitCastExpr *Node) {
1971void StmtPrinter::VisitBinComma(BinaryOperator *Node) {
1972 PrintExpr(Node->
getLHS());
1974 PrintExpr(Node->
getRHS());
1977void StmtPrinter::VisitBinaryOperator(BinaryOperator *Node) {
1978 PrintExpr(Node->
getLHS());
1980 PrintExpr(Node->
getRHS());
1983void StmtPrinter::VisitCompoundAssignOperator(CompoundAssignOperator *Node) {
1984 PrintExpr(Node->
getLHS());
1986 PrintExpr(Node->
getRHS());
1989void StmtPrinter::VisitConditionalOperator(ConditionalOperator *Node) {
1992 PrintExpr(Node->
getLHS());
1994 PrintExpr(Node->
getRHS());
2000StmtPrinter::VisitBinaryConditionalOperator(BinaryConditionalOperator *Node) {
2006void StmtPrinter::VisitAddrLabelExpr(AddrLabelExpr *Node) {
2010void StmtPrinter::VisitStmtExpr(StmtExpr *E) {
2016void StmtPrinter::VisitChooseExpr(ChooseExpr *Node) {
2017 OS <<
"__builtin_choose_expr(";
2020 PrintExpr(Node->
getLHS());
2022 PrintExpr(Node->
getRHS());
2026void StmtPrinter::VisitGNUNullExpr(GNUNullExpr *) {
2030void StmtPrinter::VisitShuffleVectorExpr(ShuffleVectorExpr *Node) {
2031 OS <<
"__builtin_shufflevector(";
2039void StmtPrinter::VisitConvertVectorExpr(ConvertVectorExpr *Node) {
2040 OS <<
"__builtin_convertvector(";
2047void StmtPrinter::VisitInitListExpr(InitListExpr* Node) {
2054 for (
unsigned i = 0, e = Node->
getNumInits(); i != e; ++i) {
2064void StmtPrinter::VisitArrayInitLoopExpr(ArrayInitLoopExpr *Node) {
2072void StmtPrinter::VisitArrayInitIndexExpr(ArrayInitIndexExpr *Node) {
2076void StmtPrinter::VisitParenListExpr(ParenListExpr* Node) {
2078 for (
unsigned i = 0, e = Node->
getNumExprs(); i != e; ++i) {
2085void StmtPrinter::VisitDesignatedInitExpr(DesignatedInitExpr *Node) {
2086 bool NeedsEquals =
true;
2087 for (
const DesignatedInitExpr::Designator &D : Node->
designators()) {
2088 if (D.isFieldDesignator()) {
2089 if (D.getDotLoc().isInvalid()) {
2090 if (
const IdentifierInfo *II = D.getFieldName()) {
2091 OS << II->getName() <<
":";
2092 NeedsEquals =
false;
2095 OS <<
"." << D.getFieldName()->getName();
2099 if (D.isArrayDesignator()) {
2117void StmtPrinter::VisitDesignatedInitUpdateExpr(
2118 DesignatedInitUpdateExpr *Node) {
2124 OS <<
"/*updater*/";
2129void StmtPrinter::VisitNoInitExpr(NoInitExpr *Node) {
2130 OS <<
"/*no init*/";
2133void StmtPrinter::VisitImplicitValueInitExpr(ImplicitValueInitExpr *Node) {
2135 OS <<
"/*implicit*/";
2139 OS <<
"/*implicit*/(";
2149void StmtPrinter::VisitVAArgExpr(VAArgExpr *Node) {
2150 OS <<
"__builtin_va_arg(";
2157void StmtPrinter::VisitPseudoObjectExpr(PseudoObjectExpr *Node) {
2161void StmtPrinter::VisitAtomicExpr(AtomicExpr *Node) {
2162 const char *Name =
nullptr;
2163 switch (Node->
getOp()) {
2164#define ATOMIC_BUILTIN(ID, TYPE, ATTRS) \
2165 case AtomicExpr::AO ## ID: \
2168#include "clang/Basic/Builtins.inc"
2173 PrintExpr(Node->
getPtr());
2178 if (Node->
getOp() == AtomicExpr::AO__atomic_exchange ||
2183 if (Node->
getOp() == AtomicExpr::AO__atomic_compare_exchange ||
2184 Node->
getOp() == AtomicExpr::AO__atomic_compare_exchange_n) {
2188 if (Node->
getOp() != AtomicExpr::AO__c11_atomic_init &&
2189 Node->
getOp() != AtomicExpr::AO__opencl_atomic_init) {
2201void StmtPrinter::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *Node) {
2203 if (Kind == OO_PlusPlus || Kind == OO_MinusMinus) {
2206 PrintExpr(Node->
getArg(0));
2208 PrintExpr(Node->
getArg(0));
2211 }
else if (Kind == OO_Arrow) {
2212 PrintExpr(Node->
getArg(0));
2213 }
else if (Kind == OO_Call || Kind == OO_Subscript) {
2214 PrintExpr(Node->
getArg(0));
2215 OS << (
Kind == OO_Call ?
'(' :
'[');
2216 for (
unsigned ArgIdx = 1; ArgIdx < Node->
getNumArgs(); ++ArgIdx) {
2220 PrintExpr(Node->
getArg(ArgIdx));
2222 OS << (
Kind == OO_Call ?
')' :
']');
2225 PrintExpr(Node->
getArg(0));
2227 PrintExpr(Node->
getArg(0));
2229 PrintExpr(Node->
getArg(1));
2231 llvm_unreachable(
"unknown overloaded operator");
2235void StmtPrinter::VisitCXXMemberCallExpr(CXXMemberCallExpr *Node) {
2238 if (isa_and_nonnull<CXXConversionDecl>(MD)) {
2245void StmtPrinter::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *Node) {
2250 PrintCallArgs(Node);
2254void StmtPrinter::VisitCXXRewrittenBinaryOperator(
2255 CXXRewrittenBinaryOperator *Node) {
2256 CXXRewrittenBinaryOperator::DecomposedForm Decomposed =
2258 PrintExpr(
const_cast<Expr*
>(Decomposed.
LHS));
2260 PrintExpr(
const_cast<Expr*
>(Decomposed.
RHS));
2263void StmtPrinter::VisitCXXNamedCastExpr(CXXNamedCastExpr *Node) {
2271void StmtPrinter::VisitCXXStaticCastExpr(CXXStaticCastExpr *Node) {
2272 VisitCXXNamedCastExpr(Node);
2275void StmtPrinter::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *Node) {
2276 VisitCXXNamedCastExpr(Node);
2279void StmtPrinter::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *Node) {
2280 VisitCXXNamedCastExpr(Node);
2283void StmtPrinter::VisitCXXConstCastExpr(CXXConstCastExpr *Node) {
2284 VisitCXXNamedCastExpr(Node);
2287void StmtPrinter::VisitBuiltinBitCastExpr(BuiltinBitCastExpr *Node) {
2288 OS <<
"__builtin_bit_cast(";
2295void StmtPrinter::VisitCXXAddrspaceCastExpr(CXXAddrspaceCastExpr *Node) {
2296 VisitCXXNamedCastExpr(Node);
2299void StmtPrinter::VisitCXXTypeidExpr(CXXTypeidExpr *Node) {
2309void StmtPrinter::VisitCXXUuidofExpr(CXXUuidofExpr *Node) {
2319void StmtPrinter::VisitMSPropertyRefExpr(MSPropertyRefExpr *Node) {
2329void StmtPrinter::VisitMSPropertySubscriptExpr(MSPropertySubscriptExpr *Node) {
2332 PrintExpr(Node->
getIdx());
2336void StmtPrinter::VisitUserDefinedLiteral(UserDefinedLiteral *Node) {
2343 const TemplateArgumentList *Args =
2348 const TemplateParameterList *TPL =
nullptr;
2349 if (!DRE->hadMultipleCandidates())
2350 if (
const auto *TD = dyn_cast<TemplateDecl>(DRE->getDecl()))
2351 TPL = TD->getTemplateParameters();
2353 printTemplateArgumentList(OS, Args->
asArray(), Policy, TPL);
2358 const TemplateArgument &Pack = Args->
get(0);
2360 char C = (char)P.getAsIntegral().getZExtValue();
2385void StmtPrinter::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *Node) {
2389void StmtPrinter::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *Node) {
2393void StmtPrinter::VisitCXXThisExpr(CXXThisExpr *Node) {
2397void StmtPrinter::VisitCXXThrowExpr(CXXThrowExpr *Node) {
2406void StmtPrinter::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *Node) {
2410void StmtPrinter::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *Node) {
2414void StmtPrinter::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *Node) {
2415 auto TargetType = Node->
getType();
2417 bool Bare =
Auto &&
Auto->isDeduced();
2422 TargetType.print(OS, Policy);
2434void StmtPrinter::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *Node) {
2438void StmtPrinter::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *Node) {
2446 for (CXXTemporaryObjectExpr::arg_iterator Arg = Node->
arg_begin(),
2448 Arg != ArgEnd; ++Arg) {
2449 if ((*Arg)->isDefaultArgument())
2463void StmtPrinter::VisitLambdaExpr(
LambdaExpr *Node) {
2465 bool NeedComma =
false;
2484 if (
C->capturesVLAType())
2491 switch (
C->getCaptureKind()) {
2503 OS <<
C->getCapturedVar()->getName();
2507 OS <<
C->getCapturedVar()->getName();
2511 llvm_unreachable(
"VLA type in explicit captures.");
2514 if (
C->isPackExpansion())
2521 llvm::StringRef
Pre;
2522 llvm::StringRef
Post;
2532 PrintExpr(D->getInit());
2548 for (
const auto *P :
Method->parameters()) {
2554 std::string ParamStr =
2555 (Policy.CleanUglifiedParameters && P->getIdentifier())
2556 ? P->getIdentifier()->deuglifiedName().str()
2557 : P->getNameAsString();
2558 P->getOriginalType().print(OS, Policy, ParamStr);
2560 if (
Method->isVariadic()) {
2570 auto *Proto =
Method->getType()->castAs<FunctionProtoType>();
2571 Proto->printExceptionSpecification(OS, Policy);
2578 Proto->getReturnType().print(OS, Policy);
2590void StmtPrinter::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *Node) {
2592 TSInfo->getType().print(OS, Policy);
2598void StmtPrinter::VisitCXXNewExpr(CXXNewExpr *E) {
2606 for (
unsigned i = 1; i < NumPlace; ++i) {
2618 llvm::raw_string_ostream s(TypeS);
2621 (*Size)->printPretty(s, Helper, Policy);
2629 if (InitStyle != CXXNewInitializationStyle::None) {
2630 bool Bare = InitStyle == CXXNewInitializationStyle::Parens &&
2640void StmtPrinter::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
2649void StmtPrinter::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
2659 OS << II->getName();
2664void StmtPrinter::VisitCXXConstructExpr(CXXConstructExpr *E) {
2668 for (
unsigned i = 0, e = E->
getNumArgs(); i != e; ++i) {
2682void StmtPrinter::VisitCXXInheritedCtorInitExpr(CXXInheritedCtorInitExpr *E) {
2684 OS <<
"<forwarded>";
2687void StmtPrinter::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E) {
2691void StmtPrinter::VisitExprWithCleanups(ExprWithCleanups *E) {
2696void StmtPrinter::VisitCXXUnresolvedConstructExpr(
2697 CXXUnresolvedConstructExpr *Node) {
2701 for (
auto Arg = Node->
arg_begin(), ArgEnd = Node->
arg_end(); Arg != ArgEnd;
2711void StmtPrinter::VisitCXXReflectExpr(CXXReflectExpr *S) {
2715 case ReflectionKind::Null:
2716 assert(
false &&
"null reflection can't be constructed from parsing a "
2717 "reflection operand");
2719 case ReflectionKind::Type:
2725void StmtPrinter::VisitDependentTemplateIdExpr(DependentTemplateIdExpr *Node) {
2731void StmtPrinter::VisitCXXDependentScopeMemberExpr(
2732 CXXDependentScopeMemberExpr *Node) {
2745void StmtPrinter::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *Node) {
2758void StmtPrinter::VisitTypeTraitExpr(TypeTraitExpr *E) {
2760 for (
unsigned I = 0, N = E->
getNumArgs(); I != N; ++I) {
2768void StmtPrinter::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
2774void StmtPrinter::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
2780void StmtPrinter::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
2786void StmtPrinter::VisitPackExpansionExpr(PackExpansionExpr *E) {
2791void StmtPrinter::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
2792 OS <<
"sizeof...(" << *E->
getPack() <<
")";
2795void StmtPrinter::VisitPackIndexingExpr(PackIndexingExpr *E) {
2802void StmtPrinter::VisitSubstNonTypeTemplateParmPackExpr(
2803 SubstNonTypeTemplateParmPackExpr *Node) {
2807void StmtPrinter::VisitSubstNonTypeTemplateParmExpr(
2808 SubstNonTypeTemplateParmExpr *Node) {
2812void StmtPrinter::VisitFunctionParmPackExpr(FunctionParmPackExpr *E) {
2816void StmtPrinter::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *Node){
2820void StmtPrinter::VisitCXXFoldExpr(CXXFoldExpr *E) {
2834void StmtPrinter::VisitCXXParenListInitExpr(CXXParenListInitExpr *Node) {
2836 [&](Expr *E) { PrintExpr(E); });
2839void StmtPrinter::VisitConceptSpecializationExpr(ConceptSpecializationExpr *E) {
2853 if (!LocalParameters.empty()) {
2855 for (ParmVarDecl *LocalParam : LocalParameters) {
2856 PrintRawDecl(LocalParam);
2857 if (LocalParam != LocalParameters.back())
2865 for (concepts::Requirement *Req : Requirements) {
2866 if (
auto *TypeReq = dyn_cast<concepts::TypeRequirement>(Req)) {
2867 if (TypeReq->isSubstitutionFailure())
2868 OS <<
"<<error-type>>";
2870 TypeReq->getType()->getType().print(OS, Policy);
2871 }
else if (
auto *ExprReq = dyn_cast<concepts::ExprRequirement>(Req)) {
2872 if (ExprReq->isCompound())
2874 if (ExprReq->isExprSubstitutionFailure())
2875 OS <<
"<<error-expression>>";
2877 PrintExpr(ExprReq->getExpr());
2878 if (ExprReq->isCompound()) {
2880 if (ExprReq->getNoexceptLoc().isValid())
2882 const auto &RetReq = ExprReq->getReturnTypeRequirement();
2883 if (!RetReq.isEmpty()) {
2885 if (RetReq.isSubstitutionFailure())
2886 OS <<
"<<error-type>>";
2887 else if (RetReq.isTypeConstraint())
2888 RetReq.getTypeConstraint()->print(OS, Policy);
2894 if (NestedReq->hasInvalidConstraint())
2895 OS <<
"<<error-expression>>";
2897 PrintExpr(NestedReq->getConstraintExpr());
2906void StmtPrinter::VisitCoroutineBodyStmt(CoroutineBodyStmt *S) {
2910void StmtPrinter::VisitCoreturnStmt(CoreturnStmt *S) {
2919void StmtPrinter::VisitCoawaitExpr(CoawaitExpr *S) {
2924void StmtPrinter::VisitDependentCoawaitExpr(DependentCoawaitExpr *S) {
2929void StmtPrinter::VisitCoyieldExpr(CoyieldExpr *S) {
2936void StmtPrinter::VisitObjCStringLiteral(ObjCStringLiteral *Node) {
2941void StmtPrinter::VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
2946void StmtPrinter::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
2948 ObjCArrayLiteral::child_range Ch = E->
children();
2949 for (
auto I = Ch.begin(), E = Ch.end(); I != E; ++I) {
2950 if (I != Ch.begin())
2957void StmtPrinter::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
2966 Visit(Element.
Value);
2973void StmtPrinter::VisitObjCEncodeExpr(ObjCEncodeExpr *Node) {
2979void StmtPrinter::VisitObjCSelectorExpr(ObjCSelectorExpr *Node) {
2985void StmtPrinter::VisitObjCProtocolExpr(ObjCProtocolExpr *Node) {
2989void StmtPrinter::VisitObjCMessageExpr(ObjCMessageExpr *Mess) {
3011 for (
unsigned i = 0, e = Mess->
getNumArgs(); i != e; ++i) {
3013 if (i > 0)
OS <<
' ';
3021 PrintExpr(Mess->
getArg(i));
3027void StmtPrinter::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *Node) {
3028 OS << (Node->
getValue() ?
"__objc_yes" :
"__objc_no");
3032StmtPrinter::VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
3037StmtPrinter::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
3044void StmtPrinter::VisitBlockExpr(BlockExpr *Node) {
3057 std::string ParamStr = (*AI)->getNameAsString();
3058 (*AI)->getType().print(OS, Policy, ParamStr);
3062 if (FT->isVariadic()) {
3071void StmtPrinter::VisitOpaqueValueExpr(OpaqueValueExpr *Node) {
3075void StmtPrinter::VisitRecoveryExpr(RecoveryExpr *Node) {
3076 OS <<
"<recovery-expr>(";
3077 const char *Sep =
"";
3086void StmtPrinter::VisitAsTypeExpr(AsTypeExpr *Node) {
3087 OS <<
"__builtin_astype(";
3094void StmtPrinter::VisitHLSLOutArgExpr(HLSLOutArgExpr *Node) {
3108 StringRef NL,
const ASTContext *Context)
const {
3109 StmtPrinter P(Out, Helper, Policy, Indentation, NL, Context);
3110 P.Visit(
const_cast<Stmt *
>(
this));
3115 unsigned Indentation, StringRef NL,
3117 StmtPrinter P(Out, Helper, Policy, Indentation, NL, Context);
3118 P.PrintControlledStmt(
const_cast<Stmt *
>(
this));
3124 llvm::raw_string_ostream TempOut(Buf);
Defines the clang::ASTContext interface.
Defines enumerations for traits support.
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 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.
C Language Family Type Representation.
OpenMPDirectiveKind getCancelRegion() const
Get cancellation region for the current cancellation point.
OpenMPDirectiveKind getCancelRegion() const
Get cancellation region for the current cancellation point.
DeclarationNameInfo getDirectiveName() const
Return name of the directive.
const Stmt * getAssociatedStmt() const
OpenACCAtomicKind getAtomicKind() const
ArrayRef< Expr * > getVarList() const
Stmt * getStructuredBlock()
Stmt * getStructuredBlock()
bool hasQueuesTag() const
bool hasDevNumExpr() const
ArrayRef< Expr * > getQueueIdExprs() const
SourceLocation getLParenLoc() const
Expr * getDevNumExpr() const
llvm::APInt getValue() const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
const LangOptions & getLangOpts() const
LabelDecl * getLabel() const
Expr * getSubExpr() const
Get the initializer to use for each array element.
Expr * getBase()
Get base of the array section.
Expr * getLength()
Get length of array section.
bool isOMPArraySection() const
Expr * getStride()
Get stride of array section.
SourceLocation getColonLocSecond() const
Expr * getLowerBound()
Get lower bound of array section.
SourceLocation getColonLocFirst() const
Expr * getLHS()
An array access can be written A[4] or 4[A] (both are equivalent).
ArrayTypeTrait getTrait() const
QualType getQueriedType() const
Expr * getSrcExpr() const
getSrcExpr - Return the Expr to be converted.
unsigned getNumClobbers() const
unsigned getNumOutputs() const
unsigned getNumInputs() const
Expr * getOrderFail() const
bool hasVal1Operand() const
ArrayRef< const Attr * > getAttrs() const
Expr * getFalseExpr() const
getFalseExpr - Return the subexpression which will be evaluated if the condition evaluates to false; ...
Expr * getCommon() const
getCommon - Return the common expression, written to the left of the condition.
StringRef getOpcodeStr() const
param_iterator param_end()
MutableArrayRef< ParmVarDecl * >::iterator param_iterator
param_iterator param_begin()
const FunctionProtoType * getFunctionType() const
getFunctionType - Return the underlying function type for this block.
const BlockDecl * getBlockDecl() const
This class is used for builtin types like 'int'.
const CallExpr * getConfig() const
const Expr * getSubExpr() const
Stmt * getHandlerBlock() const
VarDecl * getExceptionDecl() const
Expr * getArg(unsigned Arg)
Return the specified argument.
bool isStdInitListInitialization() const
Whether this constructor call was written as list-initialization, but was interpreted as forming a st...
bool isListInitialization() const
Whether this constructor call was written as list-initialization.
unsigned getNumArgs() const
Return the number of arguments to the constructor call.
bool isGlobalDelete() const
bool isArrow() const
Determine whether this member expression used the '->' operator; otherwise, it used the '.
NestedNameSpecifier getQualifier() const
Retrieve the nested-name-specifier that qualifies the member name.
const DeclarationNameInfo & getMemberNameInfo() const
Retrieve the name of the member that this expression refers to.
bool hasExplicitTemplateArgs() const
Determines whether this member expression actually had a C++ template argument list explicitly specif...
Expr * getBase() const
Retrieve the base object of this member expressions, e.g., the x in x.m.
bool hasTemplateKeyword() const
Determines whether the member name was preceded by the template keyword.
bool isImplicitAccess() const
True if this is an implicit access, i.e.
ArrayRef< TemplateArgumentLoc > template_arguments() const
InitListExpr * getRangeExpr()
DecompositionDecl * getDecompositionDecl()
const VarDecl * getRangeVar() const
Expr * getExpansionInitializer()
bool isDestructuring() const
VarDecl * getExpansionVariable()
BinaryOperatorKind getOperator() const
VarDecl * getLoopVariable()
bool isListInitialization() const
Determine whether this expression models list-initialization.
CXXMethodDecl * getMethodDecl() const
Retrieve the declaration of the called method.
Expr * getImplicitObjectArgument() const
Retrieve the implicit object argument for the member call.
const char * getCastName() const
getCastName - Get the name of the C++ cast being used, e.g., "static_cast", "dynamic_cast",...
QualType getAllocatedType() const
std::optional< Expr * > getArraySize()
This might return std::nullopt even if isArray() returns true, since there might not be an array size...
CXXNewInitializationStyle getInitializationStyle() const
The kind of initializer this new-expression has.
Expr * getPlacementArg(unsigned I)
unsigned getNumPlacementArgs() const
bool isParenTypeId() const
Expr * getInitializer()
The initializer of this new-expression.
Expr * getOperand() const
OverloadedOperatorKind getOperator() const
Returns the kind of overloaded operator that this expression refers to.
MutableArrayRef< Expr * > getUserSpecifiedInitExprs()
bool isArrow() const
Determine whether this pseudo-destructor expression was written using an '->' (otherwise,...
QualType getDestroyedType() const
Retrieve the type being destroyed.
NestedNameSpecifier getQualifier() const
If the member name was qualified, retrieves the nested-name-specifier that precedes the member name.
const IdentifierInfo * getDestroyedTypeIdentifier() const
In a dependent pseudo-destructor expression for which we do not have full type information on the des...
ReflectionKind getKind() const
const TypeSourceInfo * getTypeSourceInfo() const
DecomposedForm getDecomposedForm() const LLVM_READONLY
Decompose this operator into its syntactic form.
TypeSourceInfo * getTypeSourceInfo() const
const Expr * getSubExpr() const
CXXCatchStmt * getHandler(unsigned i)
unsigned getNumHandlers() const
CompoundStmt * getTryBlock()
bool isTypeOperand() const
TypeSourceInfo * getTypeOperandSourceInfo() const
Retrieve source information for the type operand.
Expr * getExprOperand() const
bool isListInitialization() const
Determine whether this expression models list-initialization.
QualType getTypeAsWritten() const
Retrieve the type that is being constructed, as specified in the source code.
Expr * getExprOperand() const
bool isTypeOperand() const
TypeSourceInfo * getTypeOperandSourceInfo() const
Retrieve source information for the type operand.
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
Stmt * getBody() const override
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
CapturedDecl * getCapturedDecl()
Retrieve the outlined function declaration.
static CharSourceRange getTokenRange(SourceRange R)
static void print(unsigned val, CharacterLiteralKind Kind, raw_ostream &OS)
unsigned getValue() const
CharacterLiteralKind getKind() const
const Expr * getInitializer() const
CompoundStmt - This represents a group of statements like { stmt stmt }.
FPOptionsOverride getStoredFPFeatures() const
Get FPOptionsOverride from trailing storage.
bool hasStoredFPFeatures() const
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
const NestedNameSpecifierLoc & getNestedNameSpecifierLoc() const
NamedDecl * getFoundDecl() const
ConceptDecl * getConceptDecl() const
SourceLocation getTemplateKWLoc() const
Expr * getCond() const
getCond - Return the expression representing the condition for the ?
Expr * getSrcExpr() const
getSrcExpr - Return the Expr to be converted.
Expr * getOperand() const
Retrieve the operand of the 'co_return' statement.
CompoundStmt * getBody() const
Retrieve the body of the coroutine as written.
Expr * getOperand() const
bool hasExplicitTemplateArgs() const
Determines whether this declaration reference was followed by an explicit template argument list.
NestedNameSpecifier getQualifier() const
If the name was qualified, retrieves the nested-name-specifier that precedes the name.
DeclarationNameInfo getNameInfo() const
ArrayRef< TemplateArgumentLoc > template_arguments() const
bool hadMultipleCandidates() const
Returns true if this expression refers to a function that was resolved from an overloaded set having ...
bool hasTemplateKeyword() const
Determines whether the name in this declaration reference was preceded by the template keyword.
bool isSingleDecl() const
isSingleDecl - This method returns true if this DeclStmt refers to a single Decl.
const Decl * getSingleDecl() const
ASTContext & getASTContext() const LLVM_READONLY
bool isTemplateParameter() const
isTemplateParameter - Determines whether this declaration is a template parameter.
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.
Expr * getOperand() const
ArrayRef< TemplateArgumentLoc > template_arguments() const
bool hasExplicitTemplateArgs() const
Determines whether this lookup had explicit template arguments.
NestedNameSpecifier getQualifier() const
Retrieve the nested-name-specifier that qualifies this declaration.
bool hasTemplateKeyword() const
Determines whether the name was preceded by the template keyword.
const DeclarationNameInfo & getNameInfo() const
Retrieve the name that this expression refers to.
ArrayRef< TemplateArgumentLoc > template_arguments() const
TemplateTemplateParmDecl * getParameter() const
TemplateName getTemplateName() const
Expr * getArrayRangeEnd(const Designator &D) const
Expr * getArrayRangeStart(const Designator &D) const
MutableArrayRef< Designator > designators()
Expr * getArrayIndex(const Designator &D) const
Expr * getInit() const
Retrieve the initializer value.
InitListExpr * getUpdater() const
IdentifierInfo & getAccessor() const
const Expr * getBase() const
StringRef getFileName() const
TypeSourceInfo * getTypeInfoAsWritten() const
getTypeInfoAsWritten - Returns the type source info for the type that this expression is casting to.
QualType getTypeAsWritten() const
getTypeAsWritten - Returns the type that this expression is casting to, as written in the source code...
This represents one expression.
Expr * IgnoreImpCasts() LLVM_READONLY
Skip past any implicit casts which might surround this expression until reaching a fixed point.
Expr * getQueriedExpression() const
ExpressionTrait getTrait() const
bool isAnonymousStructOrUnion() const
Determines whether this field is a representative for an anonymous struct or union.
std::string getValueAsString(unsigned Radix) const
llvm::APFloat getValue() const
DeclStmt * getConditionVariableDeclStmt()
If this ForStmt has a condition variable, return the faux DeclStmt associated with the creation of th...
const Expr * getSubExpr() const
ValueDecl * getParameterPack() const
Get the parameter pack which this expression refers to.
unsigned getNumLabels() const
const Expr * getOutputConstraintExpr(unsigned i) const
StringRef getLabelName(unsigned i) const
StringRef getInputName(unsigned i) const
StringRef getOutputName(unsigned i) const
const Expr * getInputConstraintExpr(unsigned i) const
const Expr * getAsmStringExpr() const
Expr * getOutputExpr(unsigned i)
Expr * getClobberExpr(unsigned i)
Expr * getInputExpr(unsigned i)
AssociationTy< false > Association
TypeSourceInfo * getControllingType()
Return the controlling type of this generic selection expression.
bool isExprPredicate() const
Whether this generic selection uses an expression as its controlling argument.
association_range associations()
Expr * getControllingExpr()
Return the controlling expression of this generic selection expression.
LabelDecl * getLabel() const
const Expr * getArgLValue() const
Return the l-value expression that was written as the argument in source.
StringRef getName() const
Return the actual identifier string.
const Expr * getSubExpr() const
unsigned getNumInits() const
InitListExpr * getSyntacticForm() const
const Expr * getInit(unsigned Init) const
const char * getName() const
bool hasExplicitParameters() const
Determine whether this lambda has an explicit parameter list vs.
bool isMutable() const
Determine whether the lambda is mutable, meaning that any captures values can be modified.
bool isInitCapture(const LambdaCapture *Capture) const
Determine whether one of this lambda's captures is an init-capture.
CXXMethodDecl * getCallOperator() const
Retrieve the function call operator associated with this lambda expression.
const CompoundStmt * getCompoundStmtBody() const
Retrieve the CompoundStmt representing the body of the lambda.
bool hasExplicitResultType() const
Whether this lambda had its result type explicitly specified.
TemplateParameterList * getTemplateParameterList() const
If this is a generic lambda expression, retrieve the template parameter list associated with it,...
ArrayRef< NamedDecl * > getExplicitTemplateParameters() const
Get the template parameters were explicitly specified (as opposed to being invented by use of an auto...
capture_iterator explicit_capture_end() const
Retrieve an iterator pointing past the end of the sequence of explicit lambda captures.
const LambdaCapture * capture_iterator
An iterator that walks over the captures of the lambda, both implicit and explicit.
capture_iterator explicit_capture_begin() const
Retrieve an iterator pointing to the first explicit lambda capture.
LambdaCaptureDefault getCaptureDefault() const
Determine the default capture kind for this lambda.
CXXRecordDecl * getLambdaClass() const
Retrieve the class that corresponds to the lambda.
llvm::omp::Version getOpenMPVersion() const
Return the OpenMP version.
static StringRef getSourceText(CharSourceRange Range, const SourceManager &SM, const LangOptions &LangOpts, bool *Invalid=nullptr)
Returns a string for the source that the range encompasses.
LabelDecl * getLabelDecl()
StringRef getAsmString() const
bool isIfExists() const
Determine whether this is an __if_exists statement.
DeclarationNameInfo getNameInfo() const
Retrieve the name of the entity we're testing for, along with location information.
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies this name, if any.
CompoundStmt * getSubStmt() const
Retrieve the compound statement that will be included in the program only if the existence of the sym...
NestedNameSpecifierLoc getQualifierLoc() const
MSPropertyDecl * getPropertyDecl() const
Expr * getBaseExpr() const
Expr * getSubExpr() const
Retrieve the temporary-generating subexpression whose value will be materialized into a glvalue.
ArrayRef< TemplateArgumentLoc > template_arguments() const
NestedNameSpecifier getQualifier() const
If the member name was qualified, retrieves the nested-name-specifier that precedes the member name.
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
bool hasExplicitTemplateArgs() const
Determines whether the member name was followed by an explicit template argument list.
bool hadMultipleCandidates() const
Returns true if this member expression refers to a method that was resolved from an overloaded set ha...
bool hasTemplateKeyword() const
Determines whether the member name was preceded by the template keyword.
DeclarationNameInfo getMemberNameInfo() const
Retrieve the member declaration name info.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
void printQualifiedName(raw_ostream &OS) const
Returns a human-readable qualified name for this declaration, like A::B::i, for i being member of nam...
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.
Expr * getBase()
Fetches base expression of array shaping expression.
ArrayRef< Expr * > getDimensions() const
Fetches the dimensions for array shaping expression.
IteratorRange getIteratorRange(unsigned I)
Gets the iterator range for the given iterator.
unsigned numOfIterators() const
Returns number of iterator definitions.
Decl * getIteratorDecl(unsigned I)
Gets the iterator declaration for the given iterator.
const Expr * getSynchExpr() const
const CompoundStmt * getSynchBody() const
const Expr * getThrowExpr() const
const ObjCAtFinallyStmt * getFinallyStmt() const
Retrieve the @finally statement, if any.
const Stmt * getTryBody() const
Retrieve the @try body.
catch_range catch_stmts()
const Stmt * getSubStmt() const
StringRef getBridgeKindName() const
Retrieve the kind of bridge being performed as a string.
unsigned getNumElements() const
getNumElements - Return number of elements of objective-c dictionary literal.
ObjCDictionaryElement getKeyValueElement(unsigned Index) const
QualType getEncodedType() const
const Expr * getBase() const
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.
Selector getSelector() const
ObjCPropertyDecl * getExplicitProperty() const
ObjCMethodDecl * getImplicitPropertyGetter() const
const Expr * getBase() const
bool isObjectReceiver() const
bool isImplicitProperty() const
ObjCMethodDecl * getImplicitPropertySetter() const
ObjCInterfaceDecl * getClassReceiver() const
bool isClassReceiver() const
bool isSuperReceiver() const
ObjCProtocolDecl * getProtocol() const
Selector getSelector() const
StringLiteral * getString()
Expr * getKeyExpr() const
Expr * getBaseExpr() const
Expr * getIndexExpr(unsigned Idx)
const OffsetOfNode & getComponent(unsigned Idx) const
TypeSourceInfo * getTypeSourceInfo() const
unsigned getNumComponents() const
const IdentifierInfo * getFieldName() const
For a field or identifier offsetof node, returns the name of the field.
unsigned getArrayExprIndex() const
For an array element node, returns the index into the array of expressions.
@ 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.
Expr * getSourceExpr() const
The source expression of an opaque value expression is the expression which originally generated the ...
OpenACCDirectiveKind getDirectiveKind() const
ArrayRef< const OpenACCClause * > clauses() const
bool hasExplicitTemplateArgs() const
Determines whether this expression had explicit template arguments.
NestedNameSpecifier getQualifier() const
Fetches the nested-name qualifier, if one was given.
const DeclarationNameInfo & getNameInfo() const
Gets the full name info.
bool hasTemplateKeyword() const
Determines whether the name was preceded by the template keyword.
ArrayRef< TemplateArgumentLoc > template_arguments() const
Expr * getPattern()
Retrieve the pattern of the pack expansion.
Expr * getIndexExpr() const
Expr * getPackIdExpression() const
const Expr * getSubExpr() const
Expr * getExpr(unsigned Init)
unsigned getNumExprs() const
Return the number of expressions in this paren list.
StringRef getIdentKindName() const
PredefinedIdentKind getIdentKind() const
Expr * getSyntacticForm()
Return the syntactic form of this expression, i.e.
void print(raw_ostream &OS, const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) const
ArrayRef< Expr * > subExpressions()
ArrayRef< concepts::Requirement * > getRequirements() const
ArrayRef< ParmVarDecl * > getLocalParameters() const
CompoundStmt * getBlock() const
Expr * getFilterExpr() const
CompoundStmt * getBlock() const
CompoundStmt * getTryBlock() const
SEHFinallyStmt * getFinallyHandler() const
SEHExceptStmt * getExceptHandler() const
Returns 0 if not defined.
CompoundStmt * getOriginalStmt()
TypeSourceInfo * getTypeSourceInfo()
static std::string getPropertyNameFromSetterSelector(Selector Sel)
Return the property name for the given setter selector.
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.
void print(llvm::raw_ostream &OS) const
Prints the full selector name (e.g. "foo:bar:").
bool isUnarySelector() const
unsigned getNumArgs() const
unsigned getNumSubExprs() const
getNumSubExprs - Return the size of the SubExprs array.
Expr * getExpr(unsigned Index)
getExpr - Return the Expr at the specified index.
NamedDecl * getPack() const
Retrieve the parameter pack.
StringRef getBuiltinStr() const
Return a string representing the name of the specific builtin function.
bool isValid() const
Return true if this is a valid SourceLocation object.
CompoundStmt * getSubStmt()
StmtVisitor - This class implements a simple visitor for Stmt subclasses.
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
Stmt(StmtClass SC, EmptyShell)
Construct an empty statement.
void dumpPretty(const ASTContext &Context) const
dumpPretty/printPretty - These two methods do a "pretty print" of the AST back to its original source...
void outputString(raw_ostream &OS) const
Prints the contents of the string to OS.
Expr * getReplacement() const
NonTypeTemplateParmDecl * getParameterPack() const
Retrieve the non-type template parameter pack being substituted.
DeclStmt * getConditionVariableDeclStmt()
If this SwitchStmt has a condition variable, return the faux DeclStmt associated with the creation of...
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.
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.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
void print(raw_ostream &OS, const PrintingPolicy &Policy, Qualified Qual=Qualified::AsWritten) const
Print the template name.
void print(raw_ostream &Out, const ASTContext &Context, bool OmitTemplateKW=false) const
QualType getType() const
Return the type wrapped by this type source info.
TypeSourceInfo * getArg(unsigned I) const
Retrieve the Ith argument.
unsigned getNumArgs() const
Determine the number of arguments to this type trait.
TypeTrait getTrait() const
Determine which type trait this expression uses.
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char,...
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
const T * castAs() const
Member-template castAs<specific type>.
bool isEnumeralType() const
DeducedType * getContainedDeducedType() const
Get the DeducedType whose type will be deduced for a variable with an initializer of this type.
EnumDecl * getAsEnumDecl() const
Retrieves the EnumDecl this type refers to.
bool isRecordType() const
QualType getArgumentType() const
bool isArgumentType() const
UnaryExprOrTypeTrait getKind() const
static bool isPostfix(Opcode Op)
isPostfix - Return true if this is a postfix operation, like x++.
Expr * getSubExpr() const
static StringRef getOpcodeStr(Opcode Op)
getOpcodeStr - Turn an Opcode enum value into the punctuation char it corresponds to,...
bool isArrow() const
Determine whether this member expression used the '->' operator; otherwise, it used the '.
Expr * getBase()
Retrieve the base object of this member expressions, e.g., the x in x.m.
bool isImplicitAccess() const
True if this is an implicit access, i.e., one in which the member being accessed was not written in t...
const DeclarationNameInfo & getMemberNameInfo() const
Retrieve the full name info for the member that this expression refers to.
CompoundStmt * getOriginalStmt()
LiteralOperatorKind getLiteralOperatorKind() const
Returns the kind of literal operator invocation which this expression represents.
const IdentifierInfo * getUDSuffix() const
Returns the ud-suffix specified for this literal.
Expr * getCookedLiteral()
If this is not a raw user-defined literal, get the underlying cooked literal (representing the litera...
@ 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)
const Expr * getSubExpr() const
@ CInit
C-style initialization with assignment.
@ CallInit
Call-style initialization (C++98)
const Expr * getInit() const
DeclStmt * getConditionVariableDeclStmt()
If this WhileStmt has a condition variable, return the faux DeclStmt associated with the creation of ...
@ OS
Indicates that the tracking object is a descendant of a referenced-counted OSObject,...
Top level wrappers for InstallAPI frontend operations.
const char * getTraitSpelling(TypeTrait T) LLVM_READONLY
Return the spelling of the trait T. Never null.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
bool isa(CodeGen::Address addr)
@ 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,...
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
OpenACCComputeConstruct(OpenACCDirectiveKind K, SourceLocation Start, SourceLocation DirectiveLoc, SourceLocation End, ArrayRef< const OpenACCClause * > Clauses, Stmt *StructuredBlock)
raw_ostream & Indent(raw_ostream &Out, const unsigned int Space, bool IsDot)
const FunctionProtoType * T
std::string JsonFormat(StringRef RawSR, bool AddQuotes)
const char * getOperatorSpelling(OverloadedOperatorKind Operator)
Retrieve the spelling of the given overloaded operator, without the preceding "operator" keyword.
U cast(CodeGen::Address addr)
@ ObjCSelf
Parameter for Objective-C 'self' argument.
CXXNewInitializationStyle
ArrayRef< TemplateArgumentLoc > arguments() const
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.
Expr * Value
The value of the dictionary element.
bool isPackExpansion() const
Determines whether this dictionary element is a pack expansion.
Expr * Key
The key for the dictionary element.
Describes how types, statements, expressions, and declarations should be printed.
unsigned PrettyEnums
Whether to print enumerators with a matching enumerator name or via cast.
unsigned Alignof
Whether we can use 'alignof' rather than '__alignof'.
unsigned IncludeNewlines
When true, include newlines after statements like "break", etc.
unsigned TerseOutput
Provide a 'terse' output.
unsigned SuppressLambdaBody
Whether to suppress printing the body of a lambda.
unsigned UnderscoreAlignof
Whether we can use '_Alignof' rather than '__alignof'.