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) {
196 Indent() <<
";" << NL;
199 void StmtPrinter::VisitDeclStmt(
DeclStmt *Node) {
201 PrintRawDeclStmt(Node);
205 void StmtPrinter::VisitCompoundStmt(
CompoundStmt *Node) {
207 PrintRawCompoundStmt(Node);
211 void StmtPrinter::VisitCaseStmt(
CaseStmt *Node) {
212 Indent(-1) <<
"case ";
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) {
229 Indent(-1) << Node->
getName() <<
":" << NL;
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) {
284 Indent() <<
"switch (";
286 PrintInitStmt(Node->
getInit(), 8);
288 PrintRawDeclStmt(DS);
292 PrintControlledStmt(Node->
getBody());
295 void StmtPrinter::VisitWhileStmt(
WhileStmt *Node) {
296 Indent() <<
"while (";
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) {
385 Indent() <<
"goto *";
391 void StmtPrinter::VisitContinueStmt(
ContinueStmt *Node) {
392 Indent() <<
"continue;";
396 void StmtPrinter::VisitBreakStmt(
BreakStmt *Node) {
397 Indent() <<
"break;";
401 void StmtPrinter::VisitReturnStmt(
ReturnStmt *Node) {
402 Indent() <<
"return";
411 void StmtPrinter::VisitGCCAsmStmt(
GCCAsmStmt *Node) {
425 for (
unsigned i = 0, e = Node->
getNumOutputs(); i != e; ++i) {
445 for (
unsigned i = 0, e = Node->
getNumInputs(); i != e; ++i) {
476 void StmtPrinter::VisitMSAsmStmt(
MSAsmStmt *Node) {
478 Indent() <<
"__asm ";
483 Indent() <<
"}" << NL;
486 void StmtPrinter::VisitCapturedStmt(
CapturedStmt *Node) {
492 if (
auto *TS = dyn_cast<CompoundStmt>(Node->
getTryBody())) {
493 PrintRawCompoundStmt(TS);
499 Indent() <<
"@catch(";
505 if (
auto *CS = dyn_cast<CompoundStmt>(catchStmt->
getCatchBody())) {
506 PrintRawCompoundStmt(CS);
511 if (
auto *FS = static_cast<ObjCAtFinallyStmt *>(Node->
getFinallyStmt())) {
512 Indent() <<
"@finally";
513 PrintRawCompoundStmt(dyn_cast<CompoundStmt>(FS->getFinallyBody()));
522 Indent() <<
"@catch (...) { /* todo */ } " << NL;
526 Indent() <<
"@throw";
534 void StmtPrinter::VisitObjCAvailabilityCheckExpr(
536 OS <<
"@available(...)";
540 Indent() <<
"@synchronized (";
548 Indent() <<
"@autoreleasepool";
549 PrintRawCompoundStmt(dyn_cast<CompoundStmt>(Node->
getSubStmt()));
553 void StmtPrinter::PrintRawCXXCatchStmt(
CXXCatchStmt *Node) {
556 PrintRawDecl(ExDecl);
563 void StmtPrinter::VisitCXXCatchStmt(
CXXCatchStmt *Node) {
565 PrintRawCXXCatchStmt(Node);
569 void StmtPrinter::VisitCXXTryStmt(
CXXTryStmt *Node) {
579 void StmtPrinter::VisitSEHTryStmt(
SEHTryStmt *Node) {
580 Indent() << (Node->
getIsCXXTry() ?
"try " :
"__try ");
585 PrintRawSEHExceptHandler(E);
587 assert(F &&
"Must have a finally block...");
588 PrintRawSEHFinallyStmt(F);
595 PrintRawCompoundStmt(Node->
getBlock());
599 void StmtPrinter::PrintRawSEHExceptHandler(
SEHExceptStmt *Node) {
603 PrintRawCompoundStmt(Node->
getBlock());
609 PrintRawSEHExceptHandler(Node);
615 PrintRawSEHFinallyStmt(Node);
619 void StmtPrinter::VisitSEHLeaveStmt(
SEHLeaveStmt *Node) {
620 Indent() <<
"__leave;";
632 for (
auto *Clause : Clauses)
633 if (Clause && !Clause->isImplicit()) {
635 Printer.
Visit(Clause);
643 Indent() <<
"#pragma omp parallel";
644 PrintOMPExecutableDirective(Node);
648 Indent() <<
"#pragma omp simd";
649 PrintOMPExecutableDirective(Node);
653 Indent() <<
"#pragma omp for";
654 PrintOMPExecutableDirective(Node);
658 Indent() <<
"#pragma omp for simd";
659 PrintOMPExecutableDirective(Node);
663 Indent() <<
"#pragma omp sections";
664 PrintOMPExecutableDirective(Node);
668 Indent() <<
"#pragma omp section";
669 PrintOMPExecutableDirective(Node);
673 Indent() <<
"#pragma omp single";
674 PrintOMPExecutableDirective(Node);
678 Indent() <<
"#pragma omp master";
679 PrintOMPExecutableDirective(Node);
683 Indent() <<
"#pragma omp critical";
689 PrintOMPExecutableDirective(Node);
693 Indent() <<
"#pragma omp parallel for";
694 PrintOMPExecutableDirective(Node);
697 void StmtPrinter::VisitOMPParallelForSimdDirective(
699 Indent() <<
"#pragma omp parallel for simd";
700 PrintOMPExecutableDirective(Node);
703 void StmtPrinter::VisitOMPParallelSectionsDirective(
705 Indent() <<
"#pragma omp parallel sections";
706 PrintOMPExecutableDirective(Node);
710 Indent() <<
"#pragma omp task";
711 PrintOMPExecutableDirective(Node);
715 Indent() <<
"#pragma omp taskyield";
716 PrintOMPExecutableDirective(Node);
720 Indent() <<
"#pragma omp barrier";
721 PrintOMPExecutableDirective(Node);
725 Indent() <<
"#pragma omp taskwait";
726 PrintOMPExecutableDirective(Node);
730 Indent() <<
"#pragma omp taskgroup";
731 PrintOMPExecutableDirective(Node);
735 Indent() <<
"#pragma omp flush";
736 PrintOMPExecutableDirective(Node);
740 Indent() <<
"#pragma omp ordered";
745 Indent() <<
"#pragma omp atomic";
746 PrintOMPExecutableDirective(Node);
750 Indent() <<
"#pragma omp target";
751 PrintOMPExecutableDirective(Node);
755 Indent() <<
"#pragma omp target data";
756 PrintOMPExecutableDirective(Node);
759 void StmtPrinter::VisitOMPTargetEnterDataDirective(
761 Indent() <<
"#pragma omp target enter data";
762 PrintOMPExecutableDirective(Node,
true);
765 void StmtPrinter::VisitOMPTargetExitDataDirective(
767 Indent() <<
"#pragma omp target exit data";
768 PrintOMPExecutableDirective(Node,
true);
771 void StmtPrinter::VisitOMPTargetParallelDirective(
773 Indent() <<
"#pragma omp target parallel";
774 PrintOMPExecutableDirective(Node);
777 void StmtPrinter::VisitOMPTargetParallelForDirective(
779 Indent() <<
"#pragma omp target parallel for";
780 PrintOMPExecutableDirective(Node);
784 Indent() <<
"#pragma omp teams";
785 PrintOMPExecutableDirective(Node);
788 void StmtPrinter::VisitOMPCancellationPointDirective(
790 Indent() <<
"#pragma omp cancellation point " 792 PrintOMPExecutableDirective(Node);
796 Indent() <<
"#pragma omp cancel " 798 PrintOMPExecutableDirective(Node);
802 Indent() <<
"#pragma omp taskloop";
803 PrintOMPExecutableDirective(Node);
806 void StmtPrinter::VisitOMPTaskLoopSimdDirective(
808 Indent() <<
"#pragma omp taskloop simd";
809 PrintOMPExecutableDirective(Node);
813 Indent() <<
"#pragma omp distribute";
814 PrintOMPExecutableDirective(Node);
817 void StmtPrinter::VisitOMPTargetUpdateDirective(
819 Indent() <<
"#pragma omp target update";
820 PrintOMPExecutableDirective(Node,
true);
823 void StmtPrinter::VisitOMPDistributeParallelForDirective(
825 Indent() <<
"#pragma omp distribute parallel for";
826 PrintOMPExecutableDirective(Node);
829 void StmtPrinter::VisitOMPDistributeParallelForSimdDirective(
831 Indent() <<
"#pragma omp distribute parallel for simd";
832 PrintOMPExecutableDirective(Node);
835 void StmtPrinter::VisitOMPDistributeSimdDirective(
837 Indent() <<
"#pragma omp distribute simd";
838 PrintOMPExecutableDirective(Node);
841 void StmtPrinter::VisitOMPTargetParallelForSimdDirective(
843 Indent() <<
"#pragma omp target parallel for simd";
844 PrintOMPExecutableDirective(Node);
848 Indent() <<
"#pragma omp target simd";
849 PrintOMPExecutableDirective(Node);
852 void StmtPrinter::VisitOMPTeamsDistributeDirective(
854 Indent() <<
"#pragma omp teams distribute";
855 PrintOMPExecutableDirective(Node);
858 void StmtPrinter::VisitOMPTeamsDistributeSimdDirective(
860 Indent() <<
"#pragma omp teams distribute simd";
861 PrintOMPExecutableDirective(Node);
864 void StmtPrinter::VisitOMPTeamsDistributeParallelForSimdDirective(
866 Indent() <<
"#pragma omp teams distribute parallel for simd";
867 PrintOMPExecutableDirective(Node);
870 void StmtPrinter::VisitOMPTeamsDistributeParallelForDirective(
872 Indent() <<
"#pragma omp teams distribute parallel for";
873 PrintOMPExecutableDirective(Node);
877 Indent() <<
"#pragma omp target teams";
878 PrintOMPExecutableDirective(Node);
881 void StmtPrinter::VisitOMPTargetTeamsDistributeDirective(
883 Indent() <<
"#pragma omp target teams distribute";
884 PrintOMPExecutableDirective(Node);
887 void StmtPrinter::VisitOMPTargetTeamsDistributeParallelForDirective(
889 Indent() <<
"#pragma omp target teams distribute parallel for";
890 PrintOMPExecutableDirective(Node);
893 void StmtPrinter::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
895 Indent() <<
"#pragma omp target teams distribute parallel for simd";
896 PrintOMPExecutableDirective(Node);
899 void StmtPrinter::VisitOMPTargetTeamsDistributeSimdDirective(
901 Indent() <<
"#pragma omp target teams distribute simd";
902 PrintOMPExecutableDirective(Node);
909 void StmtPrinter::VisitConstantExpr(
ConstantExpr *Node) {
913 void StmtPrinter::VisitDeclRefExpr(
DeclRefExpr *Node) {
914 if (
const auto *OCED = dyn_cast<OMPCapturedExprDecl>(Node->
getDecl())) {
915 OCED->getInit()->IgnoreImpCasts()->printPretty(OS,
nullptr, Policy);
919 Qualifier->print(OS, Policy);
927 void StmtPrinter::VisitDependentScopeDeclRefExpr(
930 Qualifier->print(OS, Policy);
949 if (
const auto *DRE = dyn_cast<DeclRefExpr>(E)) {
950 if (
const auto *PD = dyn_cast<ImplicitParamDecl>(DRE->getDecl())) {
952 DRE->getBeginLoc().isInvalid())
964 OS << (Node->
isArrow() ?
"->" :
".");
982 Getter->getSelector().print(OS);
1052 if (value < 256 &&
isPrintable((
unsigned char)value))
1053 OS <<
"'" << (
char)value <<
"'";
1054 else if (value < 256)
1055 OS <<
"'\\x" << llvm::format(
"%02x", value) <<
"'";
1056 else if (value <= 0xFFFF)
1057 OS <<
"'\\u" << llvm::format(
"%04x", value) <<
"'";
1059 OS <<
"'\\U" << llvm::format(
"%08x", value) <<
"'";
1069 bool Invalid =
false;
1084 OS << Node->
getValue().toString(10, isSigned);
1088 default: llvm_unreachable(
"Unexpected type for integer literal!");
1089 case BuiltinType::Char_S:
1090 case BuiltinType::Char_U: OS <<
"i8";
break;
1091 case BuiltinType::UChar: OS <<
"Ui8";
break;
1092 case BuiltinType::Short: OS <<
"i16";
break;
1093 case BuiltinType::UShort: OS <<
"Ui16";
break;
1094 case BuiltinType::Int:
break;
1095 case BuiltinType::UInt: OS <<
'U';
break;
1096 case BuiltinType::Long: OS <<
'L';
break;
1097 case BuiltinType::ULong: OS <<
"UL";
break;
1098 case BuiltinType::LongLong: OS <<
"LL";
break;
1099 case BuiltinType::ULongLong: OS <<
"ULL";
break;
1109 default: llvm_unreachable(
"Unexpected type for fixed point literal!");
1110 case BuiltinType::ShortFract: OS <<
"hr";
break;
1111 case BuiltinType::ShortAccum: OS <<
"hk";
break;
1112 case BuiltinType::UShortFract: OS <<
"uhr";
break;
1113 case BuiltinType::UShortAccum: OS <<
"uhk";
break;
1114 case BuiltinType::Fract: OS <<
"r";
break;
1115 case BuiltinType::Accum: OS <<
"k";
break;
1116 case BuiltinType::UFract: OS <<
"ur";
break;
1117 case BuiltinType::UAccum: OS <<
"uk";
break;
1118 case BuiltinType::LongFract: OS <<
"lr";
break;
1119 case BuiltinType::LongAccum: OS <<
"lk";
break;
1120 case BuiltinType::ULongFract: OS <<
"ulr";
break;
1121 case BuiltinType::ULongAccum: OS <<
"ulk";
break;
1130 if (Str.find_first_not_of(
"-0123456789") == StringRef::npos)
1138 default: llvm_unreachable(
"Unexpected type for float literal!");
1139 case BuiltinType::Half:
break;
1140 case BuiltinType::Double:
break;
1141 case BuiltinType::Float16: OS <<
"F16";
break;
1142 case BuiltinType::Float: OS <<
'F';
break;
1143 case BuiltinType::LongDouble: OS <<
'L';
break;
1144 case BuiltinType::Float128: OS <<
'Q';
break;
1163 void StmtPrinter::VisitParenExpr(
ParenExpr *Node) {
1195 void StmtPrinter::VisitOffsetOfExpr(
OffsetOfExpr *Node) {
1196 OS <<
"__builtin_offsetof(";
1199 bool PrintedSomething =
false;
1207 PrintedSomething =
true;
1220 if (PrintedSomething)
1223 PrintedSomething =
true;
1249 OS <<
"__builtin_omp_required_simd_align";
1271 T.
print(OS, Policy);
1279 PrintExpr(Node->
getLHS());
1281 PrintExpr(Node->
getRHS());
1298 void StmtPrinter::PrintCallArgs(
CallExpr *Call) {
1299 for (
unsigned i = 0, e = Call->
getNumArgs(); i != e; ++i) {
1300 if (isa<CXXDefaultArgExpr>(Call->
getArg(i))) {
1306 PrintExpr(Call->
getArg(i));
1310 void StmtPrinter::VisitCallExpr(
CallExpr *Call) {
1313 PrintCallArgs(Call);
1318 if (
const auto *TE = dyn_cast<CXXThisExpr>(E))
1319 return TE->isImplicit();
1323 void StmtPrinter::VisitMemberExpr(
MemberExpr *Node) {
1329 ParentMember ? dyn_cast<
FieldDecl>(ParentMember->getMemberDecl())
1332 if (!ParentDecl || !ParentDecl->isAnonymousStructOrUnion())
1333 OS << (Node->
isArrow() ?
"->" :
".");
1337 if (FD->isAnonymousStructOrUnion())
1341 Qualifier->
print(OS, Policy);
1349 void StmtPrinter::VisitObjCIsaExpr(
ObjCIsaExpr *Node) {
1351 OS << (Node->
isArrow() ?
"->isa" :
".isa");
1380 PrintExpr(Node->
getLHS());
1382 PrintExpr(Node->
getRHS());
1386 PrintExpr(Node->
getLHS());
1388 PrintExpr(Node->
getRHS());
1394 PrintExpr(Node->
getLHS());
1396 PrintExpr(Node->
getRHS());
1412 void StmtPrinter::VisitStmtExpr(
StmtExpr *E) {
1418 void StmtPrinter::VisitChooseExpr(
ChooseExpr *Node) {
1419 OS <<
"__builtin_choose_expr(";
1422 PrintExpr(Node->
getLHS());
1424 PrintExpr(Node->
getRHS());
1428 void StmtPrinter::VisitGNUNullExpr(
GNUNullExpr *) {
1433 OS <<
"__builtin_shufflevector(";
1442 OS <<
"__builtin_convertvector(";
1449 void StmtPrinter::VisitInitListExpr(
InitListExpr* Node) {
1456 for (
unsigned i = 0, e = Node->
getNumInits(); i != e; ++i) {
1480 for (
unsigned i = 0, e = Node->
getNumExprs(); i != e; ++i) {
1488 bool NeedsEquals =
true;
1490 if (D.isFieldDesignator()) {
1491 if (D.getDotLoc().isInvalid()) {
1493 OS << II->getName() <<
":";
1494 NeedsEquals =
false;
1497 OS <<
"." << D.getFieldName()->getName();
1501 if (D.isArrayDesignator()) {
1519 void StmtPrinter::VisitDesignatedInitUpdateExpr(
1526 OS <<
"/*updater*/";
1531 void StmtPrinter::VisitNoInitExpr(
NoInitExpr *Node) {
1532 OS <<
"/*no init*/";
1537 OS <<
"/*implicit*/";
1541 OS <<
"/*implicit*/(";
1551 void StmtPrinter::VisitVAArgExpr(
VAArgExpr *Node) {
1552 OS <<
"__builtin_va_arg(";
1563 void StmtPrinter::VisitAtomicExpr(
AtomicExpr *Node) {
1564 const char *Name =
nullptr;
1565 switch (Node->
getOp()) {
1566 #define BUILTIN(ID, TYPE, ATTRS) 1567 #define ATOMIC_BUILTIN(ID, TYPE, ATTRS) \ 1568 case AtomicExpr::AO ## ID: \ 1571 #include "clang/Basic/Builtins.def" 1576 PrintExpr(Node->
getPtr());
1577 if (Node->
getOp() != AtomicExpr::AO__c11_atomic_load &&
1578 Node->
getOp() != AtomicExpr::AO__atomic_load_n &&
1579 Node->
getOp() != AtomicExpr::AO__opencl_atomic_load) {
1583 if (Node->
getOp() == AtomicExpr::AO__atomic_exchange ||
1588 if (Node->
getOp() == AtomicExpr::AO__atomic_compare_exchange ||
1589 Node->
getOp() == AtomicExpr::AO__atomic_compare_exchange_n) {
1593 if (Node->
getOp() != AtomicExpr::AO__c11_atomic_init &&
1594 Node->
getOp() != AtomicExpr::AO__opencl_atomic_init) {
1609 #define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \ 1611 #include "clang/Basic/OperatorKinds.def" 1615 if (Kind == OO_PlusPlus || Kind == OO_MinusMinus) {
1617 OS << OpStrings[
Kind] <<
' ';
1618 PrintExpr(Node->
getArg(0));
1620 PrintExpr(Node->
getArg(0));
1621 OS <<
' ' << OpStrings[
Kind];
1623 }
else if (Kind == OO_Arrow) {
1624 PrintExpr(Node->
getArg(0));
1625 }
else if (Kind == OO_Call) {
1626 PrintExpr(Node->
getArg(0));
1628 for (
unsigned ArgIdx = 1; ArgIdx < Node->
getNumArgs(); ++ArgIdx) {
1631 if (!isa<CXXDefaultArgExpr>(Node->
getArg(ArgIdx)))
1632 PrintExpr(Node->
getArg(ArgIdx));
1635 }
else if (Kind == OO_Subscript) {
1636 PrintExpr(Node->
getArg(0));
1638 PrintExpr(Node->
getArg(1));
1641 OS << OpStrings[
Kind] <<
' ';
1642 PrintExpr(Node->
getArg(0));
1644 PrintExpr(Node->
getArg(0));
1645 OS <<
' ' << OpStrings[
Kind] <<
' ';
1646 PrintExpr(Node->
getArg(1));
1648 llvm_unreachable(
"unknown overloaded operator");
1655 if (MD && isa<CXXConversionDecl>(MD)) {
1659 VisitCallExpr(cast<CallExpr>(Node));
1667 PrintCallArgs(Node);
1680 VisitCXXNamedCastExpr(Node);
1684 VisitCXXNamedCastExpr(Node);
1688 VisitCXXNamedCastExpr(Node);
1692 VisitCXXNamedCastExpr(Node);
1723 Qualifier->print(OS, Policy);
1730 PrintExpr(Node->
getIdx());
1742 cast<FunctionDecl>(DRE->getDecl())->getTemplateSpecializationArgs();
1745 if (Args->size() != 1) {
1754 char C = (char)
P.getAsIntegral().getZExtValue();
1762 OS << Int->getValue().toString(10,
false);
1780 OS << (Node->
getValue() ?
"true" :
"false");
1787 void StmtPrinter::VisitCXXThisExpr(
CXXThisExpr *Node) {
1791 void StmtPrinter::VisitCXXThrowExpr(
CXXThrowExpr *Node) {
1833 Arg != ArgEnd; ++Arg) {
1834 if ((*Arg)->isDefaultArgument())
1848 void StmtPrinter::VisitLambdaExpr(
LambdaExpr *Node) {
1850 bool NeedComma =
false;
1869 if (
C->capturesVLAType())
1876 switch (
C->getCaptureKind()) {
1888 OS <<
C->getCapturedVar()->getName();
1892 OS <<
C->getCapturedVar()->getName();
1896 llvm_unreachable(
"VLA type in explicit captures.");
1900 PrintExpr(
C->getCapturedVar()->getInit());
1914 std::string ParamStr =
P->getNameAsString();
1915 P->getOriginalType().print(OS, Policy, ParamStr);
1935 Proto->getReturnType().print(OS, Policy);
1947 TSInfo->getType().print(OS, Policy);
1953 void StmtPrinter::VisitCXXNewExpr(
CXXNewExpr *E) {
1961 for (
unsigned i = 1; i < NumPlace; ++i) {
1973 llvm::raw_string_ostream s(TypeS);
1975 Size->printPretty(s, Helper, Policy);
2012 OS << II->getName();
2021 for (
unsigned i = 0, e = E->
getNumArgs(); i != e; ++i) {
2022 if (isa<CXXDefaultArgExpr>(E->
getArg(i))) {
2037 OS <<
"<forwarded>";
2050 StmtPrinter::VisitCXXUnresolvedConstructExpr(
2056 Arg != ArgEnd; ++Arg) {
2064 void StmtPrinter::VisitCXXDependentScopeMemberExpr(
2068 OS << (Node->
isArrow() ?
"->" :
".");
2071 Qualifier->print(OS, Policy);
2082 OS << (Node->
isArrow() ?
"->" :
".");
2085 Qualifier->print(OS, Policy);
2095 #define TYPE_TRAIT_1(Spelling, Name, Key) \ 2096 case clang::UTT_##Name: return #Spelling; 2097 #define TYPE_TRAIT_2(Spelling, Name, Key) \ 2098 case clang::BTT_##Name: return #Spelling; 2099 #define TYPE_TRAIT_N(Spelling, Name, Key) \ 2100 case clang::TT_##Name: return #Spelling; 2101 #include "clang/Basic/TokenKinds.def" 2103 llvm_unreachable(
"Type trait not covered by switch");
2111 llvm_unreachable(
"Array type trait not covered by switch");
2119 llvm_unreachable(
"Expression type trait not covered by switch");
2124 for (
unsigned I = 0, N = E->
getNumArgs(); I != N; ++I) {
2156 OS <<
"sizeof...(" << *E->
getPack() <<
")";
2159 void StmtPrinter::VisitSubstNonTypeTemplateParmPackExpr(
2164 void StmtPrinter::VisitSubstNonTypeTemplateParmExpr(
2177 void StmtPrinter::VisitCXXFoldExpr(
CXXFoldExpr *E) {
2206 void StmtPrinter::VisitCoawaitExpr(
CoawaitExpr *S) {
2216 void StmtPrinter::VisitCoyieldExpr(
CoyieldExpr *S) {
2236 for (
auto I = Ch.begin(), E = Ch.end(); I != E; ++I) {
2237 if (I != Ch.begin())
2253 Visit(Element.
Value);
2273 OS <<
"@protocol(" << *Node->
getProtocol() <<
')';
2298 for (
unsigned i = 0, e = Mess->
getNumArgs(); i != e; ++i) {
2300 if (i > 0) OS <<
' ';
2308 PrintExpr(Mess->
getArg(i));
2315 OS << (Node->
getValue() ?
"__objc_yes" :
"__objc_no");
2331 void StmtPrinter::VisitBlockExpr(
BlockExpr *Node) {
2337 if (isa<FunctionNoProtoType>(AFT)) {
2339 }
else if (!BD->
param_empty() || cast<FunctionProtoType>(AFT)->isVariadic()) {
2344 std::string ParamStr = (*AI)->getNameAsString();
2345 (*AI)->getType().print(OS, Policy, ParamStr);
2348 const auto *FT = cast<FunctionProtoType>(AFT);
2349 if (FT->isVariadic()) {
2362 void StmtPrinter::VisitTypoExpr(
TypoExpr *Node) {
2364 llvm_unreachable(
"Cannot print TypoExpr nodes");
2367 void StmtPrinter::VisitAsTypeExpr(
AsTypeExpr *Node) {
2368 OS <<
"__builtin_astype(";
2387 StmtPrinter
P(OS, Helper, Policy, Indentation, NL, Context);
2388 P.Visit(const_cast<Stmt*>(
this));
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.
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.
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
Retrieves 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.
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
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
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
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.
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.
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".
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.
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.
const Expr * getControllingExpr() const
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...
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.
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...
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand...
InitListExpr * getUpdater() const
ConstantExpr - An expression that occurs in a constant context.
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...
Pepresents 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
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
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
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 call to a member function that may be written either with member call syntax (e...
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
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 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.
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.
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.
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.
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.
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.
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)
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.
ParmVarDecl * getParameterPack() const
Get the parameter pack which this expression refers to.
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.
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.