;
51#define STMT(CLASS, PARENT) 52#define STMT_RANGE(BASE, FIRST, LAST) 53#define LAST_STMT_RANGE(BASE, FIRST, LAST) \ 54 static_assert(llvm::isUInt<NumStmtBits>(Stmt::StmtClass::LAST##Class), \ 55 "The number of 'StmtClass'es is strictly bound "\
56"by a bitfield of width NumStmtBits");
57#define ABSTRACT_STMT(STMT) 58#include "clang/AST/StmtNodes.inc" 73#define ABSTRACT_STMT(STMT) 74#define STMT(CLASS, PARENT) \ 75 StmtClassInfo[(unsigned)Stmt::CLASS##Class].Name = #CLASS; \ 76 StmtClassInfo[(unsigned)Stmt::CLASS##Class].Size = sizeof(CLASS); 77#include "clang/AST/StmtNodes.inc" 84return ::operator
new(
bytes,
C, alignment);
94#define STMT(CLASS, PARENT) \ 95 static_assert(!std::is_polymorphic<CLASS>::value, \ 96 #CLASS " should not be polymorphic!");
97#include "clang/AST/StmtNodes.inc" 102#define STMT(CLASS, PARENT) \ 103 static_assert(std::is_trivially_destructible<CLASS>::value, \ 104 #CLASS " should be trivially destructible!");
106#define INITLISTEXPR(CLASS, PARENT) 107#include "clang/AST/StmtNodes.inc" 114llvm::errs() <<
"\n*** Stmt/Expr Stats:\n";
115 for(
inti = 0; i != Stmt::lastStmtConstant+1; i++) {
119llvm::errs() <<
" "<< sum <<
" stmts/exprs total.\n";
121 for(
inti = 0; i != Stmt::lastStmtConstant+1; i++) {
131llvm::errs() <<
"Total bytes = "<< sum <<
"\n";
138boolStmt::StatisticsEnabled =
false;
140StatisticsEnabled =
true;
143staticstd::pair<Stmt::Likelihood, const Attr *>
145 for(
const auto*A : Attrs) {
146 if(isa<LikelyAttr>(A))
149 if(isa<UnlikelyAttr>(A))
157 if(
const auto*AS = dyn_cast_or_null<AttributedStmt>(S))
164return ::getLikelihood(Attrs).first;
168return ::getLikelihood(S).first;
172return ::getLikelihood(S).second;
192std::tuple<bool, const Attr *, const Attr *>
197 if(LHT.first !=
LH_None&& LHT.first == LHE.first)
198 returnstd::make_tuple(
true, LHT.second, LHE.second);
200 returnstd::make_tuple(
false,
nullptr,
nullptr);
208 if(
autoCapS = dyn_cast_or_null<CapturedStmt>(S))
209S = CapS->getCapturedStmt();
211 if(
autoAS = dyn_cast_or_null<AttributedStmt>(S))
212S = AS->getSubStmt();
213 else if(
autoCS = dyn_cast_or_null<CompoundStmt>(S)) {
228 const Stmt*S =
this;
230 if(
const auto*LS = dyn_cast<LabelStmt>(S))
231S = LS->getSubStmt();
232 else if(
const auto*SC = dyn_cast<SwitchCase>(S))
233S = SC->getSubStmt();
234 else if(
const auto*AS = dyn_cast<AttributedStmt>(S))
235S = AS->getSubStmt();
249 staticgood is_good(good) {
returngood(); }
252 template<
classT> good implements_children(children_t
T::*) {
255LLVM_ATTRIBUTE_UNUSED
256 staticbad implements_children(children_t
Stmt::*) {
261 template<
classT> good implements_getBeginLoc(getBeginLoc_t
T::*) {
264LLVM_ATTRIBUTE_UNUSED
265 staticbad implements_getBeginLoc(getBeginLoc_t
Stmt::*) {
returnbad(); }
268 template<
classT> good implements_getEndLoc(getLocEnd_t
T::*) {
271LLVM_ATTRIBUTE_UNUSED
272 staticbad implements_getEndLoc(getLocEnd_t
Stmt::*) {
returnbad(); }
274#define ASSERT_IMPLEMENTS_children(type) \ 275 (void) is_good(implements_children(&type::children)) 276#define ASSERT_IMPLEMENTS_getBeginLoc(type) \ 277 (void)is_good(implements_getBeginLoc(&type::getBeginLoc)) 278#define ASSERT_IMPLEMENTS_getEndLoc(type) \ 279 (void)is_good(implements_getEndLoc(&type::getEndLoc)) 285LLVM_ATTRIBUTE_UNUSED
287#define ABSTRACT_STMT(type) 288#define STMT(type, base) \ 289 ASSERT_IMPLEMENTS_children(type); \ 290 ASSERT_IMPLEMENTS_getBeginLoc(type); \ 291 ASSERT_IMPLEMENTS_getEndLoc(type); 292#include "clang/AST/StmtNodes.inc" 298#define ABSTRACT_STMT(type) 299#define STMT(type, base) \ 300 case Stmt::type##Class: \ 301 return static_cast<type*>(this)->children(); 302#include "clang/AST/StmtNodes.inc" 304llvm_unreachable(
"unknown statement kind!");
315 template<
classS,
classT>
318 return static_cast<constS*
>(
stmt)->getSourceRange();
329 static_cast<constS *
>(
stmt)->getEndLoc());
337#define ABSTRACT_STMT(type) 338#define STMT(type, base) \ 339 case Stmt::type##Class: \ 340 return getSourceRangeImpl<type>(this, &type::getSourceRange); 341#include "clang/AST/StmtNodes.inc" 343llvm_unreachable(
"unknown statement kind!");
349#define ABSTRACT_STMT(type) 350#define STMT(type, base) \ 351 case Stmt::type##Class: \ 352 return static_cast<const type *>(this)->getBeginLoc(); 353#include "clang/AST/StmtNodes.inc" 355llvm_unreachable(
"unknown statement kind");
361#define ABSTRACT_STMT(type) 362#define STMT(type, base) \ 363 case Stmt::type##Class: \ 364 return static_cast<const type *>(this)->getEndLoc(); 365#include "clang/AST/StmtNodes.inc" 367llvm_unreachable(
"unknown statement kind");
376:
Stmt(CompoundStmtClass), LBraceLoc(LB), RBraceLoc(RB) {
380 if(hasStoredFPFeatures())
381setStoredFPFeatures(FPFeatures);
386 "NumStmts doesn't fit in bits of CompoundStmtBits.NumStmts!");
388std::copy(Stmts.begin(), Stmts.end(),
body_begin());
395 C.Allocate(totalSizeToAlloc<Stmt *, FPOptionsOverride>(
398 return new(Mem)
CompoundStmt(Stmts, FPFeatures, LB, RB);
402 boolHasFPFeatures) {
403 void*Mem =
C.Allocate(
404totalSizeToAlloc<Stmt *, FPOptionsOverride>(NumStmts, HasFPFeatures),
413 const Stmt*S =
this;
415 if(
const auto*
E= dyn_cast<Expr>(S))
418 if(
const auto*LS = dyn_cast<LabelStmt>(S))
419S = LS->getSubStmt();
420 else if(
const auto*AS = dyn_cast<AttributedStmt>(S))
421S = AS->getSubStmt();
423llvm_unreachable(
"unknown kind of ValueStmt");
424}
while(isa<ValueStmt>(S));
436assert(!Attrs.empty() &&
"Attrs should not be empty");
437 void*Mem =
C.Allocate(totalSizeToAlloc<const Attr *>(Attrs.size()),
444assert(NumAttrs > 0 &&
"NumAttrs should be greater than zero");
445 void*Mem =
C.Allocate(totalSizeToAlloc<const Attr *>(NumAttrs),
451 if(
const auto*gccAsmStmt = dyn_cast<GCCAsmStmt>(
this))
452 returngccAsmStmt->generateAsmString(
C);
453 if(
const auto*msAsmStmt = dyn_cast<MSAsmStmt>(
this))
454 returnmsAsmStmt->generateAsmString(
C);
455llvm_unreachable(
"unknown asm statement kind!");
459 if(
const auto*gccAsmStmt = dyn_cast<GCCAsmStmt>(
this))
460 returngccAsmStmt->getOutputConstraint(i);
461 if(
const auto*msAsmStmt = dyn_cast<MSAsmStmt>(
this))
462 returnmsAsmStmt->getOutputConstraint(i);
463llvm_unreachable(
"unknown asm statement kind!");
467 if(
const auto*gccAsmStmt = dyn_cast<GCCAsmStmt>(
this))
468 returngccAsmStmt->getOutputExpr(i);
469 if(
const auto*msAsmStmt = dyn_cast<MSAsmStmt>(
this))
470 returnmsAsmStmt->getOutputExpr(i);
471llvm_unreachable(
"unknown asm statement kind!");
475 if(
const auto*gccAsmStmt = dyn_cast<GCCAsmStmt>(
this))
476 returngccAsmStmt->getInputConstraint(i);
477 if(
const auto*msAsmStmt = dyn_cast<MSAsmStmt>(
this))
478 returnmsAsmStmt->getInputConstraint(i);
479llvm_unreachable(
"unknown asm statement kind!");
483 if(
const auto*gccAsmStmt = dyn_cast<GCCAsmStmt>(
this))
484 returngccAsmStmt->getInputExpr(i);
485 if(
const auto*msAsmStmt = dyn_cast<MSAsmStmt>(
this))
486 returnmsAsmStmt->getInputExpr(i);
487llvm_unreachable(
"unknown asm statement kind!");
491 if(
const auto*gccAsmStmt = dyn_cast<GCCAsmStmt>(
this))
492 returngccAsmStmt->getClobber(i);
493 if(
const auto*msAsmStmt = dyn_cast<MSAsmStmt>(
this))
494 returnmsAsmStmt->getClobber(i);
495llvm_unreachable(
"unknown asm statement kind!");
509assert(
isOperand() &&
"Only Operands can have modifiers.");
510 return isLetter(Str[0]) ? Str[0] :
'\0';
518 returncast<Expr>(
Exprs[i]);
550voidGCCAsmStmt::setOutputsAndInputsAndClobbers(
const ASTContext&
C,
562this->NumLabels = NumLabels;
566 C.Deallocate(this->Names);
568std::copy(Names, Names + NumExprs, this->Names);
570 C.Deallocate(this->Exprs);
571this->Exprs =
new(
C)
Stmt*[NumExprs];
572std::copy(
Exprs,
Exprs+ NumExprs, this->Exprs);
575 C.Deallocate(this->Constraints);
577std::copy(Constraints, Constraints +
NumConstraints, this->Constraints);
579 C.Deallocate(this->Clobbers);
581std::copy(Clobbers, Clobbers +
NumClobbers, this->Clobbers);
595 for(
unsignedi = 0; i !=
NumInputs; ++i)
613 const char*StrStart = Str.begin();
614 const char*StrEnd = Str.end();
615 const char*CurPtr = StrStart;
621 for(; CurPtr != StrEnd; ++CurPtr) {
637std::string CurStringPiece;
639 boolHasVariants = !
C.getTargetInfo().hasNoAsmVariants();
641 unsignedLastAsmStringToken = 0;
642 unsignedLastAsmStringOffset = 0;
646 if(CurPtr == StrEnd) {
647 if(!CurStringPiece.empty())
652 charCurChar = *CurPtr++;
654 case '$': CurStringPiece +=
"$$";
continue;
655 case '{': CurStringPiece += (HasVariants ?
"$(":
"{");
continue;
656 case '|': CurStringPiece += (HasVariants ?
"$|":
"|");
continue;
657 case '}': CurStringPiece += (HasVariants ?
"$)":
"}");
continue;
661CurStringPiece += CurChar;
668 if(CurPtr == StrEnd) {
670DiagOffs = CurPtr-StrStart-1;
671 returndiag::err_asm_invalid_escape;
674 charEscapedChar = *CurPtr++;
675 switch(EscapedChar) {
679CurStringPiece += *MaybeReplaceStr;
686CurStringPiece += EscapedChar;
689CurStringPiece +=
"${:uid}";
695 if(!CurStringPiece.empty()) {
697CurStringPiece.clear();
703 const char*
Begin= CurPtr - 1;
704 const char*Percent =
Begin- 1;
707 if(CurPtr == StrEnd) {
708DiagOffs = CurPtr-StrStart-1;
709 returndiag::err_asm_invalid_escape;
711EscapedChar = *CurPtr++;
723 while(CurPtr != StrEnd &&
isDigit(*CurPtr))
724N = N*10 + ((*CurPtr++)-
'0');
728 if(N >= NumOperands) {
729DiagOffs = CurPtr-StrStart-1;
730 returndiag::err_asm_invalid_operand_number;
739Percent - StrStart,
SM, LO, TI, &LastAsmStringToken,
740&LastAsmStringOffset);
742CurPtr - StrStart,
SM, LO, TI, &LastAsmStringToken,
743&LastAsmStringOffset);
745Pieces.emplace_back(N, std::move(Str), BeginLoc, EndLoc);
750 if(EscapedChar ==
'[') {
751DiagOffs = CurPtr-StrStart-1;
754 const char*NameEnd = (
const char*)memchr(CurPtr,
']', StrEnd-CurPtr);
755 if(NameEnd ==
nullptr)
756 returndiag::err_asm_unterminated_symbolic_operand_name;
757 if(NameEnd == CurPtr)
758 returndiag::err_asm_empty_symbolic_operand_name;
760StringRef SymbolicName(CurPtr, NameEnd - CurPtr);
765DiagOffs = CurPtr-StrStart;
766 returndiag::err_asm_unknown_symbolic_operand_name;
770std::string Str(
Begin, NameEnd + 1 -
Begin);
775Percent - StrStart,
SM, LO, TI, &LastAsmStringToken,
776&LastAsmStringOffset);
778NameEnd + 1 - StrStart,
SM, LO, TI, &LastAsmStringToken,
779&LastAsmStringOffset);
781Pieces.emplace_back(N, std::move(Str), BeginLoc, EndLoc);
787DiagOffs = CurPtr-StrStart-1;
788 returndiag::err_asm_invalid_escape;
800std::string AsmString;
801 for(
const auto&Piece : Pieces) {
802 if(Piece.isString())
803AsmString += Piece.getString();
804 else if(Piece.getModifier() ==
'\0')
805AsmString +=
'$'+ llvm::utostr(Piece.getOperandNo());
807AsmString +=
"${"+ llvm::utostr(Piece.getOperandNo()) +
':'+
808Piece.getModifier() +
'}';
817AsmStr.split(Pieces,
"\n\t");
818std::string MSAsmString;
819 for(
size_tI = 0,
E= Pieces.size(); I <
E; ++I) {
820StringRef Instruction = Pieces[I];
823 if(Instruction.starts_with(
"vex "))
824MSAsmString +=
'{'+ Instruction.substr(0, 3).str() +
'}'+
825Instruction.substr(3).str();
826 else if(Instruction.starts_with(
"vex2 ") ||
827Instruction.starts_with(
"vex3 ") ||
828Instruction.starts_with(
"evex "))
829MSAsmString +=
'{'+ Instruction.substr(0, 4).str() +
'}'+
830Instruction.substr(4).str();
832MSAsmString += Instruction.str();
835MSAsmString +=
"\n\t";
841 returncast<Expr>(
Exprs[i]);
857 boolissimple,
boolisvolatile,
unsignednumoutputs,
863:
AsmStmt(GCCAsmStmtClass, asmloc, issimple, isvolatile, numoutputs,
864numinputs, numclobbers),
865RParenLoc(rparenloc), AsmStr(asmstr), NumLabels(numlabels) {
869std::copy(names, names + NumExprs, Names);
872std::copy(exprs, exprs + NumExprs,
Exprs);
876std::copy(constraints, constraints +
NumConstraints, Constraints);
879std::copy(clobbers, clobbers +
NumClobbers, Clobbers);
889:
AsmStmt(MSAsmStmtClass, asmloc, issimple, isvolatile, numoutputs,
890numinputs, clobbers.size()), LBraceLoc(lbraceloc),
891EndLoc(endloc), NumAsmToks(asmtoks.size()) {
892initialize(
C, asmstr, asmtoks, constraints, exprs, clobbers);
896 returnstr.copy(
C);
899voidMSAsmStmt::initialize(
const ASTContext&
C, StringRef asmstr,
904assert(NumAsmToks == asmtoks.size());
908assert(exprs.size() == constraints.size());
913std::copy(exprs.begin(), exprs.end(),
Exprs);
915AsmToks =
new(
C)
Token[asmtoks.size()];
916std::copy(asmtoks.begin(), asmtoks.end(), AsmToks);
918Constraints =
new(
C) StringRef[exprs.size()];
919std::transform(constraints.begin(), constraints.end(), Constraints,
920[&](StringRef Constraint) {
921return copyIntoContext(C, Constraint);
926std::transform(clobbers.begin(), clobbers.end(), Clobbers,
927[&](StringRef Clobber) {
928return copyIntoContext(C, Clobber);
935:
Stmt(IfStmtClass), LParenLoc(LPL), RParenLoc(RPL) {
936 boolHasElse = Else !=
nullptr;
937 boolHasVar = Var !=
nullptr;
938 boolHasInit =
Init!=
nullptr;
939IfStmtBits.HasElse = HasElse;
940IfStmtBits.HasVar = HasVar;
941IfStmtBits.HasInit = HasInit;
943setStatementKind(Kind);
950setConditionVariable(Ctx, Var);
959IfStmt::IfStmt(EmptyShell
Empty,
boolHasElse,
boolHasVar,
boolHasInit)
961IfStmtBits.HasElse = HasElse;
962IfStmtBits.HasVar = HasVar;
963IfStmtBits.HasInit = HasInit;
970 boolHasElse = Else !=
nullptr;
971 boolHasVar = Var !=
nullptr;
972 boolHasInit =
Init!=
nullptr;
974totalSizeToAlloc<Stmt *, SourceLocation>(
975NumMandatoryStmtPtr + HasElse + HasVar + HasInit, HasElse),
978 IfStmt(Ctx, IL, Kind,
Init, Var, Cond, LPL, RPL, Then, EL, Else);
984totalSizeToAlloc<Stmt *, SourceLocation>(
985NumMandatoryStmtPtr + HasElse + HasVar + HasInit, HasElse),
994 returncast<VarDecl>(DS->getSingleDecl());
999 "This if statement has no storage for a condition variable!");
1002getTrailingObjects<Stmt *>()[varOffset()] =
nullptr;
1007getTrailingObjects<Stmt *>()[varOffset()] =
new(Ctx)
1012 returnisa<ObjCAvailabilityCheckExpr>(
getCond());
1017 returnstd::nullopt;
1021std::optional<const Stmt *>
1023 if(std::optional<Stmt *>
Result=
1026 returnstd::nullopt;
1032:
Stmt(ForStmtClass), LParenLoc(LP), RParenLoc(RP)
1034SubExprs[INIT] =
Init;
1036SubExprs[COND] = Cond;
1037SubExprs[INC] = Inc;
1038SubExprs[BODY] = Body;
1043 if(!SubExprs[CONDVAR])
1046 auto*DS = cast<DeclStmt>(SubExprs[CONDVAR]);
1047 returncast<VarDecl>(DS->getSingleDecl());
1052SubExprs[CONDVAR] =
nullptr;
1064:
Stmt(SwitchStmtClass), FirstCase(nullptr), LParenLoc(LParenLoc),
1065RParenLoc(RParenLoc) {
1066 boolHasInit =
Init!=
nullptr;
1067 boolHasVar = Var !=
nullptr;
1082SwitchStmt::SwitchStmt(EmptyShell
Empty,
boolHasInit,
boolHasVar)
1092 boolHasInit =
Init!=
nullptr;
1093 boolHasVar = Var !=
nullptr;
1095totalSizeToAlloc<Stmt *>(NumMandatoryStmtPtr + HasInit + HasVar),
1097 return new(Mem)
SwitchStmt(Ctx,
Init, Var, Cond, LParenLoc, RParenLoc);
1103totalSizeToAlloc<Stmt *>(NumMandatoryStmtPtr + HasInit + HasVar),
1112 returncast<VarDecl>(DS->getSingleDecl());
1117 "This switch statement has no storage for a condition variable!");
1120getTrailingObjects<Stmt *>()[varOffset()] =
nullptr;
1125getTrailingObjects<Stmt *>()[varOffset()] =
new(Ctx)
1132:
Stmt(WhileStmtClass) {
1133 boolHasVar = Var !=
nullptr;
1146WhileStmt::WhileStmt(EmptyShell
Empty,
boolHasVar)
1155 boolHasVar = Var !=
nullptr;
1157Ctx.
Allocate(totalSizeToAlloc<Stmt *>(NumMandatoryStmtPtr + HasVar),
1159 return new(Mem)
WhileStmt(Ctx, Var, Cond, Body, WL, LParenLoc, RParenLoc);
1164Ctx.
Allocate(totalSizeToAlloc<Stmt *>(NumMandatoryStmtPtr + HasVar),
1173 returncast<VarDecl>(DS->getSingleDecl());
1178 "This while statement has no storage for a condition variable!");
1181getTrailingObjects<Stmt *>()[varOffset()] =
nullptr;
1186getTrailingObjects<Stmt *>()[varOffset()] =
new(Ctx)
1192 if(
auto*
E= dyn_cast<AddrLabelExpr>(
getTarget()->IgnoreParenImpCasts()))
1193 return E->getLabel();
1199:
Stmt(ReturnStmtClass), RetExpr(
E) {
1200 boolHasNRVOCandidate = NRVOCandidate !=
nullptr;
1202 if(HasNRVOCandidate)
1203setNRVOCandidate(NRVOCandidate);
1207ReturnStmt::ReturnStmt(EmptyShell
Empty,
boolHasNRVOCandidate)
1214 boolHasNRVOCandidate = NRVOCandidate !=
nullptr;
1215 void*Mem = Ctx.
Allocate(totalSizeToAlloc<const VarDecl *>(HasNRVOCandidate),
1217 return new(Mem)
ReturnStmt(RL,
E, NRVOCandidate);
1221 boolHasNRVOCandidate) {
1222 void*Mem = Ctx.
Allocate(totalSizeToAlloc<const VarDecl *>(HasNRVOCandidate),
1231 boolCaseStmtIsGNURange = rhs !=
nullptr;
1233totalSizeToAlloc<Stmt *, SourceLocation>(
1234NumMandatoryStmtPtr + CaseStmtIsGNURange, CaseStmtIsGNURange),
1236 return new(Mem)
CaseStmt(lhs, rhs, caseLoc, ellipsisLoc, colonLoc);
1240 boolCaseStmtIsGNURange) {
1242totalSizeToAlloc<Stmt *, SourceLocation>(
1243NumMandatoryStmtPtr + CaseStmtIsGNURange, CaseStmtIsGNURange),
1250:
Stmt(SEHTryStmtClass), IsCXXTry(IsCXXTry), TryLoc(TryLoc) {
1251Children[TRY] = TryBlock;
1252Children[HANDLER] = Handler;
1258 return new(
C)
SEHTryStmt(IsCXXTry,TryLoc,TryBlock,Handler);
1262 returndyn_cast<SEHExceptStmt>(
getHandler());
1266 returndyn_cast<SEHFinallyStmt>(
getHandler());
1271Children[FILTER_EXPR] = FilterExpr;
1290: VarAndKind(Var, Kind),
Loc(
Loc) {
1293assert(!Var &&
"'this' capture cannot have a variable!");
1296assert(Var &&
"capturing by reference must have a variable!");
1299assert(Var &&
"capturing by copy must have a variable!");
1303 "Variable-length array type capture cannot have a variable!");
1310 returnVarAndKind.getInt();
1315 "No variable available for 'this' or VAT capture");
1316 returnVarAndKind.getPointer();
1320 unsignedSize =
sizeof(
CapturedStmt) +
sizeof(
Stmt*) * (NumCaptures + 1);
1323 unsignedFirstCaptureOffset = llvm::alignTo(Size,
alignof(
Capture));
1325 return reinterpret_cast<Capture*
>(
1326 reinterpret_cast<char*
>(
const_cast<CapturedStmt*
>(
this))
1327+ FirstCaptureOffset);
1335:
Stmt(CapturedStmtClass), NumCaptures(Captures.size()),
1336CapDeclAndKind(CD, Kind), TheRecordDecl(RD) {
1337assert( S &&
"null captured statement");
1338assert(CD &&
"null captured declaration for captured statement");
1339assert(RD &&
"null record declaration for captured statement");
1342 Stmt**Stored = getStoredStmts();
1343 for(
unsignedI = 0, N = NumCaptures; I != N; ++I)
1344*Stored++ = CaptureInits[I];
1350 Capture*Buffer = getStoredCaptures();
1351std::copy(Captures.begin(), Captures.end(), Buffer);
1354CapturedStmt::CapturedStmt(EmptyShell
Empty,
unsignedNumCaptures)
1355:
Stmt(CapturedStmtClass,
Empty), NumCaptures(NumCaptures),
1357getStoredStmts()[NumCaptures] =
nullptr;
1360 Capture*Buffer = getStoredCaptures();
1361 for(
unsignedI = 0, N = NumCaptures; I != N; ++I)
1380assert(CaptureInits.size() == Captures.size() &&
"wrong number of arguments");
1382 unsignedSize =
sizeof(
CapturedStmt) +
sizeof(
Stmt*) * (Captures.size() + 1);
1383 if(!Captures.empty()) {
1385Size = llvm::alignTo(Size,
alignof(
Capture));
1386Size +=
sizeof(
Capture) * Captures.size();
1389 void*Mem = Context.
Allocate(Size);
1390 return new(Mem)
CapturedStmt(S, Kind, Captures, CaptureInits, CD, RD);
1394 unsignedNumCaptures) {
1395 unsignedSize =
sizeof(
CapturedStmt) +
sizeof(
Stmt*) * (NumCaptures + 1);
1396 if(NumCaptures > 0) {
1398Size = llvm::alignTo(Size,
alignof(
Capture));
1399Size +=
sizeof(
Capture) * NumCaptures;
1402 void*Mem = Context.
Allocate(Size);
1408 return child_range(getStoredStmts(), getStoredStmts() + NumCaptures);
1416 returnCapDeclAndKind.getPointer();
1420 returnCapDeclAndKind.getPointer();
1425assert(
D&&
"null CapturedDecl");
1426CapDeclAndKind.setPointer(
D);
1431 returnCapDeclAndKind.getInt();
1436CapDeclAndKind.setInt(Kind);
1440 for(
const auto&I :
captures()) {
1441 if(!I.capturesVariable() && !I.capturesVariableByCopy())
Defines the clang::ASTContext interface.
static StringRef bytes(const std::vector< T, Allocator > &v)
Defines the clang::Expr interface and subclasses for C++ expressions.
Defines Expressions and AST nodes for C++2a concepts.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the clang::SourceLocation class and associated facilities.
Defines the Objective-C statement AST node classes.
This file defines OpenACC AST classes for statement-level contructs.
This file defines OpenMP AST classes for executable directives and clauses.
This file defines SYCL AST classes used to represent calls to SYCL kernels.
static StmtClassNameTable & getStmtInfoTableEntry(Stmt::StmtClass E)
static LLVM_ATTRIBUTE_UNUSED void check_implementations()
Check whether the various Stmt classes implement their member functions.
static StringRef copyIntoContext(const ASTContext &C, StringRef str)
static std::pair< Stmt::Likelihood, const Attr * > getLikelihood(ArrayRef< const Attr * > Attrs)
static struct StmtClassNameTable StmtClassInfo[Stmt::lastStmtConstant+1]
#define BLOCK(DERIVED, BASE)
C Language Family Type Representation.
__device__ __2f16 float __ockl_bool s
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
llvm::BumpPtrAllocator & getAllocator() const
void * Allocate(size_t Size, unsigned Align=8) const
AddrLabelExpr - The GNU address of label extension, representing &&label.
LabelDecl * getLabel() const
AsmStmt is the base class for GCCAsmStmt and MSAsmStmt.
unsigned getNumPlusOperands() const
getNumPlusOperands - Return the number of output operands that have a "+" constraint.
StringRef getOutputConstraint(unsigned i) const
getOutputConstraint - Return the constraint string for the specified output operand.
const Expr * getInputExpr(unsigned i) const
bool isOutputPlusConstraint(unsigned i) const
isOutputPlusConstraint - Return true if the specified output constraint is a "+" constraint (which is...
const Expr * getOutputExpr(unsigned i) const
StringRef getInputConstraint(unsigned i) const
getInputConstraint - Return the specified input constraint.
unsigned getNumOutputs() const
std::string generateAsmString(const ASTContext &C) const
Assemble final IR asm string.
unsigned getNumInputs() const
StringRef getClobber(unsigned i) const
Attr - This represents one attribute.
Represents an attribute applied to a statement.
static AttributedStmt * CreateEmpty(const ASTContext &C, unsigned NumAttrs)
static AttributedStmt * Create(const ASTContext &C, SourceLocation Loc, ArrayRef< const Attr * > Attrs, Stmt *SubStmt)
Represents the body of a CapturedStmt, and serves as its DeclContext.
Describes the capture of either a variable, or 'this', or variable-length array type.
VariableCaptureKind getCaptureKind() const
Determine the kind of capture.
VarDecl * getCapturedVar() const
Retrieve the declaration of the variable being captured.
This captures a statement into a function.
static CapturedStmt * CreateDeserialized(const ASTContext &Context, unsigned NumCaptures)
void setCapturedRegionKind(CapturedRegionKind Kind)
Set the captured region kind.
CapturedDecl * getCapturedDecl()
Retrieve the outlined function declaration.
bool capturesVariable(const VarDecl *Var) const
True if this variable has been captured.
void setCapturedDecl(CapturedDecl *D)
Set the outlined function declaration.
static CapturedStmt * Create(const ASTContext &Context, Stmt *S, CapturedRegionKind Kind, ArrayRef< Capture > Captures, ArrayRef< Expr * > CaptureInits, CapturedDecl *CD, RecordDecl *RD)
CapturedRegionKind getCapturedRegionKind() const
Retrieve the captured region kind.
VariableCaptureKind
The different capture forms: by 'this', by reference, capture for variable-length array type etc.
CaseStmt - Represent a case statement.
static CaseStmt * Create(const ASTContext &Ctx, Expr *lhs, Expr *rhs, SourceLocation caseLoc, SourceLocation ellipsisLoc, SourceLocation colonLoc)
Build a case statement.
static CaseStmt * CreateEmpty(const ASTContext &Ctx, bool CaseStmtIsGNURange)
Build an empty case statement.
CompoundStmt - This represents a group of statements like { stmt stmt }.
static CompoundStmt * CreateEmpty(const ASTContext &C, unsigned NumStmts, bool HasFPFeatures)
body_iterator body_begin()
static CompoundStmt * Create(const ASTContext &C, ArrayRef< Stmt * > Stmts, FPOptionsOverride FPFeatures, SourceLocation LB, SourceLocation RB)
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
This represents one expression.
llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx, SmallVectorImpl< PartialDiagnosticAt > *Diag=nullptr) const
EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded integer.
Represents difference between two FPOptions values.
bool requiresTrailingStorage() const
ForStmt(const ASTContext &C, Stmt *Init, Expr *Cond, VarDecl *condVar, Expr *Inc, Stmt *Body, SourceLocation FL, SourceLocation LP, SourceLocation RP)
VarDecl * getConditionVariable() const
Retrieve the variable declared in this "for" statement, if any.
void setConditionVariable(const ASTContext &C, VarDecl *V)
AsmStringPiece - this is part of a decomposed asm string specification (for use with the AnalyzeAsmSt...
char getModifier() const
getModifier - Get the modifier for this operand, if present.
unsigned getNumLabels() const
const StringLiteral * getInputConstraintLiteral(unsigned i) const
std::string generateAsmString(const ASTContext &C) const
Assemble final IR asm string.
StringRef getClobber(unsigned i) const
StringRef getLabelName(unsigned i) const
unsigned AnalyzeAsmString(SmallVectorImpl< AsmStringPiece > &Pieces, const ASTContext &C, unsigned &DiagOffs) const
AnalyzeAsmString - Analyze the asm string of the current asm, decomposing it into pieces.
const StringLiteral * getOutputConstraintLiteral(unsigned i) const
StringRef getOutputConstraint(unsigned i) const
getOutputConstraint - Return the constraint string for the specified output operand.
void setInputExpr(unsigned i, Expr *E)
const StringLiteral * getAsmString() const
StringLiteral * getClobberStringLiteral(unsigned i)
StringRef getInputName(unsigned i) const
GCCAsmStmt(const ASTContext &C, SourceLocation asmloc, bool issimple, bool isvolatile, unsigned numoutputs, unsigned numinputs, IdentifierInfo **names, StringLiteral **constraints, Expr **exprs, StringLiteral *asmstr, unsigned numclobbers, StringLiteral **clobbers, unsigned numlabels, SourceLocation rparenloc)
StringRef getOutputName(unsigned i) const
Expr * getOutputExpr(unsigned i)
int getNamedOperand(StringRef SymbolicName) const
getNamedOperand - Given a symbolic operand reference like %[foo], translate this into a numeric value...
Expr * getInputExpr(unsigned i)
AddrLabelExpr * getLabelExpr(unsigned i) const
StringRef getInputConstraint(unsigned i) const
getInputConstraint - Return the specified input constraint.
One of these records is kept for each identifier that is lexed.
const char * getNameStart() const
Return the beginning of the actual null-terminated string for this identifier.
IfStmt - This represents an if/then/else.
static IfStmt * Create(const ASTContext &Ctx, SourceLocation IL, IfStatementKind Kind, Stmt *Init, VarDecl *Var, Expr *Cond, SourceLocation LPL, SourceLocation RPL, Stmt *Then, SourceLocation EL=SourceLocation(), Stmt *Else=nullptr)
Create an IfStmt.
void setConditionVariable(const ASTContext &Ctx, VarDecl *V)
Set the condition variable for this if statement.
bool hasVarStorage() const
True if this IfStmt has storage for a variable declaration.
static IfStmt * CreateEmpty(const ASTContext &Ctx, bool HasElse, bool HasVar, bool HasInit)
Create an empty IfStmt optionally with storage for an else statement, condition variable and init exp...
std::optional< const Stmt * > getNondiscardedCase(const ASTContext &Ctx) const
If this is an 'if constexpr', determine which substatement will be taken.
bool isObjCAvailabilityCheck() const
DeclStmt * getConditionVariableDeclStmt()
If this IfStmt has a condition variable, return the faux DeclStmt associated with the creation of tha...
VarDecl * getConditionVariable()
Retrieve the variable declared in this "if" statement, if any.
LabelDecl * getConstantTarget()
getConstantTarget - Returns the fixed target of this indirect goto, if one exists.
Represents the declaration of a label.
LabelDecl * getDecl() const
const char * getName() const
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Expr * getOutputExpr(unsigned i)
void setInputExpr(unsigned i, Expr *E)
MSAsmStmt(const ASTContext &C, SourceLocation asmloc, SourceLocation lbraceloc, bool issimple, bool isvolatile, ArrayRef< Token > asmtoks, unsigned numoutputs, unsigned numinputs, ArrayRef< StringRef > constraints, ArrayRef< Expr * > exprs, StringRef asmstr, ArrayRef< StringRef > clobbers, SourceLocation endloc)
std::string generateAsmString(const ASTContext &C) const
Assemble final IR asm string.
Expr * getInputExpr(unsigned i)
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
Represents a struct/union/class.
ReturnStmt - This represents a return, optionally of an expression: return; return 4;.
static ReturnStmt * Create(const ASTContext &Ctx, SourceLocation RL, Expr *E, const VarDecl *NRVOCandidate)
Create a return statement.
static ReturnStmt * CreateEmpty(const ASTContext &Ctx, bool HasNRVOCandidate)
Create an empty return statement, optionally with storage for an NRVO candidate.
static SEHExceptStmt * Create(const ASTContext &C, SourceLocation ExceptLoc, Expr *FilterExpr, Stmt *Block)
static SEHFinallyStmt * Create(const ASTContext &C, SourceLocation FinallyLoc, Stmt *Block)
SEHFinallyStmt * getFinallyHandler() const
static SEHTryStmt * Create(const ASTContext &C, bool isCXXTry, SourceLocation TryLoc, Stmt *TryBlock, Stmt *Handler)
SEHExceptStmt * getExceptHandler() const
Returns 0 if not defined.
Stmt * getHandler() const
Encodes a location in the source.
This class handles loading and caching of source files into memory.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
SourceLocation getBegin() const
Stmt - This represents one statement.
SourceLocation getEndLoc() const LLVM_READONLY
WhileStmtBitfields WhileStmtBits
static void EnableStatistics()
SwitchStmtBitfields SwitchStmtBits
const Stmt * stripLabelLikeStatements() const
Strip off all label-like statements.
StmtClass getStmtClass() const
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
static std::tuple< bool, const Attr *, const Attr * > determineLikelihoodConflict(const Stmt *Then, const Stmt *Else)
llvm::iterator_range< child_iterator > child_range
CompoundStmtBitfields CompoundStmtBits
Likelihood
The likelihood of a branch being taken.
@ LH_Unlikely
Branch has the [[unlikely]] attribute.
@ LH_None
No attribute set or branches of the IfStmt have the same attribute.
@ LH_Likely
Branch has the [[likely]] attribute.
static void addStmtClass(const StmtClass s)
ForStmtBitfields ForStmtBits
const char * getStmtClassName() const
static const Attr * getLikelihoodAttr(const Stmt *S)
Stmt * IgnoreContainers(bool IgnoreCaptured=false)
Skip no-op (attributed, compound) container stmts and skip captured stmt at the top,...
int64_t getID(const ASTContext &Context) const
ReturnStmtBitfields ReturnStmtBits
SourceLocation getBeginLoc() const LLVM_READONLY
llvm::iterator_range< const_child_iterator > const_child_range
static Likelihood getLikelihood(ArrayRef< const Attr * > Attrs)
StringLiteral - This represents a string literal expression, e.g.
SourceLocation getLocationOfByte(unsigned ByteNo, const SourceManager &SM, const LangOptions &Features, const TargetInfo &Target, unsigned *StartToken=nullptr, unsigned *StartTokenByteOffset=nullptr) const
getLocationOfByte - Return a source location that points to the specified byte of this string literal...
StringRef getString() const
SwitchStmt - This represents a 'switch' stmt.
void setRParenLoc(SourceLocation Loc)
void setConditionVariable(const ASTContext &Ctx, VarDecl *VD)
Set the condition variable in this switch statement.
static SwitchStmt * Create(const ASTContext &Ctx, Stmt *Init, VarDecl *Var, Expr *Cond, SourceLocation LParenLoc, SourceLocation RParenLoc)
Create a switch statement.
void setLParenLoc(SourceLocation Loc)
static SwitchStmt * CreateEmpty(const ASTContext &Ctx, bool HasInit, bool HasVar)
Create an empty switch statement optionally with storage for an init expression and a condition varia...
bool hasVarStorage() const
True if this SwitchStmt has storage for a condition variable.
VarDecl * getConditionVariable()
Retrieve the variable declared in this "switch" statement, if any.
DeclStmt * getConditionVariableDeclStmt()
If this SwitchStmt has a condition variable, return the faux DeclStmt associated with the creation of...
Exposes information about the current target.
virtual std::optional< std::string > handleAsmEscapedChar(char C) const
Replace some escaped characters with another string based on target-specific rules.
Token - This structure provides full information about a lexed token.
const Expr * getExprStmt() const
Represents a variable declaration or definition.
VarDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
WhileStmt - This represents a 'while' stmt.
DeclStmt * getConditionVariableDeclStmt()
If this WhileStmt has a condition variable, return the faux DeclStmt associated with the creation of ...
VarDecl * getConditionVariable()
Retrieve the variable declared in this "while" statement, if any.
void setConditionVariable(const ASTContext &Ctx, VarDecl *V)
Set the condition variable of this while statement.
bool hasVarStorage() const
True if this WhileStmt has storage for a condition variable.
static WhileStmt * Create(const ASTContext &Ctx, VarDecl *Var, Expr *Cond, Stmt *Body, SourceLocation WL, SourceLocation LParenLoc, SourceLocation RParenLoc)
Create a while statement.
static WhileStmt * CreateEmpty(const ASTContext &Ctx, bool HasVar)
Create an empty while statement optionally with storage for a condition variable.
Defines the clang::TargetInfo interface.
const internal::VariadicAllOfMatcher< Stmt > stmt
Matches statements.
The JSON file list parser is used to communicate input to InstallAPI.
IfStatementKind
In an if statement, this denotes whether the statement is a constexpr or consteval if statement.
CapturedRegionKind
The different kinds of captured statement.
LLVM_READONLY bool isLetter(unsigned char c)
Return true if this character is an ASCII letter: [a-zA-Z].
@ Result
The result type of a method or function.
LLVM_READONLY bool isDigit(unsigned char c)
Return true if this character is an ASCII digit: [0-9].
const FunctionProtoType * T
A placeholder type used to construct an empty shell of a type, that will be filled in later (e....
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4