47 #include "llvm/ADT/ArrayRef.h" 48 #include "llvm/ADT/SmallString.h" 49 #include "llvm/ADT/SmallVector.h" 50 #include "llvm/ADT/StringRef.h" 51 #include "llvm/Support/Casting.h" 52 #include "llvm/Support/Compiler.h" 53 #include "llvm/Support/ErrorHandling.h" 54 #include "llvm/Support/Format.h" 55 #include "llvm/Support/raw_ostream.h" 59 using namespace clang;
67 class StmtPrinter :
public StmtVisitor<StmtPrinter> {
80 : OS(os), IndentLevel(Indentation), Helper(helper), Policy(Policy),
81 NL(NL), Context(Context) {}
83 void PrintStmt(
Stmt *S) {
87 void PrintStmt(
Stmt *S,
int SubIndent) {
88 IndentLevel += SubIndent;
89 if (S && isa<Expr>(S)) {
97 Indent() <<
"<<<NULL STATEMENT>>>" << NL;
99 IndentLevel -= SubIndent;
102 void PrintInitStmt(
Stmt *S,
unsigned PrefixWidth) {
104 IndentLevel += (PrefixWidth + 1) / 2;
105 if (
auto *DS = dyn_cast<DeclStmt>(S))
106 PrintRawDeclStmt(DS);
108 PrintExpr(cast<Expr>(S));
110 IndentLevel -= (PrefixWidth + 1) / 2;
113 void PrintControlledStmt(
Stmt *S) {
114 if (
auto *CS = dyn_cast<CompoundStmt>(S)) {
116 PrintRawCompoundStmt(CS);
125 void PrintRawDecl(
Decl *D);
126 void PrintRawDeclStmt(
const DeclStmt *S);
127 void PrintRawIfStmt(
IfStmt *If);
133 bool ForceNoStmt =
false);
135 void PrintExpr(
Expr *E) {
142 raw_ostream &
Indent(
int Delta = 0) {
143 for (
int i = 0, e = IndentLevel+Delta; i < e; ++i)
148 void Visit(
Stmt* S) {
154 void VisitStmt(
Stmt *
Node) LLVM_ATTRIBUTE_UNUSED {
155 Indent() <<
"<<unknown stmt type>>" << NL;
158 void VisitExpr(
Expr *
Node) LLVM_ATTRIBUTE_UNUSED {
159 OS <<
"<<unknown expr type>>";
164 #define ABSTRACT_STMT(CLASS) 165 #define STMT(CLASS, PARENT) \ 166 void Visit##CLASS(CLASS *Node); 167 #include "clang/AST/StmtNodes.inc" 180 for (
auto *I : Node->
body())
186 void StmtPrinter::PrintRawDecl(
Decl *D) {
187 D->
print(OS, Policy, IndentLevel);
190 void StmtPrinter::PrintRawDeclStmt(
const DeclStmt *S) {
199 void StmtPrinter::VisitDeclStmt(
DeclStmt *Node) {
201 PrintRawDeclStmt(Node);
205 void StmtPrinter::VisitCompoundStmt(
CompoundStmt *Node) {
207 PrintRawCompoundStmt(Node);
211 void StmtPrinter::VisitCaseStmt(
CaseStmt *Node) {
213 PrintExpr(Node->
getLHS());
216 PrintExpr(Node->
getRHS());
223 void StmtPrinter::VisitDefaultStmt(
DefaultStmt *Node) {
224 Indent(-1) <<
"default:" << NL;
228 void StmtPrinter::VisitLabelStmt(
LabelStmt *Node) {
241 void StmtPrinter::PrintRawIfStmt(
IfStmt *If) {
244 PrintInitStmt(If->
getInit(), 4);
246 PrintRawDeclStmt(DS);
251 if (
auto *CS = dyn_cast<CompoundStmt>(If->
getThen())) {
253 PrintRawCompoundStmt(CS);
254 OS << (If->
getElse() ?
" " : NL);
264 if (
auto *CS = dyn_cast<CompoundStmt>(Else)) {
266 PrintRawCompoundStmt(CS);
268 }
else if (
auto *ElseIf = dyn_cast<IfStmt>(Else)) {
270 PrintRawIfStmt(ElseIf);
278 void StmtPrinter::VisitIfStmt(
IfStmt *If) {
283 void StmtPrinter::VisitSwitchStmt(
SwitchStmt *Node) {
286 PrintInitStmt(Node->
getInit(), 8);
288 PrintRawDeclStmt(DS);
292 PrintControlledStmt(Node->
getBody());
295 void StmtPrinter::VisitWhileStmt(
WhileStmt *Node) {
298 PrintRawDeclStmt(DS);
305 void StmtPrinter::VisitDoStmt(
DoStmt *Node) {
307 if (
auto *CS = dyn_cast<CompoundStmt>(Node->
getBody())) {
308 PrintRawCompoundStmt(CS);
321 void StmtPrinter::VisitForStmt(
ForStmt *Node) {
324 PrintInitStmt(Node->
getInit(), 5);
326 OS << (Node->
getCond() ?
"; " :
";");
332 PrintExpr(Node->
getInc());
335 PrintControlledStmt(Node->
getBody());
340 if (
auto *DS = dyn_cast<DeclStmt>(Node->
getElement()))
341 PrintRawDeclStmt(DS);
347 PrintControlledStmt(Node->
getBody());
353 PrintInitStmt(Node->
getInit(), 5);
360 PrintControlledStmt(Node->
getBody());
366 OS <<
"__if_exists (";
368 OS <<
"__if_not_exists (";
372 Qualifier->print(OS, Policy);
379 void StmtPrinter::VisitGotoStmt(
GotoStmt *Node) {
391 void StmtPrinter::VisitContinueStmt(
ContinueStmt *Node) {
396 void StmtPrinter::VisitBreakStmt(
BreakStmt *Node) {
401 void StmtPrinter::VisitReturnStmt(
ReturnStmt *Node) {
411 void StmtPrinter::VisitGCCAsmStmt(
GCCAsmStmt *Node) {
428 for (
unsigned i = 0, e = Node->
getNumOutputs(); i != e; ++i) {
449 for (
unsigned i = 0, e = Node->
getNumInputs(); i != e; ++i) {
480 for (
unsigned i = 0, e = Node->
getNumLabels(); i != e; ++i) {
490 void StmtPrinter::VisitMSAsmStmt(
MSAsmStmt *Node) {
500 void StmtPrinter::VisitCapturedStmt(
CapturedStmt *Node) {
506 if (
auto *TS = dyn_cast<CompoundStmt>(Node->
getTryBody())) {
507 PrintRawCompoundStmt(TS);
519 if (
auto *CS = dyn_cast<CompoundStmt>(catchStmt->
getCatchBody())) {
520 PrintRawCompoundStmt(CS);
525 if (
auto *FS = static_cast<ObjCAtFinallyStmt *>(Node->
getFinallyStmt())) {
527 PrintRawCompoundStmt(dyn_cast<CompoundStmt>(FS->getFinallyBody()));
536 Indent() <<
"@catch (...) { /* todo */ } " << NL;
548 void StmtPrinter::VisitObjCAvailabilityCheckExpr(
550 OS <<
"@available(...)";
554 Indent() <<
"@synchronized (";
562 Indent() <<
"@autoreleasepool";
563 PrintRawCompoundStmt(dyn_cast<CompoundStmt>(Node->
getSubStmt()));
567 void StmtPrinter::PrintRawCXXCatchStmt(
CXXCatchStmt *Node) {
570 PrintRawDecl(ExDecl);
577 void StmtPrinter::VisitCXXCatchStmt(
CXXCatchStmt *Node) {
579 PrintRawCXXCatchStmt(Node);
583 void StmtPrinter::VisitCXXTryStmt(
CXXTryStmt *Node) {
593 void StmtPrinter::VisitSEHTryStmt(
SEHTryStmt *Node) {
599 PrintRawSEHExceptHandler(E);
601 assert(F &&
"Must have a finally block...");
602 PrintRawSEHFinallyStmt(F);
609 PrintRawCompoundStmt(Node->
getBlock());
613 void StmtPrinter::PrintRawSEHExceptHandler(
SEHExceptStmt *Node) {
617 PrintRawCompoundStmt(Node->
getBlock());
623 PrintRawSEHExceptHandler(Node);
629 PrintRawSEHFinallyStmt(Node);
633 void StmtPrinter::VisitSEHLeaveStmt(
SEHLeaveStmt *Node) {
646 for (
auto *Clause : Clauses)
647 if (Clause && !Clause->isImplicit()) {
649 Printer.
Visit(Clause);
657 Indent() <<
"#pragma omp parallel";
658 PrintOMPExecutableDirective(Node);
662 Indent() <<
"#pragma omp simd";
663 PrintOMPExecutableDirective(Node);
667 Indent() <<
"#pragma omp for";
668 PrintOMPExecutableDirective(Node);
672 Indent() <<
"#pragma omp for simd";
673 PrintOMPExecutableDirective(Node);
677 Indent() <<
"#pragma omp sections";
678 PrintOMPExecutableDirective(Node);
682 Indent() <<
"#pragma omp section";
683 PrintOMPExecutableDirective(Node);
687 Indent() <<
"#pragma omp single";
688 PrintOMPExecutableDirective(Node);
692 Indent() <<
"#pragma omp master";
693 PrintOMPExecutableDirective(Node);
697 Indent() <<
"#pragma omp critical";
703 PrintOMPExecutableDirective(Node);
707 Indent() <<
"#pragma omp parallel for";
708 PrintOMPExecutableDirective(Node);
711 void StmtPrinter::VisitOMPParallelForSimdDirective(
713 Indent() <<
"#pragma omp parallel for simd";
714 PrintOMPExecutableDirective(Node);
717 void StmtPrinter::VisitOMPParallelMasterDirective(
719 Indent() <<
"#pragma omp parallel master";
720 PrintOMPExecutableDirective(Node);
723 void StmtPrinter::VisitOMPParallelSectionsDirective(
725 Indent() <<
"#pragma omp parallel sections";
726 PrintOMPExecutableDirective(Node);
730 Indent() <<
"#pragma omp task";
731 PrintOMPExecutableDirective(Node);
735 Indent() <<
"#pragma omp taskyield";
736 PrintOMPExecutableDirective(Node);
740 Indent() <<
"#pragma omp barrier";
741 PrintOMPExecutableDirective(Node);
745 Indent() <<
"#pragma omp taskwait";
746 PrintOMPExecutableDirective(Node);
750 Indent() <<
"#pragma omp taskgroup";
751 PrintOMPExecutableDirective(Node);
755 Indent() <<
"#pragma omp flush";
756 PrintOMPExecutableDirective(Node);
760 Indent() <<
"#pragma omp ordered";
765 Indent() <<
"#pragma omp atomic";
766 PrintOMPExecutableDirective(Node);
770 Indent() <<
"#pragma omp target";
771 PrintOMPExecutableDirective(Node);
775 Indent() <<
"#pragma omp target data";
776 PrintOMPExecutableDirective(Node);
779 void StmtPrinter::VisitOMPTargetEnterDataDirective(
781 Indent() <<
"#pragma omp target enter data";
782 PrintOMPExecutableDirective(Node,
true);
785 void StmtPrinter::VisitOMPTargetExitDataDirective(
787 Indent() <<
"#pragma omp target exit data";
788 PrintOMPExecutableDirective(Node,
true);
791 void StmtPrinter::VisitOMPTargetParallelDirective(
793 Indent() <<
"#pragma omp target parallel";
794 PrintOMPExecutableDirective(Node);
797 void StmtPrinter::VisitOMPTargetParallelForDirective(
799 Indent() <<
"#pragma omp target parallel for";
800 PrintOMPExecutableDirective(Node);
804 Indent() <<
"#pragma omp teams";
805 PrintOMPExecutableDirective(Node);
808 void StmtPrinter::VisitOMPCancellationPointDirective(
810 Indent() <<
"#pragma omp cancellation point " 812 PrintOMPExecutableDirective(Node);
816 Indent() <<
"#pragma omp cancel " 818 PrintOMPExecutableDirective(Node);
822 Indent() <<
"#pragma omp taskloop";
823 PrintOMPExecutableDirective(Node);
826 void StmtPrinter::VisitOMPTaskLoopSimdDirective(
828 Indent() <<
"#pragma omp taskloop simd";
829 PrintOMPExecutableDirective(Node);
832 void StmtPrinter::VisitOMPMasterTaskLoopDirective(
834 Indent() <<
"#pragma omp master taskloop";
835 PrintOMPExecutableDirective(Node);
838 void StmtPrinter::VisitOMPMasterTaskLoopSimdDirective(
840 Indent() <<
"#pragma omp master taskloop simd";
841 PrintOMPExecutableDirective(Node);
844 void StmtPrinter::VisitOMPParallelMasterTaskLoopDirective(
846 Indent() <<
"#pragma omp parallel master taskloop";
847 PrintOMPExecutableDirective(Node);
850 void StmtPrinter::VisitOMPParallelMasterTaskLoopSimdDirective(
852 Indent() <<
"#pragma omp parallel master taskloop simd";
853 PrintOMPExecutableDirective(Node);
857 Indent() <<
"#pragma omp distribute";
858 PrintOMPExecutableDirective(Node);
861 void StmtPrinter::VisitOMPTargetUpdateDirective(
863 Indent() <<
"#pragma omp target update";
864 PrintOMPExecutableDirective(Node,
true);
867 void StmtPrinter::VisitOMPDistributeParallelForDirective(
869 Indent() <<
"#pragma omp distribute parallel for";
870 PrintOMPExecutableDirective(Node);
873 void StmtPrinter::VisitOMPDistributeParallelForSimdDirective(
875 Indent() <<
"#pragma omp distribute parallel for simd";
876 PrintOMPExecutableDirective(Node);
879 void StmtPrinter::VisitOMPDistributeSimdDirective(
881 Indent() <<
"#pragma omp distribute simd";
882 PrintOMPExecutableDirective(Node);
885 void StmtPrinter::VisitOMPTargetParallelForSimdDirective(
887 Indent() <<
"#pragma omp target parallel for simd";
888 PrintOMPExecutableDirective(Node);
892 Indent() <<
"#pragma omp target simd";
893 PrintOMPExecutableDirective(Node);
896 void StmtPrinter::VisitOMPTeamsDistributeDirective(
898 Indent() <<
"#pragma omp teams distribute";
899 PrintOMPExecutableDirective(Node);
902 void StmtPrinter::VisitOMPTeamsDistributeSimdDirective(
904 Indent() <<
"#pragma omp teams distribute simd";
905 PrintOMPExecutableDirective(Node);
908 void StmtPrinter::VisitOMPTeamsDistributeParallelForSimdDirective(
910 Indent() <<
"#pragma omp teams distribute parallel for simd";
911 PrintOMPExecutableDirective(Node);
914 void StmtPrinter::VisitOMPTeamsDistributeParallelForDirective(
916 Indent() <<
"#pragma omp teams distribute parallel for";
917 PrintOMPExecutableDirective(Node);
921 Indent() <<
"#pragma omp target teams";
922 PrintOMPExecutableDirective(Node);
925 void StmtPrinter::VisitOMPTargetTeamsDistributeDirective(
927 Indent() <<
"#pragma omp target teams distribute";
928 PrintOMPExecutableDirective(Node);
931 void StmtPrinter::VisitOMPTargetTeamsDistributeParallelForDirective(
933 Indent() <<
"#pragma omp target teams distribute parallel for";
934 PrintOMPExecutableDirective(Node);
937 void StmtPrinter::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
939 Indent() <<
"#pragma omp target teams distribute parallel for simd";
940 PrintOMPExecutableDirective(Node);
943 void StmtPrinter::VisitOMPTargetTeamsDistributeSimdDirective(
945 Indent() <<
"#pragma omp target teams distribute simd";
946 PrintOMPExecutableDirective(Node);
957 void StmtPrinter::VisitConstantExpr(
ConstantExpr *Node) {
961 void StmtPrinter::VisitDeclRefExpr(
DeclRefExpr *Node) {
962 if (
const auto *OCED = dyn_cast<OMPCapturedExprDecl>(Node->
getDecl())) {
963 OCED->getInit()->IgnoreImpCasts()->printPretty(OS,
nullptr, Policy);
967 Qualifier->print(OS, Policy);
975 void StmtPrinter::VisitDependentScopeDeclRefExpr(
978 Qualifier->print(OS, Policy);
997 if (
const auto *DRE = dyn_cast<DeclRefExpr>(E)) {
998 if (
const auto *PD = dyn_cast<ImplicitParamDecl>(DRE->getDecl())) {
1000 DRE->getBeginLoc().isInvalid())
1012 OS << (Node->
isArrow() ?
"->" :
".");
1030 Getter->getSelector().print(OS);
1100 if (value < 256 &&
isPrintable((
unsigned char)value))
1101 OS <<
"'" << (
char)value <<
"'";
1102 else if (value < 256)
1103 OS <<
"'\\x" << llvm::format(
"%02x", value) <<
"'";
1104 else if (value <= 0xFFFF)
1105 OS <<
"'\\u" << llvm::format(
"%04x", value) <<
"'";
1107 OS <<
"'\\U" << llvm::format(
"%08x", value) <<
"'";
1117 bool Invalid =
false;
1132 OS << Node->
getValue().toString(10, isSigned);
1136 default: llvm_unreachable(
"Unexpected type for integer literal!");
1137 case BuiltinType::Char_S:
1138 case BuiltinType::Char_U: OS <<
"i8";
break;
1139 case BuiltinType::UChar: OS <<
"Ui8";
break;
1140 case BuiltinType::Short: OS <<
"i16";
break;
1141 case BuiltinType::UShort: OS <<
"Ui16";
break;
1142 case BuiltinType::Int:
break;
1143 case BuiltinType::UInt: OS <<
'U';
break;
1144 case BuiltinType::Long: OS <<
'L';
break;
1145 case BuiltinType::ULong: OS <<
"UL";
break;
1146 case BuiltinType::LongLong: OS <<
"LL";
break;
1147 case BuiltinType::ULongLong: OS <<
"ULL";
break;
1157 default: llvm_unreachable(
"Unexpected type for fixed point literal!");
1158 case BuiltinType::ShortFract: OS <<
"hr";
break;
1159 case BuiltinType::ShortAccum: OS <<
"hk";
break;
1160 case BuiltinType::UShortFract: OS <<
"uhr";
break;
1161 case BuiltinType::UShortAccum: OS <<
"uhk";
break;
1162 case BuiltinType::Fract: OS <<
"r";
break;
1163 case BuiltinType::Accum: OS <<
"k";
break;
1164 case BuiltinType::UFract: OS <<
"ur";
break;
1165 case BuiltinType::UAccum: OS <<
"uk";
break;
1166 case BuiltinType::LongFract: OS <<
"lr";
break;
1167 case BuiltinType::LongAccum: OS <<
"lk";
break;
1168 case BuiltinType::ULongFract: OS <<
"ulr";
break;
1169 case BuiltinType::ULongAccum: OS <<
"ulk";
break;
1178 if (Str.find_first_not_of(
"-0123456789") == StringRef::npos)
1186 default: llvm_unreachable(
"Unexpected type for float literal!");
1187 case BuiltinType::Half:
break;
1188 case BuiltinType::Double:
break;
1189 case BuiltinType::Float16: OS <<
"F16";
break;
1190 case BuiltinType::Float: OS <<
'F';
break;
1191 case BuiltinType::LongDouble: OS <<
'L';
break;
1192 case BuiltinType::Float128: OS <<
'Q';
break;
1211 void StmtPrinter::VisitParenExpr(
ParenExpr *Node) {
1243 void StmtPrinter::VisitOffsetOfExpr(
OffsetOfExpr *Node) {
1244 OS <<
"__builtin_offsetof(";
1247 bool PrintedSomething =
false;
1255 PrintedSomething =
true;
1268 if (PrintedSomething)
1271 PrintedSomething =
true;
1297 OS <<
"__builtin_omp_required_simd_align";
1319 T.
print(OS, Policy);
1321 PrintExpr(Assoc.getAssociationExpr());
1327 PrintExpr(Node->
getLHS());
1329 PrintExpr(Node->
getRHS());
1346 void StmtPrinter::PrintCallArgs(
CallExpr *Call) {
1347 for (
unsigned i = 0, e = Call->
getNumArgs(); i != e; ++i) {
1348 if (isa<CXXDefaultArgExpr>(Call->
getArg(i))) {
1354 PrintExpr(Call->
getArg(i));
1358 void StmtPrinter::VisitCallExpr(
CallExpr *Call) {
1361 PrintCallArgs(Call);
1366 if (
const auto *TE = dyn_cast<CXXThisExpr>(E))
1367 return TE->isImplicit();
1371 void StmtPrinter::VisitMemberExpr(
MemberExpr *Node) {
1377 ParentMember ? dyn_cast<
FieldDecl>(ParentMember->getMemberDecl())
1380 if (!ParentDecl || !ParentDecl->isAnonymousStructOrUnion())
1381 OS << (Node->
isArrow() ?
"->" :
".");
1385 if (FD->isAnonymousStructOrUnion())
1389 Qualifier->
print(OS, Policy);
1397 void StmtPrinter::VisitObjCIsaExpr(
ObjCIsaExpr *Node) {
1399 OS << (Node->
isArrow() ?
"->isa" :
".isa");
1428 PrintExpr(Node->
getLHS());
1430 PrintExpr(Node->
getRHS());
1434 PrintExpr(Node->
getLHS());
1436 PrintExpr(Node->
getRHS());
1442 PrintExpr(Node->
getLHS());
1444 PrintExpr(Node->
getRHS());
1460 void StmtPrinter::VisitStmtExpr(
StmtExpr *E) {
1466 void StmtPrinter::VisitChooseExpr(
ChooseExpr *Node) {
1467 OS <<
"__builtin_choose_expr(";
1470 PrintExpr(Node->
getLHS());
1472 PrintExpr(Node->
getRHS());
1476 void StmtPrinter::VisitGNUNullExpr(
GNUNullExpr *) {
1481 OS <<
"__builtin_shufflevector(";
1490 OS <<
"__builtin_convertvector(";
1497 void StmtPrinter::VisitInitListExpr(
InitListExpr* Node) {
1504 for (
unsigned i = 0, e = Node->
getNumInits(); i != e; ++i) {
1528 for (
unsigned i = 0, e = Node->
getNumExprs(); i != e; ++i) {
1536 bool NeedsEquals =
true;
1538 if (D.isFieldDesignator()) {
1539 if (D.getDotLoc().isInvalid()) {
1541 OS << II->getName() <<
":";
1542 NeedsEquals =
false;
1545 OS <<
"." << D.getFieldName()->getName();
1549 if (D.isArrayDesignator()) {
1567 void StmtPrinter::VisitDesignatedInitUpdateExpr(
1574 OS <<
"/*updater*/";
1579 void StmtPrinter::VisitNoInitExpr(
NoInitExpr *Node) {
1580 OS <<
"/*no init*/";
1585 OS <<
"/*implicit*/";
1589 OS <<
"/*implicit*/(";
1599 void StmtPrinter::VisitVAArgExpr(
VAArgExpr *Node) {
1600 OS <<
"__builtin_va_arg(";
1611 void StmtPrinter::VisitAtomicExpr(
AtomicExpr *Node) {
1612 const char *Name =
nullptr;
1613 switch (Node->
getOp()) {
1614 #define BUILTIN(ID, TYPE, ATTRS) 1615 #define ATOMIC_BUILTIN(ID, TYPE, ATTRS) \ 1616 case AtomicExpr::AO ## ID: \ 1619 #include "clang/Basic/Builtins.def" 1624 PrintExpr(Node->
getPtr());
1625 if (Node->
getOp() != AtomicExpr::AO__c11_atomic_load &&
1626 Node->
getOp() != AtomicExpr::AO__atomic_load_n &&
1627 Node->
getOp() != AtomicExpr::AO__opencl_atomic_load) {
1631 if (Node->
getOp() == AtomicExpr::AO__atomic_exchange ||
1636 if (Node->
getOp() == AtomicExpr::AO__atomic_compare_exchange ||
1637 Node->
getOp() == AtomicExpr::AO__atomic_compare_exchange_n) {
1641 if (Node->
getOp() != AtomicExpr::AO__c11_atomic_init &&
1642 Node->
getOp() != AtomicExpr::AO__opencl_atomic_init) {
1656 if (Kind == OO_PlusPlus || Kind == OO_MinusMinus) {
1659 PrintExpr(Node->
getArg(0));
1661 PrintExpr(Node->
getArg(0));
1664 }
else if (Kind == OO_Arrow) {
1665 PrintExpr(Node->
getArg(0));
1666 }
else if (Kind == OO_Call) {
1667 PrintExpr(Node->
getArg(0));
1669 for (
unsigned ArgIdx = 1; ArgIdx < Node->
getNumArgs(); ++ArgIdx) {
1672 if (!isa<CXXDefaultArgExpr>(Node->
getArg(ArgIdx)))
1673 PrintExpr(Node->
getArg(ArgIdx));
1676 }
else if (Kind == OO_Subscript) {
1677 PrintExpr(Node->
getArg(0));
1679 PrintExpr(Node->
getArg(1));
1683 PrintExpr(Node->
getArg(0));
1685 PrintExpr(Node->
getArg(0));
1687 PrintExpr(Node->
getArg(1));
1689 llvm_unreachable(
"unknown overloaded operator");
1696 if (MD && isa<CXXConversionDecl>(MD)) {
1700 VisitCallExpr(cast<CallExpr>(Node));
1708 PrintCallArgs(Node);
1712 void StmtPrinter::VisitCXXRewrittenBinaryOperator(
1716 PrintExpr(const_cast<Expr*>(Decomposed.
LHS));
1718 PrintExpr(const_cast<Expr*>(Decomposed.
RHS));
1730 VisitCXXNamedCastExpr(Node);
1734 VisitCXXNamedCastExpr(Node);
1738 VisitCXXNamedCastExpr(Node);
1742 VisitCXXNamedCastExpr(Node);
1746 OS <<
"__builtin_bit_cast(";
1781 Qualifier->print(OS, Policy);
1788 PrintExpr(Node->
getIdx());
1800 cast<FunctionDecl>(DRE->getDecl())->getTemplateSpecializationArgs();
1803 if (Args->size() != 1) {
1812 char C = (char)
P.getAsIntegral().getZExtValue();
1820 OS << Int->getValue().toString(10,
false);
1838 OS << (Node->
getValue() ?
"true" :
"false");
1845 void StmtPrinter::VisitCXXThisExpr(
CXXThisExpr *Node) {
1849 void StmtPrinter::VisitCXXThrowExpr(
CXXThrowExpr *Node) {
1891 Arg != ArgEnd; ++Arg) {
1892 if ((*Arg)->isDefaultArgument())
1906 void StmtPrinter::VisitLambdaExpr(
LambdaExpr *Node) {
1908 bool NeedComma =
false;
1927 if (
C->capturesVLAType())
1934 switch (
C->getCaptureKind()) {
1946 OS <<
C->getCapturedVar()->getName();
1950 OS <<
C->getCapturedVar()->getName();
1954 llvm_unreachable(
"VLA type in explicit captures.");
1957 if (
C->isPackExpansion())
1961 PrintExpr(
C->getCapturedVar()->getInit());
1981 std::string ParamStr =
P->getNameAsString();
1982 P->getOriginalType().print(OS, Policy, ParamStr);
2002 Proto->getReturnType().print(OS, Policy);
2011 PrintRawCompoundStmt(Node->
getBody());
2016 TSInfo->getType().print(OS, Policy);
2022 void StmtPrinter::VisitCXXNewExpr(
CXXNewExpr *E) {
2030 for (
unsigned i = 1; i < NumPlace; ++i) {
2042 llvm::raw_string_ostream s(TypeS);
2045 (*Size)->printPretty(s, Helper, Policy);
2082 OS << II->getName();
2091 for (
unsigned i = 0, e = E->
getNumArgs(); i != e; ++i) {
2092 if (isa<CXXDefaultArgExpr>(E->
getArg(i))) {
2107 OS <<
"<forwarded>";
2120 StmtPrinter::VisitCXXUnresolvedConstructExpr(
2126 Arg != ArgEnd; ++Arg) {
2134 void StmtPrinter::VisitCXXDependentScopeMemberExpr(
2138 OS << (Node->
isArrow() ?
"->" :
".");
2141 Qualifier->print(OS, Policy);
2152 OS << (Node->
isArrow() ?
"->" :
".");
2155 Qualifier->print(OS, Policy);
2165 #define TYPE_TRAIT_1(Spelling, Name, Key) \ 2166 case clang::UTT_##Name: return #Spelling; 2167 #define TYPE_TRAIT_2(Spelling, Name, Key) \ 2168 case clang::BTT_##Name: return #Spelling; 2169 #define TYPE_TRAIT_N(Spelling, Name, Key) \ 2170 case clang::TT_##Name: return #Spelling; 2171 #include "clang/Basic/TokenKinds.def" 2173 llvm_unreachable(
"Type trait not covered by switch");
2181 llvm_unreachable(
"Array type trait not covered by switch");
2189 llvm_unreachable(
"Expression type trait not covered by switch");
2194 for (
unsigned I = 0, N = E->
getNumArgs(); I != N; ++I) {
2226 OS <<
"sizeof...(" << *E->
getPack() <<
")";
2229 void StmtPrinter::VisitSubstNonTypeTemplateParmPackExpr(
2234 void StmtPrinter::VisitSubstNonTypeTemplateParmExpr(
2247 void StmtPrinter::VisitCXXFoldExpr(
CXXFoldExpr *E) {
2275 if (!LocalParameters.empty()) {
2278 PrintRawDecl(LocalParam);
2279 if (LocalParam != LocalParameters.back())
2288 if (
auto *TypeReq = dyn_cast<concepts::TypeRequirement>(Req)) {
2289 if (TypeReq->isSubstitutionFailure())
2290 OS <<
"<<error-type>>";
2292 TypeReq->getType()->getType().print(OS, Policy);
2293 }
else if (
auto *ExprReq = dyn_cast<concepts::ExprRequirement>(Req)) {
2294 if (ExprReq->isCompound())
2296 if (ExprReq->isExprSubstitutionFailure())
2297 OS <<
"<<error-expression>>";
2299 PrintExpr(ExprReq->getExpr());
2300 if (ExprReq->isCompound()) {
2302 if (ExprReq->getNoexceptLoc().isValid())
2304 const auto &RetReq = ExprReq->getReturnTypeRequirement();
2305 if (!RetReq.isEmpty()) {
2307 if (RetReq.isSubstitutionFailure())
2308 OS <<
"<<error-type>>";
2309 else if (RetReq.isTypeConstraint())
2310 RetReq.getTypeConstraint()->print(OS, Policy);
2314 auto *NestedReq = cast<concepts::NestedRequirement>(Req);
2316 if (NestedReq->isSubstitutionFailure())
2317 OS <<
"<<error-expression>>";
2319 PrintExpr(NestedReq->getConstraintExpr());
2341 void StmtPrinter::VisitCoawaitExpr(
CoawaitExpr *S) {
2351 void StmtPrinter::VisitCoyieldExpr(
CoyieldExpr *S) {
2371 for (
auto I = Ch.begin(), E = Ch.end(); I != E; ++I) {
2372 if (I != Ch.begin())
2388 Visit(Element.
Value);
2408 OS <<
"@protocol(" << *Node->
getProtocol() <<
')';
2433 for (
unsigned i = 0, e = Mess->
getNumArgs(); i != e; ++i) {
2435 if (i > 0) OS <<
' ';
2443 PrintExpr(Mess->
getArg(i));
2450 OS << (Node->
getValue() ?
"__objc_yes" :
"__objc_no");
2466 void StmtPrinter::VisitBlockExpr(
BlockExpr *Node) {
2472 if (isa<FunctionNoProtoType>(AFT)) {
2474 }
else if (!BD->
param_empty() || cast<FunctionProtoType>(AFT)->isVariadic()) {
2479 std::string ParamStr = (*AI)->getNameAsString();
2480 (*AI)->getType().print(OS, Policy, ParamStr);
2483 const auto *FT = cast<FunctionProtoType>(AFT);
2484 if (FT->isVariadic()) {
2497 void StmtPrinter::VisitTypoExpr(
TypoExpr *Node) {
2499 llvm_unreachable(
"Cannot print TypoExpr nodes");
2502 void StmtPrinter::VisitAsTypeExpr(
AsTypeExpr *Node) {
2503 OS <<
"__builtin_astype(";
2520 StringRef NL,
const ASTContext *Context)
const {
2521 StmtPrinter
P(Out, Helper, Policy, Indentation, NL, Context);
2522 P.Visit(const_cast<Stmt *>(
this));
2528 llvm::raw_string_ostream TempOut(Buf);
2530 printPretty(TempOut, Helper, Policy);
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
const Expr * getSubExpr() const
ObjCIndirectCopyRestoreExpr - Represents the passing of a function argument by indirect copy-restore ...
A call to an overloaded operator written using operator syntax.
The receiver is the instance of the superclass object.
ExprIterator arg_iterator
Represents a single C99 designator.
Raw form: operator "" X (const char *)
Defines the clang::ASTContext interface.
const BlockDecl * getBlockDecl() const
This represents '#pragma omp distribute simd' composite directive.
This represents '#pragma omp master' directive.
operator "" X (long double)
TypeSourceInfo * getTypeOperandSourceInfo() const
Retrieve source information for the type operand.
The null pointer literal (C++11 [lex.nullptr])
capture_iterator explicit_capture_end() const
Retrieve an iterator pointing past the end of the sequence of explicit lambda captures.
This represents '#pragma omp task' directive.
This represents a GCC inline-assembly statement extension.
Represents a 'co_await' expression while the type of the promise is dependent.
Expr * getArrayIndex(const Designator &D) const
The receiver is an object instance.
bool hasExplicitTemplateArgs() const
Determines whether this expression had explicit template arguments.
unsigned getNumInputs() const
Expr * getSyntacticForm()
Return the syntactic form of this expression, i.e.
bool hasTemplateKeyword() const
Determines whether the name was preceded by the template keyword.
bool hasTemplateKeyword() const
Determines whether the member name was preceded by the template keyword.
ObjCDictionaryElement getKeyValueElement(unsigned Index) const
const FunctionProtoType * getFunctionType() const
getFunctionType - Return the underlying function type for this block.
CompoundStmt * getBlock() const
Smart pointer class that efficiently represents Objective-C method names.
A (possibly-)qualified type.
ArrayRef< TemplateArgumentLoc > template_arguments() const
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
ArrayRef< OMPClause * > clauses()
unsigned SuppressInitializers
Suppress printing of variable initializers.
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
Selector getSelector() const
Defines enumerations for the type traits support.
const Expr * getSubExpr() const
Expr * getExpr(unsigned Index)
getExpr - Return the Expr at the specified index.
unsigned getNumSubExprs() const
getNumSubExprs - Return the size of the SubExprs array.
bool isSuperReceiver() const
A type trait used in the implementation of various C++11 and Library TR1 trait templates.
ArrayRef< ParmVarDecl * > getLocalParameters() const
VarDecl * getParameterPack() const
Get the parameter pack which this expression refers to.
CompoundStmt * getSubStmt()
const Expr * getInit(unsigned Init) const
Expr * getControllingExpr()
Return the controlling expression of this generic selection expression.
bool hasExplicitResultType() const
Whether this lambda had its result type explicitly specified.
ObjCProtocolDecl * getProtocol() const
Represents a 'co_return' statement in the C++ Coroutines TS.
Stmt - This represents one statement.
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
const ObjCAtFinallyStmt * getFinallyStmt() const
Retrieve the @finally statement, if any.
FunctionType - C99 6.7.5.3 - Function Declarators.
CXXCatchStmt * getHandler(unsigned i)
IfStmt - This represents an if/then/else.
C Language Family Type Representation.
unsigned getNumOutputs() const
static CharSourceRange getTokenRange(SourceRange R)
This represents '#pragma omp for simd' directive.
bool isRecordType() const
const StringLiteral * getAsmString() const
Decl - This represents one declaration (or definition), e.g.
This represents '#pragma omp teams distribute parallel for' composite directive.
Expr * getImplicitObjectArgument() const
Retrieve the implicit object argument for the member call.
Stmt * getHandlerBlock() const
llvm::APFloat getValue() const
ObjCMethodDecl * getImplicitPropertySetter() const
Represents the index of the current element of an array being initialized by an ArrayInitLoopExpr.
param_iterator param_end()
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
const Expr * getSubExpr() const
DeclarationNameInfo getNameInfo() const
Retrieve the name of the entity we're testing for, along with location information.
Defines the C++ template declaration subclasses.
This represents '#pragma omp parallel master' directive.
CapturedStmt * getInnermostCapturedStmt()
Get innermost captured statement for the construct.
Represents an attribute applied to a statement.
ParenExpr - This represents a parethesized expression, e.g.
static bool isImplicitThis(const Expr *E)
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies this name, if any.
Expr * getLowerBound()
Get lower bound of array section.
This represents '#pragma omp target teams distribute' combined directive.
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies this declaration.
Represents Objective-C's @throw statement.
bool hasExplicitTemplateArgs() const
Determines whether this declaration reference was followed by an explicit template argument list...
llvm::iterator_range< child_iterator > child_range
Represents a call to a C++ constructor.
ObjCSubscriptRefExpr - used for array and dictionary subscripting.
TypeSourceInfo * getTypeInfoAsWritten() const
getTypeInfoAsWritten - Returns the type source info for the type that this expression is casting to...
An Embarcadero array type trait, as used in the implementation of __array_rank and __array_extent...
A container of type source information.
NestedNameSpecifier * getQualifier() const
If the member name was qualified, retrieves the nested-name-specifier that precedes the member name...
static void printGroup(Decl **Begin, unsigned NumDecls, raw_ostream &Out, const PrintingPolicy &Policy, unsigned Indentation=0)
This represents '#pragma omp parallel for' directive.
MS property subscript expression.
IdentKind getIdentKind() const
This represents '#pragma omp target teams distribute parallel for' combined directive.
Describes the capture of a variable or of this, or of a C++1y init-capture.
Represents a prvalue temporary that is written into memory so that a reference can bind to it...
MutableArrayRef< ParmVarDecl * >::iterator param_iterator
void printExceptionSpecification(raw_ostream &OS, const PrintingPolicy &Policy) const
const Expr * getSubExpr() const
Expr * getIndexExpr(unsigned Idx)
This represents '#pragma omp target exit data' directive.
ObjCIsaExpr - Represent X->isa and X.isa when X is an ObjC 'id' type.
CompoundLiteralExpr - [C99 6.5.2.5].
unsigned getNumArgs() const
Determine the number of arguments to this type trait.
ObjCInterfaceDecl * getClassReceiver() const
DecomposedForm getDecomposedForm() const LLVM_READONLY
Decompose this operator into its syntactic form.
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]).
llvm::ArrayRef< TemplateArgumentLoc > arguments() const
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.
Represents a parameter to a function.
Defines the clang::Expr interface and subclasses for C++ expressions.
StringRef getInputName(unsigned i) const
unsigned TerseOutput
Provide a 'terse' output.
CXXRecordDecl * getLambdaClass() const
Retrieve the class that corresponds to the lambda.
ObjCPropertyDecl * getExplicitProperty() const
A C++ static_cast expression (C++ [expr.static.cast]).
Expr * getExprOperand() const
const Stmt * getSubStmt() const
LabelStmt - Represents a label, which has a substatement.
Represents a C99 designated initializer expression.
NamedDecl * getFoundDecl() const
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.
Represents a function call to one of __builtin_LINE(), __builtin_COLUMN(), __builtin_FUNCTION(), or __builtin_FILE().
An element in an Objective-C dictionary literal.
C++2a [expr.prim.req]: A requires-expression provides a concise way to express requirements on templa...
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 ...
A C++ nested-name-specifier augmented with source location information.
Expr * getInit() const
Retrieve the initializer value.
Used for GCC's __alignof.
void printJson(raw_ostream &Out, PrinterHelper *Helper, const PrintingPolicy &Policy, bool AddQuotes) const
Pretty-prints in JSON format.
Represents a member of a struct/union/class.
Expr * getBase()
Retrieve the base object of this member expressions, e.g., the x in x.m.
Represents a place-holder for an object not to be initialized by anything.
const DeclarationNameInfo & getNameInfo() const
Gets the full name info.
StringLiteral * getString()
RetTy Visit(PTR(OMPClause) S)
CompoundStmt * getBody() const
Retrieve the body of the lambda.
unsigned getArrayExprIndex() const
For an array element node, returns the index into the array of expressions.
bool hasExplicitTemplateArgs() const
Determines whether the member name was followed by an explicit template argument list.
GNUNullExpr - Implements the GNU __null extension, which is a name for a null pointer constant that h...
QualType getDestroyedType() const
Retrieve the type being destroyed.
This represents '#pragma omp target simd' directive.
Expr * getSourceExpr() const
The source expression of an opaque value expression is the expression which originally generated the ...
Represents a C++ member access expression for which lookup produced a set of overloaded functions...
Defines some OpenMP-specific enums and functions.
ExtVectorElementExpr - This represents access to specific elements of a vector, and may occur on the ...
This represents '#pragma omp barrier' directive.
ObjCArrayLiteral - used for objective-c array containers; as in: @["Hello", NSApp, [NSNumber numberWithInt:42]];.
Represents a reference to a non-type template parameter pack that has been substituted with a non-tem...
This represents '#pragma omp critical' directive.
LambdaCaptureDefault getCaptureDefault() const
Determine the default capture kind for this lambda.
OpenMPDirectiveKind getCancelRegion() const
Get cancellation region for the current cancellation point.
ArrayRef< TemplateArgumentLoc > template_arguments() const
bool hasExplicitTemplateArgs() const
Determines whether this lookup had explicit template arguments.
Selector getSelector() const
ArrayRef< ParmVarDecl * > parameters() const
bool isUnarySelector() const
Represents Objective-C's @catch statement.
StringRef getOpcodeStr() const
IndirectGotoStmt - This represents an indirect goto.
Describes an C or C++ initializer list.
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
This represents '#pragma omp distribute parallel for' composite directive.
Stmt * getBody() const override
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
Expr * getKeyExpr() const
This represents '#pragma omp teams distribute parallel for simd' composite directive.
Optional< Expr * > getArraySize()
std::string JsonFormat(StringRef RawSR, bool AddQuotes)
ForStmt - This represents a 'for (init;cond;inc)' stmt.
Expr * getBaseExpr() const
Expr * getOperand() const
const Expr * getThrowExpr() const
< Capturing the *this object by copy
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
void print(raw_ostream &OS, const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) const
Expr * getInitializer()
The initializer of this new-expression.
A builtin binary operation expression such as "x + y" or "x <= y".
Expr * getOutputExpr(unsigned i)
ArrayRef< TemplateArgumentLoc > template_arguments() const
bool isClassReceiver() const
const StringLiteral * getInputConstraintLiteral(unsigned i) const
static bool isPostfix(Opcode Op)
isPostfix - Return true if this is a postfix operation, like x++.
CXXForRangeStmt - This represents C++0x [stmt.ranged]'s ranged for statement, represented as 'for (ra...
This represents '#pragma omp cancellation point' directive.
ObjCStringLiteral, used for Objective-C string literals i.e.
const CallExpr * getConfig() const
New-expression has a C++98 paren-delimited initializer.
CaseStmt - Represent a case statement.
TypoExpr - Internal placeholder for expressions where typo correction still needs to be performed and...
This represents '#pragma omp teams' directive.
NestedNameSpecifier * getQualifier() const
Fetches the nested-name qualifier, if one was given.
Helper class for OffsetOfExpr.
Expr * getOperand() const
This represents '#pragma omp teams distribute simd' combined directive.
AssociationTy< false > Association
Represents binding an expression to a temporary.
StringLiteral * getClobberStringLiteral(unsigned i)
StringRef getOutputName(unsigned i) const
ArrayTypeTrait
Names for the array type traits.
Expr * Key
The key for the dictionary element.
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
Represents a C++ member access expression where the actual member referenced could not be resolved be...
bool isInitCapture(const LambdaCapture *Capture) const
Determine whether one of this lambda's captures is an init-capture.
void print(raw_ostream &OS, const PrintingPolicy &Policy, bool ResolveTemplateArguments=false) const
Print this nested name specifier to the given output stream.
TypeSourceInfo * getTypeSourceInfo() const
A default argument (C++ [dcl.fct.default]).
bool isTypeOperand() const
const IdentifierInfo * getUDSuffix() const
Returns the ud-suffix specified for this literal.
Expr * IgnoreImpCasts() LLVM_READONLY
Skip past any implicit casts which might surround this expression until reaching a fixed point...
Represents the this expression in C++.
TypeTrait
Names for traits that operate specifically on types.
const ObjCAtCatchStmt * getCatchStmt(unsigned I) const
Retrieve a @catch statement.
This represents '#pragma omp target parallel for simd' directive.
QualType getTypeAsWritten() const
getTypeAsWritten - Returns the type that this expression is casting to, as written in the source code...
OpenMP 4.0 [2.4, Array Sections].
ConditionalOperator - The ?: ternary operator.
bool isStdInitListInitialization() const
Whether this constructor call was written as list-initialization, but was interpreted as forming a st...
Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
CompoundStmt - This represents a group of statements like { stmt stmt }.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Represents a prototype with parameter type info, e.g.
QualType getQueriedType() const
CompoundStmt * getSubStmt() const
Retrieve the compound statement that will be included in the program only if the existence of the sym...
This represents '#pragma omp taskgroup' directive.
unsigned SuppressImplicitBase
When true, don't print the implicit 'self' or 'this' expressions.
NestedNameSpecifier * getQualifier() const
If the member name was qualified, retrieves the nested-name-specifier that precedes the member name...
StringRef getBuiltinStr() const
Return a string representing the name of the specific builtin function.
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand...
InitListExpr * getUpdater() const
ConstantExpr - An expression that occurs in a constant context and optionally the result of evaluatin...
Represents a call to the builtin function __builtin_va_arg.
void outputString(raw_ostream &OS) const
bool isImplicitAccess() const
True if this is an implicit access, i.e.
static StringRef getSourceText(CharSourceRange Range, const SourceManager &SM, const LangOptions &LangOpts, bool *Invalid=nullptr)
Returns a string for the source that the range encompasses.
unsigned getValue() const
This represents '#pragma omp distribute' directive.
This represents implicit clause 'depend' for the '#pragma omp task' directive.
Expr * getSrcExpr() const
getSrcExpr - Return the Expr to be converted.
An expression "T()" which creates a value-initialized rvalue of type T, which is a non-class type...
Represents a block literal declaration, which is like an unnamed FunctionDecl.
llvm::MutableArrayRef< Designator > designators()
This represents one expression.
bool isVariadic() const
Whether this function is variadic.
IdentifierInfo * getFieldName() const
For a field or identifier offsetof node, returns the name of the field.
bool isArrow() const
Determine whether this member expression used the '->' operator; otherwise, it used the '...
static void PrintFloatingLiteral(raw_ostream &OS, FloatingLiteral *Node, bool PrintSuffix)
bool isImplicitAccess() const
True if this is an implicit access, i.e., one in which the member being accessed was not written in t...
This represents '#pragma omp master taskloop' directive.
const T * castAs() const
Member-template castAs<specific type>.
Represents a C++ functional cast expression that builds a temporary object.
A C++ const_cast expression (C++ [expr.const.cast]).
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
VarDecl * getExceptionDecl() const
IdentifierInfo * getDestroyedTypeIdentifier() const
In a dependent pseudo-destructor expression for which we do not have full type information on the des...
unsigned getNumInits() const
Expr * getSubExpr() const
Get the initializer to use for each array element.
Defines an enumeration for C++ overloaded operators.
This represents '#pragma omp target teams distribute parallel for simd' combined directive.
QualType getArgumentType() const
bool isArrow() const
Determine whether this pseudo-destructor expression was written using an '->' (otherwise, it used a '.
StringRef getNameForSlot(unsigned argIndex) const
Retrieve the name at a given position in the selector.
ObjCDictionaryLiteral - AST node to represent objective-c dictionary literals; as in:"name" : NSUserN...
const CompoundStmt * getSynchBody() const
Represents Objective-C's @synchronized statement.
ObjCSelectorExpr used for @selector in Objective-C.
TypeSourceInfo * getTypeSourceInfo() const
Represents an expression that computes the length of a parameter pack.
CXXTryStmt - A C++ try block, including all handlers.
AsTypeExpr - Clang builtin function __builtin_astype [OpenCL 6.2.4.2] This AST node provides support ...
IdentifierInfo & getAccessor() const
This represents '#pragma omp target teams distribute simd' combined directive.
ArrayTypeTrait getTrait() const
void printTemplateArgumentList(raw_ostream &OS, ArrayRef< TemplateArgument > Args, const PrintingPolicy &Policy)
Print a template argument list, including the '<' and '>' enclosing the template arguments.
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char, signed char, short, int, long..], or an enum decl which has a signed representation.
Kind getKind() const
Determine what kind of offsetof node this is.
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
void print(llvm::raw_ostream &OS) const
Prints the full selector name (e.g. "foo:bar:").
virtual bool handledStmt(Stmt *E, raw_ostream &OS)=0
This represents '#pragma omp for' directive.
LabelDecl * getLabel() const
const Stmt * getTryBody() const
Retrieve the @try body.
Represents a folding of a pack over an operator.
QualType getEncodedType() const
ReturnStmt - This represents a return, optionally of an expression: return; return 4;...
This represents '#pragma omp target teams' directive.
An expression that sends a message to the given Objective-C object or class.
This represents a Microsoft inline-assembly statement extension.
ObjCMethodDecl * getImplicitPropertyGetter() const
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
CXXMethodDecl * getMethodDecl() const
Retrieve the declaration of the called method.
ReceiverKind getReceiverKind() const
Determine the kind of receiver that this message is being sent to.
A member reference to an MSPropertyDecl.
Represents a reference to a non-type template parameter that has been substituted with a template arg...
const OffsetOfNode & getComponent(unsigned Idx) const
unsigned getNumArgs() const
This represents '#pragma omp cancel' directive.
Selector getSelector() const
const Expr * getSubExpr() const
const Expr * getSubExpr() const
CStyleCastExpr - An explicit cast in C (C99 6.5.4) or a C-style cast in C++ (C++ [expr.cast]), which uses the syntax (Type)expr.
CXXMethodDecl * getCallOperator() const
Retrieve the function call operator associated with this lambda expression.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Expr * getLHS()
An array access can be written A[4] or 4[A] (both are equivalent).
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
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.
ArrayRef< concepts::Requirement * > getRequirements() const
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.
This represents '#pragma omp parallel master taskloop' directive.
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 '#pragma omp master taskloop simd' directive.
A C++ dynamic_cast expression (C++ [expr.dynamic.cast]).
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
ConvertVectorExpr - Clang builtin function __builtin_convertvector This AST node provides support for...
unsigned getNumArgs() const
Return the number of actual arguments in this message, not counting the receiver. ...
static StringRef getIdentKindName(IdentKind IK)
This captures a statement into a function.
Represents a call to an inherited base class constructor from an inheriting constructor.
operator "" X (const CharT *, size_t)
ExpressionTrait getTrait() const
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
bool isImplicitProperty() const
IdentifierInfo * getIdentifierInfoForSlot(unsigned argIndex) const
Retrieve the identifier at a given position in the selector.
Raw form: operator "" X<cs...> ()
unsigned getNumExprs() const
Return the number of expressions in this paren list.
This represents '#pragma omp single' directive.
unsigned Indentation
The number of spaces to use to indent each line.
capture_iterator explicit_capture_begin() const
Retrieve an iterator pointing to the first explicit lambda capture.
Defines enumerations for expression traits intrinsics.
unsigned ConstantsAsWritten
Whether we should print the constant expressions as written in the sources.
unsigned UnderscoreAlignof
Whether we can use '_Alignof' rather than '__alignof'.
const Stmt * getCatchBody() const
StringRef getLabelName(unsigned i) const
unsigned getNumHandlers() const
Expr * getSubExpr() const
bool hasExplicitTemplateArgs() const
Determines whether this member expression actually had a C++ template argument list explicitly specif...
This is a basic class for representing single OpenMP executable directive.
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)"...
unsigned getNumElements() const
getNumElements - Return number of elements of objective-c dictionary literal.
static const char * getExpressionTraitName(ExpressionTrait ET)
A call to a literal operator (C++11 [over.literal]) written as a user-defined literal (C++11 [lit...
DeclarationName getName() const
getName - Returns the embedded declaration name.
Represents a C++2a __builtin_bit_cast(T, v) expression.
Represents a call to a member function that may be written either with member call syntax (e...
ASTContext & getASTContext() const LLVM_READONLY
Defines several types used to describe C++ lambda expressions that are shared between the parser and ...
DeclStmt - Adaptor class for mixing declarations with statements and expressions. ...
DeclarationNameInfo getDirectiveName() const
Return name of the directive.
Represents a static or instance method of a struct/union/class.
std::string getValueAsString(unsigned Radix) const
StmtVisitor - This class implements a simple visitor for Stmt subclasses.
SourceLocation getColonLoc() const
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
This represents '#pragma omp taskwait' directive.
QualType getAllocatedType() const
This file defines OpenMP nodes for declarative directives.
AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*, __atomic_load, __atomic_store, and __atomic_compare_exchange_*, for the similarly-named C++11 instructions, and __c11 variants for <stdatomic.h>, and corresponding __opencl_atomic_* for OpenCL 2.0.
UnaryExprOrTypeTrait getKind() const
ArrayRef< NamedDecl * > getExplicitTemplateParameters() const
Get the template parameters were explicitly specified (as opposed to being invented by use of an auto...
Expr * getExpr(unsigned Init)
ObjCProtocolExpr used for protocol expression in Objective-C.
const StringLiteral * getOutputConstraintLiteral(unsigned i) const
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
Stmt * getCapturedStmt()
Retrieve the statement being captured.
bool hasTemplateKeyword() const
Determines whether the member name was preceded by the template keyword.
CharacterKind getKind() const
This represents '#pragma omp target' directive.
Expr * getInputExpr(unsigned i)
static const char * getTypeTraitName(TypeTrait TT)
void dumpPretty(const ASTContext &Context) const
dumpPretty/printPretty - These two methods do a "pretty print" of the AST back to its original source...
Used for C's _Alignof and C++'s alignof.
bool isParenTypeId() const
void printPretty(raw_ostream &OS, const PrintingPolicy &Policy) const
Expr * getArrayRangeStart(const Designator &D) const
An expression trait intrinsic.
A static requirement that can be used in a requires-expression to check properties of types and expre...
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 ...
This represents '#pragma omp parallel master taskloop simd' directive.
Representation of a Microsoft __if_exists or __if_not_exists statement with a dependent name...
bool hasTemplateKeyword() const
Determines whether the name in this declaration reference was preceded by the template keyword...
A qualified reference to a name whose declaration cannot yet be resolved.
Expr * Value
The value of the dictionary element.
const Expr * getInitializer() const
InitializationStyle getInitializationStyle() const
The kind of initializer this new-expression has.
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
CompoundAssignOperator - For compound assignments (e.g.
Represents a C11 generic selection.
StringRef getName() const
Return the actual identifier string.
const Expr * getBase() const
Expr * getInstanceReceiver()
Returns the object expression (receiver) for an instance message, or null for a message that is not a...
AddrLabelExpr - The GNU address of label extension, representing &&label.
An Objective-C "bridged" cast expression, which casts between Objective-C pointers and C pointers...
ast_type_traits::DynTypedNode Node
Represents a reference to a function parameter pack or init-capture pack that has been substituted bu...
Represents a template argument.
Expr * getFalseExpr() const
getFalseExpr - Return the subexpression which will be evaluated if the condnition evaluates to false;...
NullStmt - This is the null statement ";": C99 6.8.3p3.
bool isMutable() const
Determine whether the lambda is mutable, meaning that any captures values can be modified.
bool isTypeOperand() const
Dataflow Directional Tag Classes.
static std::string getPropertyNameFromSetterSelector(Selector Sel)
Return the property name for the given setter selector.
NestedNameSpecifier * getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
bool isValid() const
Return true if this is a valid SourceLocation object.
[C99 6.4.2.2] - A predefined identifier such as func.
DeclarationNameInfo getMemberNameInfo() const
Retrieve the member declaration name info.
Represents a delete expression for memory deallocation and destructor calls, e.g. ...
OverloadedOperatorKind getOperator() const
Returns the kind of overloaded operator that this expression refers to.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
NonTypeTemplateParmDecl * getParameterPack() const
Retrieve the non-type template parameter pack being substituted.
MSPropertyDecl * getPropertyDecl() const
ArrayRef< const Attr * > getAttrs() const
Parameter for Objective-C 'self' argument.
This represents '#pragma omp section' directive.
This represents '#pragma omp teams distribute' directive.
A runtime availability query.
void print(raw_ostream &Out, const ASTContext &Context, bool OmitTemplateKW=false) const
A C++ reinterpret_cast expression (C++ [expr.reinterpret.cast]).
This represents '#pragma omp simd' directive.
Represents a 'co_yield' expression.
Expr * getOperand() const
Retrieve the operand of the 'co_return' statement.
Represents a C++11 pack expansion that produces a sequence of expressions.
bool isListInitialization() const
Whether this constructor call was written as list-initialization.
SEHExceptStmt * getExceptHandler() const
Returns 0 if not defined.
const NestedNameSpecifierLoc & getNestedNameSpecifierLoc() const
const Expr * getSynchExpr() const
void printName(raw_ostream &OS, PrintingPolicy Policy) const
printName - Print the human-readable name to a stream.
bool isIfExists() const
Determine whether this is an __if_exists statement.
NestedNameSpecifierLoc getQualifierLoc() const
const DeclarationNameInfo & getMemberNameInfo() const
Retrieve the full name info for the member that this expression refers to.
TemplateParameterList * getTemplateParameterList() const
If this is a generic lambda expression, retrieve the template parameter list associated with it...
Expr * getPlacementArg(unsigned I)
This represents '#pragma omp atomic' directive.
DeclStmt * getConditionVariableDeclStmt()
If this IfStmt has a condition variable, return the faux DeclStmt associated with the creation of tha...
TypeSourceInfo * getTypeOperandSourceInfo() const
Retrieve source information for the type operand.
Expr * getArrayRangeEnd(const Designator &D) const
llvm::APInt getValue() const
Represents a __leave statement.
LabelDecl * getLabel() const
QualType getClassReceiver() const
Returns the type of a class message send, or NULL if the message is not a class message.
Represents a C++11 noexcept expression (C++ [expr.unary.noexcept]).
SwitchStmt - This represents a 'switch' stmt.
Capturing variable-length array type.
Expr * getOrderFail() const
DeclarationNameInfo getNameInfo() const
Represents the body of a coroutine.
bool hasTemplateKeyword() const
Determines whether the name was preceded by the template keyword.
Indicates that the tracking object is a descendant of a referenced-counted OSObject, used in the Darwin kernel.
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
This file defines OpenMP AST classes for executable directives and clauses.
Represents Objective-C's collection statement.
ObjCEncodeExpr, used for @encode in Objective-C.
const char * getOperatorSpelling(OverloadedOperatorKind Operator)
Retrieve the spelling of the given overloaded operator, without the preceding "operator" keyword...
An implicit indirection through a C++ base class, when the field found is in a base class...
Represents a call to a CUDA kernel function.
Represents a 'co_await' expression.
Expr * getReplacement() const
Expr * getArg(unsigned Arg)
Return the specified argument.
Represents Objective-C's @finally statement.
StringRef getAsmString() const
unsigned Alignof
Whether we can use 'alignof' rather than '__alignof'.
bool hasAssociatedStmt() const
Returns true if directive has associated statement.
const Expr * getBase() const
bool isArrow() const
Determine whether this member expression used the '->' operator; otherwise, it used the '...
Capturing the *this object by reference.
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.
Represents the specialization of a concept - evaluates to a prvalue of type bool. ...
SourceLocation getLParenLoc() const
This class is used for builtin types like 'int'.
CompoundStmt * getTryBlock()
Represents Objective-C's @try ... @catch ... @finally statement.
SourceLocation getTemplateKWLoc() const
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
bool isGlobalDelete() const
This represents '#pragma omp taskloop simd' directive.
unsigned getNumCatchStmts() const
Retrieve the number of @catch statements in this try-catch-finally block.
Expr * getBase() const
Retrieve the base object of this member expressions, e.g., the x in x.m.
StringLiteral - This represents a string literal expression, e.g.
bool hasExplicitParameters() const
Determine whether this lambda has an explicit parameter list vs.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Expr * getPattern()
Retrieve the pattern of the pack expansion.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
RetTy Visit(PTR(Stmt) S, ParamTys... P)
Stmt * getBody() const
Retrieve the body of the coroutine as written.
static Decl::Kind getKind(const Decl *D)
Abstract class common to all of the C++ "named"/"keyword" casts.
This represents '#pragma omp sections' directive.
ObjCBoolLiteralExpr - Objective-C Boolean Literal.
bool isObjectReceiver() const
unsigned getNumComponents() const
This represents '#pragma omp target data' directive.
OpenMPDirectiveKind getCancelRegion() const
Get cancellation region for the current cancellation point.
raw_ostream & Indent(raw_ostream &Out, const unsigned int Space, bool IsDot)
A rewritten comparison expression that was originally written using operator syntax.
A reference to a declared variable, function, enum, etc.
static bool printExprAsWritten(raw_ostream &OS, Expr *E, const ASTContext *Context)
Prints the given expression using the original source text.
unsigned IncludeNewlines
When true, include newlines after statements like "break", etc.
BreakStmt - This represents a break.
const VarDecl * getCatchParamDecl() const
static bool isImplicitSelf(const Expr *E)
unsigned getNumLabels() const
const char * getCastName() const
getCastName - Get the name of the C++ cast being used, e.g., "static_cast", "dynamic_cast", "reinterpret_cast", or "const_cast".
Expr * getOperand() const
QualType getTypeAsWritten() const
Retrieve the type that is being constructed, as specified in the source code.
unsigned getNumArgs() const
Return the number of arguments to the constructor call.
const Expr * getBase() const
static StringRef getOpcodeStr(Opcode Op)
getOpcodeStr - Turn an Opcode enum value into the punctuation char it corresponds to...
This represents '#pragma omp taskyield' directive.
This represents '#pragma omp distribute parallel for simd' composite directive.
A boolean literal, per ([C++ lex.bool] Boolean literals).
NestedNameSpecifier * getQualifier() const
If the name was qualified, retrieves the nested-name-specifier that precedes the name.
OffsetOfExpr - [C99 7.17] - This represents an expression of the form offsetof(record-type, member-designator).
Expr * getQueriedExpression() const
This represents '#pragma omp parallel sections' directive.
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
Expr * getCommon() const
getCommon - Return the common expression, written to the left of the condition.
The receiver is a superclass.
Expr * getSubExpr() const
Retrieve the temporary-generating subexpression whose value will be materialized into a glvalue...
BinaryOperatorKind getOperator() const
const LangOptions & getLangOpts() const
NamedDecl * getPack() const
Retrieve the parameter pack.
Represents Objective-C's @autoreleasepool Statement.
CompoundStmt * getTryBlock() const
InitListExpr * getSyntacticForm() const
Expr * getBaseExpr() const
Represents an implicitly-generated value initialization of an object of a given type.
CompoundStmt * getBlock() const
This represents '#pragma omp target parallel for' directive.
Attr - This represents one attribute.
operator "" X (unsigned long long)
QualType getType() const
Return the type wrapped by this type source info.
TypeTrait getTrait() const
Determine which type trait this expression uses.
association_range associations()
Expr * getLength()
Get length of array section.
const DeclarationNameInfo & getMemberNameInfo() const
Retrieve the name of the member that this expression refers to.
Expr * getCookedLiteral()
If this is not a raw user-defined literal, get the underlying cooked literal (representing the litera...
Expr * getBase()
An array section can be written only as Base[LowerBound:Length].
This represents '#pragma omp taskloop' directive.