13#ifndef LLVM_CLANG_AST_STMT_H
14#define LLVM_CLANG_AST_STMT_H
30#include "llvm/ADT/APFloat.h"
31#include "llvm/ADT/ArrayRef.h"
32#include "llvm/ADT/BitmaskEnum.h"
33#include "llvm/ADT/PointerIntPair.h"
34#include "llvm/ADT/StringRef.h"
35#include "llvm/ADT/iterator.h"
36#include "llvm/ADT/iterator_range.h"
37#include "llvm/Support/Casting.h"
38#include "llvm/Support/Compiler.h"
39#include "llvm/Support/ErrorHandling.h"
49class FoldingSetNodeID;
84class alignas(void *)
Stmt {
88#define STMT(CLASS, PARENT) CLASS##Class,
89#define STMT_RANGE(BASE, FIRST, LAST) \
90 first##BASE##Constant=FIRST##Class, last##BASE##Constant=LAST##Class,
91#define LAST_STMT_RANGE(BASE, FIRST, LAST) \
92 first##BASE##Constant=FIRST##Class, last##BASE##Constant=LAST##Class
93#define ABSTRACT_STMT(STMT)
94#include "clang/AST/StmtNodes.inc"
102 void *
operator new(
size_t bytes)
noexcept {
103 llvm_unreachable(
"Stmts cannot be allocated with regular 'new'.");
106 void operator delete(
void *data)
noexcept {
107 llvm_unreachable(
"Stmts cannot be released with regular 'delete'.");
136 LLVM_PREFERRED_TYPE(
bool)
137 unsigned HasLeadingEmptyMacro : 1;
152 LLVM_PREFERRED_TYPE(
bool)
153 unsigned HasFPFeatures : 1;
193 LLVM_PREFERRED_TYPE(
bool)
194 unsigned HasElse : 1;
197 LLVM_PREFERRED_TYPE(
bool)
201 LLVM_PREFERRED_TYPE(
bool)
202 unsigned HasInit : 1;
215 LLVM_PREFERRED_TYPE(
bool)
216 unsigned HasInit : 1;
219 LLVM_PREFERRED_TYPE(
bool)
225 LLVM_PREFERRED_TYPE(
bool)
226 unsigned AllEnumCasesCovered : 1;
240 LLVM_PREFERRED_TYPE(
bool)
305 LLVM_PREFERRED_TYPE(
bool)
306 unsigned HasNRVOCandidate : 1;
321 LLVM_PREFERRED_TYPE(
bool)
322 unsigned CaseStmtIsGNURange : 1;
358 unsigned ValueKind : 2;
360 unsigned ObjectKind : 3;
362 unsigned Dependent : llvm::BitWidth<ExprDependence>;
376 unsigned ResultKind : 2;
380 unsigned APValueKind : 4;
384 LLVM_PREFERRED_TYPE(
bool)
385 unsigned IsUnsigned : 1;
391 unsigned BitWidth : 7;
395 LLVM_PREFERRED_TYPE(
bool)
396 unsigned HasCleanup : 1;
399 LLVM_PREFERRED_TYPE(
bool)
400 unsigned IsImmediateInvocation : 1;
415 LLVM_PREFERRED_TYPE(
bool)
416 unsigned HasFunctionName : 1;
420 LLVM_PREFERRED_TYPE(
bool)
421 unsigned IsTransparent : 1;
434 LLVM_PREFERRED_TYPE(
bool)
435 unsigned HasQualifier : 1;
436 LLVM_PREFERRED_TYPE(
bool)
437 unsigned HasTemplateKWAndArgsInfo : 1;
438 LLVM_PREFERRED_TYPE(
bool)
439 unsigned HasFoundDecl : 1;
440 LLVM_PREFERRED_TYPE(
bool)
441 unsigned HadMultipleCandidates : 1;
442 LLVM_PREFERRED_TYPE(
bool)
443 unsigned RefersToEnclosingVariableOrCapture : 1;
444 LLVM_PREFERRED_TYPE(
bool)
445 unsigned CapturedByCopyInLambdaWithExplicitObjectParameter : 1;
448 LLVM_PREFERRED_TYPE(
bool)
449 unsigned IsImmediateEscalating : 1;
463 llvm::APFloat::S_MaxSemantics < 32,
464 "Too many Semantics enum values to fit in bitfield of size 5");
465 LLVM_PREFERRED_TYPE(llvm::APFloat::Semantics)
466 unsigned Semantics : 5;
467 LLVM_PREFERRED_TYPE(
bool)
468 unsigned IsExact : 1;
486 unsigned CharByteWidth : 3;
488 LLVM_PREFERRED_TYPE(
bool)
489 unsigned IsPascal : 1;
493 unsigned NumConcatenated;
514 LLVM_PREFERRED_TYPE(
bool)
515 unsigned CanOverflow : 1;
520 LLVM_PREFERRED_TYPE(
bool)
521 unsigned HasFPFeatures : 1;
534 LLVM_PREFERRED_TYPE(
bool)
554 unsigned NumPreArgs : 1;
557 LLVM_PREFERRED_TYPE(
bool)
558 unsigned UsesADL : 1;
561 LLVM_PREFERRED_TYPE(
bool)
562 unsigned HasFPFeatures : 1;
570 unsigned OffsetToTrailingObjects : 8;
582 LLVM_PREFERRED_TYPE(
bool)
583 unsigned IsArrow : 1;
587 LLVM_PREFERRED_TYPE(
bool)
588 unsigned HasQualifier : 1;
591 LLVM_PREFERRED_TYPE(
bool)
592 unsigned HasFoundDecl : 1;
599 LLVM_PREFERRED_TYPE(
bool)
600 unsigned HasTemplateKWAndArgsInfo : 1;
604 LLVM_PREFERRED_TYPE(
bool)
605 unsigned HadMultipleCandidates : 1;
626 LLVM_PREFERRED_TYPE(
bool)
627 unsigned PartOfExplicitCast : 1;
630 LLVM_PREFERRED_TYPE(
bool)
631 unsigned HasFPFeatures : 1;
635 unsigned BasePathSize;
650 LLVM_PREFERRED_TYPE(
bool)
651 unsigned HasFPFeatures : 1;
664 LLVM_PREFERRED_TYPE(
bool)
665 unsigned HadArrayRangeDesignator : 1;
697 unsigned NumSubExprs : 16;
698 unsigned ResultIndex : 16;
724 unsigned TemplateDepth;
739 unsigned OperatorKind : 6;
749 LLVM_PREFERRED_TYPE(
bool)
750 unsigned IsReversed : 1;
760 LLVM_PREFERRED_TYPE(
bool)
784 LLVM_PREFERRED_TYPE(
bool)
785 unsigned IsImplicit : 1;
789 LLVM_PREFERRED_TYPE(
bool)
790 unsigned CapturedByCopyInLambdaWithExplicitObjectParameter : 1;
804 LLVM_PREFERRED_TYPE(
bool)
805 unsigned IsThrownVariableInScope : 1;
819 LLVM_PREFERRED_TYPE(
bool)
820 unsigned HasRewrittenInit : 1;
835 LLVM_PREFERRED_TYPE(
bool)
836 unsigned HasRewrittenInit : 1;
861 LLVM_PREFERRED_TYPE(
bool)
862 unsigned IsGlobalNew : 1;
866 LLVM_PREFERRED_TYPE(
bool)
867 unsigned IsArray : 1;
870 LLVM_PREFERRED_TYPE(
bool)
871 unsigned ShouldPassAlignment : 1;
875 LLVM_PREFERRED_TYPE(
bool)
876 unsigned UsualArrayDeleteWantsSize : 1;
879 LLVM_PREFERRED_TYPE(
bool)
880 unsigned HasInitializer : 1;
884 unsigned StoredInitializationStyle : 2;
887 LLVM_PREFERRED_TYPE(
bool)
888 unsigned IsParenTypeId : 1;
891 unsigned NumPlacementArgs;
902 LLVM_PREFERRED_TYPE(
bool)
903 unsigned GlobalDelete : 1;
906 LLVM_PREFERRED_TYPE(
bool)
907 unsigned ArrayForm : 1;
912 LLVM_PREFERRED_TYPE(
bool)
913 unsigned ArrayFormAsWritten : 1;
917 LLVM_PREFERRED_TYPE(
bool)
918 unsigned UsualArrayDeleteWantsSize : 1;
938 LLVM_PREFERRED_TYPE(
bool)
957 LLVM_PREFERRED_TYPE(
bool)
958 unsigned HasTemplateKWAndArgsInfo : 1;
968 LLVM_PREFERRED_TYPE(
bool)
969 unsigned Elidable : 1;
970 LLVM_PREFERRED_TYPE(
bool)
971 unsigned HadMultipleCandidates : 1;
972 LLVM_PREFERRED_TYPE(
bool)
973 unsigned ListInitialization : 1;
974 LLVM_PREFERRED_TYPE(
bool)
975 unsigned StdInitListInitialization : 1;
976 LLVM_PREFERRED_TYPE(
bool)
977 unsigned ZeroInitialization : 1;
979 unsigned ConstructionKind : 3;
980 LLVM_PREFERRED_TYPE(
bool)
981 unsigned IsImmediateEscalating : 1;
994 LLVM_PREFERRED_TYPE(
bool)
995 unsigned CleanupsHaveSideEffects : 1;
1020 LLVM_PREFERRED_TYPE(
bool)
1021 unsigned IsArrow : 1;
1025 LLVM_PREFERRED_TYPE(
bool)
1026 unsigned HasTemplateKWAndArgsInfo : 1;
1030 LLVM_PREFERRED_TYPE(
bool)
1031 unsigned HasFirstQualifierFoundInScope : 1;
1046 LLVM_PREFERRED_TYPE(
bool)
1047 unsigned HasTemplateKWAndArgsInfo : 1;
1055 unsigned NumResults;
1068 LLVM_PREFERRED_TYPE(
bool)
1069 unsigned RequiresADL : 1;
1072 "UnresolvedLookupExprBitfields must be <= than 4 bytes to"
1073 "avoid trashing OverloadExprBitfields::NumResults!");
1084 LLVM_PREFERRED_TYPE(
bool)
1085 unsigned IsArrow : 1;
1088 LLVM_PREFERRED_TYPE(
bool)
1089 unsigned HasUnresolvedUsing : 1;
1092 "UnresolvedMemberExprBitfields must be <= than 4 bytes to"
1093 "avoid trashing OverloadExprBitfields::NumResults!");
1102 LLVM_PREFERRED_TYPE(
bool)
1128 unsigned CaptureDefault : 2;
1132 LLVM_PREFERRED_TYPE(
bool)
1133 unsigned ExplicitParams : 1;
1136 LLVM_PREFERRED_TYPE(
bool)
1137 unsigned ExplicitResultType : 1;
1140 unsigned NumCaptures : 16;
1151 LLVM_PREFERRED_TYPE(
bool)
1152 unsigned IsSatisfied : 1;
1164 LLVM_PREFERRED_TYPE(
bool)
1165 unsigned IsImplicit : 1;
1176 LLVM_PREFERRED_TYPE(
bool)
1177 unsigned ShouldCopy : 1;
1191 LLVM_PREFERRED_TYPE(
bool)
1192 unsigned IsUnique : 1;
1280 unsigned alignment = 8);
1283 unsigned alignment = 8) {
1284 return operator new(
bytes, *
C, alignment);
1287 void *
operator new(
size_t bytes,
void *mem)
noexcept {
return mem; }
1291 void operator delete(
void *,
size_t)
noexcept {}
1292 void operator delete(
void *,
void *)
noexcept {}
1313 template<
typename T,
typename TPtr = T *,
typename StmtPtr = Stmt *>
1315 : llvm::iterator_adaptor_base<CastIterator<T, TPtr, StmtPtr>, StmtPtr *,
1316 std::random_access_iterator_tag, TPtr> {
1317 using Base =
typename CastIterator::iterator_adaptor_base;
1323 return cast_or_null<T>(*this->I);
1328 template <
typename T>
1336 static bool StatisticsEnabled;
1350 static_assert(
sizeof(*this) <= 8,
1351 "changing bitfields changed sizeof(Stmt)");
1352 static_assert(
sizeof(*this) %
alignof(
void *) == 0,
1353 "Insufficient alignment!");
1393 static
std::tuple<
bool, const
Attr *, const
Attr *>
1412 StringRef NewlineSymbol = "\n",
1416 unsigned Indentation = 0,
1417 StringRef NewlineSymbol = "\n",
1437 return const_cast<Stmt*
>(
1481 bool Canonical,
bool ProfileLambdaExpr =
false)
const;
1503 :
Stmt(DeclStmtClass), DG(dg), StartLoc(startLoc), EndLoc(endLoc) {}
1526 return T->getStmtClass() == DeclStmtClass;
1572 :
Stmt(NullStmtClass) {
1591 return T->getStmtClass() == NullStmtClass;
1606 private llvm::TrailingObjects<CompoundStmt, Stmt *, FPOptionsOverride> {
1608 friend TrailingObjects;
1625 *getTrailingObjects<FPOptionsOverride>() = F;
1628 size_t numTrailingObjects(OverloadToken<Stmt *>)
const {
1633 static CompoundStmt *
Create(
const ASTContext &
C, ArrayRef<Stmt *> Stmts,
1634 FPOptionsOverride FPFeatures, SourceLocation LB,
1641 :
Stmt(CompoundStmtClass), LBraceLoc(
Loc), RBraceLoc(EndLoc) {
1648 bool HasFPFeatures);
1658 return *getTrailingObjects<FPOptionsOverride>();
1686 return getTrailingObjects<Stmt *>();
1710 std::reverse_iterator<const_body_iterator>;
1729 for (
auto *B : llvm::reverse(
body())) {
1730 if (!isa<NullStmt>(B))
1747 return T->getStmtClass() == CompoundStmtClass;
1797 return T->getStmtClass() == CaseStmtClass ||
1798 T->getStmtClass() == DefaultStmtClass;
1806 private llvm::TrailingObjects<CaseStmt, Stmt *, SourceLocation> {
1807 friend TrailingObjects;
1824 enum { LhsOffset = 0, SubStmtOffsetFromRhs = 1 };
1825 enum { NumMandatoryStmtPtr = 2 };
1827 unsigned numTrailingObjects(OverloadToken<Stmt *>)
const {
1831 unsigned numTrailingObjects(OverloadToken<SourceLocation>)
const {
1835 unsigned lhsOffset()
const {
return LhsOffset; }
1837 unsigned subStmtOffset()
const {
return rhsOffset() + SubStmtOffsetFromRhs; }
1843 :
SwitchCase(CaseStmtClass, caseLoc, colonLoc) {
1845 bool IsGNURange = rhs !=
nullptr;
1889 "setEllipsisLoc but this is not a case stmt of the form LHS ... RHS!");
1890 *getTrailingObjects<SourceLocation>() = L;
1894 return reinterpret_cast<Expr *
>(getTrailingObjects<Stmt *>()[lhsOffset()]);
1898 return reinterpret_cast<Expr *
>(getTrailingObjects<Stmt *>()[lhsOffset()]);
1902 getTrailingObjects<Stmt *>()[lhsOffset()] =
reinterpret_cast<Stmt *
>(Val);
1907 getTrailingObjects<Stmt *>()[rhsOffset()])
1913 getTrailingObjects<Stmt *>()[rhsOffset()])
1919 "setRHS but this is not a case stmt of the form LHS ... RHS!");
1920 getTrailingObjects<Stmt *>()[rhsOffset()] =
reinterpret_cast<Stmt *
>(Val);
1925 return getTrailingObjects<Stmt *>()[subStmtOffset()];
1929 getTrailingObjects<Stmt *>()[subStmtOffset()] = S;
1936 while (
const auto *CS2 = dyn_cast<CaseStmt>(CS->
getSubStmt()))
1943 return T->getStmtClass() == CaseStmtClass;
1949 getTrailingObjects<Stmt *>() +
1950 numTrailingObjects(OverloadToken<Stmt *>()));
1955 getTrailingObjects<Stmt *>() +
1956 numTrailingObjects(OverloadToken<Stmt *>()));
1965 :
SwitchCase(DefaultStmtClass, DL, CL), SubStmt(substmt) {}
1984 return T->getStmtClass() == DefaultStmtClass;
1996 if (
const auto *CS = dyn_cast<CaseStmt>(
this))
1997 return CS->getEndLoc();
1998 else if (
const auto *DS = dyn_cast<DefaultStmt>(
this))
1999 return DS->getEndLoc();
2000 llvm_unreachable(
"SwitchCase is neither a CaseStmt nor a DefaultStmt!");
2004 if (
auto *CS = dyn_cast<CaseStmt>(
this))
2005 return CS->getSubStmt();
2006 else if (
auto *DS = dyn_cast<DefaultStmt>(
this))
2007 return DS->getSubStmt();
2008 llvm_unreachable(
"SwitchCase is neither a CaseStmt nor a DefaultStmt!");
2029 return T->getStmtClass() >= firstValueStmtConstant &&
2030 T->getStmtClass() <= lastValueStmtConstant;
2039 bool SideEntry =
false;
2044 :
ValueStmt(LabelStmtClass), TheDecl(
D), SubStmt(substmt) {
2073 return T->getStmtClass() == LabelStmtClass;
2085 private llvm::TrailingObjects<AttributedStmt, const Attr *> {
2087 friend TrailingObjects;
2093 :
ValueStmt(AttributedStmtClass), SubStmt(SubStmt) {
2096 std::copy(Attrs.begin(), Attrs.end(), getAttrArrayPtr());
2103 std::fill_n(getAttrArrayPtr(), NumAttrs,
nullptr);
2106 const Attr *
const *getAttrArrayPtr()
const {
2107 return getTrailingObjects<const Attr *>();
2109 const Attr **getAttrArrayPtr() {
return getTrailingObjects<const Attr *>(); }
2112 static AttributedStmt *
Create(
const ASTContext &
C, SourceLocation
Loc,
2113 ArrayRef<const Attr *> Attrs,
Stmt *SubStmt);
2116 static AttributedStmt *
CreateEmpty(
const ASTContext &
C,
unsigned NumAttrs);
2136 return T->getStmtClass() == AttributedStmtClass;
2143 private llvm::TrailingObjects<IfStmt, Stmt *, SourceLocation> {
2144 friend TrailingObjects;
2168 enum { InitOffset = 0, ThenOffsetFromCond = 1, ElseOffsetFromCond = 2 };
2169 enum { NumMandatoryStmtPtr = 2 };
2173 unsigned numTrailingObjects(OverloadToken<Stmt *>)
const {
2178 unsigned numTrailingObjects(OverloadToken<SourceLocation>)
const {
2182 unsigned initOffset()
const {
return InitOffset; }
2183 unsigned varOffset()
const {
return InitOffset +
hasInitStorage(); }
2184 unsigned condOffset()
const {
2187 unsigned thenOffset()
const {
return condOffset() + ThenOffsetFromCond; }
2188 unsigned elseOffset()
const {
return condOffset() + ElseOffsetFromCond; }
2204 Stmt *Else =
nullptr);
2221 return reinterpret_cast<Expr *
>(getTrailingObjects<Stmt *>()[condOffset()]);
2225 return reinterpret_cast<Expr *
>(getTrailingObjects<Stmt *>()[condOffset()]);
2229 getTrailingObjects<Stmt *>()[condOffset()] =
reinterpret_cast<Stmt *
>(Cond);
2232 Stmt *
getThen() {
return getTrailingObjects<Stmt *>()[thenOffset()]; }
2234 return getTrailingObjects<Stmt *>()[thenOffset()];
2238 getTrailingObjects<Stmt *>()[thenOffset()] = Then;
2242 return hasElseStorage() ? getTrailingObjects<Stmt *>()[elseOffset()]
2247 return hasElseStorage() ? getTrailingObjects<Stmt *>()[elseOffset()]
2253 "This if statement has no storage for an else statement!");
2254 getTrailingObjects<Stmt *>()[elseOffset()] = Else;
2278 getTrailingObjects<Stmt *>()[varOffset()])
2284 getTrailingObjects<Stmt *>()[varOffset()])
2290 getTrailingObjects<Stmt *>()[varOffset()] = CondVar;
2294 return hasInitStorage() ? getTrailingObjects<Stmt *>()[initOffset()]
2299 return hasInitStorage() ? getTrailingObjects<Stmt *>()[initOffset()]
2305 "This if statement has no storage for an init statement!");
2306 getTrailingObjects<Stmt *>()[initOffset()] =
Init;
2319 "This if statement has no storage for an else statement!");
2320 *getTrailingObjects<SourceLocation>() = ElseLoc;
2373 getTrailingObjects<Stmt *>() +
2374 numTrailingObjects(OverloadToken<Stmt *>()));
2382 getTrailingObjects<Stmt *>() +
2383 numTrailingObjects(OverloadToken<Stmt *>()));
2387 return T->getStmtClass() == IfStmtClass;
2393 private llvm::TrailingObjects<SwitchStmt, Stmt *> {
2394 friend TrailingObjects;
2416 enum { InitOffset = 0, BodyOffsetFromCond = 1 };
2417 enum { NumMandatoryStmtPtr = 2 };
2421 unsigned numTrailingObjects(OverloadToken<Stmt *>)
const {
2425 unsigned initOffset()
const {
return InitOffset; }
2426 unsigned varOffset()
const {
return InitOffset +
hasInitStorage(); }
2427 unsigned condOffset()
const {
2430 unsigned bodyOffset()
const {
return condOffset() + BodyOffsetFromCond; }
2457 return reinterpret_cast<Expr *
>(getTrailingObjects<Stmt *>()[condOffset()]);
2461 return reinterpret_cast<Expr *
>(getTrailingObjects<Stmt *>()[condOffset()]);
2465 getTrailingObjects<Stmt *>()[condOffset()] =
reinterpret_cast<Stmt *
>(Cond);
2468 Stmt *
getBody() {
return getTrailingObjects<Stmt *>()[bodyOffset()]; }
2470 return getTrailingObjects<Stmt *>()[bodyOffset()];
2474 getTrailingObjects<Stmt *>()[bodyOffset()] = Body;
2478 return hasInitStorage() ? getTrailingObjects<Stmt *>()[initOffset()]
2483 return hasInitStorage() ? getTrailingObjects<Stmt *>()[initOffset()]
2489 "This switch statement has no storage for an init statement!");
2490 getTrailingObjects<Stmt *>()[initOffset()] =
Init;
2515 getTrailingObjects<Stmt *>()[varOffset()])
2521 getTrailingObjects<Stmt *>()[varOffset()])
2527 getTrailingObjects<Stmt *>()[varOffset()] = CondVar;
2548 "case/default already added to a switch");
2572 getTrailingObjects<Stmt *>() +
2573 numTrailingObjects(OverloadToken<Stmt *>()));
2578 getTrailingObjects<Stmt *>() +
2579 numTrailingObjects(OverloadToken<Stmt *>()));
2583 return T->getStmtClass() == SwitchStmtClass;
2589 private llvm::TrailingObjects<WhileStmt, Stmt *> {
2590 friend TrailingObjects;
2607 enum { VarOffset = 0, BodyOffsetFromCond = 1 };
2608 enum { NumMandatoryStmtPtr = 2 };
2612 unsigned varOffset()
const {
return VarOffset; }
2613 unsigned condOffset()
const {
return VarOffset +
hasVarStorage(); }
2614 unsigned bodyOffset()
const {
return condOffset() + BodyOffsetFromCond; }
2616 unsigned numTrailingObjects(OverloadToken<Stmt *>)
const {
2642 return reinterpret_cast<Expr *
>(getTrailingObjects<Stmt *>()[condOffset()]);
2646 return reinterpret_cast<Expr *
>(getTrailingObjects<Stmt *>()[condOffset()]);
2650 getTrailingObjects<Stmt *>()[condOffset()] =
reinterpret_cast<Stmt *
>(Cond);
2653 Stmt *
getBody() {
return getTrailingObjects<Stmt *>()[bodyOffset()]; }
2655 return getTrailingObjects<Stmt *>()[bodyOffset()];
2659 getTrailingObjects<Stmt *>()[bodyOffset()] = Body;
2683 getTrailingObjects<Stmt *>()[varOffset()])
2689 getTrailingObjects<Stmt *>()[varOffset()])
2695 getTrailingObjects<Stmt *>()[varOffset()] = CondVar;
2712 return T->getStmtClass() == WhileStmtClass;
2718 getTrailingObjects<Stmt *>() +
2719 numTrailingObjects(OverloadToken<Stmt *>()));
2724 getTrailingObjects<Stmt *>() +
2725 numTrailingObjects(OverloadToken<Stmt *>()));
2731 enum { BODY, COND, END_EXPR };
2732 Stmt *SubExprs[END_EXPR];
2739 :
Stmt(DoStmtClass), WhileLoc(WL), RParenLoc(RP) {
2750 return reinterpret_cast<Expr *
>(SubExprs[COND]);
2770 return T->getStmtClass() == DoStmtClass;
2775 return child_range(&SubExprs[0], &SubExprs[0] + END_EXPR);
2789 enum { INIT, CONDVAR, COND, INC, BODY, END_EXPR };
2790 Stmt* SubExprs[END_EXPR];
2817 return reinterpret_cast<DeclStmt*
>(SubExprs[CONDVAR]);
2821 return reinterpret_cast<DeclStmt*
>(SubExprs[CONDVAR]);
2825 SubExprs[CONDVAR] = CondVar;
2853 return T->getStmtClass() == ForStmtClass;
2858 return child_range(&SubExprs[0], &SubExprs[0]+END_EXPR);
2873 :
Stmt(GotoStmtClass),
Label(label), LabelLoc(LL) {
2892 return T->getStmtClass() == GotoStmtClass;
2912 :
Stmt(IndirectGotoStmtClass), StarLoc(starLoc) {
2928 return reinterpret_cast<const Expr *
>(
Target);
2943 return T->getStmtClass() == IndirectGotoStmtClass;
2971 return T->getStmtClass() == ContinueStmtClass;
3001 return T->getStmtClass() == BreakStmtClass;
3024 private llvm::TrailingObjects<ReturnStmt, const VarDecl *> {
3025 friend TrailingObjects;
3034 bool hasNRVOCandidate()
const {
return ReturnStmtBits.HasNRVOCandidate; }
3036 unsigned numTrailingObjects(OverloadToken<const VarDecl *>)
const {
3037 return hasNRVOCandidate();
3049 const VarDecl *NRVOCandidate);
3065 return hasNRVOCandidate() ? *getTrailingObjects<const VarDecl *>()
3073 assert(hasNRVOCandidate() &&
3074 "This return statement has no storage for an NRVO candidate!");
3075 *getTrailingObjects<const VarDecl *>() = Var;
3087 return T->getStmtClass() == ReturnStmtClass;
3126 unsigned numoutputs,
unsigned numinputs,
unsigned numclobbers)
3190 return T->getStmtClass() == GCCAsmStmtClass ||
3191 T->getStmtClass() == MSAsmStmtClass;
3274 unsigned NumLabels = 0;
3278 bool isvolatile,
unsigned numoutputs,
unsigned numinputs,
3318 : MyKind(
Operand), Str(S), OperandNo(OpNo),
3332 assert(
isOperand() &&
"Range is currently used only for Operands.");
3358 return II->getName();
3366 return Constraints[i];
3369 return Constraints[i];
3386 return II->getName();
3410 return NumLabels > 0;
3453 void setOutputsAndInputsAndClobbers(
const ASTContext &
C,
3482 return T->getStmtClass() == GCCAsmStmtClass;
3493 unsigned NumAsmToks = 0;
3495 Token *AsmToks =
nullptr;
3496 StringRef *Constraints =
nullptr;
3497 StringRef *Clobbers =
nullptr;
3530 return Constraints[i];
3571 void initialize(
const ASTContext &
C, StringRef AsmString,
3579 return T->getStmtClass() == MSAsmStmtClass;
3598 enum { FILTER_EXPR,
BLOCK };
3604 static SEHExceptStmt*
Create(
const ASTContext &
C,
3605 SourceLocation ExceptLoc,
3615 return reinterpret_cast<Expr*
>(Children[FILTER_EXPR]);
3619 return cast<CompoundStmt>(Children[
BLOCK]);
3631 return T->getStmtClass() == SEHExceptStmtClass;
3666 return T->getStmtClass() == SEHFinallyStmtClass;
3678 enum { TRY = 0, HANDLER = 1 };
3688 static SEHTryStmt*
Create(
const ASTContext &
C,
bool isCXXTry,
3689 SourceLocation TryLoc,
Stmt *TryBlock,
3700 return cast<CompoundStmt>(Children[TRY]);
3718 return T->getStmtClass() == SEHTryStmtClass;
3728 :
Stmt(SEHLeaveStmtClass), LeaveLoc(LL) {}
3740 return T->getStmtClass() == SEHLeaveStmtClass;
3776 llvm::PointerIntPair<VarDecl *, 2, VariableCaptureKind> VarAndKind;
3827 unsigned NumCaptures;
3831 llvm::PointerIntPair<CapturedDecl *, 2, CapturedRegionKind> CapDeclAndKind;
3843 Stmt **getStoredStmts() {
return reinterpret_cast<Stmt **
>(
this + 1); }
3845 Stmt *
const *getStoredStmts()
const {
3846 return reinterpret_cast<Stmt *
const *
>(
this + 1);
3849 Capture *getStoredCaptures()
const;
3851 void setCapturedStmt(
Stmt *S) { getStoredStmts()[NumCaptures] = S; }
3863 unsigned NumCaptures);
3887 assert(
D &&
"null RecordDecl");
3914 return getStoredCaptures() + NumCaptures;
3928 llvm::iterator_range<const_capture_init_iterator>;
3940 return reinterpret_cast<Expr **
>(getStoredStmts());
3944 return reinterpret_cast<Expr *
const *
>(getStoredStmts());
3970 return T->getStmtClass() == CapturedStmtClass;
static StringRef bytes(const std::vector< T, Allocator > &v)
enum clang::sema::@1655::IndirectLocalPathEntry::EntryKind Kind
const LambdaCapture * Capture
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines several types used to describe C++ lambda expressions that are shared between the parser and ...
Defines the clang::LangOptions interface.
llvm::MachO::Target Target
Defines an enumeration for C++ overloaded operators.
Defines the clang::SourceLocation class and associated facilities.
Defines various enumerations that describe declaration and type specifiers.
#define BLOCK(DERIVED, BASE)
Defines enumerations for the type traits support.
__device__ __2f16 float __ockl_bool s
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Reads an AST files chain containing the contents of a translation unit.
AddrLabelExpr - The GNU address of label extension, representing &&label.
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
AsmStmt is the base class for GCCAsmStmt and MSAsmStmt.
outputs_iterator begin_outputs()
void setAsmLoc(SourceLocation L)
const_outputs_iterator end_outputs() const
outputs_iterator end_outputs()
const_inputs_iterator begin_inputs() const
unsigned getNumPlusOperands() const
getNumPlusOperands - Return the number of output operands that have a "+" constraint.
AsmStmt(StmtClass SC, SourceLocation asmloc, bool issimple, bool isvolatile, unsigned numoutputs, unsigned numinputs, unsigned numclobbers)
static bool classof(const Stmt *T)
StringRef getOutputConstraint(unsigned i) const
getOutputConstraint - Return the constraint string for the specified output operand.
inputs_const_range inputs() const
SourceLocation getAsmLoc() const
const Expr * getInputExpr(unsigned i) const
SourceLocation getEndLoc() const LLVM_READONLY
llvm::iterator_range< inputs_iterator > inputs_range
bool isOutputPlusConstraint(unsigned i) const
isOutputPlusConstraint - Return true if the specified output constraint is a "+" constraint (which is...
unsigned getNumClobbers() const
const_inputs_iterator end_inputs() const
llvm::iterator_range< const_inputs_iterator > inputs_const_range
const_child_range children() const
bool IsSimple
True if the assembly statement does not have any input or output operands.
const Expr * getOutputExpr(unsigned i) const
StringRef getInputConstraint(unsigned i) const
getInputConstraint - Return the specified input constraint.
outputs_const_range outputs() const
inputs_iterator end_inputs()
unsigned getNumOutputs() const
SourceLocation getBeginLoc() const LLVM_READONLY
inputs_iterator begin_inputs()
AsmStmt(StmtClass SC, EmptyShell Empty)
Build an empty inline-assembly statement.
std::string generateAsmString(const ASTContext &C) const
Assemble final IR asm string.
bool IsVolatile
If true, treat this inline assembly as having side effects.
unsigned getNumInputs() const
llvm::iterator_range< outputs_iterator > outputs_range
StringRef getClobber(unsigned i) const
const_outputs_iterator begin_outputs() const
llvm::iterator_range< const_outputs_iterator > outputs_const_range
AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*, __atomic_load,...
Attr - This represents one attribute.
Represents an attribute applied to a statement.
static AttributedStmt * CreateEmpty(const ASTContext &C, unsigned NumAttrs)
const Stmt * getSubStmt() const
SourceLocation getAttrLoc() const
ArrayRef< const Attr * > getAttrs() const
const_child_range children() const
static bool classof(const Stmt *T)
SourceLocation getEndLoc() const LLVM_READONLY
SourceLocation getBeginLoc() const
A builtin binary operation expression such as "x + y" or "x <= y".
BreakStmt - This represents a break.
SourceLocation getBreakLoc() const
SourceLocation getEndLoc() const
SourceLocation getBeginLoc() const
BreakStmt(SourceLocation BL)
const_child_range children() const
static bool classof(const Stmt *T)
void setBreakLoc(SourceLocation L)
BreakStmt(EmptyShell Empty)
Build an empty break statement.
A boolean literal, per ([C++ lex.bool] Boolean literals).
Represents a call to a C++ constructor.
A default argument (C++ [dcl.fct.default]).
A use of a default initializer in a constructor or in aggregate initialization.
Represents a delete expression for memory deallocation and destructor calls, e.g.
Represents a C++ member access expression where the actual member referenced could not be resolved be...
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)".
Represents a C++11 noexcept expression (C++ [expr.unary.noexcept]).
The null pointer literal (C++11 [lex.nullptr])
A call to an overloaded operator written using operator syntax.
A rewritten comparison expression that was originally written using operator syntax.
An expression "T()" which creates a value-initialized rvalue of type T, which is a non-class type.
Represents the this expression in C++.
A C++ throw-expression (C++ [except.throw]).
Describes an explicit type conversion that uses functional notion but could not be resolved because o...
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
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.
bool capturesVariableByCopy() const
Determine whether this capture handles a variable by copy.
VariableCaptureKind getCaptureKind() const
Determine the kind of capture.
VarDecl * getCapturedVar() const
Retrieve the declaration of the variable being captured.
bool capturesVariableArrayType() const
Determine whether this capture handles a variable-length array type.
bool capturesThis() const
Determine whether this capture handles the C++ 'this' pointer.
bool capturesVariable() const
Determine whether this capture handles a variable (by reference).
SourceLocation getLocation() const
Retrieve the source location at which the variable or 'this' was first used.
This captures a statement into a function.
unsigned capture_size() const
Retrieve the number of captures, including 'this'.
const_capture_iterator capture_begin() const
static CapturedStmt * CreateDeserialized(const ASTContext &Context, unsigned NumCaptures)
SourceLocation getEndLoc() const LLVM_READONLY
capture_init_range capture_inits()
void setCapturedRegionKind(CapturedRegionKind Kind)
Set the captured region kind.
const_capture_init_iterator capture_init_begin() const
CapturedDecl * getCapturedDecl()
Retrieve the outlined function declaration.
SourceRange getSourceRange() const LLVM_READONLY
capture_iterator capture_end() const
Retrieve an iterator pointing past the end of the sequence of captures.
const RecordDecl * getCapturedRecordDecl() const
Retrieve the record declaration for captured variables.
Stmt * getCapturedStmt()
Retrieve the statement being captured.
llvm::iterator_range< capture_init_iterator > capture_init_range
llvm::iterator_range< capture_iterator > capture_range
bool capturesVariable(const VarDecl *Var) const
True if this variable has been captured.
static bool classof(const Stmt *T)
capture_init_iterator capture_init_begin()
Retrieve the first initialization argument.
void setCapturedDecl(CapturedDecl *D)
Set the outlined function declaration.
capture_iterator capture_begin()
Retrieve an iterator pointing to the first capture.
llvm::iterator_range< const_capture_init_iterator > const_capture_init_range
const_capture_init_iterator capture_init_end() const
SourceLocation getBeginLoc() const LLVM_READONLY
void setCapturedRecordDecl(RecordDecl *D)
Set the record declaration for captured variables.
llvm::iterator_range< const_capture_iterator > capture_const_range
capture_init_iterator capture_init_end()
Retrieve the iterator pointing one past the last initialization argument.
Expr *const * const_capture_init_iterator
Const iterator that walks over the capture initialization arguments.
const Stmt * getCapturedStmt() const
capture_const_range captures() const
CapturedRegionKind getCapturedRegionKind() const
Retrieve the captured region kind.
VariableCaptureKind
The different capture forms: by 'this', by reference, capture for variable-length array type etc.
const_capture_init_range capture_inits() const
CaseStmt - Represent a case statement.
const Expr * getRHS() const
const_child_range children() const
SourceLocation getBeginLoc() const
void setEllipsisLoc(SourceLocation L)
Set the location of the ... in a case statement of the form LHS ... RHS.
static bool classof(const Stmt *T)
bool caseStmtIsGNURange() const
True if this case statement is of the form case LHS ... RHS, which is a GNU extension.
const Expr * getLHS() const
SourceLocation getEllipsisLoc() const
Get the location of the ... in a case statement of the form LHS ... RHS.
void setCaseLoc(SourceLocation L)
SourceLocation getCaseLoc() const
static CaseStmt * CreateEmpty(const ASTContext &Ctx, bool CaseStmtIsGNURange)
Build an empty case statement.
const Stmt * getSubStmt() const
SourceLocation getEndLoc() const LLVM_READONLY
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
Represents a character-granular source range.
Represents a 'co_await' expression.
CompoundStmt - This represents a group of statements like { stmt stmt }.
static bool classof(const Stmt *T)
std::reverse_iterator< const_body_iterator > const_reverse_body_iterator
body_const_range body() const
Stmt *const * const_body_iterator
const_reverse_body_iterator body_rend() const
llvm::iterator_range< const_body_iterator > body_const_range
std::reverse_iterator< body_iterator > reverse_body_iterator
reverse_body_iterator body_rbegin()
llvm::iterator_range< body_iterator > body_range
const Stmt * getStmtExprResult() const
FPOptionsOverride getStoredFPFeatures() const
Get FPOptionsOverride from trailing storage.
const Stmt * body_front() const
SourceLocation getBeginLoc() const
static CompoundStmt * CreateEmpty(const ASTContext &C, unsigned NumStmts, bool HasFPFeatures)
SourceLocation getLBracLoc() const
body_iterator body_begin()
SourceLocation getEndLoc() const
bool hasStoredFPFeatures() const
const_child_range children() const
CompoundStmt(SourceLocation Loc, SourceLocation EndLoc)
reverse_body_iterator body_rend()
CompoundStmt(SourceLocation Loc)
const_body_iterator body_begin() const
Stmt * getStmtExprResult()
const Stmt * body_back() const
const_reverse_body_iterator body_rbegin() const
FPOptionsOverride getStoredFPFeaturesOrDefault() const
Get the store FPOptionsOverride or default if not stored.
SourceLocation getRBracLoc() const
const_body_iterator body_end() const
ConstantExpr - An expression that occurs in a constant context and optionally the result of evaluatin...
ContinueStmt - This represents a continue.
ContinueStmt(EmptyShell Empty)
Build an empty continue statement.
ContinueStmt(SourceLocation CL)
static bool classof(const Stmt *T)
void setContinueLoc(SourceLocation L)
SourceLocation getContinueLoc() const
SourceLocation getEndLoc() const
const_child_range children() const
SourceLocation getBeginLoc() const
Decl *const * const_iterator
bool isSingleDecl() const
A reference to a declared variable, function, enum, etc.
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
std::reverse_iterator< decl_iterator > reverse_decl_iterator
llvm::iterator_range< decl_iterator > decl_range
const_child_range children() const
SourceLocation getEndLoc() const
const DeclGroupRef getDeclGroup() const
DeclStmt(EmptyShell Empty)
Build an empty declaration statement.
bool isSingleDecl() const
isSingleDecl - This method returns true if this DeclStmt refers to a single Decl.
const_decl_iterator decl_begin() const
void setStartLoc(SourceLocation L)
DeclGroupRef::const_iterator const_decl_iterator
static bool classof(const Stmt *T)
void setEndLoc(SourceLocation L)
decl_iterator decl_begin()
decl_range decls()
Definition:<