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> {
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#define ABSTRACT_STMT(CLASS)
165#define STMT(CLASS, PARENT) \
166 void Visit##CLASS(CLASS *Node);
167#include "clang/AST/StmtNodes.inc"
178void StmtPrinter::PrintRawCompoundStmt(
CompoundStmt *Node) {
179 assert(Node &&
"Compound statement cannot be null");
181 PrintFPPragmas(Node);
182 for (
auto *I : Node->
body())
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()) {
199 LangOptions::FPExceptionModeKind EM =
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()) {
220 LangOptions::RoundingMode RM = FPO.getConstRoundingModeOverride();
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) {
252void StmtPrinter::PrintRawDeclStmt(
const DeclStmt *S) {
253 SmallVector<Decl *, 2> Decls(S->
decls());
257void StmtPrinter::VisitNullStmt(NullStmt *Node) {
261void StmtPrinter::VisitDeclStmt(DeclStmt *Node) {
263 PrintRawDeclStmt(Node);
271void StmtPrinter::VisitCompoundStmt(
CompoundStmt *Node) {
273 PrintRawCompoundStmt(Node);
277void StmtPrinter::VisitCaseStmt(CaseStmt *Node) {
279 PrintExpr(Node->
getLHS());
282 PrintExpr(Node->
getRHS());
289void StmtPrinter::VisitDefaultStmt(DefaultStmt *Node) {
290 Indent(-1) <<
"default:" << NL;
294void StmtPrinter::VisitLabelStmt(LabelStmt *Node) {
299void StmtPrinter::VisitAttributedStmt(AttributedStmt *Node) {
300 ArrayRef<const Attr *> Attrs = Node->
getAttrs();
301 for (
const auto *Attr : Attrs) {
302 Attr->printPretty(OS, Policy);
303 if (Attr != Attrs.back())
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());
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) {
368void StmtPrinter::VisitSwitchStmt(SwitchStmt *Node) {
371 PrintInitStmt(Node->
getInit(), 8);
373 PrintRawDeclStmt(DS);
377 PrintControlledStmt(Node->
getBody());
380void StmtPrinter::VisitWhileStmt(WhileStmt *Node) {
383 PrintRawDeclStmt(DS);
390void StmtPrinter::VisitDoStmt(DoStmt *Node) {
392 if (
auto *CS = dyn_cast<CompoundStmt>(Node->
getBody())) {
393 PrintRawCompoundStmt(CS);
406void StmtPrinter::VisitForStmt(ForStmt *Node) {
409 PrintInitStmt(Node->
getInit(), 5);
413 PrintRawDeclStmt(DS);
419 PrintExpr(Node->
getInc());
422 PrintControlledStmt(Node->
getBody());
425void StmtPrinter::VisitObjCForCollectionStmt(ObjCForCollectionStmt *Node) {
427 if (
auto *DS = dyn_cast<DeclStmt>(Node->
getElement()))
428 PrintRawDeclStmt(DS);
434 PrintControlledStmt(Node->
getBody());
437void StmtPrinter::VisitCXXForRangeStmt(CXXForRangeStmt *Node) {
440 PrintInitStmt(Node->
getInit(), 5);
441 PrintingPolicy SubPolicy(Policy);
442 SubPolicy.SuppressInitializers =
true;
447 PrintControlledStmt(Node->
getBody());
450void StmtPrinter::VisitMSDependentExistsStmt(MSDependentExistsStmt *Node) {
453 OS <<
"__if_exists (";
455 OS <<
"__if_not_exists (";
463void StmtPrinter::VisitGotoStmt(GotoStmt *Node) {
468void StmtPrinter::VisitIndirectGotoStmt(IndirectGotoStmt *Node) {
475void StmtPrinter::VisitContinueStmt(ContinueStmt *Node) {
485void StmtPrinter::VisitBreakStmt(BreakStmt *Node) {
494void StmtPrinter::VisitDeferStmt(DeferStmt *Node) {
496 PrintControlledStmt(Node->
getBody());
499void StmtPrinter::VisitReturnStmt(ReturnStmt *Node) {
509void StmtPrinter::VisitGCCAsmStmt(GCCAsmStmt *Node) {
526 for (
unsigned i = 0, e = Node->
getNumOutputs(); i != e; ++i) {
547 for (
unsigned i = 0, e = Node->
getNumInputs(); i != e; ++i) {
578 for (
unsigned i = 0, e = Node->
getNumLabels(); i != e; ++i) {
588void StmtPrinter::VisitMSAsmStmt(MSAsmStmt *Node) {
598void StmtPrinter::VisitCapturedStmt(CapturedStmt *Node) {
602void StmtPrinter::VisitSYCLKernelCallStmt(SYCLKernelCallStmt *Node) {
606void StmtPrinter::VisitObjCAtTryStmt(ObjCAtTryStmt *Node) {
608 if (
auto *TS = dyn_cast<CompoundStmt>(Node->
getTryBody())) {
609 PrintRawCompoundStmt(TS);
613 for (ObjCAtCatchStmt *catchStmt : Node->
catch_stmts()) {
615 if (Decl *DS = catchStmt->getCatchParamDecl())
618 if (
auto *CS = dyn_cast<CompoundStmt>(catchStmt->getCatchBody())) {
619 PrintRawCompoundStmt(CS);
626 if (
auto *CS = dyn_cast<CompoundStmt>(FS->getFinallyBody())) {
627 PrintRawCompoundStmt(CS);
633void StmtPrinter::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *Node) {
636void StmtPrinter::VisitObjCAtCatchStmt (ObjCAtCatchStmt *Node) {
637 Indent() <<
"@catch (...) { /* todo */ } " << NL;
640void StmtPrinter::VisitObjCAtThrowStmt(ObjCAtThrowStmt *Node) {
649void StmtPrinter::VisitObjCAvailabilityCheckExpr(
650 ObjCAvailabilityCheckExpr *Node) {
651 OS <<
"@available(...)";
654void StmtPrinter::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *Node) {
655 Indent() <<
"@synchronized (";
662void StmtPrinter::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *Node) {
663 Indent() <<
"@autoreleasepool";
668void StmtPrinter::PrintRawCXXCatchStmt(CXXCatchStmt *Node) {
671 PrintRawDecl(ExDecl);
678void StmtPrinter::VisitCXXCatchStmt(CXXCatchStmt *Node) {
680 PrintRawCXXCatchStmt(Node);
684void StmtPrinter::VisitCXXTryStmt(CXXTryStmt *Node) {
694void StmtPrinter::VisitSEHTryStmt(SEHTryStmt *Node) {
700 PrintRawSEHExceptHandler(E);
702 assert(F &&
"Must have a finally block...");
703 PrintRawSEHFinallyStmt(F);
708void StmtPrinter::PrintRawSEHFinallyStmt(SEHFinallyStmt *Node) {
710 PrintRawCompoundStmt(Node->
getBlock());
714void StmtPrinter::PrintRawSEHExceptHandler(SEHExceptStmt *Node) {
718 PrintRawCompoundStmt(Node->
getBlock());
722void StmtPrinter::VisitSEHExceptStmt(SEHExceptStmt *Node) {
724 PrintRawSEHExceptHandler(Node);
728void StmtPrinter::VisitSEHFinallyStmt(SEHFinallyStmt *Node) {
730 PrintRawSEHFinallyStmt(Node);
734void StmtPrinter::VisitSEHLeaveStmt(SEHLeaveStmt *Node) {
743void StmtPrinter::VisitOMPCanonicalLoop(OMPCanonicalLoop *Node) {
744 PrintStmt(Node->getLoopStmt());
747void StmtPrinter::PrintOMPExecutableDirective(OMPExecutableDirective *S,
749 unsigned OpenMPVersion =
750 Context ? Context->
getLangOpts().OpenMP : llvm::omp::FallbackVersion;
751 OMPClausePrinter Printer(OS, Policy, OpenMPVersion);
752 ArrayRef<OMPClause *> Clauses = S->clauses();
753 for (
auto *Clause : Clauses)
754 if (Clause && !Clause->isImplicit()) {
756 Printer.Visit(Clause);
759 if (!ForceNoStmt && S->hasAssociatedStmt())
760 PrintStmt(S->getRawStmt());
763void StmtPrinter::VisitOMPMetaDirective(OMPMetaDirective *Node) {
764 Indent() <<
"#pragma omp metadirective";
765 PrintOMPExecutableDirective(Node);
768void StmtPrinter::VisitOMPParallelDirective(OMPParallelDirective *Node) {
769 Indent() <<
"#pragma omp parallel";
770 PrintOMPExecutableDirective(Node);
773void StmtPrinter::VisitOMPSimdDirective(OMPSimdDirective *Node) {
774 Indent() <<
"#pragma omp simd";
775 PrintOMPExecutableDirective(Node);
778void StmtPrinter::VisitOMPTileDirective(OMPTileDirective *Node) {
779 Indent() <<
"#pragma omp tile";
780 PrintOMPExecutableDirective(Node);
783void StmtPrinter::VisitOMPStripeDirective(OMPStripeDirective *Node) {
784 Indent() <<
"#pragma omp stripe";
785 PrintOMPExecutableDirective(Node);
788void StmtPrinter::VisitOMPUnrollDirective(OMPUnrollDirective *Node) {
789 Indent() <<
"#pragma omp unroll";
790 PrintOMPExecutableDirective(Node);
793void StmtPrinter::VisitOMPReverseDirective(OMPReverseDirective *Node) {
794 Indent() <<
"#pragma omp reverse";
795 PrintOMPExecutableDirective(Node);
798void StmtPrinter::VisitOMPInterchangeDirective(OMPInterchangeDirective *Node) {
799 Indent() <<
"#pragma omp interchange";
800 PrintOMPExecutableDirective(Node);
803void StmtPrinter::VisitOMPFuseDirective(OMPFuseDirective *Node) {
804 Indent() <<
"#pragma omp fuse";
805 PrintOMPExecutableDirective(Node);
808void StmtPrinter::VisitOMPForDirective(OMPForDirective *Node) {
809 Indent() <<
"#pragma omp for";
810 PrintOMPExecutableDirective(Node);
813void StmtPrinter::VisitOMPForSimdDirective(OMPForSimdDirective *Node) {
814 Indent() <<
"#pragma omp for simd";
815 PrintOMPExecutableDirective(Node);
818void StmtPrinter::VisitOMPSectionsDirective(OMPSectionsDirective *Node) {
819 Indent() <<
"#pragma omp sections";
820 PrintOMPExecutableDirective(Node);
823void StmtPrinter::VisitOMPSectionDirective(OMPSectionDirective *Node) {
824 Indent() <<
"#pragma omp section";
825 PrintOMPExecutableDirective(Node);
828void StmtPrinter::VisitOMPScopeDirective(OMPScopeDirective *Node) {
829 Indent() <<
"#pragma omp scope";
830 PrintOMPExecutableDirective(Node);
833void StmtPrinter::VisitOMPSingleDirective(OMPSingleDirective *Node) {
834 Indent() <<
"#pragma omp single";
835 PrintOMPExecutableDirective(Node);
838void StmtPrinter::VisitOMPMasterDirective(OMPMasterDirective *Node) {
839 Indent() <<
"#pragma omp master";
840 PrintOMPExecutableDirective(Node);
843void StmtPrinter::VisitOMPCriticalDirective(OMPCriticalDirective *Node) {
844 Indent() <<
"#pragma omp critical";
845 if (Node->getDirectiveName().getName()) {
847 Node->getDirectiveName().printName(OS, Policy);
850 PrintOMPExecutableDirective(Node);
853void StmtPrinter::VisitOMPParallelForDirective(OMPParallelForDirective *Node) {
854 Indent() <<
"#pragma omp parallel for";
855 PrintOMPExecutableDirective(Node);
858void StmtPrinter::VisitOMPParallelForSimdDirective(
859 OMPParallelForSimdDirective *Node) {
860 Indent() <<
"#pragma omp parallel for simd";
861 PrintOMPExecutableDirective(Node);
864void StmtPrinter::VisitOMPParallelMasterDirective(
865 OMPParallelMasterDirective *Node) {
866 Indent() <<
"#pragma omp parallel master";
867 PrintOMPExecutableDirective(Node);
870void StmtPrinter::VisitOMPParallelMaskedDirective(
871 OMPParallelMaskedDirective *Node) {
872 Indent() <<
"#pragma omp parallel masked";
873 PrintOMPExecutableDirective(Node);
876void StmtPrinter::VisitOMPParallelSectionsDirective(
877 OMPParallelSectionsDirective *Node) {
878 Indent() <<
"#pragma omp parallel sections";
879 PrintOMPExecutableDirective(Node);
882void StmtPrinter::VisitOMPTaskDirective(OMPTaskDirective *Node) {
883 Indent() <<
"#pragma omp task";
884 PrintOMPExecutableDirective(Node);
887void StmtPrinter::VisitOMPTaskyieldDirective(OMPTaskyieldDirective *Node) {
888 Indent() <<
"#pragma omp taskyield";
889 PrintOMPExecutableDirective(Node);
892void StmtPrinter::VisitOMPBarrierDirective(OMPBarrierDirective *Node) {
893 Indent() <<
"#pragma omp barrier";
894 PrintOMPExecutableDirective(Node);
897void StmtPrinter::VisitOMPTaskwaitDirective(OMPTaskwaitDirective *Node) {
898 Indent() <<
"#pragma omp taskwait";
899 PrintOMPExecutableDirective(Node);
902void StmtPrinter::VisitOMPAssumeDirective(OMPAssumeDirective *Node) {
903 Indent() <<
"#pragma omp assume";
904 PrintOMPExecutableDirective(Node);
907void StmtPrinter::VisitOMPErrorDirective(OMPErrorDirective *Node) {
908 Indent() <<
"#pragma omp error";
909 PrintOMPExecutableDirective(Node);
912void StmtPrinter::VisitOMPTaskgroupDirective(OMPTaskgroupDirective *Node) {
913 Indent() <<
"#pragma omp taskgroup";
914 PrintOMPExecutableDirective(Node);
917void StmtPrinter::VisitOMPFlushDirective(OMPFlushDirective *Node) {
918 Indent() <<
"#pragma omp flush";
919 PrintOMPExecutableDirective(Node);
922void StmtPrinter::VisitOMPDepobjDirective(OMPDepobjDirective *Node) {
923 Indent() <<
"#pragma omp depobj";
924 PrintOMPExecutableDirective(Node);
927void StmtPrinter::VisitOMPScanDirective(OMPScanDirective *Node) {
928 Indent() <<
"#pragma omp scan";
929 PrintOMPExecutableDirective(Node);
932void StmtPrinter::VisitOMPOrderedDirective(OMPOrderedDirective *Node) {
933 Indent() <<
"#pragma omp ordered";
934 PrintOMPExecutableDirective(Node, Node->hasClausesOfKind<OMPDependClause>());
937void StmtPrinter::VisitOMPAtomicDirective(OMPAtomicDirective *Node) {
938 Indent() <<
"#pragma omp atomic";
939 PrintOMPExecutableDirective(Node);
942void StmtPrinter::VisitOMPTargetDirective(OMPTargetDirective *Node) {
943 Indent() <<
"#pragma omp target";
944 PrintOMPExecutableDirective(Node);
947void StmtPrinter::VisitOMPTargetDataDirective(OMPTargetDataDirective *Node) {
948 Indent() <<
"#pragma omp target data";
949 PrintOMPExecutableDirective(Node);
952void StmtPrinter::VisitOMPTargetEnterDataDirective(
953 OMPTargetEnterDataDirective *Node) {
954 Indent() <<
"#pragma omp target enter data";
955 PrintOMPExecutableDirective(Node,
true);
958void StmtPrinter::VisitOMPTargetExitDataDirective(
959 OMPTargetExitDataDirective *Node) {
960 Indent() <<
"#pragma omp target exit data";
961 PrintOMPExecutableDirective(Node,
true);
964void StmtPrinter::VisitOMPTargetParallelDirective(
965 OMPTargetParallelDirective *Node) {
966 Indent() <<
"#pragma omp target parallel";
967 PrintOMPExecutableDirective(Node);
970void StmtPrinter::VisitOMPTargetParallelForDirective(
971 OMPTargetParallelForDirective *Node) {
972 Indent() <<
"#pragma omp target parallel for";
973 PrintOMPExecutableDirective(Node);
976void StmtPrinter::VisitOMPTeamsDirective(OMPTeamsDirective *Node) {
977 Indent() <<
"#pragma omp teams";
978 PrintOMPExecutableDirective(Node);
981void StmtPrinter::VisitOMPCancellationPointDirective(
982 OMPCancellationPointDirective *Node) {
983 unsigned OpenMPVersion =
984 Context ? Context->
getLangOpts().OpenMP : llvm::omp::FallbackVersion;
985 Indent() <<
"#pragma omp cancellation point "
987 PrintOMPExecutableDirective(Node);
990void StmtPrinter::VisitOMPCancelDirective(OMPCancelDirective *Node) {
991 unsigned OpenMPVersion =
992 Context ? Context->
getLangOpts().OpenMP : llvm::omp::FallbackVersion;
993 Indent() <<
"#pragma omp cancel "
995 PrintOMPExecutableDirective(Node);
998void StmtPrinter::VisitOMPTaskLoopDirective(OMPTaskLoopDirective *Node) {
999 Indent() <<
"#pragma omp taskloop";
1000 PrintOMPExecutableDirective(Node);
1003void StmtPrinter::VisitOMPTaskLoopSimdDirective(
1004 OMPTaskLoopSimdDirective *Node) {
1005 Indent() <<
"#pragma omp taskloop simd";
1006 PrintOMPExecutableDirective(Node);
1009void StmtPrinter::VisitOMPMasterTaskLoopDirective(
1010 OMPMasterTaskLoopDirective *Node) {
1011 Indent() <<
"#pragma omp master taskloop";
1012 PrintOMPExecutableDirective(Node);
1015void StmtPrinter::VisitOMPMaskedTaskLoopDirective(
1016 OMPMaskedTaskLoopDirective *Node) {
1017 Indent() <<
"#pragma omp masked taskloop";
1018 PrintOMPExecutableDirective(Node);
1021void StmtPrinter::VisitOMPMasterTaskLoopSimdDirective(
1022 OMPMasterTaskLoopSimdDirective *Node) {
1023 Indent() <<
"#pragma omp master taskloop simd";
1024 PrintOMPExecutableDirective(Node);
1027void StmtPrinter::VisitOMPMaskedTaskLoopSimdDirective(
1028 OMPMaskedTaskLoopSimdDirective *Node) {
1029 Indent() <<
"#pragma omp masked taskloop simd";
1030 PrintOMPExecutableDirective(Node);
1033void StmtPrinter::VisitOMPParallelMasterTaskLoopDirective(
1034 OMPParallelMasterTaskLoopDirective *Node) {
1035 Indent() <<
"#pragma omp parallel master taskloop";
1036 PrintOMPExecutableDirective(Node);
1039void StmtPrinter::VisitOMPParallelMaskedTaskLoopDirective(
1040 OMPParallelMaskedTaskLoopDirective *Node) {
1041 Indent() <<
"#pragma omp parallel masked taskloop";
1042 PrintOMPExecutableDirective(Node);
1045void StmtPrinter::VisitOMPParallelMasterTaskLoopSimdDirective(
1046 OMPParallelMasterTaskLoopSimdDirective *Node) {
1047 Indent() <<
"#pragma omp parallel master taskloop simd";
1048 PrintOMPExecutableDirective(Node);
1051void StmtPrinter::VisitOMPParallelMaskedTaskLoopSimdDirective(
1052 OMPParallelMaskedTaskLoopSimdDirective *Node) {
1053 Indent() <<
"#pragma omp parallel masked taskloop simd";
1054 PrintOMPExecutableDirective(Node);
1057void StmtPrinter::VisitOMPDistributeDirective(OMPDistributeDirective *Node) {
1058 Indent() <<
"#pragma omp distribute";
1059 PrintOMPExecutableDirective(Node);
1062void StmtPrinter::VisitOMPTargetUpdateDirective(
1063 OMPTargetUpdateDirective *Node) {
1064 Indent() <<
"#pragma omp target update";
1065 PrintOMPExecutableDirective(Node,
true);
1068void StmtPrinter::VisitOMPDistributeParallelForDirective(
1069 OMPDistributeParallelForDirective *Node) {
1070 Indent() <<
"#pragma omp distribute parallel for";
1071 PrintOMPExecutableDirective(Node);
1074void StmtPrinter::VisitOMPDistributeParallelForSimdDirective(
1075 OMPDistributeParallelForSimdDirective *Node) {
1076 Indent() <<
"#pragma omp distribute parallel for simd";
1077 PrintOMPExecutableDirective(Node);
1080void StmtPrinter::VisitOMPDistributeSimdDirective(
1081 OMPDistributeSimdDirective *Node) {
1082 Indent() <<
"#pragma omp distribute simd";
1083 PrintOMPExecutableDirective(Node);
1086void StmtPrinter::VisitOMPTargetParallelForSimdDirective(
1087 OMPTargetParallelForSimdDirective *Node) {
1088 Indent() <<
"#pragma omp target parallel for simd";
1089 PrintOMPExecutableDirective(Node);
1092void StmtPrinter::VisitOMPTargetSimdDirective(OMPTargetSimdDirective *Node) {
1093 Indent() <<
"#pragma omp target simd";
1094 PrintOMPExecutableDirective(Node);
1097void StmtPrinter::VisitOMPTeamsDistributeDirective(
1098 OMPTeamsDistributeDirective *Node) {
1099 Indent() <<
"#pragma omp teams distribute";
1100 PrintOMPExecutableDirective(Node);
1103void StmtPrinter::VisitOMPTeamsDistributeSimdDirective(
1104 OMPTeamsDistributeSimdDirective *Node) {
1105 Indent() <<
"#pragma omp teams distribute simd";
1106 PrintOMPExecutableDirective(Node);
1109void StmtPrinter::VisitOMPTeamsDistributeParallelForSimdDirective(
1110 OMPTeamsDistributeParallelForSimdDirective *Node) {
1111 Indent() <<
"#pragma omp teams distribute parallel for simd";
1112 PrintOMPExecutableDirective(Node);
1115void StmtPrinter::VisitOMPTeamsDistributeParallelForDirective(
1116 OMPTeamsDistributeParallelForDirective *Node) {
1117 Indent() <<
"#pragma omp teams distribute parallel for";
1118 PrintOMPExecutableDirective(Node);
1121void StmtPrinter::VisitOMPTargetTeamsDirective(OMPTargetTeamsDirective *Node) {
1122 Indent() <<
"#pragma omp target teams";
1123 PrintOMPExecutableDirective(Node);
1126void StmtPrinter::VisitOMPTargetTeamsDistributeDirective(
1127 OMPTargetTeamsDistributeDirective *Node) {
1128 Indent() <<
"#pragma omp target teams distribute";
1129 PrintOMPExecutableDirective(Node);
1132void StmtPrinter::VisitOMPTargetTeamsDistributeParallelForDirective(
1133 OMPTargetTeamsDistributeParallelForDirective *Node) {
1134 Indent() <<
"#pragma omp target teams distribute parallel for";
1135 PrintOMPExecutableDirective(Node);
1138void StmtPrinter::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
1139 OMPTargetTeamsDistributeParallelForSimdDirective *Node) {
1140 Indent() <<
"#pragma omp target teams distribute parallel for simd";
1141 PrintOMPExecutableDirective(Node);
1144void StmtPrinter::VisitOMPTargetTeamsDistributeSimdDirective(
1145 OMPTargetTeamsDistributeSimdDirective *Node) {
1146 Indent() <<
"#pragma omp target teams distribute simd";
1147 PrintOMPExecutableDirective(Node);
1150void StmtPrinter::VisitOMPInteropDirective(OMPInteropDirective *Node) {
1151 Indent() <<
"#pragma omp interop";
1152 PrintOMPExecutableDirective(Node);
1155void StmtPrinter::VisitOMPDispatchDirective(OMPDispatchDirective *Node) {
1156 Indent() <<
"#pragma omp dispatch";
1157 PrintOMPExecutableDirective(Node);
1160void StmtPrinter::VisitOMPMaskedDirective(OMPMaskedDirective *Node) {
1161 Indent() <<
"#pragma omp masked";
1162 PrintOMPExecutableDirective(Node);
1165void StmtPrinter::VisitOMPGenericLoopDirective(OMPGenericLoopDirective *Node) {
1166 Indent() <<
"#pragma omp loop";
1167 PrintOMPExecutableDirective(Node);
1170void StmtPrinter::VisitOMPTeamsGenericLoopDirective(
1171 OMPTeamsGenericLoopDirective *Node) {
1172 Indent() <<
"#pragma omp teams loop";
1173 PrintOMPExecutableDirective(Node);
1176void StmtPrinter::VisitOMPTargetTeamsGenericLoopDirective(
1177 OMPTargetTeamsGenericLoopDirective *Node) {
1178 Indent() <<
"#pragma omp target teams loop";
1179 PrintOMPExecutableDirective(Node);
1182void StmtPrinter::VisitOMPParallelGenericLoopDirective(
1183 OMPParallelGenericLoopDirective *Node) {
1184 Indent() <<
"#pragma omp parallel loop";
1185 PrintOMPExecutableDirective(Node);
1188void StmtPrinter::VisitOMPTargetParallelGenericLoopDirective(
1189 OMPTargetParallelGenericLoopDirective *Node) {
1190 Indent() <<
"#pragma omp target parallel loop";
1191 PrintOMPExecutableDirective(Node);
1197void StmtPrinter::PrintOpenACCClauseList(OpenACCConstructStmt *S) {
1200 OpenACCClausePrinter Printer(OS, Policy);
1201 Printer.VisitClauseList(S->
clauses());
1204void StmtPrinter::PrintOpenACCConstruct(OpenACCConstructStmt *S) {
1206 PrintOpenACCClauseList(S);
1210 PrintOpenACCConstruct(S);
1211 PrintStmt(S->getStructuredBlock());
1214void StmtPrinter::VisitOpenACCLoopConstruct(OpenACCLoopConstruct *S) {
1215 PrintOpenACCConstruct(S);
1219void StmtPrinter::VisitOpenACCCombinedConstruct(OpenACCCombinedConstruct *S) {
1220 PrintOpenACCConstruct(S);
1224void StmtPrinter::VisitOpenACCDataConstruct(OpenACCDataConstruct *S) {
1225 PrintOpenACCConstruct(S);
1228void StmtPrinter::VisitOpenACCHostDataConstruct(OpenACCHostDataConstruct *S) {
1229 PrintOpenACCConstruct(S);
1232void StmtPrinter::VisitOpenACCEnterDataConstruct(OpenACCEnterDataConstruct *S) {
1233 PrintOpenACCConstruct(S);
1235void StmtPrinter::VisitOpenACCExitDataConstruct(OpenACCExitDataConstruct *S) {
1236 PrintOpenACCConstruct(S);
1238void StmtPrinter::VisitOpenACCInitConstruct(OpenACCInitConstruct *S) {
1239 PrintOpenACCConstruct(S);
1241void StmtPrinter::VisitOpenACCShutdownConstruct(OpenACCShutdownConstruct *S) {
1242 PrintOpenACCConstruct(S);
1244void StmtPrinter::VisitOpenACCSetConstruct(OpenACCSetConstruct *S) {
1245 PrintOpenACCConstruct(S);
1247void StmtPrinter::VisitOpenACCUpdateConstruct(OpenACCUpdateConstruct *S) {
1248 PrintOpenACCConstruct(S);
1251void StmtPrinter::VisitOpenACCWaitConstruct(OpenACCWaitConstruct *S) {
1252 Indent() <<
"#pragma acc wait";
1265 E->printPretty(OS, nullptr, Policy);
1271 PrintOpenACCClauseList(S);
1275void StmtPrinter::VisitOpenACCAtomicConstruct(OpenACCAtomicConstruct *S) {
1276 Indent() <<
"#pragma acc atomic";
1281 PrintOpenACCClauseList(S);
1286void StmtPrinter::VisitOpenACCCacheConstruct(OpenACCCacheConstruct *S) {
1287 Indent() <<
"#pragma acc cache(";
1291 llvm::interleaveComma(S->
getVarList(), OS, [&](
const Expr *E) {
1292 E->printPretty(OS, nullptr, Policy);
1302void StmtPrinter::VisitSourceLocExpr(SourceLocExpr *Node) {
1306void StmtPrinter::VisitEmbedExpr(EmbedExpr *Node) {
1314void StmtPrinter::VisitConstantExpr(ConstantExpr *Node) {
1318void StmtPrinter::VisitDeclRefExpr(DeclRefExpr *Node) {
1319 ValueDecl *VD = Node->
getDecl();
1320 if (
const auto *OCED = dyn_cast<OMPCapturedExprDecl>(VD)) {
1321 OCED->getInit()->IgnoreImpCasts()->printPretty(OS,
nullptr, Policy);
1324 if (
const auto *TPOD = dyn_cast<TemplateParamObjectDecl>(VD)) {
1325 TPOD->printAsExpr(OS, Policy);
1332 bool ForceAnonymous =
1334 DeclarationNameInfo NameInfo = Node->
getNameInfo();
1340 OS <<
ID->deuglifiedName();
1345 case Decl::NonTypeTemplateParm: {
1347 OS <<
"value-parameter-" << TD->getDepth() <<
'-' << TD->getIndex() <<
"";
1350 case Decl::ParmVar: {
1352 OS <<
"function-parameter-" << PD->getFunctionScopeDepth() <<
'-'
1353 << PD->getFunctionScopeIndex();
1356 case Decl::Decomposition:
1357 OS <<
"decomposition";
1359 OS <<
'-' << I->getName();
1367 const TemplateParameterList *TPL =
nullptr;
1369 if (
auto *TD = dyn_cast<TemplateDecl>(VD))
1370 TPL = TD->getTemplateParameters();
1375void StmtPrinter::VisitDependentScopeDeclRefExpr(
1376 DependentScopeDeclRefExpr *Node) {
1385void StmtPrinter::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *Node) {
1395 if (
const auto *DRE = dyn_cast<DeclRefExpr>(E)) {
1396 if (
const auto *PD = dyn_cast<ImplicitParamDecl>(DRE->getDecl())) {
1398 DRE->getBeginLoc().isInvalid())
1405void StmtPrinter::VisitObjCIvarRefExpr(ObjCIvarRefExpr *Node) {
1416void StmtPrinter::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *Node) {
1428 Getter->getSelector().print(OS);
1436void StmtPrinter::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *Node) {
1443void StmtPrinter::VisitSYCLUniqueStableNameExpr(
1444 SYCLUniqueStableNameExpr *Node) {
1445 OS <<
"__builtin_sycl_unique_stable_name(";
1450void StmtPrinter::VisitPredefinedExpr(PredefinedExpr *Node) {
1454void StmtPrinter::VisitOpenACCAsteriskSizeExpr(OpenACCAsteriskSizeExpr *Node) {
1458void StmtPrinter::VisitCharacterLiteral(CharacterLiteral *Node) {
1471 Context->getSourceManager(), Context->getLangOpts(), &
Invalid);
1479void StmtPrinter::VisitIntegerLiteral(IntegerLiteral *Node) {
1486 OS << (isSigned ?
"wb" :
"uwb");
1491 switch (Node->
getType()->
castAs<BuiltinType>()->getKind()) {
1492 default: llvm_unreachable(
"Unexpected type for integer literal!");
1493 case BuiltinType::Char_S:
1494 case BuiltinType::Char_U:
OS <<
"i8";
break;
1495 case BuiltinType::UChar:
OS <<
"Ui8";
break;
1496 case BuiltinType::SChar:
OS <<
"i8";
break;
1497 case BuiltinType::Short:
OS <<
"i16";
break;
1498 case BuiltinType::UShort:
OS <<
"Ui16";
break;
1499 case BuiltinType::Int:
break;
1500 case BuiltinType::UInt:
OS <<
'U';
break;
1501 case BuiltinType::Long:
OS <<
'L';
break;
1502 case BuiltinType::ULong:
OS <<
"UL";
break;
1503 case BuiltinType::LongLong:
OS <<
"LL";
break;
1504 case BuiltinType::ULongLong:
OS <<
"ULL";
break;
1505 case BuiltinType::Int128:
1507 case BuiltinType::UInt128:
1509 case BuiltinType::WChar_S:
1510 case BuiltinType::WChar_U:
1515void StmtPrinter::VisitFixedPointLiteral(FixedPointLiteral *Node) {
1520 switch (Node->
getType()->
castAs<BuiltinType>()->getKind()) {
1521 default: llvm_unreachable(
"Unexpected type for fixed point literal!");
1522 case BuiltinType::ShortFract:
OS <<
"hr";
break;
1523 case BuiltinType::ShortAccum:
OS <<
"hk";
break;
1524 case BuiltinType::UShortFract:
OS <<
"uhr";
break;
1525 case BuiltinType::UShortAccum:
OS <<
"uhk";
break;
1526 case BuiltinType::Fract:
OS <<
"r";
break;
1527 case BuiltinType::Accum:
OS <<
"k";
break;
1528 case BuiltinType::UFract:
OS <<
"ur";
break;
1529 case BuiltinType::UAccum:
OS <<
"uk";
break;
1530 case BuiltinType::LongFract:
OS <<
"lr";
break;
1531 case BuiltinType::LongAccum:
OS <<
"lk";
break;
1532 case BuiltinType::ULongFract:
OS <<
"ulr";
break;
1533 case BuiltinType::ULongAccum:
OS <<
"ulk";
break;
1542 if (Str.find_first_not_of(
"-0123456789") == StringRef::npos)
1550 default: llvm_unreachable(
"Unexpected type for float literal!");
1551 case BuiltinType::Half:
break;
1552 case BuiltinType::Ibm128:
break;
1553 case BuiltinType::Double:
break;
1554 case BuiltinType::Float16: OS <<
"F16";
break;
1555 case BuiltinType::Float: OS <<
'F';
break;
1556 case BuiltinType::LongDouble: OS <<
'L';
break;
1557 case BuiltinType::Float128: OS <<
'Q';
break;
1561void StmtPrinter::VisitFloatingLiteral(FloatingLiteral *Node) {
1567void StmtPrinter::VisitImaginaryLiteral(ImaginaryLiteral *Node) {
1572void StmtPrinter::VisitStringLiteral(StringLiteral *Str) {
1576void StmtPrinter::VisitParenExpr(ParenExpr *Node) {
1582void StmtPrinter::VisitUnaryOperator(UnaryOperator *Node) {
1608void StmtPrinter::VisitOffsetOfExpr(OffsetOfExpr *Node) {
1609 OS <<
"__builtin_offsetof(";
1612 bool PrintedSomething =
false;
1620 PrintedSomething =
true;
1633 if (PrintedSomething)
1636 PrintedSomething =
true;
1642void StmtPrinter::VisitUnaryExprOrTypeTraitExpr(
1643 UnaryExprOrTypeTraitExpr *Node) {
1645 if (Node->
getKind() == UETT_AlignOf) {
1647 Spelling =
"alignof";
1649 Spelling =
"_Alignof";
1651 Spelling =
"__alignof";
1666void StmtPrinter::VisitGenericSelectionExpr(GenericSelectionExpr *Node) {
1675 QualType
T = Assoc.getType();
1679 T.print(OS, Policy);
1681 PrintExpr(Assoc.getAssociationExpr());
1686void StmtPrinter::VisitArraySubscriptExpr(ArraySubscriptExpr *Node) {
1687 PrintExpr(Node->
getLHS());
1689 PrintExpr(Node->
getRHS());
1693void StmtPrinter::VisitMatrixSubscriptExpr(MatrixSubscriptExpr *Node) {
1703void StmtPrinter::VisitArraySectionExpr(ArraySectionExpr *Node) {
1721void StmtPrinter::VisitOMPArrayShapingExpr(OMPArrayShapingExpr *Node) {
1732void StmtPrinter::VisitOMPIteratorExpr(OMPIteratorExpr *Node) {
1739 PrintExpr(
Range.Begin);
1741 PrintExpr(
Range.End);
1744 PrintExpr(
Range.Step);
1752void StmtPrinter::PrintCallArgs(CallExpr *
Call) {
1753 for (
unsigned i = 0, e =
Call->getNumArgs(); i != e; ++i) {
1760 PrintExpr(
Call->getArg(i));
1764void StmtPrinter::VisitCallExpr(CallExpr *
Call) {
1765 PrintExpr(
Call->getCallee());
1767 PrintCallArgs(
Call);
1772 if (
const auto *TE = dyn_cast<CXXThisExpr>(E))
1773 return TE->isImplicit();
1777void StmtPrinter::VisitMemberExpr(MemberExpr *Node) {
1781 auto *ParentMember = dyn_cast<MemberExpr>(Node->
getBase());
1782 FieldDecl *ParentDecl =
1783 ParentMember ? dyn_cast<FieldDecl>(ParentMember->getMemberDecl())
1791 if (FD->isAnonymousStructOrUnion())
1798 const TemplateParameterList *TPL =
nullptr;
1799 if (
auto *FD = dyn_cast<FunctionDecl>(Node->
getMemberDecl())) {
1801 if (
auto *FTD = FD->getPrimaryTemplate())
1802 TPL = FTD->getTemplateParameters();
1803 }
else if (
auto *VTSD =
1804 dyn_cast<VarTemplateSpecializationDecl>(Node->
getMemberDecl()))
1805 TPL = VTSD->getSpecializedTemplate()->getTemplateParameters();
1810void StmtPrinter::VisitObjCIsaExpr(ObjCIsaExpr *Node) {
1812 OS << (Node->
isArrow() ?
"->isa" :
".isa");
1815void StmtPrinter::VisitExtVectorElementExpr(ExtVectorElementExpr *Node) {
1821void StmtPrinter::VisitCStyleCastExpr(CStyleCastExpr *Node) {
1828void StmtPrinter::VisitCompoundLiteralExpr(CompoundLiteralExpr *Node) {
1835void StmtPrinter::VisitImplicitCastExpr(ImplicitCastExpr *Node) {
1840void StmtPrinter::VisitBinaryOperator(BinaryOperator *Node) {
1841 PrintExpr(Node->
getLHS());
1843 PrintExpr(Node->
getRHS());
1846void StmtPrinter::VisitCompoundAssignOperator(CompoundAssignOperator *Node) {
1847 PrintExpr(Node->
getLHS());
1849 PrintExpr(Node->
getRHS());
1852void StmtPrinter::VisitConditionalOperator(ConditionalOperator *Node) {
1855 PrintExpr(Node->
getLHS());
1857 PrintExpr(Node->
getRHS());
1863StmtPrinter::VisitBinaryConditionalOperator(BinaryConditionalOperator *Node) {
1869void StmtPrinter::VisitAddrLabelExpr(AddrLabelExpr *Node) {
1873void StmtPrinter::VisitStmtExpr(StmtExpr *E) {
1879void StmtPrinter::VisitChooseExpr(ChooseExpr *Node) {
1880 OS <<
"__builtin_choose_expr(";
1883 PrintExpr(Node->
getLHS());
1885 PrintExpr(Node->
getRHS());
1889void StmtPrinter::VisitGNUNullExpr(GNUNullExpr *) {
1893void StmtPrinter::VisitShuffleVectorExpr(ShuffleVectorExpr *Node) {
1894 OS <<
"__builtin_shufflevector(";
1902void StmtPrinter::VisitConvertVectorExpr(ConvertVectorExpr *Node) {
1903 OS <<
"__builtin_convertvector(";
1910void StmtPrinter::VisitInitListExpr(InitListExpr* Node) {
1917 for (
unsigned i = 0, e = Node->
getNumInits(); i != e; ++i) {
1927void StmtPrinter::VisitArrayInitLoopExpr(ArrayInitLoopExpr *Node) {
1935void StmtPrinter::VisitArrayInitIndexExpr(ArrayInitIndexExpr *Node) {
1939void StmtPrinter::VisitParenListExpr(ParenListExpr* Node) {
1941 for (
unsigned i = 0, e = Node->
getNumExprs(); i != e; ++i) {
1948void StmtPrinter::VisitDesignatedInitExpr(DesignatedInitExpr *Node) {
1949 bool NeedsEquals =
true;
1950 for (
const DesignatedInitExpr::Designator &D : Node->
designators()) {
1951 if (D.isFieldDesignator()) {
1952 if (D.getDotLoc().isInvalid()) {
1953 if (
const IdentifierInfo *II = D.getFieldName()) {
1954 OS << II->getName() <<
":";
1955 NeedsEquals =
false;
1958 OS <<
"." << D.getFieldName()->getName();
1962 if (D.isArrayDesignator()) {
1980void StmtPrinter::VisitDesignatedInitUpdateExpr(
1981 DesignatedInitUpdateExpr *Node) {
1987 OS <<
"/*updater*/";
1992void StmtPrinter::VisitNoInitExpr(NoInitExpr *Node) {
1993 OS <<
"/*no init*/";
1996void StmtPrinter::VisitImplicitValueInitExpr(ImplicitValueInitExpr *Node) {
1998 OS <<
"/*implicit*/";
2002 OS <<
"/*implicit*/(";
2012void StmtPrinter::VisitVAArgExpr(VAArgExpr *Node) {
2013 OS <<
"__builtin_va_arg(";
2020void StmtPrinter::VisitPseudoObjectExpr(PseudoObjectExpr *Node) {
2024void StmtPrinter::VisitAtomicExpr(AtomicExpr *Node) {
2025 const char *Name =
nullptr;
2026 switch (Node->
getOp()) {
2027#define ATOMIC_BUILTIN(ID, TYPE, ATTRS) \
2028 case AtomicExpr::AO ## ID: \
2031#include "clang/Basic/Builtins.inc"
2036 PrintExpr(Node->
getPtr());
2041 if (Node->
getOp() == AtomicExpr::AO__atomic_exchange ||
2046 if (Node->
getOp() == AtomicExpr::AO__atomic_compare_exchange ||
2047 Node->
getOp() == AtomicExpr::AO__atomic_compare_exchange_n) {
2051 if (Node->
getOp() != AtomicExpr::AO__c11_atomic_init &&
2052 Node->
getOp() != AtomicExpr::AO__opencl_atomic_init) {
2064void StmtPrinter::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *Node) {
2066 if (Kind == OO_PlusPlus || Kind == OO_MinusMinus) {
2069 PrintExpr(Node->
getArg(0));
2071 PrintExpr(Node->
getArg(0));
2074 }
else if (Kind == OO_Arrow) {
2075 PrintExpr(Node->
getArg(0));
2076 }
else if (Kind == OO_Call || Kind == OO_Subscript) {
2077 PrintExpr(Node->
getArg(0));
2078 OS << (
Kind == OO_Call ?
'(' :
'[');
2079 for (
unsigned ArgIdx = 1; ArgIdx < Node->
getNumArgs(); ++ArgIdx) {
2083 PrintExpr(Node->
getArg(ArgIdx));
2085 OS << (
Kind == OO_Call ?
')' :
']');
2088 PrintExpr(Node->
getArg(0));
2090 PrintExpr(Node->
getArg(0));
2092 PrintExpr(Node->
getArg(1));
2094 llvm_unreachable(
"unknown overloaded operator");
2098void StmtPrinter::VisitCXXMemberCallExpr(CXXMemberCallExpr *Node) {
2101 if (isa_and_nonnull<CXXConversionDecl>(MD)) {
2108void StmtPrinter::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *Node) {
2113 PrintCallArgs(Node);
2117void StmtPrinter::VisitCXXRewrittenBinaryOperator(
2118 CXXRewrittenBinaryOperator *Node) {
2119 CXXRewrittenBinaryOperator::DecomposedForm Decomposed =
2121 PrintExpr(
const_cast<Expr*
>(Decomposed.
LHS));
2123 PrintExpr(
const_cast<Expr*
>(Decomposed.
RHS));
2126void StmtPrinter::VisitCXXNamedCastExpr(CXXNamedCastExpr *Node) {
2134void StmtPrinter::VisitCXXStaticCastExpr(CXXStaticCastExpr *Node) {
2135 VisitCXXNamedCastExpr(Node);
2138void StmtPrinter::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *Node) {
2139 VisitCXXNamedCastExpr(Node);
2142void StmtPrinter::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *Node) {
2143 VisitCXXNamedCastExpr(Node);
2146void StmtPrinter::VisitCXXConstCastExpr(CXXConstCastExpr *Node) {
2147 VisitCXXNamedCastExpr(Node);
2150void StmtPrinter::VisitBuiltinBitCastExpr(BuiltinBitCastExpr *Node) {
2151 OS <<
"__builtin_bit_cast(";
2158void StmtPrinter::VisitCXXAddrspaceCastExpr(CXXAddrspaceCastExpr *Node) {
2159 VisitCXXNamedCastExpr(Node);
2162void StmtPrinter::VisitCXXTypeidExpr(CXXTypeidExpr *Node) {
2172void StmtPrinter::VisitCXXUuidofExpr(CXXUuidofExpr *Node) {
2182void StmtPrinter::VisitMSPropertyRefExpr(MSPropertyRefExpr *Node) {
2192void StmtPrinter::VisitMSPropertySubscriptExpr(MSPropertySubscriptExpr *Node) {
2195 PrintExpr(Node->
getIdx());
2199void StmtPrinter::VisitUserDefinedLiteral(UserDefinedLiteral *Node) {
2206 const TemplateArgumentList *Args =
2211 const TemplateParameterList *TPL =
nullptr;
2212 if (!DRE->hadMultipleCandidates())
2213 if (
const auto *TD = dyn_cast<TemplateDecl>(DRE->getDecl()))
2214 TPL = TD->getTemplateParameters();
2216 printTemplateArgumentList(OS, Args->
asArray(), Policy, TPL);
2221 const TemplateArgument &Pack = Args->
get(0);
2223 char C = (char)P.getAsIntegral().getZExtValue();
2248void StmtPrinter::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *Node) {
2252void StmtPrinter::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *Node) {
2256void StmtPrinter::VisitCXXThisExpr(CXXThisExpr *Node) {
2260void StmtPrinter::VisitCXXThrowExpr(CXXThrowExpr *Node) {
2269void StmtPrinter::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *Node) {
2273void StmtPrinter::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *Node) {
2277void StmtPrinter::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *Node) {
2278 auto TargetType = Node->
getType();
2280 bool Bare =
Auto &&
Auto->isDeduced();
2285 TargetType.print(OS, Policy);
2297void StmtPrinter::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *Node) {
2301void StmtPrinter::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *Node) {
2309 for (CXXTemporaryObjectExpr::arg_iterator Arg = Node->
arg_begin(),
2311 Arg != ArgEnd; ++Arg) {
2312 if ((*Arg)->isDefaultArgument())
2326void StmtPrinter::VisitLambdaExpr(
LambdaExpr *Node) {
2328 bool NeedComma =
false;
2347 if (
C->capturesVLAType())
2354 switch (
C->getCaptureKind()) {
2366 OS <<
C->getCapturedVar()->getName();
2370 OS <<
C->getCapturedVar()->getName();
2374 llvm_unreachable(
"VLA type in explicit captures.");
2377 if (
C->isPackExpansion())
2384 llvm::StringRef
Pre;
2385 llvm::StringRef
Post;
2395 PrintExpr(D->getInit());
2411 for (
const auto *P :
Method->parameters()) {
2417 std::string ParamStr =
2419 ? P->getIdentifier()->deuglifiedName().str()
2420 : P->getNameAsString();
2421 P->getOriginalType().print(OS, Policy, ParamStr);
2423 if (
Method->isVariadic()) {
2433 auto *Proto =
Method->getType()->castAs<FunctionProtoType>();
2434 Proto->printExceptionSpecification(OS, Policy);
2441 Proto->getReturnType().print(OS, Policy);
2453void StmtPrinter::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *Node) {
2455 TSInfo->getType().print(OS, Policy);
2461void StmtPrinter::VisitCXXNewExpr(CXXNewExpr *E) {
2469 for (
unsigned i = 1; i < NumPlace; ++i) {
2481 llvm::raw_string_ostream
s(TypeS);
2484 (*Size)->printPretty(
s, Helper, Policy);
2492 if (InitStyle != CXXNewInitializationStyle::None) {
2493 bool Bare = InitStyle == CXXNewInitializationStyle::Parens &&
2503void StmtPrinter::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
2512void StmtPrinter::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
2522 OS << II->getName();
2527void StmtPrinter::VisitCXXConstructExpr(CXXConstructExpr *E) {
2531 for (
unsigned i = 0, e = E->
getNumArgs(); i != e; ++i) {
2545void StmtPrinter::VisitCXXInheritedCtorInitExpr(CXXInheritedCtorInitExpr *E) {
2547 OS <<
"<forwarded>";
2550void StmtPrinter::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E) {
2554void StmtPrinter::VisitExprWithCleanups(ExprWithCleanups *E) {
2559void StmtPrinter::VisitCXXUnresolvedConstructExpr(
2560 CXXUnresolvedConstructExpr *Node) {
2564 for (
auto Arg = Node->
arg_begin(), ArgEnd = Node->
arg_end(); Arg != ArgEnd;
2574void StmtPrinter::VisitCXXDependentScopeMemberExpr(
2575 CXXDependentScopeMemberExpr *Node) {
2588void StmtPrinter::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *Node) {
2601void StmtPrinter::VisitTypeTraitExpr(TypeTraitExpr *E) {
2603 for (
unsigned I = 0, N = E->
getNumArgs(); I != N; ++I) {
2611void StmtPrinter::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
2617void StmtPrinter::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
2623void StmtPrinter::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
2629void StmtPrinter::VisitPackExpansionExpr(PackExpansionExpr *E) {
2634void StmtPrinter::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
2635 OS <<
"sizeof...(" << *E->
getPack() <<
")";
2638void StmtPrinter::VisitPackIndexingExpr(PackIndexingExpr *E) {
2645void StmtPrinter::VisitSubstNonTypeTemplateParmPackExpr(
2646 SubstNonTypeTemplateParmPackExpr *Node) {
2650void StmtPrinter::VisitSubstNonTypeTemplateParmExpr(
2651 SubstNonTypeTemplateParmExpr *Node) {
2655void StmtPrinter::VisitFunctionParmPackExpr(FunctionParmPackExpr *E) {
2659void StmtPrinter::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *Node){
2663void StmtPrinter::VisitCXXFoldExpr(CXXFoldExpr *E) {
2677void StmtPrinter::VisitCXXParenListInitExpr(CXXParenListInitExpr *Node) {
2679 [&](Expr *E) { PrintExpr(E); });
2682void StmtPrinter::VisitConceptSpecializationExpr(ConceptSpecializationExpr *E) {
2696 if (!LocalParameters.empty()) {
2698 for (ParmVarDecl *LocalParam : LocalParameters) {
2699 PrintRawDecl(LocalParam);
2700 if (LocalParam != LocalParameters.back())
2708 for (concepts::Requirement *Req : Requirements) {
2709 if (
auto *TypeReq = dyn_cast<concepts::TypeRequirement>(Req)) {
2710 if (TypeReq->isSubstitutionFailure())
2711 OS <<
"<<error-type>>";
2713 TypeReq->getType()->getType().print(OS, Policy);
2714 }
else if (
auto *ExprReq = dyn_cast<concepts::ExprRequirement>(Req)) {
2715 if (ExprReq->isCompound())
2717 if (ExprReq->isExprSubstitutionFailure())
2718 OS <<
"<<error-expression>>";
2720 PrintExpr(ExprReq->getExpr());
2721 if (ExprReq->isCompound()) {
2723 if (ExprReq->getNoexceptLoc().isValid())
2725 const auto &RetReq = ExprReq->getReturnTypeRequirement();
2726 if (!RetReq.isEmpty()) {
2728 if (RetReq.isSubstitutionFailure())
2729 OS <<
"<<error-type>>";
2730 else if (RetReq.isTypeConstraint())
2731 RetReq.getTypeConstraint()->print(OS, Policy);
2737 if (NestedReq->hasInvalidConstraint())
2738 OS <<
"<<error-expression>>";
2740 PrintExpr(NestedReq->getConstraintExpr());
2749void StmtPrinter::VisitCoroutineBodyStmt(CoroutineBodyStmt *S) {
2753void StmtPrinter::VisitCoreturnStmt(CoreturnStmt *S) {
2762void StmtPrinter::VisitCoawaitExpr(CoawaitExpr *S) {
2767void StmtPrinter::VisitDependentCoawaitExpr(DependentCoawaitExpr *S) {
2772void StmtPrinter::VisitCoyieldExpr(CoyieldExpr *S) {
2779void StmtPrinter::VisitObjCStringLiteral(ObjCStringLiteral *Node) {
2784void StmtPrinter::VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
2789void StmtPrinter::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
2791 ObjCArrayLiteral::child_range Ch = E->
children();
2792 for (
auto I = Ch.begin(), E = Ch.end(); I != E; ++I) {
2793 if (I != Ch.begin())
2800void StmtPrinter::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
2809 Visit(Element.
Value);
2816void StmtPrinter::VisitObjCEncodeExpr(ObjCEncodeExpr *Node) {
2822void StmtPrinter::VisitObjCSelectorExpr(ObjCSelectorExpr *Node) {
2828void StmtPrinter::VisitObjCProtocolExpr(ObjCProtocolExpr *Node) {
2832void StmtPrinter::VisitObjCMessageExpr(ObjCMessageExpr *Mess) {
2854 for (
unsigned i = 0, e = Mess->
getNumArgs(); i != e; ++i) {
2856 if (i > 0)
OS <<
' ';
2864 PrintExpr(Mess->
getArg(i));
2870void StmtPrinter::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *Node) {
2871 OS << (Node->
getValue() ?
"__objc_yes" :
"__objc_no");
2875StmtPrinter::VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
2880StmtPrinter::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
2887void StmtPrinter::VisitBlockExpr(BlockExpr *Node) {
2900 std::string ParamStr = (*AI)->getNameAsString();
2901 (*AI)->getType().print(OS, Policy, ParamStr);
2905 if (FT->isVariadic()) {
2914void StmtPrinter::VisitOpaqueValueExpr(OpaqueValueExpr *Node) {
2918void StmtPrinter::VisitRecoveryExpr(RecoveryExpr *Node) {
2919 OS <<
"<recovery-expr>(";
2920 const char *Sep =
"";
2929void StmtPrinter::VisitAsTypeExpr(AsTypeExpr *Node) {
2930 OS <<
"__builtin_astype(";
2937void StmtPrinter::VisitHLSLOutArgExpr(HLSLOutArgExpr *Node) {
2951 StringRef NL,
const ASTContext *Context)
const {
2952 StmtPrinter P(Out, Helper, Policy, Indentation, NL, Context);
2953 P.Visit(
const_cast<Stmt *
>(
this));
2958 unsigned Indentation, StringRef NL,
2960 StmtPrinter P(Out, Helper, Policy, Indentation, NL, Context);
2961 P.PrintControlledStmt(
const_cast<Stmt *
>(
this));
2967 llvm::raw_string_ostream TempOut(Buf);
Defines the clang::ASTContext interface.
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
OpenMPDirectiveKind getCancelRegion() const
Get cancellation region for the current cancellation point.
OpenMPDirectiveKind getCancelRegion() const
Get cancellation region for the current cancellation point.
const Stmt * getAssociatedStmt() const
OpenACCAtomicKind getAtomicKind() const
ArrayRef< Expr * > getVarList() const
Stmt * getStructuredBlock()
Stmt * getStructuredBlock()
bool hasQueuesTag() const
ArrayRef< Expr * > getQueueIdExprs()
bool hasDevNumExpr() 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
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.
ArrayRef< 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...
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
SourceLocation getTemplateKWLoc() const
ConceptDecl * getNamedConcept() 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
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.
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
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
const Expr * getBase() const
IdentifierInfo & getAccessor() 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.
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()
bool hasLabelTarget() const
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.
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
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.
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
Stmt * getBody() const override
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
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.
OutlinedFunctionDecl * getOutlinedFunctionDecl()
Retrieve the outlined function declaration.
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
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 &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>.
DeducedType * getContainedDeducedType() const
Get the DeducedType whose type will be deduced for a variable with an initializer of this type.
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.
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)
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,...
The JSON file list parser is used to communicate input to InstallAPI.
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 * getTraitSpelling(ExpressionTrait T) LLVM_READONLY
Return the spelling of the type trait TT. Never null.
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 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 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.