28 #include "llvm/ADT/SmallString.h" 29 #include "llvm/Support/Format.h" 30 using namespace clang;
37 class StmtPrinter :
public StmtVisitor<StmtPrinter> {
48 : OS(os), IndentLevel(Indentation), Helper(helper), Policy(Policy),
51 void PrintStmt(
Stmt *S) {
55 void PrintStmt(
Stmt *S,
int SubIndent) {
56 IndentLevel += SubIndent;
57 if (S && isa<Expr>(S)) {
65 Indent() <<
"<<<NULL STATEMENT>>>\n";
67 IndentLevel -= SubIndent;
71 void PrintRawDecl(
Decl *D);
72 void PrintRawDeclStmt(
const DeclStmt *S);
73 void PrintRawIfStmt(
IfStmt *If);
79 bool ForceNoStmt =
false);
81 void PrintExpr(
Expr *E) {
88 raw_ostream &Indent(
int Delta = 0) {
89 for (
int i = 0, e = IndentLevel+Delta; i < e; ++i)
100 void VisitStmt(
Stmt *
Node) LLVM_ATTRIBUTE_UNUSED {
101 Indent() <<
"<<unknown stmt type>>\n";
103 void VisitExpr(
Expr *
Node) LLVM_ATTRIBUTE_UNUSED {
104 OS <<
"<<unknown expr type>>";
108 #define ABSTRACT_STMT(CLASS) 109 #define STMT(CLASS, PARENT) \ 110 void Visit##CLASS(CLASS *Node); 111 #include "clang/AST/StmtNodes.inc" 123 for (
auto *I : Node->
body())
129 void StmtPrinter::PrintRawDecl(
Decl *D) {
130 D->
print(OS, Policy, IndentLevel);
133 void StmtPrinter::PrintRawDeclStmt(
const DeclStmt *S) {
142 void StmtPrinter::VisitDeclStmt(
DeclStmt *Node) {
144 PrintRawDeclStmt(Node);
148 void StmtPrinter::VisitCompoundStmt(
CompoundStmt *Node) {
150 PrintRawCompoundStmt(Node);
154 void StmtPrinter::VisitCaseStmt(
CaseStmt *Node) {
155 Indent(-1) <<
"case ";
156 PrintExpr(Node->
getLHS());
159 PrintExpr(Node->
getRHS());
166 void StmtPrinter::VisitDefaultStmt(
DefaultStmt *Node) {
167 Indent(-1) <<
"default:\n";
171 void StmtPrinter::VisitLabelStmt(
LabelStmt *Node) {
172 Indent(-1) << Node->
getName() <<
":\n";
184 void StmtPrinter::PrintRawIfStmt(
IfStmt *If) {
187 PrintRawDeclStmt(DS);
194 PrintRawCompoundStmt(CS);
195 OS << (If->
getElse() ?
' ' :
'\n');
207 PrintRawCompoundStmt(CS);
209 }
else if (
IfStmt *ElseIf = dyn_cast<IfStmt>(Else)) {
211 PrintRawIfStmt(ElseIf);
219 void StmtPrinter::VisitIfStmt(
IfStmt *If) {
224 void StmtPrinter::VisitSwitchStmt(
SwitchStmt *Node) {
225 Indent() <<
"switch (";
227 PrintRawDeclStmt(DS);
235 PrintRawCompoundStmt(CS);
243 void StmtPrinter::VisitWhileStmt(
WhileStmt *Node) {
244 Indent() <<
"while (";
246 PrintRawDeclStmt(DS);
253 void StmtPrinter::VisitDoStmt(
DoStmt *Node) {
256 PrintRawCompoundStmt(CS);
269 void StmtPrinter::VisitForStmt(
ForStmt *Node) {
273 PrintRawDeclStmt(DS);
275 PrintExpr(cast<Expr>(Node->
getInit()));
285 PrintExpr(Node->
getInc());
290 PrintRawCompoundStmt(CS);
301 PrintRawDeclStmt(DS);
309 PrintRawCompoundStmt(CS);
333 OS <<
"__if_exists (";
335 OS <<
"__if_not_exists (";
339 Qualifier->print(OS, Policy);
346 void StmtPrinter::VisitGotoStmt(
GotoStmt *Node) {
352 Indent() <<
"goto *";
358 void StmtPrinter::VisitContinueStmt(
ContinueStmt *Node) {
359 Indent() <<
"continue;";
363 void StmtPrinter::VisitBreakStmt(
BreakStmt *Node) {
364 Indent() <<
"break;";
369 void StmtPrinter::VisitReturnStmt(
ReturnStmt *Node) {
370 Indent() <<
"return";
380 void StmtPrinter::VisitGCCAsmStmt(
GCCAsmStmt *Node) {
394 for (
unsigned i = 0, e = Node->
getNumOutputs(); i != e; ++i) {
414 for (
unsigned i = 0, e = Node->
getNumInputs(); i != e; ++i) {
445 void StmtPrinter::VisitMSAsmStmt(
MSAsmStmt *Node) {
447 Indent() <<
"__asm ";
455 void StmtPrinter::VisitCapturedStmt(
CapturedStmt *Node) {
462 PrintRawCompoundStmt(TS);
468 Indent() <<
"@catch(";
475 PrintRawCompoundStmt(CS);
482 Indent() <<
"@finally";
483 PrintRawCompoundStmt(dyn_cast<CompoundStmt>(FS->getFinallyBody()));
492 Indent() <<
"@catch (...) { /* todo */ } \n";
496 Indent() <<
"@throw";
504 void StmtPrinter::VisitObjCAvailabilityCheckExpr(
506 OS <<
"@available(...)";
510 Indent() <<
"@synchronized (";
518 Indent() <<
"@autoreleasepool";
519 PrintRawCompoundStmt(dyn_cast<CompoundStmt>(Node->
getSubStmt()));
523 void StmtPrinter::PrintRawCXXCatchStmt(
CXXCatchStmt *Node) {
526 PrintRawDecl(ExDecl);
533 void StmtPrinter::VisitCXXCatchStmt(
CXXCatchStmt *Node) {
535 PrintRawCXXCatchStmt(Node);
539 void StmtPrinter::VisitCXXTryStmt(
CXXTryStmt *Node) {
549 void StmtPrinter::VisitSEHTryStmt(
SEHTryStmt *Node) {
550 Indent() << (Node->
getIsCXXTry() ?
"try " :
"__try ");
555 PrintRawSEHExceptHandler(E);
557 assert(F &&
"Must have a finally block...");
558 PrintRawSEHFinallyStmt(F);
565 PrintRawCompoundStmt(Node->
getBlock());
569 void StmtPrinter::PrintRawSEHExceptHandler(
SEHExceptStmt *Node) {
573 PrintRawCompoundStmt(Node->
getBlock());
579 PrintRawSEHExceptHandler(Node);
585 PrintRawSEHFinallyStmt(Node);
589 void StmtPrinter::VisitSEHLeaveStmt(
SEHLeaveStmt *Node) {
590 Indent() <<
"__leave;";
603 template <
typename T>
604 void VisitOMPClauseList(
T *Node,
char StartSym);
607 : OS(OS), Policy(Policy) { }
608 #define OPENMP_CLAUSE(Name, Class) \ 609 void Visit##Class(Class *S); 610 #include "clang/Basic/OpenMPKinds.def" 613 void OMPClausePrinter::VisitOMPIfClause(
OMPIfClause *Node) {
621 void OMPClausePrinter::VisitOMPFinalClause(
OMPFinalClause *Node) {
628 OS <<
"num_threads(";
687 Num->printPretty(OS,
nullptr, Policy, 0);
708 void OMPClausePrinter::VisitOMPReadClause(
OMPReadClause *) { OS <<
"read"; }
710 void OMPClausePrinter::VisitOMPWriteClause(
OMPWriteClause *) { OS <<
"write"; }
728 void OMPClausePrinter::VisitOMPSIMDClause(
OMPSIMDClause *) { OS <<
"simd"; }
743 OS <<
"thread_limit(";
766 void OMPClausePrinter::VisitOMPHintClause(
OMPHintClause *Node) {
773 void OMPClausePrinter::VisitOMPClauseList(
T *Node,
char StartSym) {
774 for (
typename T::varlist_iterator I = Node->varlist_begin(),
775 E = Node->varlist_end();
777 assert(*I &&
"Expected non-null Stmt");
778 OS << (I == Node->varlist_begin() ? StartSym :
',');
779 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(*I)) {
780 if (isa<OMPCapturedExprDecl>(DRE->getDecl()))
781 DRE->printPretty(OS,
nullptr, Policy, 0);
783 DRE->getDecl()->printQualifiedName(OS);
785 (*I)->printPretty(OS,
nullptr, Policy, 0);
792 VisitOMPClauseList(Node,
'(');
799 OS <<
"firstprivate";
800 VisitOMPClauseList(Node,
'(');
808 VisitOMPClauseList(Node,
'(');
816 VisitOMPClauseList(Node,
'(');
828 if (QualifierLoc ==
nullptr && OOK !=
OO_None) {
833 if (QualifierLoc !=
nullptr)
834 QualifierLoc->
print(OS, Policy);
838 VisitOMPClauseList(Node,
' ');
843 void OMPClausePrinter::VisitOMPTaskReductionClause(
846 OS <<
"task_reduction(";
851 if (QualifierLoc ==
nullptr && OOK !=
OO_None) {
856 if (QualifierLoc !=
nullptr)
857 QualifierLoc->
print(OS, Policy);
861 VisitOMPClauseList(Node,
' ');
868 OS <<
"in_reduction(";
873 if (QualifierLoc ==
nullptr && OOK !=
OO_None) {
878 if (QualifierLoc !=
nullptr)
879 QualifierLoc->
print(OS, Policy);
883 VisitOMPClauseList(Node,
' ');
891 if (Node->getModifierLoc().isValid()) {
895 VisitOMPClauseList(Node,
'(');
896 if (Node->getModifierLoc().isValid())
898 if (Node->getStep() !=
nullptr) {
900 Node->getStep()->printPretty(OS,
nullptr, Policy, 0);
907 if (!Node->varlist_empty()) {
909 VisitOMPClauseList(Node,
'(');
919 if (!Node->varlist_empty()) {
921 VisitOMPClauseList(Node,
'(');
927 if (!Node->varlist_empty()) {
929 VisitOMPClauseList(Node,
'(');
934 void OMPClausePrinter::VisitOMPFlushClause(
OMPFlushClause *Node) {
935 if (!Node->varlist_empty()) {
936 VisitOMPClauseList(Node,
'(');
945 if (!Node->varlist_empty()) {
947 VisitOMPClauseList(Node,
' ');
952 void OMPClausePrinter::VisitOMPMapClause(
OMPMapClause *Node) {
953 if (!Node->varlist_empty()) {
964 VisitOMPClauseList(Node,
' ');
969 void OMPClausePrinter::VisitOMPToClause(
OMPToClause *Node) {
970 if (!Node->varlist_empty()) {
972 VisitOMPClauseList(Node,
'(');
977 void OMPClausePrinter::VisitOMPFromClause(
OMPFromClause *Node) {
978 if (!Node->varlist_empty()) {
980 VisitOMPClauseList(Node,
'(');
1006 if (!Node->varlist_empty()) {
1007 OS <<
"use_device_ptr";
1008 VisitOMPClauseList(Node,
'(');
1014 if (!Node->varlist_empty()) {
1015 OS <<
"is_device_ptr";
1016 VisitOMPClauseList(Node,
'(');
1028 OMPClausePrinter Printer(OS, Policy);
1032 if (*I && !(*I)->isImplicit()) {
1039 "Expected captured statement!");
1046 Indent() <<
"#pragma omp parallel ";
1047 PrintOMPExecutableDirective(Node);
1051 Indent() <<
"#pragma omp simd ";
1052 PrintOMPExecutableDirective(Node);
1056 Indent() <<
"#pragma omp for ";
1057 PrintOMPExecutableDirective(Node);
1061 Indent() <<
"#pragma omp for simd ";
1062 PrintOMPExecutableDirective(Node);
1066 Indent() <<
"#pragma omp sections ";
1067 PrintOMPExecutableDirective(Node);
1071 Indent() <<
"#pragma omp section";
1072 PrintOMPExecutableDirective(Node);
1076 Indent() <<
"#pragma omp single ";
1077 PrintOMPExecutableDirective(Node);
1081 Indent() <<
"#pragma omp master";
1082 PrintOMPExecutableDirective(Node);
1086 Indent() <<
"#pragma omp critical";
1093 PrintOMPExecutableDirective(Node);
1097 Indent() <<
"#pragma omp parallel for ";
1098 PrintOMPExecutableDirective(Node);
1101 void StmtPrinter::VisitOMPParallelForSimdDirective(
1103 Indent() <<
"#pragma omp parallel for simd ";
1104 PrintOMPExecutableDirective(Node);
1107 void StmtPrinter::VisitOMPParallelSectionsDirective(
1109 Indent() <<
"#pragma omp parallel sections ";
1110 PrintOMPExecutableDirective(Node);
1114 Indent() <<
"#pragma omp task ";
1115 PrintOMPExecutableDirective(Node);
1119 Indent() <<
"#pragma omp taskyield";
1120 PrintOMPExecutableDirective(Node);
1124 Indent() <<
"#pragma omp barrier";
1125 PrintOMPExecutableDirective(Node);
1129 Indent() <<
"#pragma omp taskwait";
1130 PrintOMPExecutableDirective(Node);
1134 Indent() <<
"#pragma omp taskgroup ";
1135 PrintOMPExecutableDirective(Node);
1139 Indent() <<
"#pragma omp flush ";
1140 PrintOMPExecutableDirective(Node);
1144 Indent() <<
"#pragma omp ordered ";
1145 PrintOMPExecutableDirective(Node);
1149 Indent() <<
"#pragma omp atomic ";
1150 PrintOMPExecutableDirective(Node);
1154 Indent() <<
"#pragma omp target ";
1155 PrintOMPExecutableDirective(Node);
1159 Indent() <<
"#pragma omp target data ";
1160 PrintOMPExecutableDirective(Node);
1163 void StmtPrinter::VisitOMPTargetEnterDataDirective(
1165 Indent() <<
"#pragma omp target enter data ";
1166 PrintOMPExecutableDirective(Node,
true);
1169 void StmtPrinter::VisitOMPTargetExitDataDirective(
1171 Indent() <<
"#pragma omp target exit data ";
1172 PrintOMPExecutableDirective(Node,
true);
1175 void StmtPrinter::VisitOMPTargetParallelDirective(
1177 Indent() <<
"#pragma omp target parallel ";
1178 PrintOMPExecutableDirective(Node);
1181 void StmtPrinter::VisitOMPTargetParallelForDirective(
1183 Indent() <<
"#pragma omp target parallel for ";
1184 PrintOMPExecutableDirective(Node);
1188 Indent() <<
"#pragma omp teams ";
1189 PrintOMPExecutableDirective(Node);
1192 void StmtPrinter::VisitOMPCancellationPointDirective(
1194 Indent() <<
"#pragma omp cancellation point " 1196 PrintOMPExecutableDirective(Node);
1200 Indent() <<
"#pragma omp cancel " 1202 PrintOMPExecutableDirective(Node);
1206 Indent() <<
"#pragma omp taskloop ";
1207 PrintOMPExecutableDirective(Node);
1210 void StmtPrinter::VisitOMPTaskLoopSimdDirective(
1212 Indent() <<
"#pragma omp taskloop simd ";
1213 PrintOMPExecutableDirective(Node);
1217 Indent() <<
"#pragma omp distribute ";
1218 PrintOMPExecutableDirective(Node);
1221 void StmtPrinter::VisitOMPTargetUpdateDirective(
1223 Indent() <<
"#pragma omp target update ";
1224 PrintOMPExecutableDirective(Node,
true);
1227 void StmtPrinter::VisitOMPDistributeParallelForDirective(
1229 Indent() <<
"#pragma omp distribute parallel for ";
1230 PrintOMPExecutableDirective(Node);
1233 void StmtPrinter::VisitOMPDistributeParallelForSimdDirective(
1235 Indent() <<
"#pragma omp distribute parallel for simd ";
1236 PrintOMPExecutableDirective(Node);
1239 void StmtPrinter::VisitOMPDistributeSimdDirective(
1241 Indent() <<
"#pragma omp distribute simd ";
1242 PrintOMPExecutableDirective(Node);
1245 void StmtPrinter::VisitOMPTargetParallelForSimdDirective(
1247 Indent() <<
"#pragma omp target parallel for simd ";
1248 PrintOMPExecutableDirective(Node);
1252 Indent() <<
"#pragma omp target simd ";
1253 PrintOMPExecutableDirective(Node);
1256 void StmtPrinter::VisitOMPTeamsDistributeDirective(
1258 Indent() <<
"#pragma omp teams distribute ";
1259 PrintOMPExecutableDirective(Node);
1262 void StmtPrinter::VisitOMPTeamsDistributeSimdDirective(
1264 Indent() <<
"#pragma omp teams distribute simd ";
1265 PrintOMPExecutableDirective(Node);
1268 void StmtPrinter::VisitOMPTeamsDistributeParallelForSimdDirective(
1270 Indent() <<
"#pragma omp teams distribute parallel for simd ";
1271 PrintOMPExecutableDirective(Node);
1274 void StmtPrinter::VisitOMPTeamsDistributeParallelForDirective(
1276 Indent() <<
"#pragma omp teams distribute parallel for ";
1277 PrintOMPExecutableDirective(Node);
1281 Indent() <<
"#pragma omp target teams ";
1282 PrintOMPExecutableDirective(Node);
1285 void StmtPrinter::VisitOMPTargetTeamsDistributeDirective(
1287 Indent() <<
"#pragma omp target teams distribute ";
1288 PrintOMPExecutableDirective(Node);
1291 void StmtPrinter::VisitOMPTargetTeamsDistributeParallelForDirective(
1293 Indent() <<
"#pragma omp target teams distribute parallel for ";
1294 PrintOMPExecutableDirective(Node);
1297 void StmtPrinter::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
1299 Indent() <<
"#pragma omp target teams distribute parallel for simd ";
1300 PrintOMPExecutableDirective(Node);
1303 void StmtPrinter::VisitOMPTargetTeamsDistributeSimdDirective(
1305 Indent() <<
"#pragma omp target teams distribute simd ";
1306 PrintOMPExecutableDirective(Node);
1313 void StmtPrinter::VisitDeclRefExpr(
DeclRefExpr *Node) {
1314 if (
auto *OCED = dyn_cast<OMPCapturedExprDecl>(Node->
getDecl())) {
1315 OCED->getInit()->IgnoreImpCasts()->printPretty(OS,
nullptr, Policy);
1319 Qualifier->print(OS, Policy);
1327 void StmtPrinter::VisitDependentScopeDeclRefExpr(
1330 Qualifier->print(OS, Policy);
1349 if (
const auto *DRE = dyn_cast<DeclRefExpr>(E)) {
1351 dyn_cast<ImplicitParamDecl>(DRE->getDecl())) {
1353 DRE->getLocStart().isInvalid())
1365 OS << (Node->
isArrow() ?
"->" :
".");
1450 if (value < 256 &&
isPrintable((
unsigned char)value))
1451 OS <<
"'" << (
char)value <<
"'";
1452 else if (value < 256)
1453 OS <<
"'\\x" << llvm::format(
"%02x", value) <<
"'";
1454 else if (value <= 0xFFFF)
1455 OS <<
"'\\u" << llvm::format(
"%04x", value) <<
"'";
1457 OS <<
"'\\U" << llvm::format(
"%08x", value) <<
"'";
1467 bool Invalid =
false;
1482 OS << Node->
getValue().toString(10, isSigned);
1486 default: llvm_unreachable(
"Unexpected type for integer literal!");
1487 case BuiltinType::Char_S:
1488 case BuiltinType::Char_U: OS <<
"i8";
break;
1489 case BuiltinType::UChar: OS <<
"Ui8";
break;
1490 case BuiltinType::Short: OS <<
"i16";
break;
1491 case BuiltinType::UShort: OS <<
"Ui16";
break;
1492 case BuiltinType::Int:
break;
1493 case BuiltinType::UInt: OS <<
'U';
break;
1494 case BuiltinType::Long: OS <<
'L';
break;
1495 case BuiltinType::ULong: OS <<
"UL";
break;
1496 case BuiltinType::LongLong: OS <<
"LL";
break;
1497 case BuiltinType::ULongLong: OS <<
"ULL";
break;
1506 if (Str.find_first_not_of(
"-0123456789") == StringRef::npos)
1514 default: llvm_unreachable(
"Unexpected type for float literal!");
1515 case BuiltinType::Half:
break;
1516 case BuiltinType::Double:
break;
1517 case BuiltinType::Float16: OS <<
"F16";
break;
1518 case BuiltinType::Float: OS <<
'F';
break;
1519 case BuiltinType::LongDouble: OS <<
'L';
break;
1520 case BuiltinType::Float128: OS <<
'Q';
break;
1538 void StmtPrinter::VisitParenExpr(
ParenExpr *Node) {
1569 void StmtPrinter::VisitOffsetOfExpr(
OffsetOfExpr *Node) {
1570 OS <<
"__builtin_offsetof(";
1573 bool PrintedSomething =
false;
1581 PrintedSomething =
true;
1594 if (PrintedSomething)
1597 PrintedSomething =
true;
1620 OS <<
"__builtin_omp_required_simd_align";
1642 T.
print(OS, Policy);
1650 PrintExpr(Node->
getLHS());
1652 PrintExpr(Node->
getRHS());
1669 void StmtPrinter::PrintCallArgs(
CallExpr *Call) {
1670 for (
unsigned i = 0, e = Call->
getNumArgs(); i != e; ++i) {
1671 if (isa<CXXDefaultArgExpr>(Call->
getArg(i))) {
1677 PrintExpr(Call->
getArg(i));
1681 void StmtPrinter::VisitCallExpr(
CallExpr *Call) {
1684 PrintCallArgs(Call);
1689 if (
const auto *TE = dyn_cast<CXXThisExpr>(E))
1690 return TE->isImplicit();
1694 void StmtPrinter::VisitMemberExpr(
MemberExpr *Node) {
1700 ParentMember ? dyn_cast<
FieldDecl>(ParentMember->getMemberDecl())
1703 if (!ParentDecl || !ParentDecl->isAnonymousStructOrUnion())
1704 OS << (Node->
isArrow() ?
"->" :
".");
1708 if (FD->isAnonymousStructOrUnion())
1712 Qualifier->
print(OS, Policy);
1719 void StmtPrinter::VisitObjCIsaExpr(
ObjCIsaExpr *Node) {
1721 OS << (Node->
isArrow() ?
"->isa" :
".isa");
1746 PrintExpr(Node->
getLHS());
1748 PrintExpr(Node->
getRHS());
1751 PrintExpr(Node->
getLHS());
1753 PrintExpr(Node->
getRHS());
1758 PrintExpr(Node->
getLHS());
1760 PrintExpr(Node->
getRHS());
1775 void StmtPrinter::VisitStmtExpr(
StmtExpr *E) {
1781 void StmtPrinter::VisitChooseExpr(
ChooseExpr *Node) {
1782 OS <<
"__builtin_choose_expr(";
1785 PrintExpr(Node->
getLHS());
1787 PrintExpr(Node->
getRHS());
1791 void StmtPrinter::VisitGNUNullExpr(
GNUNullExpr *) {
1796 OS <<
"__builtin_shufflevector(";
1805 OS <<
"__builtin_convertvector(";
1812 void StmtPrinter::VisitInitListExpr(
InitListExpr* Node) {
1819 for (
unsigned i = 0, e = Node->
getNumInits(); i != e; ++i) {
1843 for (
unsigned i = 0, e = Node->
getNumExprs(); i != e; ++i) {
1851 bool NeedsEquals =
true;
1853 if (D.isFieldDesignator()) {
1854 if (D.getDotLoc().isInvalid()) {
1856 OS << II->getName() <<
":";
1857 NeedsEquals =
false;
1860 OS <<
"." << D.getFieldName()->getName();
1864 if (D.isArrayDesignator()) {
1882 void StmtPrinter::VisitDesignatedInitUpdateExpr(
1889 OS <<
"/*updater*/";
1894 void StmtPrinter::VisitNoInitExpr(
NoInitExpr *Node) {
1895 OS <<
"/*no init*/";
1900 OS <<
"/*implicit*/";
1904 OS <<
"/*implicit*/(";
1914 void StmtPrinter::VisitVAArgExpr(
VAArgExpr *Node) {
1915 OS <<
"__builtin_va_arg(";
1926 void StmtPrinter::VisitAtomicExpr(
AtomicExpr *Node) {
1927 const char *Name =
nullptr;
1928 switch (Node->
getOp()) {
1929 #define BUILTIN(ID, TYPE, ATTRS) 1930 #define ATOMIC_BUILTIN(ID, TYPE, ATTRS) \ 1931 case AtomicExpr::AO ## ID: \ 1934 #include "clang/Basic/Builtins.def" 1939 PrintExpr(Node->
getPtr());
1940 if (Node->
getOp() != AtomicExpr::AO__c11_atomic_load &&
1941 Node->
getOp() != AtomicExpr::AO__atomic_load_n &&
1942 Node->
getOp() != AtomicExpr::AO__opencl_atomic_load) {
1946 if (Node->
getOp() == AtomicExpr::AO__atomic_exchange ||
1951 if (Node->
getOp() == AtomicExpr::AO__atomic_compare_exchange ||
1952 Node->
getOp() == AtomicExpr::AO__atomic_compare_exchange_n) {
1956 if (Node->
getOp() != AtomicExpr::AO__c11_atomic_init &&
1957 Node->
getOp() != AtomicExpr::AO__opencl_atomic_init) {
1972 #define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \ 1974 #include "clang/Basic/OperatorKinds.def" 1978 if (Kind == OO_PlusPlus || Kind == OO_MinusMinus) {
1980 OS << OpStrings[
Kind] <<
' ';
1981 PrintExpr(Node->
getArg(0));
1983 PrintExpr(Node->
getArg(0));
1984 OS <<
' ' << OpStrings[
Kind];
1986 }
else if (Kind == OO_Arrow) {
1987 PrintExpr(Node->
getArg(0));
1988 }
else if (Kind == OO_Call) {
1989 PrintExpr(Node->
getArg(0));
1991 for (
unsigned ArgIdx = 1; ArgIdx < Node->
getNumArgs(); ++ArgIdx) {
1994 if (!isa<CXXDefaultArgExpr>(Node->
getArg(ArgIdx)))
1995 PrintExpr(Node->
getArg(ArgIdx));
1998 }
else if (Kind == OO_Subscript) {
1999 PrintExpr(Node->
getArg(0));
2001 PrintExpr(Node->
getArg(1));
2004 OS << OpStrings[
Kind] <<
' ';
2005 PrintExpr(Node->
getArg(0));
2007 PrintExpr(Node->
getArg(0));
2008 OS <<
' ' << OpStrings[
Kind] <<
' ';
2009 PrintExpr(Node->
getArg(1));
2011 llvm_unreachable(
"unknown overloaded operator");
2018 if (MD && isa<CXXConversionDecl>(MD)) {
2022 VisitCallExpr(cast<CallExpr>(Node));
2030 PrintCallArgs(Node);
2043 VisitCXXNamedCastExpr(Node);
2047 VisitCXXNamedCastExpr(Node);
2051 VisitCXXNamedCastExpr(Node);
2055 VisitCXXNamedCastExpr(Node);
2086 Qualifier->print(OS, Policy);
2093 PrintExpr(Node->
getIdx());
2105 cast<FunctionDecl>(DRE->
getDecl())->getTemplateSpecializationArgs();
2108 if (Args->size() != 1) {
2117 char C = (char)
P.getAsIntegral().getZExtValue();
2125 OS << Int->
getValue().toString(10,
false);
2143 OS << (Node->
getValue() ?
"true" :
"false");
2150 void StmtPrinter::VisitCXXThisExpr(
CXXThisExpr *Node) {
2154 void StmtPrinter::VisitCXXThrowExpr(
CXXThrowExpr *Node) {
2196 Arg != ArgEnd; ++Arg) {
2197 if ((*Arg)->isDefaultArgument())
2211 void StmtPrinter::VisitLambdaExpr(
LambdaExpr *Node) {
2213 bool NeedComma =
false;
2232 if (
C->capturesVLAType())
2239 switch (
C->getCaptureKind()) {
2249 OS <<
C->getCapturedVar()->getName();
2253 OS <<
C->getCapturedVar()->getName();
2256 llvm_unreachable(
"VLA type in explicit captures.");
2260 PrintExpr(
C->getCapturedVar()->getInit());
2274 std::string ParamStr =
P->getNameAsString();
2275 P->getOriginalType().print(OS, Policy, ParamStr);
2308 TSInfo->getType().print(OS, Policy);
2314 void StmtPrinter::VisitCXXNewExpr(
CXXNewExpr *E) {
2322 for (
unsigned i = 1; i < NumPlace; ++i) {
2334 llvm::raw_string_ostream s(TypeS);
2336 Size->printPretty(s, Helper, Policy);
2373 OS << II->getName();
2382 for (
unsigned i = 0, e = E->
getNumArgs(); i != e; ++i) {
2383 if (isa<CXXDefaultArgExpr>(E->
getArg(i))) {
2398 OS <<
"<forwarded>";
2411 StmtPrinter::VisitCXXUnresolvedConstructExpr(
2417 Arg != ArgEnd; ++Arg) {
2425 void StmtPrinter::VisitCXXDependentScopeMemberExpr(
2429 OS << (Node->
isArrow() ?
"->" :
".");
2432 Qualifier->print(OS, Policy);
2443 OS << (Node->
isArrow() ?
"->" :
".");
2446 Qualifier->print(OS, Policy);
2456 #define TYPE_TRAIT_1(Spelling, Name, Key) \ 2457 case clang::UTT_##Name: return #Spelling; 2458 #define TYPE_TRAIT_2(Spelling, Name, Key) \ 2459 case clang::BTT_##Name: return #Spelling; 2460 #define TYPE_TRAIT_N(Spelling, Name, Key) \ 2461 case clang::TT_##Name: return #Spelling; 2462 #include "clang/Basic/TokenKinds.def" 2464 llvm_unreachable(
"Type trait not covered by switch");
2472 llvm_unreachable(
"Array type trait not covered by switch");
2480 llvm_unreachable(
"Expression type trait not covered by switch");
2485 for (
unsigned I = 0, N = E->
getNumArgs(); I != N; ++I) {
2517 OS <<
"sizeof...(" << *E->
getPack() <<
")";
2520 void StmtPrinter::VisitSubstNonTypeTemplateParmPackExpr(
2525 void StmtPrinter::VisitSubstNonTypeTemplateParmExpr(
2538 void StmtPrinter::VisitCXXFoldExpr(
CXXFoldExpr *E) {
2567 void StmtPrinter::VisitCoawaitExpr(
CoawaitExpr *S) {
2579 void StmtPrinter::VisitCoyieldExpr(
CoyieldExpr *S) {
2599 for (
auto I = Ch.begin(), E = Ch.end(); I != E; ++I) {
2600 if (I != Ch.begin())
2616 Visit(Element.
Value);
2636 OS <<
"@protocol(" << *Node->
getProtocol() <<
')';
2661 for (
unsigned i = 0, e = Mess->
getNumArgs(); i != e; ++i) {
2663 if (i > 0) OS <<
' ';
2671 PrintExpr(Mess->
getArg(i));
2678 OS << (Node->
getValue() ?
"__objc_yes" :
"__objc_no");
2694 void StmtPrinter::VisitBlockExpr(
BlockExpr *Node) {
2700 if (isa<FunctionNoProtoType>(AFT)) {
2702 }
else if (!BD->
param_empty() || cast<FunctionProtoType>(AFT)->isVariadic()) {
2707 std::string ParamStr = (*AI)->getNameAsString();
2708 (*AI)->getType().print(OS, Policy, ParamStr);
2725 void StmtPrinter::VisitTypoExpr(
TypoExpr *Node) {
2727 llvm_unreachable(
"Cannot print TypoExpr nodes");
2730 void StmtPrinter::VisitAsTypeExpr(
AsTypeExpr *Node) {
2731 OS <<
"__builtin_astype(";
2749 StmtPrinter
P(OS, Helper, Policy, Indentation, Context);
2750 P.Visit(const_cast<Stmt*>(
this));
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
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
This represents 'thread_limit' clause in the '#pragma omp ...' directive.
The receiver is an object instance.
bool hasExplicitTemplateArgs() const
Determines whether this expression had explicit template arguments.
const Stmt * getElse() const
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.
This represents clause 'copyin' in the '#pragma omp ...' directives.
A (possibly-)qualified type.
ArrayRef< TemplateArgumentLoc > template_arguments() const
bool varlist_empty() const
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
ArrayRef< OMPClause * > clauses()
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
Selector getSelector() const
const Expr * getSubExpr() const
void print(raw_ostream &OS, const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) 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.
CompoundStmt * getSubStmt()
const Expr * getInit(unsigned Init) const
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.
This represents clause 'in_reduction' in the '#pragma omp task' directives.
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.
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 'grainsize' clause in the '#pragma omp ...' directive.
This represents '#pragma omp teams distribute parallel for' composite directive.
Expr * getImplicitObjectArgument() const
Retrieves the implicit object argument for the member call.
Stmt * getHandlerBlock() const
llvm::APFloat getValue() 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...
This represents 'if' clause in the '#pragma omp ...' directive.
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.
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 'priority' clause in the '#pragma omp ...' directive.
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.
const char * getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind, unsigned Type)
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.
An Embarcadero array type trait, as used in the implementation of __array_rank and __array_extent...
Expr * getCondition() const
Returns condition.
A container of type source information.
This represents 'update' clause in the '#pragma omp atomic' directive.
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)
Expr * getCondition() const
Returns condition.
This represents '#pragma omp parallel for' directive.
MS property subscript expression.
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
Expr * getAlignment()
Returns alignment.
void printExceptionSpecification(raw_ostream &OS, const PrintingPolicy &Policy) const
Expr * getNumForLoops() const
Return the number of associated for-loops.
const Expr * getSubExpr() const
Expr * getIndexExpr(unsigned Idx)
This represents '#pragma omp target exit data' directive.
This represents 'read' clause in the '#pragma omp atomic' directive.
This represents clause 'private' in the '#pragma omp ...' directives.
ObjCIsaExpr - Represent X->isa and X.isa when X is an ObjC 'id' type.
CompoundLiteralExpr - [C99 6.5.2.5].
This represents 'num_threads' clause in the '#pragma omp ...' directive.
const T * getAs() const
Member-template getAs<specific type>'.
unsigned getNumArgs() const
Determine the number of arguments to this type trait.
This represents 'defaultmap' clause in the '#pragma omp ...' directive.
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
This represents implicit clause 'flush' for the '#pragma omp flush' directive.
Describes how types, statements, expressions, and declarations should be printed. ...
const DeclarationNameInfo & getNameInfo() const
Gets the name info for specified reduction identifier.
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
Expr * getGrainsize() const
Return safe iteration space distance.
This represents 'nogroup' clause in the '#pragma omp ...' directive.
This represents 'safelen' clause in the '#pragma omp ...' directive.
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.
Expr * IgnoreImpCasts() LLVM_READONLY
IgnoreImpCasts - Skip past any implicit casts which might surround this expression.
Represents a C99 designated initializer expression.
DeclarationName getDeclName() const
getDeclName - 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...
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
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.
This represents 'simd' clause in the '#pragma omp ...' directive.
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
This represents clause 'lastprivate' in the '#pragma omp ...' directives.
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()
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.
const Expr * getRetValue() const
bool SuppressInitializers
Suppress printing of variable initializers.
bool hasExplicitTemplateArgs() const
Determines whether the member name was followed by an explicit template argument list.
Expr * getChunkSize()
Get chunk size.
GNUNullExpr - Implements the GNU __null extension, which is a name for a null pointer constant that h...
This represents clause 'map' in the '#pragma omp ...' directives.
QualType getDestroyedType() const
Retrieve the type being destroyed.
This represents clause 'to' in the '#pragma omp ...' directives.
Expr * getPlacementArg(unsigned i)
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...
ExtVectorElementExpr - This represents access to specific elements of a vector, and may occur on the ...
Expr * getSafelen() const
Return safe iteration space distance.
This represents '#pragma omp barrier' directive.
ObjCArrayLiteral - used for objective-c array containers; as in: @["Hello", NSApp, [NSNumber numberWithInt:42]];.
Expr * getNumTeams()
Return NumTeams number.
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
This represents clause 'copyprivate' in the '#pragma omp ...' directives.
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.
ForStmt - This represents a 'for (init;cond;inc)' stmt.
NestedNameSpecifierLoc getQualifierLoc() const
Gets the nested name specifier.
Expr * getBaseExpr() const
Expr * getOperand() const
const Expr * getThrowExpr() const
< Capturing the *this object by copy
Expr * getInitializer()
The initializer of this new-expression.
A builtin binary operation expression such as "x + y" or "x <= y".
const Expr * getAssocExpr(unsigned i) const
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.
This represents 'default' clause in the '#pragma omp ...' directive.
ObjCStringLiteral, used for Objective-C string literals i.e.
void printPretty(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation=0, const ASTContext *Context=nullptr) const
const CallExpr * getConfig() const
New-expression has a C++98 paren-delimited initializer.
TypoExpr - Internal placeholder for expressions where typo correction still needs to be performed and...
This represents 'final' clause in the '#pragma omp ...' directive.
This represents 'mergeable' clause in the '#pragma omp ...' directive.
This represents '#pragma omp teams' directive.
OpenMPDependClauseKind getDependencyKind() const
Get dependency type.
NestedNameSpecifier * getQualifier() const
Fetches the nested-name qualifier, if one was given.
const Expr * getControllingExpr() const
This represents clause 'reduction' in the '#pragma omp ...' directives.
Helper class for OffsetOfExpr.
Expr * getOperand() const
This represents '#pragma omp teams distribute simd' combined directive.
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...
This represents clause 'is_device_ptr' in the '#pragma omp ...' directives.
bool isInitCapture(const LambdaCapture *Capture) const
Determine whether one of this lambda's captures is an init-capture.
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.
This represents clause 'from' in the '#pragma omp ...' directives.
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 }.
OpenMPDefaultClauseKind getDefaultKind() const
Returns kind of the clause.
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
This represents 'threads' clause in the '#pragma omp ...' directive.
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.
Expr * getSimdlen() const
Return safe iteration space distance.
NestedNameSpecifier * getQualifier() const
If the member name was qualified, retrieves the nested-name-specifier that precedes the member name...
This represents clause 'aligned' in the '#pragma omp ...' directives.
OverloadedOperatorKind getCXXOverloadedOperator() const
getCXXOverloadedOperator - If this name is the name of an overloadable operator in C++ (e...
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand...
This represents clause 'task_reduction' in the '#pragma omp taskgroup' directives.
InitListExpr * getUpdater() const
Represents a call to the builtin function __builtin_va_arg.
void print(raw_ostream &OS, const PrintingPolicy &Policy) const
Print this nested name specifier to the given output stream.
void outputString(raw_ostream &OS) const
const DeclStmt * getConditionVariableDeclStmt() const
If this IfStmt has a condition variable, return the faux DeclStmt associated with the creation of tha...
OpenMPProcBindClauseKind getProcBindKind() const
Returns kind of the clause.
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...
const Stmt * getAssociatedStmt() const
Returns statement associated with the directive.
BlockDecl - This represents a block literal declaration, which is like an unnamed FunctionDecl...
llvm::MutableArrayRef< Designator > designators()
This represents 'proc_bind' clause in the '#pragma omp ...' directive.
This represents 'capture' clause in the '#pragma omp atomic' directive.
Expr - 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)
const FunctionProtoType * T
This represents 'simdlen' clause in the '#pragma omp ...' directive.
Expr * getNumTasks() const
Return safe iteration space distance.
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.
const Stmt * getThen() const
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
bool isImplicitAccess() const
True if this is an implicit access, i.e.
Expr * getSubExpr() const
Get the initializer to use for each array element.
const Expr * getCallee() const
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 ...
OpenMPDistScheduleClauseKind getDistScheduleKind() const
Get kind of the clause.
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.
This represents 'ordered' clause in the '#pragma omp ...' directive.
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.
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
Retrieves 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
Expr * getDevice()
Return device number.
This represents '#pragma omp cancel' directive.
This represents 'collapse' clause in the '#pragma omp ...' directive.
This represents clause 'firstprivate' in the '#pragma omp ...' directives.
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).
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.
This represents '#pragma omp parallel for simd' directive.
DoStmt - This represents a 'do/while' stmt.
This represents 'seq_cst' clause in the '#pragma omp atomic' directive.
This represents 'untied' clause in the '#pragma omp ...' directive.
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.
This represents 'num_teams' clause in the '#pragma omp ...' 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. ...
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
This represents '#pragma omp single' directive.
unsigned Indentation
The number of spaces to use to indent each line.
QualType getReturnType() const
capture_iterator explicit_capture_begin() const
Retrieve an iterator pointing to the first explicit lambda capture.
This represents 'hint' clause in the '#pragma omp ...' directive.
unsigned UnderscoreAlignof
Whether we can use '_Alignof' rather than '__alignof'.
const Stmt * getCatchBody() 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.
ArrayRef< const Attr * > getAttrs() const
This represents 'schedule' clause in the '#pragma omp ...' directive.
Represents a call to a member function that may be written either with member call syntax (e...
DeclStmt - Adaptor class for mixing declarations with statements and expressions. ...
This represents clause 'shared' in the '#pragma omp ...' directives.
const Expr * getExpr(unsigned Init) const
DeclarationNameInfo getDirectiveName() const
Return name of the directive.
Represents a static or instance method of a struct/union/class.
Expr * getPriority()
Return Priority number.
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
OpenMPMapClauseKind getMapType() const LLVM_READONLY
Fetches mapping kind for the clause.
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
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 ...
bool hasTemplateKeyword() const
Determines whether the member name was preceded by the template keyword.
OpenMPMapClauseKind getMapTypeModifier() const LLVM_READONLY
Fetches the map type modifier for the clause.
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...
Expr * getNumForLoops() const
Return the number of associated for-loops.
bool isParenTypeId() const
IdentType getIdentType() const
void printPretty(raw_ostream &OS, const PrintingPolicy &Policy) const
Expr * getArrayRangeStart(const Designator &D) const
An expression trait intrinsic.
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 ...
const DeclStmt * getConditionVariableDeclStmt() const
If this WhileStmt has a condition variable, return the faux DeclStmt associated with the creation of ...
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 that has been substituted but not yet expanded...
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
unsigned getNumAssocs() const
Dataflow Directional Tag Classes.
This represents 'device' clause in the '#pragma omp ...' directive.
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.
OpenMPDefaultmapClauseKind getDefaultmapKind() const
Get kind of the clause.
[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
Parameter for Objective-C 'self' argument.
This represents '#pragma omp section' directive.
This represents '#pragma omp teams distribute' directive.
QualType getAssocType(unsigned i) const
A runtime availability query.
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.
This represents clause 'linear' in the '#pragma omp ...' directives.
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.
OpenMPDefaultmapClauseModifier getDefaultmapModifier() const
Get the modifier of the clause.
This represents '#pragma omp atomic' directive.
bool SuppressImplicitBase
When true, don't print the implicit 'self' or 'this' expressions.
TypeSourceInfo * getTypeOperandSourceInfo() const
Retrieve source information for the type operand.
Expr * getArrayRangeEnd(const Designator &D) const
const Stmt * getBody() 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.
Not an overloaded operator.
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.
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
OpenMPDirectiveKind getNameModifier() const
Return directive name modifier associated with the clause.
Represents Objective-C's collection statement.
static StringRef getIdentTypeName(IdentType IT)
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 '...
const DeclarationNameInfo & getNameInfo() const
Gets the name info for specified reduction identifier.
Capturing the *this object by reference.
This represents 'write' clause in the '#pragma omp atomic' directive.
const char * getOpenMPDirectiveName(OpenMPDirectiveKind Kind)
unsigned getNumClobbers() const
ObjCIvarRefExpr - A reference to an ObjC instance variable.
bool ConstantsAsWritten
Whether we should print the constant expressions as written in the sources.
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).
const DeclarationNameInfo & getNameInfo() const
Gets the name info for specified reduction identifier.
OpenMPScheduleClauseModifier getSecondScheduleModifier() const
Get the second modifier of the clause.
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
This represents '#pragma omp target parallel' directive.
This represents 'nowait' clause in the '#pragma omp ...' directive.
ContinueStmt - This represents a continue.
OpenMPScheduleClauseModifier getFirstScheduleModifier() const
Get the first modifier of the clause.
Represents a loop initializing the elements of an array.
This represents 'num_tasks' clause in the '#pragma omp ...' directive.
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]).
OpenMPScheduleClauseKind getScheduleKind() const
Get kind of the clause.
bool isPackExpansion() const
Determines whether this dictionary element is a pack expansion.
Expr * getOperand() const
WhileStmt - This represents a 'while' stmt.
SourceLocation getLParenLoc() const
Expr * getThreadLimit()
Return ThreadLimit number.
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
getName - Get the name of identifier for this declaration as a StringRef.
This represents 'dist_schedule' clause in the '#pragma omp ...' directive.
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.
Expr * getHint() const
Returns number of threads.
NestedNameSpecifierLoc getQualifierLoc() const
Gets the nested name specifier.
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.
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.
NestedNameSpecifierLoc getQualifierLoc() const
Gets the nested name specifier.
unsigned IncludeNewlines
When true, include newlines after statements like "break", etc.
BreakStmt - This represents a break.
Expr * getChunkSize()
Get chunk size.
const VarDecl * getCatchParamDecl() const
static bool isImplicitSelf(const Expr *E)
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
Expr * getNumThreads() const
Returns number of threads.
QualType getTypeAsWritten() const
Retrieve the type that is being constructed, as specified in the source code.
ParmVarDecl * getParameterPack() const
Get the parameter pack which this expression refers to.
unsigned getNumArgs() const
const Expr * getBase() const
const Expr * getCond() 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.
const Expr * getCond() const
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.
This represents clause 'use_device_ptr' in the '#pragma omp ...' directives.
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.
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].
const DeclStmt * getConditionVariableDeclStmt() const
If this SwitchStmt has a condition variable, return the faux DeclStmt associated with the creation of...
This represents '#pragma omp taskloop' directive.