47#include "llvm/ADT/ArrayRef.h"
48#include "llvm/ADT/STLExtras.h"
49#include "llvm/ADT/StringExtras.h"
50#include "llvm/ADT/StringRef.h"
51#include "llvm/Support/Compiler.h"
52#include "llvm/Support/ErrorHandling.h"
53#include "llvm/Support/raw_ostream.h"
66 class StmtPrinter :
public StmtVisitor<StmtPrinter> {
69 PrinterHelper* Helper;
70 PrintingPolicy Policy;
72 const ASTContext *Context;
75 StmtPrinter(raw_ostream &os, PrinterHelper *helper,
76 const PrintingPolicy &Policy,
unsigned Indentation = 0,
77 StringRef NL =
"\n",
const ASTContext *Context =
nullptr)
78 : OS(os), IndentLevel(Indentation), Helper(helper), Policy(Policy),
79 NL(NL), Context(Context) {}
81 void PrintStmt(Stmt *S) { PrintStmt(S, Policy.Indentation); }
83 void PrintStmt(Stmt *S,
int SubIndent) {
84 IndentLevel += SubIndent;
85 if (isa_and_nonnull<Expr>(S)) {
93 Indent() <<
"<<<NULL STATEMENT>>>" << NL;
95 IndentLevel -= SubIndent;
98 void PrintInitStmt(Stmt *S,
unsigned PrefixWidth) {
100 IndentLevel += (PrefixWidth + 1) / 2;
101 if (
auto *DS = dyn_cast<DeclStmt>(S))
102 PrintRawDeclStmt(DS);
106 IndentLevel -= (PrefixWidth + 1) / 2;
109 void PrintControlledStmt(Stmt *S) {
110 if (
auto *CS = dyn_cast<CompoundStmt>(S)) {
112 PrintRawCompoundStmt(CS);
121 void PrintRawDecl(Decl *D);
122 void PrintRawDeclStmt(
const DeclStmt *S);
123 void PrintRawIfStmt(IfStmt *
If);
124 void PrintRawCXXCatchStmt(CXXCatchStmt *Catch);
125 void PrintCallArgs(CallExpr *E);
126 void PrintRawSEHExceptHandler(SEHExceptStmt *S);
127 void PrintRawSEHFinallyStmt(SEHFinallyStmt *S);
128 void PrintOMPExecutableDirective(OMPExecutableDirective *S,
129 bool ForceNoStmt =
false);
131 void PrintOpenACCClauseList(OpenACCConstructStmt *S);
132 void PrintOpenACCConstruct(OpenACCConstructStmt *S);
134 void PrintExpr(Expr *E) {
141 raw_ostream &
Indent(
int Delta = 0) {
142 for (
int i = 0, e = IndentLevel+Delta; i < e; ++i)
147 void Visit(Stmt* S) {
148 if (Helper && Helper->handledStmt(S,OS))
150 else StmtVisitor<StmtPrinter>::Visit(S);
153 [[maybe_unused]]
void VisitStmt(Stmt *Node) {
154 Indent() <<
"<<unknown stmt type>>" << NL;
157 [[maybe_unused]]
void VisitExpr(Expr *Node) {
158 OS <<
"<<unknown expr type>>";
161 void VisitCXXNamedCastExpr(CXXNamedCastExpr *Node);
163 void VisitBinComma(BinaryOperator *Node);
165#define ABSTRACT_STMT(CLASS)
166#define STMT(CLASS, PARENT) \
167 void Visit##CLASS(CLASS *Node);
168#include "clang/AST/StmtNodes.inc"
179void StmtPrinter::PrintRawCompoundStmt(
CompoundStmt *Node) {
180 assert(Node &&
"Compound statement cannot be null");
182 PrintFPPragmas(Node);
183 for (
auto *I : Node->
body())
193 bool FEnvAccess =
false;
194 if (FPO.hasAllowFEnvAccessOverride()) {
195 FEnvAccess = FPO.getAllowFEnvAccessOverride();
196 Indent() <<
"#pragma STDC FENV_ACCESS " << (FEnvAccess ?
"ON" :
"OFF")
199 if (FPO.hasSpecifiedExceptionModeOverride()) {
200 LangOptions::FPExceptionModeKind EM =
201 FPO.getSpecifiedExceptionModeOverride();
202 if (!FEnvAccess || EM != LangOptions::FPE_Strict) {
203 Indent() <<
"#pragma clang fp exceptions(";
204 switch (FPO.getSpecifiedExceptionModeOverride()) {
207 case LangOptions::FPE_Ignore:
210 case LangOptions::FPE_MayTrap:
213 case LangOptions::FPE_Strict:
220 if (FPO.hasConstRoundingModeOverride()) {
221 LangOptions::RoundingMode RM = FPO.getConstRoundingModeOverride();
222 Indent() <<
"#pragma STDC FENV_ROUND ";
224 case llvm::RoundingMode::TowardZero:
225 OS <<
"FE_TOWARDZERO";
227 case llvm::RoundingMode::NearestTiesToEven:
228 OS <<
"FE_TONEAREST";
230 case llvm::RoundingMode::TowardPositive:
233 case llvm::RoundingMode::TowardNegative:
236 case llvm::RoundingMode::NearestTiesToAway:
237 OS <<
"FE_TONEARESTFROMZERO";
239 case llvm::RoundingMode::Dynamic:
243 llvm_unreachable(
"Invalid rounding mode");
249void StmtPrinter::PrintRawDecl(Decl *D) {
253void StmtPrinter::PrintRawDeclStmt(
const DeclStmt *S) {
254 SmallVector<Decl *, 2> Decls(S->
decls());
258void StmtPrinter::VisitNullStmt(NullStmt *Node) {
262void StmtPrinter::VisitDeclStmt(DeclStmt *Node) {
264 PrintRawDeclStmt(Node);
273void StmtPrinter::VisitCompoundStmt(
CompoundStmt *Node) {
275 PrintRawCompoundStmt(Node);
279void StmtPrinter::VisitCaseStmt(CaseStmt *Node) {
281 PrintExpr(Node->
getLHS());
284 PrintExpr(Node->
getRHS());
291void StmtPrinter::VisitDefaultStmt(DefaultStmt *Node) {
292 Indent(-1) <<
"default:" << NL;
296void StmtPrinter::VisitLabelStmt(LabelStmt *Node) {
301void StmtPrinter::VisitAttributedStmt(AttributedStmt *Node) {
302 ArrayRef<const Attr *> Attrs = Node->
getAttrs();
303 for (
const auto *Attr : Attrs) {
304 Attr->printPretty(OS, Policy);
305 if (Attr != Attrs.back())
312void StmtPrinter::PrintRawIfStmt(IfStmt *
If) {
313 if (
If->isConsteval()) {
315 if (
If->isNegatedConsteval())
319 PrintStmt(
If->getThen());
320 if (Stmt *Else =
If->getElse()) {
331 PrintInitStmt(
If->getInit(), 4);
332 if (
const DeclStmt *DS =
If->getConditionVariableDeclStmt())
333 PrintRawDeclStmt(DS);
335 PrintExpr(
If->getCond());
338 if (
auto *CS = dyn_cast<CompoundStmt>(
If->getThen())) {
340 PrintRawCompoundStmt(CS);
341 OS << (
If->getElse() ?
" " : NL);
344 PrintStmt(
If->getThen());
348 if (Stmt *Else =
If->getElse()) {
351 if (
auto *CS = dyn_cast<CompoundStmt>(Else)) {
353 PrintRawCompoundStmt(CS);
355 }
else if (
auto *ElseIf = dyn_cast<IfStmt>(Else)) {
357 PrintRawIfStmt(ElseIf);
360 PrintStmt(
If->getElse());
365void StmtPrinter::VisitIfStmt(IfStmt *
If) {
370void StmtPrinter::VisitSwitchStmt(SwitchStmt *Node) {
373 PrintInitStmt(Node->
getInit(), 8);
375 PrintRawDeclStmt(DS);
379 PrintControlledStmt(Node->
getBody());
382void StmtPrinter::VisitWhileStmt(WhileStmt *Node) {
385 PrintRawDeclStmt(DS);
392void StmtPrinter::VisitDoStmt(DoStmt *Node) {
394 if (
auto *CS = dyn_cast<CompoundStmt>(Node->
getBody())) {
395 PrintRawCompoundStmt(CS);
408void StmtPrinter::VisitForStmt(ForStmt *Node) {
411 PrintInitStmt(Node->
getInit(), 5);
415 PrintRawDeclStmt(DS);
421 PrintExpr(Node->
getInc());
424 PrintControlledStmt(Node->
getBody());
427void StmtPrinter::VisitObjCForCollectionStmt(ObjCForCollectionStmt *Node) {
429 if (
auto *DS = dyn_cast<DeclStmt>(Node->
getElement()))
430 PrintRawDeclStmt(DS);
436 PrintControlledStmt(Node->
getBody());
439void StmtPrinter::VisitCXXForRangeStmt(CXXForRangeStmt *Node) {
442 PrintInitStmt(Node->
getInit(), 5);
443 PrintingPolicy SubPolicy(Policy);
444 SubPolicy.SuppressInitializers =
true;
449 PrintControlledStmt(Node->
getBody());
452void StmtPrinter::VisitCXXExpansionStmtPattern(CXXExpansionStmtPattern *Node) {
453 OS <<
"template for (";
455 PrintInitStmt(Node->
getInit(), 14);
456 PrintingPolicy SubPolicy(Policy);
457 SubPolicy.SuppressInitializers =
true;
471 PrintControlledStmt(Node->
getBody());
474void StmtPrinter::VisitCXXExpansionStmtInstantiation(
475 CXXExpansionStmtInstantiation *) {
476 llvm_unreachable(
"should never be printed");
479void StmtPrinter::VisitCXXExpansionSelectExpr(CXXExpansionSelectExpr *Node) {
483void StmtPrinter::VisitMSDependentExistsStmt(MSDependentExistsStmt *Node) {
486 OS <<
"__if_exists (";
488 OS <<
"__if_not_exists (";
496void StmtPrinter::VisitGotoStmt(GotoStmt *Node) {
501void StmtPrinter::VisitIndirectGotoStmt(IndirectGotoStmt *Node) {
508void StmtPrinter::VisitContinueStmt(ContinueStmt *Node) {
518void StmtPrinter::VisitBreakStmt(BreakStmt *Node) {
527void StmtPrinter::VisitDeferStmt(DeferStmt *Node) {
529 PrintControlledStmt(Node->
getBody());
532void StmtPrinter::VisitReturnStmt(ReturnStmt *Node) {
542void StmtPrinter::VisitGCCAsmStmt(GCCAsmStmt *Node) {
559 for (
unsigned i = 0, e = Node->
getNumOutputs(); i != e; ++i) {
580 for (
unsigned i = 0, e = Node->
getNumInputs(); i != e; ++i) {
611 for (
unsigned i = 0, e = Node->
getNumLabels(); i != e; ++i) {
621void StmtPrinter::VisitMSAsmStmt(MSAsmStmt *Node) {
631void StmtPrinter::VisitCapturedStmt(CapturedStmt *Node) {
635void StmtPrinter::VisitSYCLKernelCallStmt(SYCLKernelCallStmt *Node) {
639void StmtPrinter::VisitObjCAtTryStmt(ObjCAtTryStmt *Node) {
641 if (
auto *TS = dyn_cast<CompoundStmt>(Node->
getTryBody())) {
642 PrintRawCompoundStmt(TS);
646 for (ObjCAtCatchStmt *catchStmt : Node->
catch_stmts()) {
648 if (Decl *DS = catchStmt->getCatchParamDecl())
651 if (
auto *CS = dyn_cast<CompoundStmt>(catchStmt->getCatchBody())) {
652 PrintRawCompoundStmt(CS);
659 if (
auto *CS = dyn_cast<CompoundStmt>(FS->getFinallyBody())) {
660 PrintRawCompoundStmt(CS);
666void StmtPrinter::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *Node) {
669void StmtPrinter::VisitObjCAtCatchStmt (ObjCAtCatchStmt *Node) {
670 Indent() <<
"@catch (...) { /* todo */ } " << NL;
673void StmtPrinter::VisitObjCAtThrowStmt(ObjCAtThrowStmt *Node) {
682void StmtPrinter::VisitObjCAvailabilityCheckExpr(
683 ObjCAvailabilityCheckExpr *Node) {
684 OS <<
"@available(...)";
687void StmtPrinter::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *Node) {
688 Indent() <<
"@synchronized (";
695void StmtPrinter::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *Node) {
696 Indent() <<
"@autoreleasepool";
701void StmtPrinter::PrintRawCXXCatchStmt(CXXCatchStmt *Node) {
704 PrintRawDecl(ExDecl);
711void StmtPrinter::VisitCXXCatchStmt(CXXCatchStmt *Node) {
713 PrintRawCXXCatchStmt(Node);
717void StmtPrinter::VisitCXXTryStmt(CXXTryStmt *Node) {
727void StmtPrinter::VisitSEHTryStmt(SEHTryStmt *Node) {
733 PrintRawSEHExceptHandler(E);
735 assert(F &&
"Must have a finally block...");
736 PrintRawSEHFinallyStmt(F);
741void StmtPrinter::PrintRawSEHFinallyStmt(SEHFinallyStmt *Node) {
743 PrintRawCompoundStmt(Node->
getBlock());
747void StmtPrinter::PrintRawSEHExceptHandler(SEHExceptStmt *Node) {
751 PrintRawCompoundStmt(Node->
getBlock());
755void StmtPrinter::VisitSEHExceptStmt(SEHExceptStmt *Node) {
757 PrintRawSEHExceptHandler(Node);
761void StmtPrinter::VisitSEHFinallyStmt(SEHFinallyStmt *Node) {
763 PrintRawSEHFinallyStmt(Node);
767void StmtPrinter::VisitSEHLeaveStmt(SEHLeaveStmt *Node) {
776void StmtPrinter::VisitOMPCanonicalLoop(OMPCanonicalLoop *Node) {
777 PrintStmt(Node->getLoopStmt());
780void StmtPrinter::PrintOMPExecutableDirective(OMPExecutableDirective *S,
782 llvm::omp::Version OpenMPVersion =
784 : llvm::omp::FallbackVersion;
785 OMPClausePrinter Printer(OS, Policy, OpenMPVersion);
786 ArrayRef<OMPClause *> Clauses = S->clauses();
787 for (
auto *Clause : Clauses)
788 if (Clause && !Clause->isImplicit()) {
790 Printer.Visit(Clause);
793 if (!ForceNoStmt && S->hasAssociatedStmt())
794 PrintStmt(S->getRawStmt());
797void StmtPrinter::VisitOMPMetaDirective(OMPMetaDirective *Node) {
798 Indent() <<
"#pragma omp metadirective";
799 PrintOMPExecutableDirective(Node);
802void StmtPrinter::VisitOMPParallelDirective(OMPParallelDirective *Node) {
803 Indent() <<
"#pragma omp parallel";
804 PrintOMPExecutableDirective(Node);
807void StmtPrinter::VisitOMPSimdDirective(OMPSimdDirective *Node) {
808 Indent() <<
"#pragma omp simd";
809 PrintOMPExecutableDirective(Node);
812void StmtPrinter::VisitOMPTileDirective(OMPTileDirective *Node) {
813 Indent() <<
"#pragma omp tile";
814 PrintOMPExecutableDirective(Node);
817void StmtPrinter::VisitOMPStripeDirective(OMPStripeDirective *Node) {
818 Indent() <<
"#pragma omp stripe";
819 PrintOMPExecutableDirective(Node);
822void StmtPrinter::VisitOMPUnrollDirective(OMPUnrollDirective *Node) {
823 Indent() <<
"#pragma omp unroll";
824 PrintOMPExecutableDirective(Node);
827void StmtPrinter::VisitOMPReverseDirective(OMPReverseDirective *Node) {
828 Indent() <<
"#pragma omp reverse";
829 PrintOMPExecutableDirective(Node);
832void StmtPrinter::VisitOMPInterchangeDirective(OMPInterchangeDirective *Node) {
833 Indent() <<
"#pragma omp interchange";
834 PrintOMPExecutableDirective(Node);
837void StmtPrinter::VisitOMPFlattenDirective(OMPFlattenDirective *Node) {
838 Indent() <<
"#pragma omp flatten";
839 PrintOMPExecutableDirective(Node);
842void StmtPrinter::VisitOMPSplitDirective(OMPSplitDirective *Node) {
843 Indent() <<
"#pragma omp split";
844 PrintOMPExecutableDirective(Node);
847void StmtPrinter::VisitOMPFuseDirective(OMPFuseDirective *Node) {
848 Indent() <<
"#pragma omp fuse";
849 PrintOMPExecutableDirective(Node);
852void StmtPrinter::VisitOMPForDirective(OMPForDirective *Node) {
853 Indent() <<
"#pragma omp for";
854 PrintOMPExecutableDirective(Node);
857void StmtPrinter::VisitOMPForSimdDirective(OMPForSimdDirective *Node) {
858 Indent() <<
"#pragma omp for simd";
859 PrintOMPExecutableDirective(Node);
862void StmtPrinter::VisitOMPSectionsDirective(OMPSectionsDirective *Node) {
863 Indent() <<
"#pragma omp sections";
864 PrintOMPExecutableDirective(Node);
867void StmtPrinter::VisitOMPSectionDirective(OMPSectionDirective *Node) {
868 Indent() <<
"#pragma omp section";
869 PrintOMPExecutableDirective(Node);
872void StmtPrinter::VisitOMPScopeDirective(OMPScopeDirective *Node) {
873 Indent() <<
"#pragma omp scope";
874 PrintOMPExecutableDirective(Node);
877void StmtPrinter::VisitOMPSingleDirective(OMPSingleDirective *Node) {
878 Indent() <<
"#pragma omp single";
879 PrintOMPExecutableDirective(Node);
882void StmtPrinter::VisitOMPMasterDirective(OMPMasterDirective *Node) {
883 Indent() <<
"#pragma omp master";
884 PrintOMPExecutableDirective(Node);
887void StmtPrinter::VisitOMPCriticalDirective(OMPCriticalDirective *Node) {
888 Indent() <<
"#pragma omp critical";
894 PrintOMPExecutableDirective(Node);
897void StmtPrinter::VisitOMPParallelForDirective(OMPParallelForDirective *Node) {
898 Indent() <<
"#pragma omp parallel for";
899 PrintOMPExecutableDirective(Node);
902void StmtPrinter::VisitOMPParallelForSimdDirective(
903 OMPParallelForSimdDirective *Node) {
904 Indent() <<
"#pragma omp parallel for simd";
905 PrintOMPExecutableDirective(Node);
908void StmtPrinter::VisitOMPParallelMasterDirective(
909 OMPParallelMasterDirective *Node) {
910 Indent() <<
"#pragma omp parallel master";
911 PrintOMPExecutableDirective(Node);
914void StmtPrinter::VisitOMPParallelMaskedDirective(
915 OMPParallelMaskedDirective *Node) {
916 Indent() <<
"#pragma omp parallel masked";
917 PrintOMPExecutableDirective(Node);
920void StmtPrinter::VisitOMPParallelSectionsDirective(
921 OMPParallelSectionsDirective *Node) {
922 Indent() <<
"#pragma omp parallel sections";
923 PrintOMPExecutableDirective(Node);
926void StmtPrinter::VisitOMPTaskDirective(OMPTaskDirective *Node) {
927 Indent() <<
"#pragma omp task";
928 PrintOMPExecutableDirective(Node);
931void StmtPrinter::VisitOMPTaskyieldDirective(OMPTaskyieldDirective *Node) {
932 Indent() <<
"#pragma omp taskyield";
933 PrintOMPExecutableDirective(Node);
936void StmtPrinter::VisitOMPBarrierDirective(OMPBarrierDirective *Node) {
937 Indent() <<
"#pragma omp barrier";
938 PrintOMPExecutableDirective(Node);
941void StmtPrinter::VisitOMPTaskwaitDirective(OMPTaskwaitDirective *Node) {
942 Indent() <<
"#pragma omp taskwait";
943 PrintOMPExecutableDirective(Node);
946void StmtPrinter::VisitOMPAssumeDirective(OMPAssumeDirective *Node) {
947 Indent() <<
"#pragma omp assume";
948 PrintOMPExecutableDirective(Node);
951void StmtPrinter::VisitOMPErrorDirective(OMPErrorDirective *Node) {
952 Indent() <<
"#pragma omp error";
953 PrintOMPExecutableDirective(Node);
956void StmtPrinter::VisitOMPTaskgroupDirective(OMPTaskgroupDirective *Node) {
957 Indent() <<
"#pragma omp taskgroup";
958 PrintOMPExecutableDirective(Node);
961void StmtPrinter::VisitOMPFlushDirective(OMPFlushDirective *Node) {
962 Indent() <<
"#pragma omp flush";
963 PrintOMPExecutableDirective(Node);
966void StmtPrinter::VisitOMPDepobjDirective(OMPDepobjDirective *Node) {
967 Indent() <<
"#pragma omp depobj";
968 PrintOMPExecutableDirective(Node);
971void StmtPrinter::VisitOMPScanDirective(OMPScanDirective *Node) {
972 Indent() <<
"#pragma omp scan";
973 PrintOMPExecutableDirective(Node);
976void StmtPrinter::VisitOMPOrderedStandaloneDirective(
977 OMPOrderedStandaloneDirective *Node) {
978 Indent() <<
"#pragma omp ordered";
979 PrintOMPExecutableDirective(Node,
true);
982void StmtPrinter::VisitOMPOrderedBlockAssocDirective(
983 OMPOrderedBlockAssocDirective *Node) {
984 Indent() <<
"#pragma omp ordered";
985 PrintOMPExecutableDirective(Node);
988void StmtPrinter::VisitOMPAtomicDirective(OMPAtomicDirective *Node) {
989 Indent() <<
"#pragma omp atomic";
990 PrintOMPExecutableDirective(Node);
993void StmtPrinter::VisitOMPTargetDirective(OMPTargetDirective *Node) {
994 Indent() <<
"#pragma omp target";
995 PrintOMPExecutableDirective(Node);
998void StmtPrinter::VisitOMPTargetDataDirective(OMPTargetDataDirective *Node) {
999 Indent() <<
"#pragma omp target data";
1000 PrintOMPExecutableDirective(Node);
1003void StmtPrinter::VisitOMPTargetEnterDataDirective(
1004 OMPTargetEnterDataDirective *Node) {
1005 Indent() <<
"#pragma omp target enter data";
1006 PrintOMPExecutableDirective(Node,
true);
1009void StmtPrinter::VisitOMPTargetExitDataDirective(
1010 OMPTargetExitDataDirective *Node) {
1011 Indent() <<
"#pragma omp target exit data";
1012 PrintOMPExecutableDirective(Node,
true);
1015void StmtPrinter::VisitOMPTargetParallelDirective(
1016 OMPTargetParallelDirective *Node) {
1017 Indent() <<
"#pragma omp target parallel";
1018 PrintOMPExecutableDirective(Node);
1021void StmtPrinter::VisitOMPTargetParallelForDirective(
1022 OMPTargetParallelForDirective *Node) {
1023 Indent() <<
"#pragma omp target parallel for";
1024 PrintOMPExecutableDirective(Node);
1027void StmtPrinter::VisitOMPTeamsDirective(OMPTeamsDirective *Node) {
1028 Indent() <<
"#pragma omp teams";
1029 PrintOMPExecutableDirective(Node);
1032void StmtPrinter::VisitOMPCancellationPointDirective(
1033 OMPCancellationPointDirective *Node) {
1034 llvm::omp::Version OpenMPVersion =
1036 : llvm::omp::FallbackVersion;
1037 Indent() <<
"#pragma omp cancellation point "
1039 PrintOMPExecutableDirective(Node);
1042void StmtPrinter::VisitOMPCancelDirective(OMPCancelDirective *Node) {
1043 llvm::omp::Version OpenMPVersion =
1045 : llvm::omp::FallbackVersion;
1046 Indent() <<
"#pragma omp cancel "
1048 PrintOMPExecutableDirective(Node);
1051void StmtPrinter::VisitOMPTaskLoopDirective(OMPTaskLoopDirective *Node) {
1052 Indent() <<
"#pragma omp taskloop";
1053 PrintOMPExecutableDirective(Node);
1056void StmtPrinter::VisitOMPTaskLoopSimdDirective(
1057 OMPTaskLoopSimdDirective *Node) {
1058 Indent() <<
"#pragma omp taskloop simd";
1059 PrintOMPExecutableDirective(Node);
1062void StmtPrinter::VisitOMPMasterTaskLoopDirective(
1063 OMPMasterTaskLoopDirective *Node) {
1064 Indent() <<
"#pragma omp master taskloop";
1065 PrintOMPExecutableDirective(Node);
1068void StmtPrinter::VisitOMPMaskedTaskLoopDirective(
1069 OMPMaskedTaskLoopDirective *Node) {
1070 Indent() <<
"#pragma omp masked taskloop";
1071 PrintOMPExecutableDirective(Node);
1074void StmtPrinter::VisitOMPMasterTaskLoopSimdDirective(
1075 OMPMasterTaskLoopSimdDirective *Node) {
1076 Indent() <<
"#pragma omp master taskloop simd";
1077 PrintOMPExecutableDirective(Node);
1080void StmtPrinter::VisitOMPMaskedTaskLoopSimdDirective(
1081 OMPMaskedTaskLoopSimdDirective *Node) {
1082 Indent() <<
"#pragma omp masked taskloop simd";
1083 PrintOMPExecutableDirective(Node);
1086void StmtPrinter::VisitOMPParallelMasterTaskLoopDirective(
1087 OMPParallelMasterTaskLoopDirective *Node) {
1088 Indent() <<
"#pragma omp parallel master taskloop";
1089 PrintOMPExecutableDirective(Node);
1092void StmtPrinter::VisitOMPParallelMaskedTaskLoopDirective(
1093 OMPParallelMaskedTaskLoopDirective *Node) {
1094 Indent() <<
"#pragma omp parallel masked taskloop";
1095 PrintOMPExecutableDirective(Node);
1098void StmtPrinter::VisitOMPParallelMasterTaskLoopSimdDirective(
1099 OMPParallelMasterTaskLoopSimdDirective *Node) {
1100 Indent() <<
"#pragma omp parallel master taskloop simd";
1101 PrintOMPExecutableDirective(Node);
1104void StmtPrinter::VisitOMPParallelMaskedTaskLoopSimdDirective(
1105 OMPParallelMaskedTaskLoopSimdDirective *Node) {
1106 Indent() <<
"#pragma omp parallel masked taskloop simd";
1107 PrintOMPExecutableDirective(Node);
1110void StmtPrinter::VisitOMPDistributeDirective(OMPDistributeDirective *Node) {
1111 Indent() <<
"#pragma omp distribute";
1112 PrintOMPExecutableDirective(Node);
1115void StmtPrinter::VisitOMPTargetUpdateDirective(
1116 OMPTargetUpdateDirective *Node) {
1117 Indent() <<
"#pragma omp target update";
1118 PrintOMPExecutableDirective(Node,
true);
1121void StmtPrinter::VisitOMPDistributeParallelForDirective(
1122 OMPDistributeParallelForDirective *Node) {
1123 Indent() <<
"#pragma omp distribute parallel for";
1124 PrintOMPExecutableDirective(Node);
1127void StmtPrinter::VisitOMPDistributeParallelForSimdDirective(
1128 OMPDistributeParallelForSimdDirective *Node) {
1129 Indent() <<
"#pragma omp distribute parallel for simd";
1130 PrintOMPExecutableDirective(Node);
1133void StmtPrinter::VisitOMPDistributeSimdDirective(
1134 OMPDistributeSimdDirective *Node) {
1135 Indent() <<
"#pragma omp distribute simd";
1136 PrintOMPExecutableDirective(Node);
1139void StmtPrinter::VisitOMPTargetParallelForSimdDirective(
1140 OMPTargetParallelForSimdDirective *Node) {
1141 Indent() <<
"#pragma omp target parallel for simd";
1142 PrintOMPExecutableDirective(Node);
1145void StmtPrinter::VisitOMPTargetSimdDirective(OMPTargetSimdDirective *Node) {
1146 Indent() <<
"#pragma omp target simd";
1147 PrintOMPExecutableDirective(Node);
1150void StmtPrinter::VisitOMPTeamsDistributeDirective(
1151 OMPTeamsDistributeDirective *Node) {
1152 Indent() <<
"#pragma omp teams distribute";
1153 PrintOMPExecutableDirective(Node);
1156void StmtPrinter::VisitOMPTeamsDistributeSimdDirective(
1157 OMPTeamsDistributeSimdDirective *Node) {
1158 Indent() <<
"#pragma omp teams distribute simd";
1159 PrintOMPExecutableDirective(Node);
1162void StmtPrinter::VisitOMPTeamsDistributeParallelForSimdDirective(
1163 OMPTeamsDistributeParallelForSimdDirective *Node) {
1164 Indent() <<
"#pragma omp teams distribute parallel for simd";
1165 PrintOMPExecutableDirective(Node);
1168void StmtPrinter::VisitOMPTeamsDistributeParallelForDirective(
1169 OMPTeamsDistributeParallelForDirective *Node) {
1170 Indent() <<
"#pragma omp teams distribute parallel for";
1171 PrintOMPExecutableDirective(Node);
1174void StmtPrinter::VisitOMPTargetTeamsDirective(OMPTargetTeamsDirective *Node) {
1175 Indent() <<
"#pragma omp target teams";
1176 PrintOMPExecutableDirective(Node);
1179void StmtPrinter::VisitOMPTargetTeamsDistributeDirective(
1180 OMPTargetTeamsDistributeDirective *Node) {
1181 Indent() <<
"#pragma omp target teams distribute";
1182 PrintOMPExecutableDirective(Node);
1185void StmtPrinter::VisitOMPTargetTeamsDistributeParallelForDirective(
1186 OMPTargetTeamsDistributeParallelForDirective *Node) {
1187 Indent() <<
"#pragma omp target teams distribute parallel for";
1188 PrintOMPExecutableDirective(Node);
1191void StmtPrinter::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
1192 OMPTargetTeamsDistributeParallelForSimdDirective *Node) {
1193 Indent() <<
"#pragma omp target teams distribute parallel for simd";
1194 PrintOMPExecutableDirective(Node);
1197void StmtPrinter::VisitOMPTargetTeamsDistributeSimdDirective(
1198 OMPTargetTeamsDistributeSimdDirective *Node) {
1199 Indent() <<
"#pragma omp target teams distribute simd";
1200 PrintOMPExecutableDirective(Node);
1203void StmtPrinter::VisitOMPInteropDirective(OMPInteropDirective *Node) {
1204 Indent() <<
"#pragma omp interop";
1205 PrintOMPExecutableDirective(Node);
1208void StmtPrinter::VisitOMPDispatchDirective(OMPDispatchDirective *Node) {
1209 Indent() <<
"#pragma omp dispatch";
1210 PrintOMPExecutableDirective(Node);
1213void StmtPrinter::VisitOMPMaskedDirective(OMPMaskedDirective *Node) {
1214 Indent() <<
"#pragma omp masked";
1215 PrintOMPExecutableDirective(Node);
1218void StmtPrinter::VisitOMPGenericLoopDirective(OMPGenericLoopDirective *Node) {
1219 Indent() <<
"#pragma omp loop";
1220 PrintOMPExecutableDirective(Node);
1223void StmtPrinter::VisitOMPTeamsGenericLoopDirective(
1224 OMPTeamsGenericLoopDirective *Node) {
1225 Indent() <<
"#pragma omp teams loop";
1226 PrintOMPExecutableDirective(Node);
1229void StmtPrinter::VisitOMPTargetTeamsGenericLoopDirective(
1230 OMPTargetTeamsGenericLoopDirective *Node) {
1231 Indent() <<
"#pragma omp target teams loop";
1232 PrintOMPExecutableDirective(Node);
1235void StmtPrinter::VisitOMPParallelGenericLoopDirective(
1236 OMPParallelGenericLoopDirective *Node) {
1237 Indent() <<
"#pragma omp parallel loop";
1238 PrintOMPExecutableDirective(Node);
1241void StmtPrinter::VisitOMPTargetParallelGenericLoopDirective(
1242 OMPTargetParallelGenericLoopDirective *Node) {
1243 Indent() <<
"#pragma omp target parallel loop";
1244 PrintOMPExecutableDirective(Node);
1250void StmtPrinter::PrintOpenACCClauseList(OpenACCConstructStmt *S) {
1253 OpenACCClausePrinter Printer(OS, Policy);
1254 Printer.VisitClauseList(S->
clauses());
1257void StmtPrinter::PrintOpenACCConstruct(OpenACCConstructStmt *S) {
1259 PrintOpenACCClauseList(S);
1263 PrintOpenACCConstruct(S);
1264 PrintStmt(S->getStructuredBlock());
1267void StmtPrinter::VisitOpenACCLoopConstruct(OpenACCLoopConstruct *S) {
1268 PrintOpenACCConstruct(S);
1272void StmtPrinter::VisitOpenACCCombinedConstruct(OpenACCCombinedConstruct *S) {
1273 PrintOpenACCConstruct(S);
1277void StmtPrinter::VisitOpenACCDataConstruct(OpenACCDataConstruct *S) {
1278 PrintOpenACCConstruct(S);
1281void StmtPrinter::VisitOpenACCHostDataConstruct(OpenACCHostDataConstruct *S) {
1282 PrintOpenACCConstruct(S);
1285void StmtPrinter::VisitOpenACCEnterDataConstruct(OpenACCEnterDataConstruct *S) {
1286 PrintOpenACCConstruct(S);
1288void StmtPrinter::VisitOpenACCExitDataConstruct(OpenACCExitDataConstruct *S) {
1289 PrintOpenACCConstruct(S);
1291void StmtPrinter::VisitOpenACCInitConstruct(OpenACCInitConstruct *S) {
1292 PrintOpenACCConstruct(S);
1294void StmtPrinter::VisitOpenACCShutdownConstruct(OpenACCShutdownConstruct *S) {
1295 PrintOpenACCConstruct(S);
1297void StmtPrinter::VisitOpenACCSetConstruct(OpenACCSetConstruct *S) {
1298 PrintOpenACCConstruct(S);
1300void StmtPrinter::VisitOpenACCUpdateConstruct(OpenACCUpdateConstruct *S) {
1301 PrintOpenACCConstruct(S);
1304void StmtPrinter::VisitOpenACCWaitConstruct(OpenACCWaitConstruct *S) {
1305 Indent() <<
"#pragma acc wait";
1318 E->printPretty(OS, nullptr, Policy);
1324 PrintOpenACCClauseList(S);
1328void StmtPrinter::VisitOpenACCAtomicConstruct(OpenACCAtomicConstruct *S) {
1329 Indent() <<
"#pragma acc atomic";
1334 PrintOpenACCClauseList(S);
1339void StmtPrinter::VisitOpenACCCacheConstruct(OpenACCCacheConstruct *S) {
1340 Indent() <<
"#pragma acc cache(";
1344 llvm::interleaveComma(S->
getVarList(), OS, [&](
const Expr *E) {
1345 E->printPretty(OS, nullptr, Policy);
1355void StmtPrinter::VisitSourceLocExpr(SourceLocExpr *Node) {
1359void StmtPrinter::VisitEmbedExpr(EmbedExpr *Node) {
1367void StmtPrinter::VisitConstantExpr(ConstantExpr *Node) {
1371void StmtPrinter::VisitDeclRefExpr(DeclRefExpr *Node) {
1372 ValueDecl *VD = Node->
getDecl();
1373 if (
const auto *OCED = dyn_cast<OMPCapturedExprDecl>(VD)) {
1374 OCED->getInit()->IgnoreImpCasts()->printPretty(OS,
nullptr, Policy);
1377 if (
const auto *TPOD = dyn_cast<TemplateParamObjectDecl>(VD)) {
1378 TPOD->printAsExpr(OS, Policy);
1381 bool ForceAnonymous =
1382 Policy.PrintAsCanonical && VD->
getKind() == Decl::NonTypeTemplateParm;
1383 bool CleanUglifiedParameter = Policy.CleanUglifiedParameters &&
1386 if (Policy.FullyQualifiedName && !ForceAnonymous && !CleanUglifiedParameter &&
1394 DeclarationNameInfo NameInfo = Node->
getNameInfo();
1398 if (CleanUglifiedParameter && ID)
1399 OS <<
ID->deuglifiedName();
1404 case Decl::NonTypeTemplateParm: {
1406 OS <<
"value-parameter-" << TD->getDepth() <<
'-' << TD->getIndex()
1410 case Decl::ParmVar: {
1412 OS <<
"function-parameter-" << PD->getFunctionScopeDepth() <<
'-'
1413 << PD->getFunctionScopeIndex();
1416 case Decl::Decomposition:
1417 OS <<
"decomposition";
1419 OS <<
'-' << I->getName();
1428 const TemplateParameterList *TPL =
nullptr;
1430 if (
auto *TD = dyn_cast<TemplateDecl>(VD))
1431 TPL = TD->getTemplateParameters();
1436void StmtPrinter::VisitDependentScopeDeclRefExpr(
1437 DependentScopeDeclRefExpr *Node) {
1446void StmtPrinter::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *Node) {
1456 if (
const auto *DRE = dyn_cast<DeclRefExpr>(E)) {
1457 if (
const auto *PD = dyn_cast<ImplicitParamDecl>(DRE->getDecl())) {
1459 DRE->getBeginLoc().isInvalid())
1466void StmtPrinter::VisitObjCIvarRefExpr(ObjCIvarRefExpr *Node) {
1468 if (!Policy.SuppressImplicitBase ||
1477void StmtPrinter::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *Node) {
1489 Getter->getSelector().print(OS);
1497void StmtPrinter::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *Node) {
1504void StmtPrinter::VisitSYCLUniqueStableNameExpr(
1505 SYCLUniqueStableNameExpr *Node) {
1506 OS <<
"__builtin_sycl_unique_stable_name(";
1511void StmtPrinter::VisitUnresolvedSYCLKernelCallStmt(
1512 UnresolvedSYCLKernelCallStmt *Node) {
1516void StmtPrinter::VisitPredefinedExpr(PredefinedExpr *Node) {
1520void StmtPrinter::VisitOpenACCAsteriskSizeExpr(OpenACCAsteriskSizeExpr *Node) {
1524void StmtPrinter::VisitCharacterLiteral(CharacterLiteral *Node) {
1537 Context->getSourceManager(), Context->getLangOpts(), &
Invalid);
1545void StmtPrinter::VisitIntegerLiteral(IntegerLiteral *Node) {
1552 OS << (isSigned ?
"wb" :
"uwb");
1557 switch (Node->
getType()->
castAs<BuiltinType>()->getKind()) {
1558 default: llvm_unreachable(
"Unexpected type for integer literal!");
1559 case BuiltinType::Char_S:
1560 case BuiltinType::Char_U:
OS <<
"i8";
break;
1561 case BuiltinType::UChar:
OS <<
"Ui8";
break;
1562 case BuiltinType::SChar:
OS <<
"i8";
break;
1563 case BuiltinType::Short:
OS <<
"i16";
break;
1564 case BuiltinType::UShort:
OS <<
"Ui16";
break;
1565 case BuiltinType::Int:
break;
1566 case BuiltinType::UInt:
OS <<
'U';
break;
1567 case BuiltinType::Long:
OS <<
'L';
break;
1568 case BuiltinType::ULong:
OS <<
"UL";
break;
1569 case BuiltinType::LongLong:
OS <<
"LL";
break;
1570 case BuiltinType::ULongLong:
OS <<
"ULL";
break;
1571 case BuiltinType::Int128:
1573 case BuiltinType::UInt128:
1575 case BuiltinType::WChar_S:
1576 case BuiltinType::WChar_U:
1581void StmtPrinter::VisitFixedPointLiteral(FixedPointLiteral *Node) {
1586 switch (Node->
getType()->
castAs<BuiltinType>()->getKind()) {
1587 default: llvm_unreachable(
"Unexpected type for fixed point literal!");
1588 case BuiltinType::ShortFract:
OS <<
"hr";
break;
1589 case BuiltinType::ShortAccum:
OS <<
"hk";
break;
1590 case BuiltinType::UShortFract:
OS <<
"uhr";
break;
1591 case BuiltinType::UShortAccum:
OS <<
"uhk";
break;
1592 case BuiltinType::Fract:
OS <<
"r";
break;
1593 case BuiltinType::Accum:
OS <<
"k";
break;
1594 case BuiltinType::UFract:
OS <<
"ur";
break;
1595 case BuiltinType::UAccum:
OS <<
"uk";
break;
1596 case BuiltinType::LongFract:
OS <<
"lr";
break;
1597 case BuiltinType::LongAccum:
OS <<
"lk";
break;
1598 case BuiltinType::ULongFract:
OS <<
"ulr";
break;
1599 case BuiltinType::ULongAccum:
OS <<
"ulk";
break;
1608 if (Str.find_first_not_of(
"-0123456789") == StringRef::npos)
1616 default: llvm_unreachable(
"Unexpected type for float literal!");
1617 case BuiltinType::Half:
break;
1618 case BuiltinType::Ibm128:
break;
1619 case BuiltinType::Double:
break;
1620 case BuiltinType::Float16: OS <<
"F16";
break;
1621 case BuiltinType::Float: OS <<
'F';
break;
1622 case BuiltinType::LongDouble: OS <<
'L';
break;
1623 case BuiltinType::Float128: OS <<
'Q';
break;
1627void StmtPrinter::VisitFloatingLiteral(FloatingLiteral *Node) {
1633void StmtPrinter::VisitImaginaryLiteral(ImaginaryLiteral *Node) {
1638void StmtPrinter::VisitStringLiteral(StringLiteral *Str) {
1642void StmtPrinter::VisitParenExpr(ParenExpr *Node) {
1648void StmtPrinter::VisitUnaryOperator(UnaryOperator *Node) {
1674void StmtPrinter::VisitOffsetOfExpr(OffsetOfExpr *Node) {
1675 OS <<
"__builtin_offsetof(";
1678 bool PrintedSomething =
false;
1686 PrintedSomething =
true;
1699 if (PrintedSomething)
1702 PrintedSomething =
true;
1708void StmtPrinter::VisitUnaryExprOrTypeTraitExpr(
1709 UnaryExprOrTypeTraitExpr *Node) {
1711 if (Node->
getKind() == UETT_AlignOf) {
1713 Spelling =
"alignof";
1715 Spelling =
"_Alignof";
1717 Spelling =
"__alignof";
1732void StmtPrinter::VisitGenericSelectionExpr(GenericSelectionExpr *Node) {
1741 QualType
T = Assoc.getType();
1745 T.print(OS, Policy);
1747 PrintExpr(Assoc.getAssociationExpr());
1752void StmtPrinter::VisitArraySubscriptExpr(ArraySubscriptExpr *Node) {
1753 PrintExpr(Node->
getLHS());
1755 PrintExpr(Node->
getRHS());
1759void StmtPrinter::VisitMatrixSingleSubscriptExpr(
1760 MatrixSingleSubscriptExpr *Node) {
1767void StmtPrinter::VisitMatrixSubscriptExpr(MatrixSubscriptExpr *Node) {
1777void StmtPrinter::VisitArraySectionExpr(ArraySectionExpr *Node) {
1795void StmtPrinter::VisitOMPArrayShapingExpr(OMPArrayShapingExpr *Node) {
1806void StmtPrinter::VisitOMPIteratorExpr(OMPIteratorExpr *Node) {
1813 PrintExpr(
Range.Begin);
1815 PrintExpr(
Range.End);
1818 PrintExpr(
Range.Step);
1826void StmtPrinter::PrintCallArgs(CallExpr *
Call) {
1827 for (
unsigned i = 0, e =
Call->getNumArgs(); i != e; ++i) {
1834 PrintExpr(
Call->getArg(i));
1838void StmtPrinter::VisitCallExpr(CallExpr *
Call) {
1839 PrintExpr(
Call->getCallee());
1841 PrintCallArgs(
Call);
1846 if (
const auto *TE = dyn_cast<CXXThisExpr>(E))
1847 return TE->isImplicit();
1851void StmtPrinter::VisitMemberExpr(MemberExpr *Node) {
1855 auto *ParentMember = dyn_cast<MemberExpr>(Node->
getBase());
1856 FieldDecl *ParentDecl =
1857 ParentMember ? dyn_cast<FieldDecl>(ParentMember->getMemberDecl())
1865 if (FD->isAnonymousStructOrUnion())
1872 const TemplateParameterList *TPL =
nullptr;
1873 if (
auto *FD = dyn_cast<FunctionDecl>(Node->
getMemberDecl())) {
1875 if (
auto *FTD = FD->getPrimaryTemplate())
1876 TPL = FTD->getTemplateParameters();
1877 }
else if (
auto *VTSD =
1878 dyn_cast<VarTemplateSpecializationDecl>(Node->
getMemberDecl()))
1879 TPL = VTSD->getSpecializedTemplate()->getTemplateParameters();
1884void StmtPrinter::VisitObjCIsaExpr(ObjCIsaExpr *Node) {
1886 OS << (Node->
isArrow() ?
"->isa" :
".isa");
1889void StmtPrinter::VisitExtVectorElementExpr(ExtVectorElementExpr *Node) {
1895void StmtPrinter::VisitMatrixElementExpr(MatrixElementExpr *Node) {
1901void StmtPrinter::VisitCStyleCastExpr(CStyleCastExpr *Node) {
1906 const auto *IL = dyn_cast<IntegerLiteral>(Node->
getSubExpr());
1909 llvm::APInt Val = IL->getValue();
1911 llvm::find_if(ED->enumerators(), [&](
const EnumConstantDecl *ECD) {
1912 return llvm::APInt::isSameValue(ECD->getInitVal(), Val);
1914 if (ECD != ED->enumerator_end()) {
1915 ECD->printQualifiedName(OS, Policy);
1926void StmtPrinter::VisitCompoundLiteralExpr(CompoundLiteralExpr *Node) {
1933void StmtPrinter::VisitImplicitCastExpr(ImplicitCastExpr *Node) {
1938void StmtPrinter::VisitBinComma(BinaryOperator *Node) {
1939 PrintExpr(Node->
getLHS());
1941 PrintExpr(Node->
getRHS());
1944void StmtPrinter::VisitBinaryOperator(BinaryOperator *Node) {
1945 PrintExpr(Node->
getLHS());
1947 PrintExpr(Node->
getRHS());
1950void StmtPrinter::VisitCompoundAssignOperator(CompoundAssignOperator *Node) {
1951 PrintExpr(Node->
getLHS());
1953 PrintExpr(Node->
getRHS());
1956void StmtPrinter::VisitConditionalOperator(ConditionalOperator *Node) {
1959 PrintExpr(Node->
getLHS());
1961 PrintExpr(Node->
getRHS());
1967StmtPrinter::VisitBinaryConditionalOperator(BinaryConditionalOperator *Node) {
1973void StmtPrinter::VisitAddrLabelExpr(AddrLabelExpr *Node) {
1977void StmtPrinter::VisitStmtExpr(StmtExpr *E) {
1983void StmtPrinter::VisitChooseExpr(ChooseExpr *Node) {
1984 OS <<
"__builtin_choose_expr(";
1987 PrintExpr(Node->
getLHS());
1989 PrintExpr(Node->
getRHS());
1993void StmtPrinter::VisitGNUNullExpr(GNUNullExpr *) {
1997void StmtPrinter::VisitShuffleVectorExpr(ShuffleVectorExpr *Node) {
1998 OS <<
"__builtin_shufflevector(";
2006void StmtPrinter::VisitConvertVectorExpr(ConvertVectorExpr *Node) {
2007 OS <<
"__builtin_convertvector(";
2014void StmtPrinter::VisitInitListExpr(InitListExpr* Node) {
2021 for (
unsigned i = 0, e = Node->
getNumInits(); i != e; ++i) {
2031void StmtPrinter::VisitArrayInitLoopExpr(ArrayInitLoopExpr *Node) {
2039void StmtPrinter::VisitArrayInitIndexExpr(ArrayInitIndexExpr *Node) {
2043void StmtPrinter::VisitParenListExpr(ParenListExpr* Node) {
2045 for (
unsigned i = 0, e = Node->
getNumExprs(); i != e; ++i) {
2052void StmtPrinter::VisitDesignatedInitExpr(DesignatedInitExpr *Node) {
2053 bool NeedsEquals =
true;
2054 for (
const DesignatedInitExpr::Designator &D : Node->
designators()) {
2055 if (D.isFieldDesignator()) {
2056 if (D.getDotLoc().isInvalid()) {
2057 if (
const IdentifierInfo *II = D.getFieldName()) {
2058 OS << II->getName() <<
":";
2059 NeedsEquals =
false;
2062 OS <<
"." << D.getFieldName()->getName();
2066 if (D.isArrayDesignator()) {
2084void StmtPrinter::VisitDesignatedInitUpdateExpr(
2085 DesignatedInitUpdateExpr *Node) {
2091 OS <<
"/*updater*/";
2096void StmtPrinter::VisitNoInitExpr(NoInitExpr *Node) {
2097 OS <<
"/*no init*/";
2100void StmtPrinter::VisitImplicitValueInitExpr(ImplicitValueInitExpr *Node) {
2102 OS <<
"/*implicit*/";
2106 OS <<
"/*implicit*/(";
2116void StmtPrinter::VisitVAArgExpr(VAArgExpr *Node) {
2117 OS <<
"__builtin_va_arg(";
2124void StmtPrinter::VisitPseudoObjectExpr(PseudoObjectExpr *Node) {
2128void StmtPrinter::VisitAtomicExpr(AtomicExpr *Node) {
2129 const char *Name =
nullptr;
2130 switch (Node->
getOp()) {
2131#define ATOMIC_BUILTIN(ID, TYPE, ATTRS) \
2132 case AtomicExpr::AO ## ID: \
2135#include "clang/Basic/Builtins.inc"
2140 PrintExpr(Node->
getPtr());
2145 if (Node->
getOp() == AtomicExpr::AO__atomic_exchange ||
2150 if (Node->
getOp() == AtomicExpr::AO__atomic_compare_exchange ||
2151 Node->
getOp() == AtomicExpr::AO__atomic_compare_exchange_n) {
2155 if (Node->
getOp() != AtomicExpr::AO__c11_atomic_init &&
2156 Node->
getOp() != AtomicExpr::AO__opencl_atomic_init) {
2168void StmtPrinter::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *Node) {
2170 if (Kind == OO_PlusPlus || Kind == OO_MinusMinus) {
2173 PrintExpr(Node->
getArg(0));
2175 PrintExpr(Node->
getArg(0));
2178 }
else if (Kind == OO_Arrow) {
2179 PrintExpr(Node->
getArg(0));
2180 }
else if (Kind == OO_Call || Kind == OO_Subscript) {
2181 PrintExpr(Node->
getArg(0));
2182 OS << (
Kind == OO_Call ?
'(' :
'[');
2183 for (
unsigned ArgIdx = 1; ArgIdx < Node->
getNumArgs(); ++ArgIdx) {
2187 PrintExpr(Node->
getArg(ArgIdx));
2189 OS << (
Kind == OO_Call ?
')' :
']');
2192 PrintExpr(Node->
getArg(0));
2194 PrintExpr(Node->
getArg(0));
2196 PrintExpr(Node->
getArg(1));
2198 llvm_unreachable(
"unknown overloaded operator");
2202void StmtPrinter::VisitCXXMemberCallExpr(CXXMemberCallExpr *Node) {
2205 if (isa_and_nonnull<CXXConversionDecl>(MD)) {
2212void StmtPrinter::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *Node) {
2217 PrintCallArgs(Node);
2221void StmtPrinter::VisitCXXRewrittenBinaryOperator(
2222 CXXRewrittenBinaryOperator *Node) {
2223 CXXRewrittenBinaryOperator::DecomposedForm Decomposed =
2225 PrintExpr(
const_cast<Expr*
>(Decomposed.
LHS));
2227 PrintExpr(
const_cast<Expr*
>(Decomposed.
RHS));
2230void StmtPrinter::VisitCXXNamedCastExpr(CXXNamedCastExpr *Node) {
2238void StmtPrinter::VisitCXXStaticCastExpr(CXXStaticCastExpr *Node) {
2239 VisitCXXNamedCastExpr(Node);
2242void StmtPrinter::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *Node) {
2243 VisitCXXNamedCastExpr(Node);
2246void StmtPrinter::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *Node) {
2247 VisitCXXNamedCastExpr(Node);
2250void StmtPrinter::VisitCXXConstCastExpr(CXXConstCastExpr *Node) {
2251 VisitCXXNamedCastExpr(Node);
2254void StmtPrinter::VisitBuiltinBitCastExpr(BuiltinBitCastExpr *Node) {
2255 OS <<
"__builtin_bit_cast(";
2262void StmtPrinter::VisitCXXAddrspaceCastExpr(CXXAddrspaceCastExpr *Node) {
2263 VisitCXXNamedCastExpr(Node);
2266void StmtPrinter::VisitCXXTypeidExpr(CXXTypeidExpr *Node) {
2276void StmtPrinter::VisitCXXUuidofExpr(CXXUuidofExpr *Node) {
2286void StmtPrinter::VisitMSPropertyRefExpr(MSPropertyRefExpr *Node) {
2296void StmtPrinter::VisitMSPropertySubscriptExpr(MSPropertySubscriptExpr *Node) {
2299 PrintExpr(Node->
getIdx());
2303void StmtPrinter::VisitUserDefinedLiteral(UserDefinedLiteral *Node) {
2310 const TemplateArgumentList *Args =
2315 const TemplateParameterList *TPL =
nullptr;
2316 if (!DRE->hadMultipleCandidates())
2317 if (
const auto *TD = dyn_cast<TemplateDecl>(DRE->getDecl()))
2318 TPL = TD->getTemplateParameters();
2320 printTemplateArgumentList(OS, Args->
asArray(), Policy, TPL);
2325 const TemplateArgument &Pack = Args->
get(0);
2327 char C = (char)P.getAsIntegral().getZExtValue();
2352void StmtPrinter::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *Node) {
2356void StmtPrinter::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *Node) {
2360void StmtPrinter::VisitCXXThisExpr(CXXThisExpr *Node) {
2364void StmtPrinter::VisitCXXThrowExpr(CXXThrowExpr *Node) {
2373void StmtPrinter::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *Node) {
2377void StmtPrinter::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *Node) {
2381void StmtPrinter::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *Node) {
2382 auto TargetType = Node->
getType();
2384 bool Bare =
Auto &&
Auto->isDeduced();
2389 TargetType.print(OS, Policy);
2401void StmtPrinter::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *Node) {
2405void StmtPrinter::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *Node) {
2413 for (CXXTemporaryObjectExpr::arg_iterator Arg = Node->
arg_begin(),
2415 Arg != ArgEnd; ++Arg) {
2416 if ((*Arg)->isDefaultArgument())
2430void StmtPrinter::VisitLambdaExpr(
LambdaExpr *Node) {
2432 bool NeedComma =
false;
2451 if (
C->capturesVLAType())
2458 switch (
C->getCaptureKind()) {
2470 OS <<
C->getCapturedVar()->getName();
2474 OS <<
C->getCapturedVar()->getName();
2478 llvm_unreachable(
"VLA type in explicit captures.");
2481 if (
C->isPackExpansion())
2488 llvm::StringRef
Pre;
2489 llvm::StringRef
Post;
2499 PrintExpr(D->getInit());
2515 for (
const auto *P :
Method->parameters()) {
2521 std::string ParamStr =
2522 (Policy.CleanUglifiedParameters && P->getIdentifier())
2523 ? P->getIdentifier()->deuglifiedName().str()
2524 : P->getNameAsString();
2525 P->getOriginalType().print(OS, Policy, ParamStr);
2527 if (
Method->isVariadic()) {
2537 auto *Proto =
Method->getType()->castAs<FunctionProtoType>();
2538 Proto->printExceptionSpecification(OS, Policy);
2545 Proto->getReturnType().print(OS, Policy);
2557void StmtPrinter::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *Node) {
2559 TSInfo->getType().print(OS, Policy);
2565void StmtPrinter::VisitCXXNewExpr(CXXNewExpr *E) {
2573 for (
unsigned i = 1; i < NumPlace; ++i) {
2585 llvm::raw_string_ostream s(TypeS);
2588 (*Size)->printPretty(s, Helper, Policy);
2596 if (InitStyle != CXXNewInitializationStyle::None) {
2597 bool Bare = InitStyle == CXXNewInitializationStyle::Parens &&
2607void StmtPrinter::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
2616void StmtPrinter::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
2626 OS << II->getName();
2631void StmtPrinter::VisitCXXConstructExpr(CXXConstructExpr *E) {
2635 for (
unsigned i = 0, e = E->
getNumArgs(); i != e; ++i) {
2649void StmtPrinter::VisitCXXInheritedCtorInitExpr(CXXInheritedCtorInitExpr *E) {
2651 OS <<
"<forwarded>";
2654void StmtPrinter::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E) {
2658void StmtPrinter::VisitExprWithCleanups(ExprWithCleanups *E) {
2663void StmtPrinter::VisitCXXUnresolvedConstructExpr(
2664 CXXUnresolvedConstructExpr *Node) {
2668 for (
auto Arg = Node->
arg_begin(), ArgEnd = Node->
arg_end(); Arg != ArgEnd;
2678void StmtPrinter::VisitCXXReflectExpr(CXXReflectExpr *S) {
2680 assert(
false &&
"not implemented yet");
2683void StmtPrinter::VisitDependentTemplateIdExpr(DependentTemplateIdExpr *Node) {
2689void StmtPrinter::VisitCXXDependentScopeMemberExpr(
2690 CXXDependentScopeMemberExpr *Node) {
2703void StmtPrinter::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *Node) {
2716void StmtPrinter::VisitTypeTraitExpr(TypeTraitExpr *E) {
2718 for (
unsigned I = 0, N = E->
getNumArgs(); I != N; ++I) {
2726void StmtPrinter::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
2732void StmtPrinter::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
2738void StmtPrinter::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
2744void StmtPrinter::VisitPackExpansionExpr(PackExpansionExpr *E) {
2749void StmtPrinter::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
2750 OS <<
"sizeof...(" << *E->
getPack() <<
")";
2753void StmtPrinter::VisitPackIndexingExpr(PackIndexingExpr *E) {
2760void StmtPrinter::VisitSubstNonTypeTemplateParmPackExpr(
2761 SubstNonTypeTemplateParmPackExpr *Node) {
2765void StmtPrinter::VisitSubstNonTypeTemplateParmExpr(
2766 SubstNonTypeTemplateParmExpr *Node) {
2770void StmtPrinter::VisitFunctionParmPackExpr(FunctionParmPackExpr *E) {
2774void StmtPrinter::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *Node){
2778void StmtPrinter::VisitCXXFoldExpr(CXXFoldExpr *E) {
2792void StmtPrinter::VisitCXXParenListInitExpr(CXXParenListInitExpr *Node) {
2794 [&](Expr *E) { PrintExpr(E); });
2797void StmtPrinter::VisitConceptSpecializationExpr(ConceptSpecializationExpr *E) {
2811 if (!LocalParameters.empty()) {
2813 for (ParmVarDecl *LocalParam : LocalParameters) {
2814 PrintRawDecl(LocalParam);
2815 if (LocalParam != LocalParameters.back())
2823 for (concepts::Requirement *Req : Requirements) {
2824 if (
auto *TypeReq = dyn_cast<concepts::TypeRequirement>(Req)) {
2825 if (TypeReq->isSubstitutionFailure())
2826 OS <<
"<<error-type>>";
2828 TypeReq->getType()->getType().print(OS, Policy);
2829 }
else if (
auto *ExprReq = dyn_cast<concepts::ExprRequirement>(Req)) {
2830 if (ExprReq->isCompound())
2832 if (ExprReq->isExprSubstitutionFailure())
2833 OS <<
"<<error-expression>>";
2835 PrintExpr(ExprReq->getExpr());
2836 if (ExprReq->isCompound()) {
2838 if (ExprReq->getNoexceptLoc().isValid())
2840 const auto &RetReq = ExprReq->getReturnTypeRequirement();
2841 if (!RetReq.isEmpty()) {
2843 if (RetReq.isSubstitutionFailure())
2844 OS <<
"<<error-type>>";
2845 else if (RetReq.isTypeConstraint())
2846 RetReq.getTypeConstraint()->print(OS, Policy);
2852 if (NestedReq->hasInvalidConstraint())
2853 OS <<
"<<error-expression>>";
2855 PrintExpr(NestedReq->getConstraintExpr());
2864void StmtPrinter::VisitCoroutineBodyStmt(CoroutineBodyStmt *S) {
2868void StmtPrinter::VisitCoreturnStmt(CoreturnStmt *S) {
2877void StmtPrinter::VisitCoawaitExpr(CoawaitExpr *S) {
2882void StmtPrinter::VisitDependentCoawaitExpr(DependentCoawaitExpr *S) {
2887void StmtPrinter::VisitCoyieldExpr(CoyieldExpr *S) {
2894void StmtPrinter::VisitObjCStringLiteral(ObjCStringLiteral *Node) {
2899void StmtPrinter::VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
2904void StmtPrinter::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
2906 ObjCArrayLiteral::child_range Ch = E->
children();
2907 for (
auto I = Ch.begin(), E = Ch.end(); I != E; ++I) {
2908 if (I != Ch.begin())
2915void StmtPrinter::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
2924 Visit(Element.
Value);
2931void StmtPrinter::VisitObjCEncodeExpr(ObjCEncodeExpr *Node) {
2937void StmtPrinter::VisitObjCSelectorExpr(ObjCSelectorExpr *Node) {
2943void StmtPrinter::VisitObjCProtocolExpr(ObjCProtocolExpr *Node) {
2947void StmtPrinter::VisitObjCMessageExpr(ObjCMessageExpr *Mess) {
2969 for (
unsigned i = 0, e = Mess->
getNumArgs(); i != e; ++i) {
2971 if (i > 0)
OS <<
' ';
2979 PrintExpr(Mess->
getArg(i));
2985void StmtPrinter::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *Node) {
2986 OS << (Node->
getValue() ?
"__objc_yes" :
"__objc_no");
2990StmtPrinter::VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
2995StmtPrinter::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
3002void StmtPrinter::VisitBlockExpr(BlockExpr *Node) {
3015 std::string ParamStr = (*AI)->getNameAsString();
3016 (*AI)->getType().print(OS, Policy, ParamStr);
3020 if (FT->isVariadic()) {
3029void StmtPrinter::VisitOpaqueValueExpr(OpaqueValueExpr *Node) {
3033void StmtPrinter::VisitRecoveryExpr(RecoveryExpr *Node) {
3034 OS <<
"<recovery-expr>(";
3035 const char *Sep =
"";
3044void StmtPrinter::VisitAsTypeExpr(AsTypeExpr *Node) {
3045 OS <<
"__builtin_astype(";
3052void StmtPrinter::VisitHLSLOutArgExpr(HLSLOutArgExpr *Node) {
3066 StringRef NL,
const ASTContext *Context)
const {
3067 StmtPrinter P(Out, Helper, Policy, Indentation, NL, Context);
3068 P.Visit(
const_cast<Stmt *
>(
this));
3073 unsigned Indentation, StringRef NL,
3075 StmtPrinter P(Out, Helper, Policy, Indentation, NL, Context);
3076 P.PrintControlledStmt(
const_cast<Stmt *
>(
this));
3082 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...
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()
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.
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'.