47 #include "llvm/ADT/ArrayRef.h" 48 #include "llvm/ADT/SmallString.h" 49 #include "llvm/ADT/SmallVector.h" 50 #include "llvm/ADT/StringRef.h" 51 #include "llvm/Support/Casting.h" 52 #include "llvm/Support/Compiler.h" 53 #include "llvm/Support/ErrorHandling.h" 54 #include "llvm/Support/Format.h" 55 #include "llvm/Support/raw_ostream.h" 59 using namespace clang;
67 class StmtPrinter :
public StmtVisitor<StmtPrinter> {
80 : OS(os), IndentLevel(Indentation), Helper(helper), Policy(Policy),
81 NL(NL), Context(Context) {}
83 void PrintStmt(
Stmt *S) {
87 void PrintStmt(
Stmt *S,
int SubIndent) {
88 IndentLevel += SubIndent;
89 if (S && isa<Expr>(S)) {
97 Indent() <<
"<<<NULL STATEMENT>>>" << NL;
99 IndentLevel -= SubIndent;
102 void PrintInitStmt(
Stmt *S,
unsigned PrefixWidth) {
104 IndentLevel += (PrefixWidth + 1) / 2;
105 if (
auto *DS = dyn_cast<DeclStmt>(S))
106 PrintRawDeclStmt(DS);
108 PrintExpr(cast<Expr>(S));
110 IndentLevel -= (PrefixWidth + 1) / 2;
113 void PrintControlledStmt(
Stmt *S) {
114 if (
auto *CS = dyn_cast<CompoundStmt>(S)) {
116 PrintRawCompoundStmt(CS);
125 void PrintRawDecl(
Decl *D);
126 void PrintRawDeclStmt(
const DeclStmt *S);
127 void PrintRawIfStmt(
IfStmt *If);
133 bool ForceNoStmt =
false);
135 void PrintExpr(
Expr *E) {
142 raw_ostream &
Indent(
int Delta = 0) {
143 for (
int i = 0, e = IndentLevel+Delta;
i < e; ++
i)
148 void Visit(
Stmt* S) {
154 void VisitStmt(
Stmt *
Node) LLVM_ATTRIBUTE_UNUSED {
155 Indent() <<
"<<unknown stmt type>>" << NL;
158 void VisitExpr(
Expr *
Node) LLVM_ATTRIBUTE_UNUSED {
159 OS <<
"<<unknown expr type>>";
164 #define ABSTRACT_STMT(CLASS) 165 #define STMT(CLASS, PARENT) \ 166 void Visit##CLASS(CLASS *Node); 167 #include "clang/AST/StmtNodes.inc" 180 for (
auto *I : Node->
body())
186 void StmtPrinter::PrintRawDecl(
Decl *D) {
187 D->
print(OS, Policy, IndentLevel);
190 void StmtPrinter::PrintRawDeclStmt(
const DeclStmt *S) {
199 void StmtPrinter::VisitDeclStmt(
DeclStmt *Node) {
201 PrintRawDeclStmt(Node);
205 void StmtPrinter::VisitCompoundStmt(
CompoundStmt *Node) {
207 PrintRawCompoundStmt(Node);
211 void StmtPrinter::VisitCaseStmt(
CaseStmt *Node) {
213 PrintExpr(Node->
getLHS());
216 PrintExpr(Node->
getRHS());
223 void StmtPrinter::VisitDefaultStmt(
DefaultStmt *Node) {
224 Indent(-1) <<
"default:" << NL;
228 void StmtPrinter::VisitLabelStmt(
LabelStmt *Node) {
241 void StmtPrinter::PrintRawIfStmt(
IfStmt *If) {
244 PrintInitStmt(If->
getInit(), 4);
246 PrintRawDeclStmt(DS);
251 if (
auto *CS = dyn_cast<CompoundStmt>(If->
getThen())) {
253 PrintRawCompoundStmt(CS);
254 OS << (If->
getElse() ?
" " : NL);
264 if (
auto *CS = dyn_cast<CompoundStmt>(Else)) {
266 PrintRawCompoundStmt(CS);
268 }
else if (
auto *ElseIf = dyn_cast<IfStmt>(Else)) {
270 PrintRawIfStmt(ElseIf);
278 void StmtPrinter::VisitIfStmt(
IfStmt *If) {
283 void StmtPrinter::VisitSwitchStmt(
SwitchStmt *Node) {
286 PrintInitStmt(Node->
getInit(), 8);
288 PrintRawDeclStmt(DS);
292 PrintControlledStmt(Node->
getBody());
295 void StmtPrinter::VisitWhileStmt(
WhileStmt *Node) {
298 PrintRawDeclStmt(DS);
305 void StmtPrinter::VisitDoStmt(
DoStmt *Node) {
307 if (
auto *CS = dyn_cast<CompoundStmt>(Node->
getBody())) {
308 PrintRawCompoundStmt(CS);
321 void StmtPrinter::VisitForStmt(
ForStmt *Node) {
324 PrintInitStmt(Node->
getInit(), 5);
326 OS << (Node->
getCond() ?
"; " :
";");
332 PrintExpr(Node->
getInc());
335 PrintControlledStmt(Node->
getBody());
340 if (
auto *DS = dyn_cast<DeclStmt>(Node->
getElement()))
341 PrintRawDeclStmt(DS);
347 PrintControlledStmt(Node->
getBody());
353 PrintInitStmt(Node->
getInit(), 5);
360 PrintControlledStmt(Node->
getBody());
366 OS <<
"__if_exists (";
368 OS <<
"__if_not_exists (";
372 Qualifier->print(OS, Policy);
379 void StmtPrinter::VisitGotoStmt(
GotoStmt *Node) {
391 void StmtPrinter::VisitContinueStmt(
ContinueStmt *Node) {
396 void StmtPrinter::VisitBreakStmt(
BreakStmt *Node) {
401 void StmtPrinter::VisitReturnStmt(
ReturnStmt *Node) {
411 void StmtPrinter::VisitGCCAsmStmt(
GCCAsmStmt *Node) {
490 void StmtPrinter::VisitMSAsmStmt(
MSAsmStmt *Node) {
500 void StmtPrinter::VisitCapturedStmt(
CapturedStmt *Node) {
506 if (
auto *TS = dyn_cast<CompoundStmt>(Node->
getTryBody())) {
507 PrintRawCompoundStmt(TS);
519 if (
auto *CS = dyn_cast<CompoundStmt>(catchStmt->
getCatchBody())) {
520 PrintRawCompoundStmt(CS);
525 if (
auto *FS = static_cast<ObjCAtFinallyStmt *>(Node->
getFinallyStmt())) {
527 PrintRawCompoundStmt(dyn_cast<CompoundStmt>(FS->getFinallyBody()));
536 Indent() <<
"@catch (...) { /* todo */ } " << NL;
548 void StmtPrinter::VisitObjCAvailabilityCheckExpr(
550 OS <<
"@available(...)";
554 Indent() <<
"@synchronized (";
562 Indent() <<
"@autoreleasepool";
563 PrintRawCompoundStmt(dyn_cast<CompoundStmt>(Node->
getSubStmt()));
567 void StmtPrinter::PrintRawCXXCatchStmt(
CXXCatchStmt *Node) {
570 PrintRawDecl(ExDecl);
577 void StmtPrinter::VisitCXXCatchStmt(
CXXCatchStmt *Node) {
579 PrintRawCXXCatchStmt(Node);
583 void StmtPrinter::VisitCXXTryStmt(
CXXTryStmt *Node) {
593 void StmtPrinter::VisitSEHTryStmt(
SEHTryStmt *Node) {
599 PrintRawSEHExceptHandler(E);
601 assert(F &&
"Must have a finally block...");
602 PrintRawSEHFinallyStmt(F);
609 PrintRawCompoundStmt(Node->
getBlock());
613 void StmtPrinter::PrintRawSEHExceptHandler(
SEHExceptStmt *Node) {
617 PrintRawCompoundStmt(Node->
getBlock());
623 PrintRawSEHExceptHandler(Node);
629 PrintRawSEHFinallyStmt(Node);
633 void StmtPrinter::VisitSEHLeaveStmt(
SEHLeaveStmt *Node) {
646 for (
auto *Clause : Clauses)
647 if (Clause && !Clause->isImplicit()) {
649 Printer.
Visit(Clause);
657 Indent() <<
"#pragma omp parallel";
658 PrintOMPExecutableDirective(Node);
662 Indent() <<
"#pragma omp simd";
663 PrintOMPExecutableDirective(Node);
667 Indent() <<
"#pragma omp for";
668 PrintOMPExecutableDirective(Node);
672 Indent() <<
"#pragma omp for simd";
673 PrintOMPExecutableDirective(Node);
677 Indent() <<
"#pragma omp sections";
678 PrintOMPExecutableDirective(Node);
682 Indent() <<
"#pragma omp section";
683 PrintOMPExecutableDirective(Node);
687 Indent() <<
"#pragma omp single";
688 PrintOMPExecutableDirective(Node);
692 Indent() <<
"#pragma omp master";
693 PrintOMPExecutableDirective(Node);
697 Indent() <<
"#pragma omp critical";
703 PrintOMPExecutableDirective(Node);
707 Indent() <<
"#pragma omp parallel for";
708 PrintOMPExecutableDirective(Node);
711 void StmtPrinter::VisitOMPParallelForSimdDirective(
713 Indent() <<
"#pragma omp parallel for simd";
714 PrintOMPExecutableDirective(Node);
717 void StmtPrinter::VisitOMPParallelSectionsDirective(
719 Indent() <<
"#pragma omp parallel sections";
720 PrintOMPExecutableDirective(Node);
724 Indent() <<
"#pragma omp task";
725 PrintOMPExecutableDirective(Node);
729 Indent() <<
"#pragma omp taskyield";
730 PrintOMPExecutableDirective(Node);
734 Indent() <<
"#pragma omp barrier";
735 PrintOMPExecutableDirective(Node);
739 Indent() <<
"#pragma omp taskwait";
740 PrintOMPExecutableDirective(Node);
744 Indent() <<
"#pragma omp taskgroup";
745 PrintOMPExecutableDirective(Node);
749 Indent() <<
"#pragma omp flush";
750 PrintOMPExecutableDirective(Node);
754 Indent() <<
"#pragma omp ordered";
759 Indent() <<
"#pragma omp atomic";
760 PrintOMPExecutableDirective(Node);
764 Indent() <<
"#pragma omp target";
765 PrintOMPExecutableDirective(Node);
769 Indent() <<
"#pragma omp target data";
770 PrintOMPExecutableDirective(Node);
773 void StmtPrinter::VisitOMPTargetEnterDataDirective(
775 Indent() <<
"#pragma omp target enter data";
776 PrintOMPExecutableDirective(Node,
true);
779 void StmtPrinter::VisitOMPTargetExitDataDirective(
781 Indent() <<
"#pragma omp target exit data";
782 PrintOMPExecutableDirective(Node,
true);
785 void StmtPrinter::VisitOMPTargetParallelDirective(
787 Indent() <<
"#pragma omp target parallel";
788 PrintOMPExecutableDirective(Node);
791 void StmtPrinter::VisitOMPTargetParallelForDirective(
793 Indent() <<
"#pragma omp target parallel for";
794 PrintOMPExecutableDirective(Node);
798 Indent() <<
"#pragma omp teams";
799 PrintOMPExecutableDirective(Node);
802 void StmtPrinter::VisitOMPCancellationPointDirective(
804 Indent() <<
"#pragma omp cancellation point " 806 PrintOMPExecutableDirective(Node);
810 Indent() <<
"#pragma omp cancel " 812 PrintOMPExecutableDirective(Node);
816 Indent() <<
"#pragma omp taskloop";
817 PrintOMPExecutableDirective(Node);
820 void StmtPrinter::VisitOMPTaskLoopSimdDirective(
822 Indent() <<
"#pragma omp taskloop simd";
823 PrintOMPExecutableDirective(Node);
827 Indent() <<
"#pragma omp distribute";
828 PrintOMPExecutableDirective(Node);
831 void StmtPrinter::VisitOMPTargetUpdateDirective(
833 Indent() <<
"#pragma omp target update";
834 PrintOMPExecutableDirective(Node,
true);
837 void StmtPrinter::VisitOMPDistributeParallelForDirective(
839 Indent() <<
"#pragma omp distribute parallel for";
840 PrintOMPExecutableDirective(Node);
843 void StmtPrinter::VisitOMPDistributeParallelForSimdDirective(
845 Indent() <<
"#pragma omp distribute parallel for simd";
846 PrintOMPExecutableDirective(Node);
849 void StmtPrinter::VisitOMPDistributeSimdDirective(
851 Indent() <<
"#pragma omp distribute simd";
852 PrintOMPExecutableDirective(Node);
855 void StmtPrinter::VisitOMPTargetParallelForSimdDirective(
857 Indent() <<
"#pragma omp target parallel for simd";
858 PrintOMPExecutableDirective(Node);
862 Indent() <<
"#pragma omp target simd";
863 PrintOMPExecutableDirective(Node);
866 void StmtPrinter::VisitOMPTeamsDistributeDirective(
868 Indent() <<
"#pragma omp teams distribute";
869 PrintOMPExecutableDirective(Node);
872 void StmtPrinter::VisitOMPTeamsDistributeSimdDirective(
874 Indent() <<
"#pragma omp teams distribute simd";
875 PrintOMPExecutableDirective(Node);
878 void StmtPrinter::VisitOMPTeamsDistributeParallelForSimdDirective(
880 Indent() <<
"#pragma omp teams distribute parallel for simd";
881 PrintOMPExecutableDirective(Node);
884 void StmtPrinter::VisitOMPTeamsDistributeParallelForDirective(
886 Indent() <<
"#pragma omp teams distribute parallel for";
887 PrintOMPExecutableDirective(Node);
891 Indent() <<
"#pragma omp target teams";
892 PrintOMPExecutableDirective(Node);
895 void StmtPrinter::VisitOMPTargetTeamsDistributeDirective(
897 Indent() <<
"#pragma omp target teams distribute";
898 PrintOMPExecutableDirective(Node);
901 void StmtPrinter::VisitOMPTargetTeamsDistributeParallelForDirective(
903 Indent() <<
"#pragma omp target teams distribute parallel for";
904 PrintOMPExecutableDirective(Node);
907 void StmtPrinter::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
909 Indent() <<
"#pragma omp target teams distribute parallel for simd";
910 PrintOMPExecutableDirective(Node);
913 void StmtPrinter::VisitOMPTargetTeamsDistributeSimdDirective(
915 Indent() <<
"#pragma omp target teams distribute simd";
916 PrintOMPExecutableDirective(Node);
927 void StmtPrinter::VisitConstantExpr(
ConstantExpr *Node) {
931 void StmtPrinter::VisitDeclRefExpr(
DeclRefExpr *Node) {
932 if (
const auto *OCED = dyn_cast<OMPCapturedExprDecl>(Node->
getDecl())) {
933 OCED->getInit()->IgnoreImpCasts()->printPretty(OS,
nullptr, Policy);
937 Qualifier->print(OS, Policy);
945 void StmtPrinter::VisitDependentScopeDeclRefExpr(
948 Qualifier->print(OS, Policy);
967 if (
const auto *DRE = dyn_cast<DeclRefExpr>(E)) {
968 if (
const auto *PD = dyn_cast<ImplicitParamDecl>(DRE->getDecl())) {
970 DRE->getBeginLoc().isInvalid())
982 OS << (Node->
isArrow() ?
"->" :
".");
1000 Getter->getSelector().print(OS);
1070 if (value < 256 &&
isPrintable((
unsigned char)value))
1071 OS <<
"'" << (
char)value <<
"'";
1072 else if (value < 256)
1073 OS <<
"'\\x" << llvm::format(
"%02x", value) <<
"'";
1074 else if (value <= 0xFFFF)
1075 OS <<
"'\\u" << llvm::format(
"%04x", value) <<
"'";
1077 OS <<
"'\\U" << llvm::format(
"%08x", value) <<
"'";
1087 bool Invalid =
false;
1102 OS << Node->
getValue().toString(10, isSigned);
1106 default: llvm_unreachable(
"Unexpected type for integer literal!");
1107 case BuiltinType::Char_S:
1108 case BuiltinType::Char_U: OS <<
"i8";
break;
1109 case BuiltinType::UChar: OS <<
"Ui8";
break;
1110 case BuiltinType::Short: OS <<
"i16";
break;
1111 case BuiltinType::UShort: OS <<
"Ui16";
break;
1112 case BuiltinType::Int:
break;
1113 case BuiltinType::UInt: OS <<
'U';
break;
1114 case BuiltinType::Long: OS <<
'L';
break;
1115 case BuiltinType::ULong: OS <<
"UL";
break;
1116 case BuiltinType::LongLong: OS <<
"LL";
break;
1117 case BuiltinType::ULongLong: OS <<
"ULL";
break;
1127 default: llvm_unreachable(
"Unexpected type for fixed point literal!");
1128 case BuiltinType::ShortFract: OS <<
"hr";
break;
1129 case BuiltinType::ShortAccum: OS <<
"hk";
break;
1130 case BuiltinType::UShortFract: OS <<
"uhr";
break;
1131 case BuiltinType::UShortAccum: OS <<
"uhk";
break;
1132 case BuiltinType::Fract: OS <<
"r";
break;
1133 case BuiltinType::Accum: OS <<
"k";
break;
1134 case BuiltinType::UFract: OS <<
"ur";
break;
1135 case BuiltinType::UAccum: OS <<
"uk";
break;
1136 case BuiltinType::LongFract: OS <<
"lr";
break;
1137 case BuiltinType::LongAccum: OS <<
"lk";
break;
1138 case BuiltinType::ULongFract: OS <<
"ulr";
break;
1139 case BuiltinType::ULongAccum: OS <<
"ulk";
break;
1148 if (Str.find_first_not_of(
"-0123456789") == StringRef::npos)
1156 default: llvm_unreachable(
"Unexpected type for float literal!");
1157 case BuiltinType::Half:
break;
1158 case BuiltinType::Double:
break;
1159 case BuiltinType::Float16: OS <<
"F16";
break;
1160 case BuiltinType::Float: OS <<
'F';
break;
1161 case BuiltinType::LongDouble: OS <<
'L';
break;
1162 case BuiltinType::Float128: OS <<
'Q';
break;
1181 void StmtPrinter::VisitParenExpr(
ParenExpr *Node) {
1213 void StmtPrinter::VisitOffsetOfExpr(
OffsetOfExpr *Node) {
1214 OS <<
"__builtin_offsetof(";
1217 bool PrintedSomething =
false;
1225 PrintedSomething =
true;
1238 if (PrintedSomething)
1241 PrintedSomething =
true;
1267 OS <<
"__builtin_omp_required_simd_align";
1289 T.
print(OS, Policy);
1291 PrintExpr(Assoc.getAssociationExpr());
1297 PrintExpr(Node->
getLHS());
1299 PrintExpr(Node->
getRHS());
1316 void StmtPrinter::PrintCallArgs(
CallExpr *Call) {
1318 if (isa<CXXDefaultArgExpr>(Call->
getArg(
i))) {
1328 void StmtPrinter::VisitCallExpr(
CallExpr *Call) {
1331 PrintCallArgs(Call);
1336 if (
const auto *TE = dyn_cast<CXXThisExpr>(E))
1337 return TE->isImplicit();
1341 void StmtPrinter::VisitMemberExpr(
MemberExpr *Node) {
1347 ParentMember ? dyn_cast<
FieldDecl>(ParentMember->getMemberDecl())
1350 if (!ParentDecl || !ParentDecl->isAnonymousStructOrUnion())
1351 OS << (Node->
isArrow() ?
"->" :
".");
1355 if (FD->isAnonymousStructOrUnion())
1359 Qualifier->
print(OS, Policy);
1367 void StmtPrinter::VisitObjCIsaExpr(
ObjCIsaExpr *Node) {
1369 OS << (Node->
isArrow() ?
"->isa" :
".isa");
1398 PrintExpr(Node->
getLHS());
1400 PrintExpr(Node->
getRHS());
1404 PrintExpr(Node->
getLHS());
1406 PrintExpr(Node->
getRHS());
1412 PrintExpr(Node->
getLHS());
1414 PrintExpr(Node->
getRHS());
1430 void StmtPrinter::VisitStmtExpr(
StmtExpr *E) {
1436 void StmtPrinter::VisitChooseExpr(
ChooseExpr *Node) {
1437 OS <<
"__builtin_choose_expr(";
1440 PrintExpr(Node->
getLHS());
1442 PrintExpr(Node->
getRHS());
1446 void StmtPrinter::VisitGNUNullExpr(
GNUNullExpr *) {
1451 OS <<
"__builtin_shufflevector(";
1460 OS <<
"__builtin_convertvector(";
1467 void StmtPrinter::VisitInitListExpr(
InitListExpr* Node) {
1506 bool NeedsEquals =
true;
1508 if (D.isFieldDesignator()) {
1509 if (D.getDotLoc().isInvalid()) {
1511 OS << II->getName() <<
":";
1512 NeedsEquals =
false;
1515 OS <<
"." << D.getFieldName()->getName();
1519 if (D.isArrayDesignator()) {
1537 void StmtPrinter::VisitDesignatedInitUpdateExpr(
1544 OS <<
"/*updater*/";
1549 void StmtPrinter::VisitNoInitExpr(
NoInitExpr *Node) {
1550 OS <<
"/*no init*/";
1555 OS <<
"/*implicit*/";
1559 OS <<
"/*implicit*/(";
1569 void StmtPrinter::VisitVAArgExpr(
VAArgExpr *Node) {
1570 OS <<
"__builtin_va_arg(";
1581 void StmtPrinter::VisitAtomicExpr(
AtomicExpr *Node) {
1582 const char *Name =
nullptr;
1583 switch (Node->
getOp()) {
1584 #define BUILTIN(ID, TYPE, ATTRS) 1585 #define ATOMIC_BUILTIN(ID, TYPE, ATTRS) \ 1586 case AtomicExpr::AO ## ID: \ 1589 #include "clang/Basic/Builtins.def" 1594 PrintExpr(Node->
getPtr());
1595 if (Node->
getOp() != AtomicExpr::AO__c11_atomic_load &&
1596 Node->
getOp() != AtomicExpr::AO__atomic_load_n &&
1597 Node->
getOp() != AtomicExpr::AO__opencl_atomic_load) {
1601 if (Node->
getOp() == AtomicExpr::AO__atomic_exchange ||
1606 if (Node->
getOp() == AtomicExpr::AO__atomic_compare_exchange ||
1607 Node->
getOp() == AtomicExpr::AO__atomic_compare_exchange_n) {
1611 if (Node->
getOp() != AtomicExpr::AO__c11_atomic_init &&
1612 Node->
getOp() != AtomicExpr::AO__opencl_atomic_init) {
1626 if (Kind == OO_PlusPlus || Kind == OO_MinusMinus) {
1629 PrintExpr(Node->
getArg(0));
1631 PrintExpr(Node->
getArg(0));
1634 }
else if (Kind == OO_Arrow) {
1635 PrintExpr(Node->
getArg(0));
1636 }
else if (Kind == OO_Call) {
1637 PrintExpr(Node->
getArg(0));
1639 for (
unsigned ArgIdx = 1; ArgIdx < Node->
getNumArgs(); ++ArgIdx) {
1642 if (!isa<CXXDefaultArgExpr>(Node->
getArg(ArgIdx)))
1643 PrintExpr(Node->
getArg(ArgIdx));
1646 }
else if (Kind == OO_Subscript) {
1647 PrintExpr(Node->
getArg(0));
1649 PrintExpr(Node->
getArg(1));
1653 PrintExpr(Node->
getArg(0));
1655 PrintExpr(Node->
getArg(0));
1657 PrintExpr(Node->
getArg(1));
1659 llvm_unreachable(
"unknown overloaded operator");
1666 if (MD && isa<CXXConversionDecl>(MD)) {
1670 VisitCallExpr(cast<CallExpr>(Node));
1678 PrintCallArgs(Node);
1691 VisitCXXNamedCastExpr(Node);
1695 VisitCXXNamedCastExpr(Node);
1699 VisitCXXNamedCastExpr(Node);
1703 VisitCXXNamedCastExpr(Node);
1707 OS <<
"__builtin_bit_cast(";
1742 Qualifier->print(OS, Policy);
1749 PrintExpr(Node->
getIdx());
1761 cast<FunctionDecl>(DRE->getDecl())->getTemplateSpecializationArgs();
1764 if (Args->size() != 1) {
1773 char C = (char)
P.getAsIntegral().getZExtValue();
1781 OS << Int->getValue().toString(10,
false);
1799 OS << (Node->
getValue() ?
"true" :
"false");
1806 void StmtPrinter::VisitCXXThisExpr(
CXXThisExpr *Node) {
1810 void StmtPrinter::VisitCXXThrowExpr(
CXXThrowExpr *Node) {
1852 Arg != ArgEnd; ++Arg) {
1853 if ((*Arg)->isDefaultArgument())
1867 void StmtPrinter::VisitLambdaExpr(
LambdaExpr *Node) {
1869 bool NeedComma =
false;
1888 if (
C->capturesVLAType())
1895 switch (
C->getCaptureKind()) {
1907 OS <<
C->getCapturedVar()->getName();
1911 OS <<
C->getCapturedVar()->getName();
1915 llvm_unreachable(
"VLA type in explicit captures.");
1918 if (
C->isPackExpansion())
1922 PrintExpr(
C->getCapturedVar()->getInit());
1942 std::string ParamStr =
P->getNameAsString();
1943 P->getOriginalType().print(OS, Policy, ParamStr);
1963 Proto->getReturnType().print(OS, Policy);
1972 PrintRawCompoundStmt(Node->
getBody());
1977 TSInfo->getType().print(OS, Policy);
1983 void StmtPrinter::VisitCXXNewExpr(
CXXNewExpr *E) {
1991 for (
unsigned i = 1;
i < NumPlace; ++
i) {
2003 llvm::raw_string_ostream s(TypeS);
2006 (*Size)->printPretty(s, Helper, Policy);
2043 OS << II->getName();
2053 if (isa<CXXDefaultArgExpr>(E->
getArg(
i))) {
2068 OS <<
"<forwarded>";
2081 StmtPrinter::VisitCXXUnresolvedConstructExpr(
2087 Arg != ArgEnd; ++Arg) {
2095 void StmtPrinter::VisitCXXDependentScopeMemberExpr(
2099 OS << (Node->
isArrow() ?
"->" :
".");
2102 Qualifier->print(OS, Policy);
2113 OS << (Node->
isArrow() ?
"->" :
".");
2116 Qualifier->print(OS, Policy);
2126 #define TYPE_TRAIT_1(Spelling, Name, Key) \ 2127 case clang::UTT_##Name: return #Spelling; 2128 #define TYPE_TRAIT_2(Spelling, Name, Key) \ 2129 case clang::BTT_##Name: return #Spelling; 2130 #define TYPE_TRAIT_N(Spelling, Name, Key) \ 2131 case clang::TT_##Name: return #Spelling; 2132 #include "clang/Basic/TokenKinds.def" 2134 llvm_unreachable(
"Type trait not covered by switch");
2142 llvm_unreachable(
"Array type trait not covered by switch");
2150 llvm_unreachable(
"Expression type trait not covered by switch");
2155 for (
unsigned I = 0, N = E->
getNumArgs(); I != N; ++I) {
2187 OS <<
"sizeof...(" << *E->
getPack() <<
")";
2190 void StmtPrinter::VisitSubstNonTypeTemplateParmPackExpr(
2195 void StmtPrinter::VisitSubstNonTypeTemplateParmExpr(
2208 void StmtPrinter::VisitCXXFoldExpr(
CXXFoldExpr *E) {
2237 void StmtPrinter::VisitCoawaitExpr(
CoawaitExpr *S) {
2247 void StmtPrinter::VisitCoyieldExpr(
CoyieldExpr *S) {
2267 for (
auto I = Ch.begin(), E = Ch.end(); I != E; ++I) {
2268 if (I != Ch.begin())
2284 Visit(Element.
Value);
2304 OS <<
"@protocol(" << *Node->
getProtocol() <<
')';
2331 if (
i > 0) OS <<
' ';
2346 OS << (Node->
getValue() ?
"__objc_yes" :
"__objc_no");
2362 void StmtPrinter::VisitBlockExpr(
BlockExpr *Node) {
2368 if (isa<FunctionNoProtoType>(AFT)) {
2370 }
else if (!BD->
param_empty() || cast<FunctionProtoType>(AFT)->isVariadic()) {
2375 std::string ParamStr = (*AI)->getNameAsString();
2376 (*AI)->getType().print(OS, Policy, ParamStr);
2379 const auto *FT = cast<FunctionProtoType>(AFT);
2380 if (FT->isVariadic()) {
2393 void StmtPrinter::VisitTypoExpr(
TypoExpr *Node) {
2395 llvm_unreachable(
"Cannot print TypoExpr nodes");
2398 void StmtPrinter::VisitAsTypeExpr(
AsTypeExpr *Node) {
2399 OS <<
"__builtin_astype(";
2416 StringRef NL,
const ASTContext *Context)
const {
2417 StmtPrinter
P(Out, Helper, Policy, Indentation, NL, Context);
2418 P.Visit(const_cast<Stmt *>(
this));
2424 llvm::raw_string_ostream TempOut(Buf);
2426 printPretty(TempOut, Helper, Policy);
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
const Expr * getSubExpr() const
ObjCIndirectCopyRestoreExpr - Represents the passing of a function argument by indirect copy-restore ...
A call to an overloaded operator written using operator syntax.
The receiver is the instance of the superclass object.
ExprIterator arg_iterator
Represents a single C99 designator.
Raw form: operator "" X (const char *)
Defines the clang::ASTContext interface.
const BlockDecl * getBlockDecl() const
This represents '#pragma omp distribute simd' composite directive.
This represents '#pragma omp master' directive.
operator "" X (long double)
TypeSourceInfo * getTypeOperandSourceInfo() const
Retrieve source information for the type operand.
The null pointer literal (C++11 [lex.nullptr])
capture_iterator explicit_capture_end() const
Retrieve an iterator pointing past the end of the sequence of explicit lambda captures.
This represents '#pragma omp task' directive.
This represents a GCC inline-assembly statement extension.
Represents a 'co_await' expression while the type of the promise is dependent.
Expr * getArrayIndex(const Designator &D) const
The receiver is an object instance.
bool hasExplicitTemplateArgs() const
Determines whether this expression had explicit template arguments.
unsigned getNumInputs() const
Expr * getSyntacticForm()
Return the syntactic form of this expression, i.e.
bool hasTemplateKeyword() const
Determines whether the name was preceded by the template keyword.
bool hasTemplateKeyword() const
Determines whether the member name was preceded by the template keyword.
ObjCDictionaryElement getKeyValueElement(unsigned Index) const
const FunctionProtoType * getFunctionType() const
getFunctionType - Return the underlying function type for this block.
CompoundStmt * getBlock() const
Smart pointer class that efficiently represents Objective-C method names.
A (possibly-)qualified type.
ArrayRef< TemplateArgumentLoc > template_arguments() const
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
ArrayRef< OMPClause * > clauses()
unsigned SuppressInitializers
Suppress printing of variable initializers.
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
Selector getSelector() const
Defines enumerations for the type traits support.
const Expr * getSubExpr() const
Expr * getExpr(unsigned Index)
getExpr - Return the Expr at the specified index.
unsigned getNumSubExprs() const
getNumSubExprs - Return the size of the SubExprs array.
bool isSuperReceiver() const
A type trait used in the implementation of various C++11 and Library TR1 trait templates.
VarDecl * getParameterPack() const
Get the parameter pack which this expression refers to.
CompoundStmt * getSubStmt()
const Expr * getInit(unsigned Init) const
Expr * getControllingExpr()
Return the controlling expression of this generic selection expression.
bool hasExplicitResultType() const
Whether this lambda had its result type explicitly specified.
ObjCProtocolDecl * getProtocol() const
Represents a 'co_return' statement in the C++ Coroutines TS.
Stmt - This represents one statement.
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
const ObjCAtFinallyStmt * getFinallyStmt() const
Retrieve the @finally statement, if any.
FunctionType - C99 6.7.5.3 - Function Declarators.
CXXCatchStmt * getHandler(unsigned i)
IfStmt - This represents an if/then/else.
C Language Family Type Representation.
unsigned getNumOutputs() const
static CharSourceRange getTokenRange(SourceRange R)
This represents '#pragma omp for simd' directive.
bool isRecordType() const
const StringLiteral * getAsmString() const
Decl - This represents one declaration (or definition), e.g.
This represents '#pragma omp teams distribute parallel for' composite directive.
Expr * getImplicitObjectArgument() const
Retrieve the implicit object argument for the member call.
Stmt * getHandlerBlock() const
llvm::APFloat getValue() const
ObjCMethodDecl * getImplicitPropertySetter() const
Represents the index of the current element of an array being initialized by an ArrayInitLoopExpr.
param_iterator param_end()
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
const Expr * getSubExpr() const
DeclarationNameInfo getNameInfo() const
Retrieve the name of the entity we're testing for, along with location information.
Defines the C++ template declaration subclasses.
CapturedStmt * getInnermostCapturedStmt()
Get innermost captured statement for the construct.
Represents an attribute applied to a statement.
ParenExpr - This represents a parethesized expression, e.g.
static bool isImplicitThis(const Expr *E)
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies this name, if any.
Expr * getLowerBound()
Get lower bound of array section.
This represents '#pragma omp target teams distribute' combined directive.
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies this declaration.
Represents Objective-C's @throw statement.
bool hasExplicitTemplateArgs() const
Determines whether this declaration reference was followed by an explicit template argument list...
llvm::iterator_range< child_iterator > child_range
Represents a call to a C++ constructor.
ObjCSubscriptRefExpr - used for array and dictionary subscripting.
TypeSourceInfo * getTypeInfoAsWritten() const
getTypeInfoAsWritten - Returns the type source info for the type that this expression is casting to...
An Embarcadero array type trait, as used in the implementation of __array_rank and __array_extent...
A container of type source information.
NestedNameSpecifier * getQualifier() const
If the member name was qualified, retrieves the nested-name-specifier that precedes the member name...
static void printGroup(Decl **Begin, unsigned NumDecls, raw_ostream &Out, const PrintingPolicy &Policy, unsigned Indentation=0)
This represents '#pragma omp parallel for' directive.
MS property subscript expression.
IdentKind getIdentKind() const
This represents '#pragma omp target teams distribute parallel for' combined directive.
Describes the capture of a variable or of this, or of a C++1y init-capture.
Represents a prvalue temporary that is written into memory so that a reference can bind to it...
MutableArrayRef< ParmVarDecl * >::iterator param_iterator
void printExceptionSpecification(raw_ostream &OS, const PrintingPolicy &Policy) const
const Expr * getSubExpr() const
Expr * getIndexExpr(unsigned Idx)
This represents '#pragma omp target exit data' directive.
ObjCIsaExpr - Represent X->isa and X.isa when X is an ObjC 'id' type.
CompoundLiteralExpr - [C99 6.5.2.5].
const T * getAs() const
Member-template getAs<specific type>'.
unsigned getNumArgs() const
Determine the number of arguments to this type trait.
ObjCInterfaceDecl * getClassReceiver() const
Implicit construction of a std::initializer_list<T> object from an array temporary within list-initia...
const char * getName() const
unsigned getNumPlacementArgs() const
Describes how types, statements, expressions, and declarations should be printed. ...
Defines the Objective-C statement AST node classes.
A C++ throw-expression (C++ [except.throw]).
Expr * getExprOperand() const
Represents an expression – generally a full-expression – that introduces cleanups to be run at the ...
TypeSourceInfo * getArg(unsigned I) const
Retrieve the Ith argument.
Defines the clang::Expr interface and subclasses for C++ expressions.
StringRef getInputName(unsigned i) const
unsigned TerseOutput
Provide a 'terse' output.
CXXRecordDecl * getLambdaClass() const
Retrieve the class that corresponds to the lambda.
ObjCPropertyDecl * getExplicitProperty() const
A C++ static_cast expression (C++ [expr.static.cast]).
Expr * getExprOperand() const
const Stmt * getSubStmt() const
LabelStmt - Represents a label, which has a substatement.
Represents a C99 designated initializer expression.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
One of these records is kept for each identifier that is lexed.
Expr * GetTemporaryExpr() const
Retrieve the temporary-generating subexpression whose value will be materialized into a glvalue...
Represents a function call to one of __builtin_LINE(), __builtin_COLUMN(), __builtin_FUNCTION(), or __builtin_FILE().
An element in an Objective-C dictionary literal.
This represents '#pragma omp parallel' directive.
ShuffleVectorExpr - clang-specific builtin-in function __builtin_shufflevector.
void print(raw_ostream &Out, unsigned Indentation=0, bool PrintInstantiation=false) const
DeclStmt * getConditionVariableDeclStmt()
If this SwitchStmt has a condition variable, return the faux DeclStmt associated with the creation of...
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Expr * getInit() const
Retrieve the initializer value.
Used for GCC's __alignof.
void printJson(raw_ostream &Out, PrinterHelper *Helper, const PrintingPolicy &Policy, bool AddQuotes) const
Pretty-prints in JSON format.
Represents a member of a struct/union/class.
Expr * getBase()
Retrieve the base object of this member expressions, e.g., the x in x.m.
Represents a place-holder for an object not to be initialized by anything.
const DeclarationNameInfo & getNameInfo() const
Gets the full name info.
StringLiteral * getString()
RetTy Visit(PTR(OMPClause) S)
CompoundStmt * getBody() const
Retrieve the body of the lambda.
unsigned getArrayExprIndex() const
For an array element node, returns the index into the array of expressions.
bool hasExplicitTemplateArgs() const
Determines whether the member name was followed by an explicit template argument list.
GNUNullExpr - Implements the GNU __null extension, which is a name for a null pointer constant that h...
QualType getDestroyedType() const
Retrieve the type being destroyed.
This represents '#pragma omp target simd' directive.
Expr * getSourceExpr() const
The source expression of an opaque value expression is the expression which originally generated the ...
Represents a C++ member access expression for which lookup produced a set of overloaded functions...
Defines some OpenMP-specific enums and functions.
ExtVectorElementExpr - This represents access to specific elements of a vector, and may occur on the ...
This represents '#pragma omp barrier' directive.
ObjCArrayLiteral - used for objective-c array containers; as in: @["Hello", NSApp, [NSNumber numberWithInt:42]];.
Represents a reference to a non-type template parameter pack that has been substituted with a non-tem...
This represents '#pragma omp critical' directive.
LambdaCaptureDefault getCaptureDefault() const
Determine the default capture kind for this lambda.
OpenMPDirectiveKind getCancelRegion() const
Get cancellation region for the current cancellation point.
ArrayRef< TemplateArgumentLoc > template_arguments() const
bool hasExplicitTemplateArgs() const
Determines whether this lookup had explicit template arguments.
Selector getSelector() const
ArrayRef< ParmVarDecl * > parameters() const
bool isUnarySelector() const
Represents Objective-C's @catch statement.
StringRef getOpcodeStr() const
IndirectGotoStmt - This represents an indirect goto.
Describes an C or C++ initializer list.
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
This represents '#pragma omp distribute parallel for' composite directive.
Stmt * getBody() const override
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
Expr * getKeyExpr() const
This represents '#pragma omp teams distribute parallel for simd' composite directive.
Optional< Expr * > getArraySize()
std::string JsonFormat(StringRef RawSR, bool AddQuotes)
ForStmt - This represents a 'for (init;cond;inc)' stmt.
Expr * getBaseExpr() const
Expr * getOperand() const
const Expr * getThrowExpr() const
< Capturing the *this object by copy
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
void print(raw_ostream &OS, const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) const
Expr * getInitializer()
The initializer of this new-expression.
A builtin binary operation expression such as "x + y" or "x <= y".
Expr * getOutputExpr(unsigned i)
ArrayRef< TemplateArgumentLoc > template_arguments() const
bool isClassReceiver() const
const StringLiteral * getInputConstraintLiteral(unsigned i) const
static bool isPostfix(Opcode Op)
isPostfix - Return true if this is a postfix operation, like x++.
CXXForRangeStmt - This represents C++0x [stmt.ranged]'s ranged for statement, represented as 'for (ra...
This represents '#pragma omp cancellation point' directive.
ObjCStringLiteral, used for Objective-C string literals i.e.
const CallExpr * getConfig() const
New-expression has a C++98 paren-delimited initializer.
CaseStmt - Represent a case statement.
TypoExpr - Internal placeholder for expressions where typo correction still needs to be performed and...
This represents '#pragma omp teams' directive.
NestedNameSpecifier * getQualifier() const
Fetches the nested-name qualifier, if one was given.
Helper class for OffsetOfExpr.
Expr * getOperand() const
This represents '#pragma omp teams distribute simd' combined directive.
AssociationTy< false > Association
Represents binding an expression to a temporary.
StringLiteral * getClobberStringLiteral(unsigned i)
StringRef getOutputName(unsigned i) const
ArrayTypeTrait
Names for the array type traits.
Expr * Key
The key for the dictionary element.
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
Represents a C++ member access expression where the actual member referenced could not be resolved be...
bool isInitCapture(const LambdaCapture *Capture) const
Determine whether one of this lambda's captures is an init-capture.
void print(raw_ostream &OS, const PrintingPolicy &Policy, bool ResolveTemplateArguments=false) const
Print this nested name specifier to the given output stream.
TypeSourceInfo * getTypeSourceInfo() const
A default argument (C++ [dcl.fct.default]).
bool isTypeOperand() const
const IdentifierInfo * getUDSuffix() const
Returns the ud-suffix specified for this literal.
Expr * IgnoreImpCasts() LLVM_READONLY
Skip past any implicit casts which might surround this expression until reaching a fixed point...
Represents the this expression in C++.
TypeTrait
Names for traits that operate specifically on types.
const ObjCAtCatchStmt * getCatchStmt(unsigned I) const
Retrieve a @catch statement.
This represents '#pragma omp target parallel for simd' directive.
QualType getTypeAsWritten() const
getTypeAsWritten - Returns the type that this expression is casting to, as written in the source code...
OpenMP 4.0 [2.4, Array Sections].
ConditionalOperator - The ?: ternary operator.
bool isStdInitListInitialization() const
Whether this constructor call was written as list-initialization, but was interpreted as forming a st...
Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
CompoundStmt - This represents a group of statements like { stmt stmt }.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Represents a prototype with parameter type info, e.g.
QualType getQueriedType() const
CompoundStmt * getSubStmt() const
Retrieve the compound statement that will be included in the program only if the existence of the sym...
This represents '#pragma omp taskgroup' directive.
unsigned SuppressImplicitBase
When true, don't print the implicit 'self' or 'this' expressions.
NestedNameSpecifier * getQualifier() const
If the member name was qualified, retrieves the nested-name-specifier that precedes the member name...
StringRef getBuiltinStr() const
Return a string representing the name of the specific builtin function.
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand...
InitListExpr * getUpdater() const
ConstantExpr - An expression that occurs in a constant context and optionally the result of evaluatin...
Represents a call to the builtin function __builtin_va_arg.
void outputString(raw_ostream &OS) const
bool isImplicitAccess() const
True if this is an implicit access, i.e.
static StringRef getSourceText(CharSourceRange Range, const SourceManager &SM, const LangOptions &LangOpts, bool *Invalid=nullptr)
Returns a string for the source that the range encompasses.
unsigned getValue() const
This represents '#pragma omp distribute' directive.
This represents implicit clause 'depend' for the '#pragma omp task' directive.
Expr * getSrcExpr() const
getSrcExpr - Return the Expr to be converted.
An expression "T()" which creates a value-initialized rvalue of type T, which is a non-class type...
Represents a block literal declaration, which is like an unnamed FunctionDecl.
llvm::MutableArrayRef< Designator > designators()
This represents one expression.
bool isVariadic() const
Whether this function is variadic.
IdentifierInfo * getFieldName() const
For a field or identifier offsetof node, returns the name of the field.
bool isArrow() const
Determine whether this member expression used the '->' operator; otherwise, it used the '...
static void PrintFloatingLiteral(raw_ostream &OS, FloatingLiteral *Node, bool PrintSuffix)
bool isImplicitAccess() const
True if this is an implicit access, i.e., one in which the member being accessed was not written in t...
Represents a C++ functional cast expression that builds a temporary object.
A C++ const_cast expression (C++ [expr.const.cast]).
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
VarDecl * getExceptionDecl() const
IdentifierInfo * getDestroyedTypeIdentifier() const
In a dependent pseudo-destructor expression for which we do not have full type information on the des...
unsigned getNumInits() const
Expr * getSubExpr() const
Get the initializer to use for each array element.
Defines an enumeration for C++ overloaded operators.
This represents '#pragma omp target teams distribute parallel for simd' combined directive.
QualType getArgumentType() const
bool isArrow() const
Determine whether this pseudo-destructor expression was written using an '->' (otherwise, it used a '.
StringRef getNameForSlot(unsigned argIndex) const
Retrieve the name at a given position in the selector.
ObjCDictionaryLiteral - AST node to represent objective-c dictionary literals; as in:"name" : NSUserN...
const CompoundStmt * getSynchBody() const
Represents Objective-C's @synchronized statement.
ObjCSelectorExpr used for @selector in Objective-C.
TypeSourceInfo * getTypeSourceInfo() const
Represents an expression that computes the length of a parameter pack.
CXXTryStmt - A C++ try block, including all handlers.
AsTypeExpr - Clang builtin function __builtin_astype [OpenCL 6.2.4.2] This AST node provides support ...
IdentifierInfo & getAccessor() const
This represents '#pragma omp target teams distribute simd' combined directive.
ArrayTypeTrait getTrait() const
void printTemplateArgumentList(raw_ostream &OS, ArrayRef< TemplateArgument > Args, const PrintingPolicy &Policy)
Print a template argument list, including the '<' and '>' enclosing the template arguments.
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char, signed char, short, int, long..], or an enum decl which has a signed representation.
Kind getKind() const
Determine what kind of offsetof node this is.
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
void print(llvm::raw_ostream &OS) const
Prints the full selector name (e.g. "foo:bar:").
virtual bool handledStmt(Stmt *E, raw_ostream &OS)=0
This represents '#pragma omp for' directive.
LabelDecl * getLabel() const
const Stmt * getTryBody() const
Retrieve the @try body.
Represents a folding of a pack over an operator.
QualType getEncodedType() const
ReturnStmt - This represents a return, optionally of an expression: return; return 4;...
This represents '#pragma omp target teams' directive.
An expression that sends a message to the given Objective-C object or class.
This represents a Microsoft inline-assembly statement extension.
ObjCMethodDecl * getImplicitPropertyGetter() const
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
CXXMethodDecl * getMethodDecl() const
Retrieve the declaration of the called method.
ReceiverKind getReceiverKind() const
Determine the kind of receiver that this message is being sent to.
A member reference to an MSPropertyDecl.
Represents a reference to a non-type template parameter that has been substituted with a template arg...
const OffsetOfNode & getComponent(unsigned Idx) const
unsigned getNumArgs() const
This represents '#pragma omp cancel' directive.
Selector getSelector() const
const Expr * getSubExpr() const
const Expr * getSubExpr() const
CStyleCastExpr - An explicit cast in C (C99 6.5.4) or a C-style cast in C++ (C++ [expr.cast]), which uses the syntax (Type)expr.
CXXMethodDecl * getCallOperator() const
Retrieve the function call operator associated with this lambda expression.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Expr * getLHS()
An array access can be written A[4] or 4[A] (both are equivalent).
This file defines OpenMP AST classes for clauses.
ImaginaryLiteral - We support imaginary integer and floating point literals, like "1...
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
This represents '#pragma omp flush' directive.
bool hasClausesOfKind() const
Returns true if the current directive has one or more clauses of a specific kind. ...
This represents '#pragma omp parallel for simd' directive.
DoStmt - This represents a 'do/while' stmt.
StringRef getBridgeKindName() const
Retrieve the kind of bridge being performed as a string.
param_iterator param_begin()
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the member name.
const DeclarationNameInfo & getNameInfo() const
Retrieve the name that this expression refers to.
LiteralOperatorKind getLiteralOperatorKind() const
Returns the kind of literal operator invocation which this expression represents. ...
This represents '#pragma omp target enter data' directive.
A C++ dynamic_cast expression (C++ [expr.dynamic.cast]).
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
ConvertVectorExpr - Clang builtin function __builtin_convertvector This AST node provides support for...
unsigned getNumArgs() const
Return the number of actual arguments in this message, not counting the receiver. ...
static StringRef getIdentKindName(IdentKind IK)
This captures a statement into a function.
Represents a call to an inherited base class constructor from an inheriting constructor.
operator "" X (const CharT *, size_t)
ExpressionTrait getTrait() const
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
bool isImplicitProperty() const
IdentifierInfo * getIdentifierInfoForSlot(unsigned argIndex) const
Retrieve the identifier at a given position in the selector.
Raw form: operator "" X<cs...> ()
unsigned getNumExprs() const
Return the number of expressions in this paren list.
This represents '#pragma omp single' directive.
unsigned Indentation
The number of spaces to use to indent each line.
capture_iterator explicit_capture_begin() const
Retrieve an iterator pointing to the first explicit lambda capture.
Defines enumerations for expression traits intrinsics.
unsigned ConstantsAsWritten
Whether we should print the constant expressions as written in the sources.
unsigned UnderscoreAlignof
Whether we can use '_Alignof' rather than '__alignof'.
const Stmt * getCatchBody() const
StringRef getLabelName(unsigned i) const
unsigned getNumHandlers() const
Expr * getSubExpr() const
bool hasExplicitTemplateArgs() const
Determines whether this member expression actually had a C++ template argument list explicitly specif...
This is a basic class for representing single OpenMP executable directive.
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)"...
unsigned getNumElements() const
getNumElements - Return number of elements of objective-c dictionary literal.
static const char * getExpressionTraitName(ExpressionTrait ET)
A call to a literal operator (C++11 [over.literal]) written as a user-defined literal (C++11 [lit...
DeclarationName getName() const
getName - Returns the embedded declaration name.
Represents a C++2a __builtin_bit_cast(T, v) expression.
Represents a call to a member function that may be written either with member call syntax (e...
ASTContext & getASTContext() const LLVM_READONLY
Defines several types used to describe C++ lambda expressions that are shared between the parser and ...
DeclStmt - Adaptor class for mixing declarations with statements and expressions. ...
DeclarationNameInfo getDirectiveName() const
Return name of the directive.
Represents a static or instance method of a struct/union/class.
std::string getValueAsString(unsigned Radix) const
StmtVisitor - This class implements a simple visitor for Stmt subclasses.
SourceLocation getColonLoc() const
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
This represents '#pragma omp taskwait' directive.
QualType getAllocatedType() const
This file defines OpenMP nodes for declarative directives.
AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*, __atomic_load, __atomic_store, and __atomic_compare_exchange_*, for the similarly-named C++11 instructions, and __c11 variants for <stdatomic.h>, and corresponding __opencl_atomic_* for OpenCL 2.0.
UnaryExprOrTypeTrait getKind() const
ArrayRef< NamedDecl * > getExplicitTemplateParameters() const
Get the template parameters were explicitly specified (as opposed to being invented by use of an auto...
Expr * getExpr(unsigned Init)
ObjCProtocolExpr used for protocol expression in Objective-C.
const StringLiteral * getOutputConstraintLiteral(unsigned i) const
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
Stmt * getCapturedStmt()
Retrieve the statement being captured.
bool hasTemplateKeyword() const
Determines whether the member name was preceded by the template keyword.
CharacterKind getKind() const
This represents '#pragma omp target' directive.
Expr * getInputExpr(unsigned i)
static const char * getTypeTraitName(TypeTrait TT)
void dumpPretty(const ASTContext &Context) const
dumpPretty/printPretty - These two methods do a "pretty print" of the AST back to its original source...
Used for C's _Alignof and C++'s alignof.
bool isParenTypeId() const
void printPretty(raw_ostream &OS, const PrintingPolicy &Policy) const
Expr * getArrayRangeStart(const Designator &D) const
An expression trait intrinsic.
DeclStmt * getConditionVariableDeclStmt()
If this WhileStmt has a condition variable, return the faux DeclStmt associated with the creation of ...
This represents '#pragma omp ordered' directive.
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
This represents '#pragma omp target update' directive.
ObjCBoxedExpr - used for generalized expression boxing.
bool isArgumentType() const
ArrayRef< TemplateArgumentLoc > template_arguments() const
LLVM_READONLY bool isPrintable(unsigned char c)
Return true if this character is an ASCII printable character; that is, a character that should take ...
Representation of a Microsoft __if_exists or __if_not_exists statement with a dependent name...
void printName(raw_ostream &OS) const
printName - Print the human-readable name to a stream.
bool hasTemplateKeyword() const
Determines whether the name in this declaration reference was preceded by the template keyword...
A qualified reference to a name whose declaration cannot yet be resolved.
Expr * Value
The value of the dictionary element.
const Expr * getInitializer() const
InitializationStyle getInitializationStyle() const
The kind of initializer this new-expression has.
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
CompoundAssignOperator - For compound assignments (e.g.
Represents a C11 generic selection.
StringRef getName() const
Return the actual identifier string.
const Expr * getBase() const
Expr * getInstanceReceiver()
Returns the object expression (receiver) for an instance message, or null for a message that is not a...
AddrLabelExpr - The GNU address of label extension, representing &&label.
An Objective-C "bridged" cast expression, which casts between Objective-C pointers and C pointers...
ast_type_traits::DynTypedNode Node
Represents a reference to a function parameter pack or init-capture pack that has been substituted bu...
Represents a template argument.
Expr * getFalseExpr() const
getFalseExpr - Return the subexpression which will be evaluated if the condnition evaluates to false;...
NullStmt - This is the null statement ";": C99 6.8.3p3.
bool isMutable() const
Determine whether the lambda is mutable, meaning that any captures values can be modified.
bool isTypeOperand() const
Dataflow Directional Tag Classes.
static std::string getPropertyNameFromSetterSelector(Selector Sel)
Return the property name for the given setter selector.
NestedNameSpecifier * getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
bool isValid() const
Return true if this is a valid SourceLocation object.
[C99 6.4.2.2] - A predefined identifier such as func.
DeclarationNameInfo getMemberNameInfo() const
Retrieve the member declaration name info.
Represents a delete expression for memory deallocation and destructor calls, e.g. ...
OverloadedOperatorKind getOperator() const
Returns the kind of overloaded operator that this expression refers to.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
NonTypeTemplateParmDecl * getParameterPack() const
Retrieve the non-type template parameter pack being substituted.
MSPropertyDecl * getPropertyDecl() const
ArrayRef< const Attr * > getAttrs() const
Parameter for Objective-C 'self' argument.
This represents '#pragma omp section' directive.
This represents '#pragma omp teams distribute' directive.
A runtime availability query.
void print(raw_ostream &Out, const ASTContext &Context, bool OmitTemplateKW=false) const
A C++ reinterpret_cast expression (C++ [expr.reinterpret.cast]).
This represents '#pragma omp simd' directive.
Represents a 'co_yield' expression.
Expr * getOperand() const
Retrieve the operand of the 'co_return' statement.
Represents a C++11 pack expansion that produces a sequence of expressions.
bool isListInitialization() const
Whether this constructor call was written as list-initialization.
SEHExceptStmt * getExceptHandler() const
Returns 0 if not defined.
const Expr * getSynchExpr() const
bool isIfExists() const
Determine whether this is an __if_exists statement.
NestedNameSpecifierLoc getQualifierLoc() const
const DeclarationNameInfo & getMemberNameInfo() const
Retrieve the full name info for the member that this expression refers to.
TemplateParameterList * getTemplateParameterList() const
If this is a generic lambda expression, retrieve the template parameter list associated with it...
Expr * getPlacementArg(unsigned I)
This represents '#pragma omp atomic' directive.
DeclStmt * getConditionVariableDeclStmt()
If this IfStmt has a condition variable, return the faux DeclStmt associated with the creation of tha...
TypeSourceInfo * getTypeOperandSourceInfo() const
Retrieve source information for the type operand.
Expr * getArrayRangeEnd(const Designator &D) const
llvm::APInt getValue() const
Represents a __leave statement.
LabelDecl * getLabel() const
QualType getClassReceiver() const
Returns the type of a class message send, or NULL if the message is not a class message.
Represents a C++11 noexcept expression (C++ [expr.unary.noexcept]).
SwitchStmt - This represents a 'switch' stmt.
Capturing variable-length array type.
Expr * getOrderFail() const
DeclarationNameInfo getNameInfo() const
Represents the body of a coroutine.
bool hasTemplateKeyword() const
Determines whether the name was preceded by the template keyword.
Indicates that the tracking object is a descendant of a referenced-counted OSObject, used in the Darwin kernel.
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
This file defines OpenMP AST classes for executable directives and clauses.
Represents Objective-C's collection statement.
ObjCEncodeExpr, used for @encode in Objective-C.
const char * getOperatorSpelling(OverloadedOperatorKind Operator)
Retrieve the spelling of the given overloaded operator, without the preceding "operator" keyword...
An implicit indirection through a C++ base class, when the field found is in a base class...
Represents a call to a CUDA kernel function.
Represents a 'co_await' expression.
Expr * getReplacement() const
Expr * getArg(unsigned Arg)
Return the specified argument.
Represents Objective-C's @finally statement.
StringRef getAsmString() const
unsigned Alignof
Whether we can use 'alignof' rather than '__alignof'.
bool hasAssociatedStmt() const
Returns true if directive has associated statement.
const Expr * getBase() const
bool isArrow() const
Determine whether this member expression used the '->' operator; otherwise, it used the '...
Capturing the *this object by reference.
const char * getOpenMPDirectiveName(OpenMPDirectiveKind Kind)
unsigned getNumClobbers() const
ObjCIvarRefExpr - A reference to an ObjC instance variable.
SourceManager & getSourceManager()
Describes an explicit type conversion that uses functional notion but could not be resolved because o...
SEHFinallyStmt * getFinallyHandler() const
GotoStmt - This represents a direct goto.
A use of a default initializer in a constructor or in aggregate initialization.
A template argument list.
Expr * getSrcExpr() const
getSrcExpr - Return the Expr to be converted.
ArrayRef< TemplateArgumentLoc > template_arguments() const
CapturedDecl * getCapturedDecl()
Retrieve the outlined function declaration.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
void printPretty(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation=0, StringRef NewlineSymbol="\, const ASTContext *Context=nullptr) const
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Defines the clang::SourceLocation class and associated facilities.
This represents '#pragma omp target parallel' directive.
ContinueStmt - This represents a continue.
Represents a loop initializing the elements of an array.
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
Expr * getFilterExpr() const
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
CXXCatchStmt - This represents a C++ catch block.
VarDecl * getLoopVariable()
Represents an explicit C++ type conversion that uses "functional" notation (C++ [expr.type.conv]).
bool isPackExpansion() const
Determines whether this dictionary element is a pack expansion.
Expr * getOperand() const
WhileStmt - This represents a 'while' stmt.
SourceLocation getLParenLoc() const
This class is used for builtin types like 'int'.
CompoundStmt * getTryBlock()
Represents Objective-C's @try ... @catch ... @finally statement.
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
bool isGlobalDelete() const
This represents '#pragma omp taskloop simd' directive.
unsigned getNumCatchStmts() const
Retrieve the number of @catch statements in this try-catch-finally block.
Expr * getBase() const
Retrieve the base object of this member expressions, e.g., the x in x.m.
StringLiteral - This represents a string literal expression, e.g.
bool hasExplicitParameters() const
Determine whether this lambda has an explicit parameter list vs.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Expr * getPattern()
Retrieve the pattern of the pack expansion.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
RetTy Visit(PTR(Stmt) S, ParamTys... P)
Stmt * getBody() const
Retrieve the body of the coroutine as written.
static Decl::Kind getKind(const Decl *D)
Abstract class common to all of the C++ "named"/"keyword" casts.
This represents '#pragma omp sections' directive.
ObjCBoolLiteralExpr - Objective-C Boolean Literal.
bool isObjectReceiver() const
unsigned getNumComponents() const
This represents '#pragma omp target data' directive.
OpenMPDirectiveKind getCancelRegion() const
Get cancellation region for the current cancellation point.
raw_ostream & Indent(raw_ostream &Out, const unsigned int Space, bool IsDot)
A reference to a declared variable, function, enum, etc.
static bool printExprAsWritten(raw_ostream &OS, Expr *E, const ASTContext *Context)
Prints the given expression using the original source text.
unsigned IncludeNewlines
When true, include newlines after statements like "break", etc.
BreakStmt - This represents a break.
const VarDecl * getCatchParamDecl() const
static bool isImplicitSelf(const Expr *E)
unsigned getNumLabels() const
const char * getCastName() const
getCastName - Get the name of the C++ cast being used, e.g., "static_cast", "dynamic_cast", "reinterpret_cast", or "const_cast".
Expr * getOperand() const
QualType getTypeAsWritten() const
Retrieve the type that is being constructed, as specified in the source code.
unsigned getNumArgs() const
Return the number of arguments to the constructor call.
const Expr * getBase() const
static StringRef getOpcodeStr(Opcode Op)
getOpcodeStr - Turn an Opcode enum value into the punctuation char it corresponds to...
This represents '#pragma omp taskyield' directive.
This represents '#pragma omp distribute parallel for simd' composite directive.
A boolean literal, per ([C++ lex.bool] Boolean literals).
NestedNameSpecifier * getQualifier() const
If the name was qualified, retrieves the nested-name-specifier that precedes the name.
OffsetOfExpr - [C99 7.17] - This represents an expression of the form offsetof(record-type, member-designator).
Expr * getQueriedExpression() const
This represents '#pragma omp parallel sections' directive.
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
Expr * getCommon() const
getCommon - Return the common expression, written to the left of the condition.
The receiver is a superclass.
BinaryOperatorKind getOperator() const
const LangOptions & getLangOpts() const
NamedDecl * getPack() const
Retrieve the parameter pack.
Represents Objective-C's @autoreleasepool Statement.
CompoundStmt * getTryBlock() const
InitListExpr * getSyntacticForm() const
Expr * getBaseExpr() const
Represents an implicitly-generated value initialization of an object of a given type.
CompoundStmt * getBlock() const
This represents '#pragma omp target parallel for' directive.
Attr - This represents one attribute.
operator "" X (unsigned long long)
QualType getType() const
Return the type wrapped by this type source info.
TypeTrait getTrait() const
Determine which type trait this expression uses.
association_range associations()
Expr * getLength()
Get length of array section.
const DeclarationNameInfo & getMemberNameInfo() const
Retrieve the name of the member that this expression refers to.
Expr * getCookedLiteral()
If this is not a raw user-defined literal, get the underlying cooked literal (representing the litera...
Expr * getBase()
An array section can be written only as Base[LowerBound:Length].
This represents '#pragma omp taskloop' directive.