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'.");
112 #define NumStmtBits 9
137 LLVM_PREFERRED_TYPE(
bool)
138 unsigned HasLeadingEmptyMacro : 1;
153 LLVM_PREFERRED_TYPE(
bool)
154 unsigned HasFPFeatures : 1;
194 LLVM_PREFERRED_TYPE(
bool)
195 unsigned HasElse : 1;
198 LLVM_PREFERRED_TYPE(
bool)
202 LLVM_PREFERRED_TYPE(
bool)
203 unsigned HasInit : 1;
216 LLVM_PREFERRED_TYPE(
bool)
217 unsigned HasInit : 1;
220 LLVM_PREFERRED_TYPE(
bool)
226 LLVM_PREFERRED_TYPE(
bool)
227 unsigned AllEnumCasesCovered : 1;
241 LLVM_PREFERRED_TYPE(
bool)
306 LLVM_PREFERRED_TYPE(
bool)
307 unsigned HasNRVOCandidate : 1;
322 LLVM_PREFERRED_TYPE(
bool)
323 unsigned CaseStmtIsGNURange : 1;
359 unsigned ValueKind : 2;
361 unsigned ObjectKind : 3;
363 unsigned Dependent : llvm::BitWidth<ExprDependence>;
377 unsigned ResultKind : 2;
381 unsigned APValueKind : 4;
385 LLVM_PREFERRED_TYPE(
bool)
386 unsigned IsUnsigned : 1;
392 unsigned BitWidth : 7;
396 LLVM_PREFERRED_TYPE(
bool)
397 unsigned HasCleanup : 1;
400 LLVM_PREFERRED_TYPE(
bool)
401 unsigned IsImmediateInvocation : 1;
416 LLVM_PREFERRED_TYPE(
bool)
417 unsigned HasFunctionName : 1;
421 LLVM_PREFERRED_TYPE(
bool)
422 unsigned IsTransparent : 1;
435 LLVM_PREFERRED_TYPE(
bool)
436 unsigned HasQualifier : 1;
437 LLVM_PREFERRED_TYPE(
bool)
438 unsigned HasTemplateKWAndArgsInfo : 1;
439 LLVM_PREFERRED_TYPE(
bool)
440 unsigned HasFoundDecl : 1;
441 LLVM_PREFERRED_TYPE(
bool)
442 unsigned HadMultipleCandidates : 1;
443 LLVM_PREFERRED_TYPE(
bool)
444 unsigned RefersToEnclosingVariableOrCapture : 1;
445 LLVM_PREFERRED_TYPE(
bool)
446 unsigned CapturedByCopyInLambdaWithExplicitObjectParameter : 1;
449 LLVM_PREFERRED_TYPE(
bool)
450 unsigned IsImmediateEscalating : 1;
464 llvm::APFloat::S_MaxSemantics < 32,
465 "Too many Semantics enum values to fit in bitfield of size 5");
466 LLVM_PREFERRED_TYPE(llvm::APFloat::Semantics)
467 unsigned Semantics : 5;
468 LLVM_PREFERRED_TYPE(
bool)
469 unsigned IsExact : 1;
487 unsigned CharByteWidth : 3;
489 LLVM_PREFERRED_TYPE(
bool)
490 unsigned IsPascal : 1;
494 unsigned NumConcatenated;
515 LLVM_PREFERRED_TYPE(
bool)
516 unsigned CanOverflow : 1;
521 LLVM_PREFERRED_TYPE(
bool)
522 unsigned HasFPFeatures : 1;
535 LLVM_PREFERRED_TYPE(
bool)
555 unsigned NumPreArgs : 1;
558 LLVM_PREFERRED_TYPE(
bool)
559 unsigned UsesADL : 1;
562 LLVM_PREFERRED_TYPE(
bool)
563 unsigned HasFPFeatures : 1;
566 unsigned IsCoroElideSafe : 1;
574 unsigned OffsetToTrailingObjects : 8;
586 LLVM_PREFERRED_TYPE(
bool)
587 unsigned IsArrow : 1;
591 LLVM_PREFERRED_TYPE(
bool)
592 unsigned HasQualifier : 1;
595 LLVM_PREFERRED_TYPE(
bool)
596 unsigned HasFoundDecl : 1;
603 LLVM_PREFERRED_TYPE(
bool)
604 unsigned HasTemplateKWAndArgsInfo : 1;
608 LLVM_PREFERRED_TYPE(
bool)
609 unsigned HadMultipleCandidates : 1;
630 LLVM_PREFERRED_TYPE(
bool)
631 unsigned PartOfExplicitCast : 1;
634 LLVM_PREFERRED_TYPE(
bool)
635 unsigned HasFPFeatures : 1;
639 unsigned BasePathSize;
654 LLVM_PREFERRED_TYPE(
bool)
655 unsigned HasFPFeatures : 1;
659 LLVM_PREFERRED_TYPE(
bool)
660 unsigned ExcludedOverflowPattern : 1;
673 LLVM_PREFERRED_TYPE(
bool)
674 unsigned HadArrayRangeDesignator : 1;
706 unsigned NumSubExprs : 16;
707 unsigned ResultIndex : 16;
731 LLVM_PREFERRED_TYPE(
bool)
732 unsigned ProducedByFoldExpansion : 1;
745 unsigned TemplateDepth;
760 unsigned OperatorKind : 6;
770 LLVM_PREFERRED_TYPE(
bool)
771 unsigned IsReversed : 1;
781 LLVM_PREFERRED_TYPE(
bool)
805 LLVM_PREFERRED_TYPE(
bool)
806 unsigned IsImplicit : 1;
810 LLVM_PREFERRED_TYPE(
bool)
811 unsigned CapturedByCopyInLambdaWithExplicitObjectParameter : 1;
825 LLVM_PREFERRED_TYPE(
bool)
826 unsigned IsThrownVariableInScope : 1;
840 LLVM_PREFERRED_TYPE(
bool)
841 unsigned HasRewrittenInit : 1;
856 LLVM_PREFERRED_TYPE(
bool)
857 unsigned HasRewrittenInit : 1;
882 LLVM_PREFERRED_TYPE(
bool)
883 unsigned IsGlobalNew : 1;
887 LLVM_PREFERRED_TYPE(
bool)
888 unsigned IsArray : 1;
891 LLVM_PREFERRED_TYPE(
bool)
892 unsigned ShouldPassAlignment : 1;
896 LLVM_PREFERRED_TYPE(
bool)
897 unsigned UsualArrayDeleteWantsSize : 1;
900 LLVM_PREFERRED_TYPE(
bool)
901 unsigned HasInitializer : 1;
905 unsigned StoredInitializationStyle : 2;
908 LLVM_PREFERRED_TYPE(
bool)
909 unsigned IsParenTypeId : 1;
912 unsigned NumPlacementArgs;
923 LLVM_PREFERRED_TYPE(
bool)
924 unsigned GlobalDelete : 1;
927 LLVM_PREFERRED_TYPE(
bool)
928 unsigned ArrayForm : 1;
933 LLVM_PREFERRED_TYPE(
bool)
934 unsigned ArrayFormAsWritten : 1;
938 LLVM_PREFERRED_TYPE(
bool)
939 unsigned UsualArrayDeleteWantsSize : 1;
959 LLVM_PREFERRED_TYPE(
bool)
978 LLVM_PREFERRED_TYPE(
bool)
979 unsigned HasTemplateKWAndArgsInfo : 1;
989 LLVM_PREFERRED_TYPE(
bool)
990 unsigned Elidable : 1;
991 LLVM_PREFERRED_TYPE(
bool)
992 unsigned HadMultipleCandidates : 1;
993 LLVM_PREFERRED_TYPE(
bool)
994 unsigned ListInitialization : 1;
995 LLVM_PREFERRED_TYPE(
bool)
996 unsigned StdInitListInitialization : 1;
997 LLVM_PREFERRED_TYPE(
bool)
998 unsigned ZeroInitialization : 1;
1000 unsigned ConstructionKind : 3;
1001 LLVM_PREFERRED_TYPE(
bool)
1002 unsigned IsImmediateEscalating : 1;
1015 LLVM_PREFERRED_TYPE(
bool)
1016 unsigned CleanupsHaveSideEffects : 1;
1041 LLVM_PREFERRED_TYPE(
bool)
1042 unsigned IsArrow : 1;
1046 LLVM_PREFERRED_TYPE(
bool)
1047 unsigned HasTemplateKWAndArgsInfo : 1;
1051 LLVM_PREFERRED_TYPE(
bool)
1052 unsigned HasFirstQualifierFoundInScope : 1;
1067 LLVM_PREFERRED_TYPE(
bool)
1068 unsigned HasTemplateKWAndArgsInfo : 1;
1076 unsigned NumResults;
1089 LLVM_PREFERRED_TYPE(
bool)
1090 unsigned RequiresADL : 1;
1093 "UnresolvedLookupExprBitfields must be <= than 4 bytes to"
1094 "avoid trashing OverloadExprBitfields::NumResults!");
1105 LLVM_PREFERRED_TYPE(
bool)
1106 unsigned IsArrow : 1;
1109 LLVM_PREFERRED_TYPE(
bool)
1110 unsigned HasUnresolvedUsing : 1;
1113 "UnresolvedMemberExprBitfields must be <= than 4 bytes to"
1114 "avoid trashing OverloadExprBitfields::NumResults!");
1123 LLVM_PREFERRED_TYPE(
bool)
1149 unsigned CaptureDefault : 2;
1153 LLVM_PREFERRED_TYPE(
bool)
1154 unsigned ExplicitParams : 1;
1157 LLVM_PREFERRED_TYPE(
bool)
1158 unsigned ExplicitResultType : 1;
1161 unsigned NumCaptures : 16;
1172 LLVM_PREFERRED_TYPE(
bool)
1173 unsigned IsSatisfied : 1;
1185 LLVM_PREFERRED_TYPE(
bool)
1186 unsigned IsImplicit : 1;
1197 LLVM_PREFERRED_TYPE(
bool)
1198 unsigned ShouldCopy : 1;
1212 LLVM_PREFERRED_TYPE(
bool)
1213 unsigned IsUnique : 1;
1302 unsigned alignment = 8);
1305 unsigned alignment = 8) {
1306 return operator new(
bytes, *
C, alignment);
1309 void *
operator new(
size_t bytes,
void *mem)
noexcept {
return mem; }
1313 void operator delete(
void *,
size_t)
noexcept {}
1314 void operator delete(
void *,
void *)
noexcept {}
1335 template<
typename T,
typename TPtr = T *,
typename StmtPtr = Stmt *>
1337 : llvm::iterator_adaptor_base<CastIterator<T, TPtr, StmtPtr>, StmtPtr *,
1338 std::random_access_iterator_tag, TPtr> {
1339 using Base =
typename CastIterator::iterator_adaptor_base;
1345 return cast_or_null<T>(*this->I);
1350 template <
typename T>
1358 static bool StatisticsEnabled;
1372 static_assert(
sizeof(*this) <= 8,
1373 "changing bitfields changed sizeof(Stmt)");
1374 static_assert(
sizeof(*this) %
alignof(
void *) == 0,
1375 "Insufficient alignment!");
1415 static
std::tuple<
bool, const
Attr *, const
Attr *>
1434 StringRef NewlineSymbol = "\n",
1438 unsigned Indentation = 0,
1439 StringRef NewlineSymbol = "\n",
1459 return const_cast<Stmt*
>(
1503 bool Canonical,
bool ProfileLambdaExpr =
false)
const;
1525 :
Stmt(DeclStmtClass), DG(dg), StartLoc(startLoc), EndLoc(endLoc) {}
1548 return T->getStmtClass() == DeclStmtClass;
1594 :
Stmt(NullStmtClass) {
1613 return T->getStmtClass() == NullStmtClass;
1628 private llvm::TrailingObjects<CompoundStmt, Stmt *, FPOptionsOverride> {
1630 friend TrailingObjects;
1647 *getTrailingObjects<FPOptionsOverride>() = F;
1650 size_t numTrailingObjects(OverloadToken<Stmt *>)
const {
1655 static CompoundStmt *
Create(
const ASTContext &
C, ArrayRef<Stmt *> Stmts,
1656 FPOptionsOverride FPFeatures, SourceLocation LB,
1663 :
Stmt(CompoundStmtClass), LBraceLoc(
Loc), RBraceLoc(EndLoc) {
1670 bool HasFPFeatures);
1680 return *getTrailingObjects<FPOptionsOverride>();
1708 return getTrailingObjects<Stmt *>();
1732 std::reverse_iterator<const_body_iterator>;
1751 for (
auto *B : llvm::reverse(
body())) {
1752 if (!isa<NullStmt>(B))
1769 return T->getStmtClass() == CompoundStmtClass;
1819 return T->getStmtClass() == CaseStmtClass ||
1820 T->getStmtClass() == DefaultStmtClass;
1828 private llvm::TrailingObjects<CaseStmt, Stmt *, SourceLocation> {
1829 friend TrailingObjects;
1846 enum { LhsOffset = 0, SubStmtOffsetFromRhs = 1 };
1847 enum { NumMandatoryStmtPtr = 2 };
1849 unsigned numTrailingObjects(OverloadToken<Stmt *>)
const {
1853 unsigned numTrailingObjects(OverloadToken<SourceLocation>)
const {
1857 unsigned lhsOffset()
const {
return LhsOffset; }
1859 unsigned subStmtOffset()
const {
return rhsOffset() + SubStmtOffsetFromRhs; }
1865 :
SwitchCase(CaseStmtClass, caseLoc, colonLoc) {
1867 bool IsGNURange = rhs !=
nullptr;
1911 "setEllipsisLoc but this is not a case stmt of the form LHS ... RHS!");
1912 *getTrailingObjects<SourceLocation>() = L;
1916 return reinterpret_cast<Expr *
>(getTrailingObjects<Stmt *>()[lhsOffset()]);
1920 return reinterpret_cast<Expr *
>(getTrailingObjects<Stmt *>()[lhsOffset()]);
1924 getTrailingObjects<Stmt *>()[lhsOffset()] =
reinterpret_cast<Stmt *
>(Val);
1929 getTrailingObjects<Stmt *>()[rhsOffset()])
1935 getTrailingObjects<Stmt *>()[rhsOffset()])
1941 "setRHS but this is not a case stmt of the form LHS ... RHS!");
1942 getTrailingObjects<Stmt *>()[rhsOffset()] =
reinterpret_cast<Stmt *
>(Val);
1947 return getTrailingObjects<Stmt *>()[subStmtOffset()];
1951 getTrailingObjects<Stmt *>()[subStmtOffset()] = S;
1958 while (
const auto *CS2 = dyn_cast<CaseStmt>(CS->
getSubStmt()))
1965 return T->getStmtClass() == CaseStmtClass;
1971 getTrailingObjects<Stmt *>() +
1972 numTrailingObjects(OverloadToken<Stmt *>()));
1977 getTrailingObjects<Stmt *>() +
1978 numTrailingObjects(OverloadToken<Stmt *>()));
1987 :
SwitchCase(DefaultStmtClass, DL, CL), SubStmt(substmt) {}
2006 return T->getStmtClass() == DefaultStmtClass;
2018 if (
const auto *CS = dyn_cast<CaseStmt>(
this))
2019 return CS->getEndLoc();
2020 else if (
const auto *DS = dyn_cast<DefaultStmt>(
this))
2021 return DS->getEndLoc();
2022 llvm_unreachable(
"SwitchCase is neither a CaseStmt nor a DefaultStmt!");
2026 if (
auto *CS = dyn_cast<CaseStmt>(
this))
2027 return CS->getSubStmt();
2028 else if (
auto *DS = dyn_cast<DefaultStmt>(
this))
2029 return DS->getSubStmt();
2030 llvm_unreachable(
"SwitchCase is neither a CaseStmt nor a DefaultStmt!");
2051 return T->getStmtClass() >= firstValueStmtConstant &&
2052 T->getStmtClass() <= lastValueStmtConstant;
2061 bool SideEntry =
false;
2066 :
ValueStmt(LabelStmtClass), TheDecl(
D), SubStmt(substmt) {
2095 return T->getStmtClass() == LabelStmtClass;
2107 private llvm::TrailingObjects<AttributedStmt, const Attr *> {
2109 friend TrailingObjects;
2115 :
ValueStmt(AttributedStmtClass), SubStmt(SubStmt) {
2118 std::copy(Attrs.begin(), Attrs.end(), getAttrArrayPtr());
2125 std::fill_n(getAttrArrayPtr(), NumAttrs,
nullptr);
2128 const Attr *
const *getAttrArrayPtr()
const {
2129 return getTrailingObjects<const Attr *>();
2131 const Attr **getAttrArrayPtr() {
return getTrailingObjects<const Attr *>(); }
2134 static AttributedStmt *
Create(
const ASTContext &
C, SourceLocation
Loc,
2135 ArrayRef<const Attr *> Attrs,
Stmt *SubStmt);
2138 static AttributedStmt *
CreateEmpty(
const ASTContext &
C,
unsigned NumAttrs);
2158 return T->getStmtClass() == AttributedStmtClass;
2165 private llvm::TrailingObjects<IfStmt, Stmt *, SourceLocation> {
2166 friend TrailingObjects;
2190 enum { InitOffset = 0, ThenOffsetFromCond = 1, ElseOffsetFromCond = 2 };
2191 enum { NumMandatoryStmtPtr = 2 };
2195 unsigned numTrailingObjects(OverloadToken<Stmt *>)
const {
2200 unsigned numTrailingObjects(OverloadToken<SourceLocation>)
const {
2204 unsigned initOffset()
const {
return InitOffset; }
2205 unsigned varOffset()
const {
return InitOffset +
hasInitStorage(); }
2206 unsigned condOffset()
const {
2209 unsigned thenOffset()
const {
return condOffset() + ThenOffsetFromCond; }
2210 unsigned elseOffset()
const {
return condOffset() + ElseOffsetFromCond; }
2226 Stmt *Else =
nullptr);
2243 return reinterpret_cast<Expr *
>(getTrailingObjects<Stmt *>()[condOffset()]);
2247 return reinterpret_cast<Expr *
>(getTrailingObjects<Stmt *>()[condOffset()]);
2251 getTrailingObjects<Stmt *>()[condOffset()] =
reinterpret_cast<Stmt *
>(Cond);
2254 Stmt *
getThen() {
return getTrailingObjects<Stmt *>()[thenOffset()]; }
2256 return getTrailingObjects<Stmt *>()[thenOffset()];
2260 getTrailingObjects<Stmt *>()[thenOffset()] = Then;
2264 return hasElseStorage() ? getTrailingObjects<Stmt *>()[elseOffset()]
2269 return hasElseStorage() ? getTrailingObjects<Stmt *>()[elseOffset()]
2275 "This if statement has no storage for an else statement!");
2276 getTrailingObjects<Stmt *>()[elseOffset()] = Else;
2300 getTrailingObjects<Stmt *>()[varOffset()])
2306 getTrailingObjects<Stmt *>()[varOffset()])
2312 getTrailingObjects<Stmt *>()[varOffset()] = CondVar;
2316 return hasInitStorage() ? getTrailingObjects<Stmt *>()[initOffset()]
2321 return hasInitStorage() ? getTrailingObjects<Stmt *>()[initOffset()]
2327 "This if statement has no storage for an init statement!");
2328 getTrailingObjects<Stmt *>()[initOffset()] =
Init;
2341 "This if statement has no storage for an else statement!");
2342 *getTrailingObjects<SourceLocation>() = ElseLoc;
2395 getTrailingObjects<Stmt *>() +
2396 numTrailingObjects(OverloadToken<Stmt *>()));
2404 getTrailingObjects<Stmt *>() +
2405 numTrailingObjects(OverloadToken<Stmt *>()));
2409 return T->getStmtClass() == IfStmtClass;
2415 private llvm::TrailingObjects<SwitchStmt, Stmt *> {
2416 friend TrailingObjects;
2438 enum { InitOffset = 0, BodyOffsetFromCond = 1 };
2439 enum { NumMandatoryStmtPtr = 2 };
2443 unsigned numTrailingObjects(OverloadToken<Stmt *>)
const {
2447 unsigned initOffset()
const {
return InitOffset; }
2448 unsigned varOffset()
const {
return InitOffset +
hasInitStorage(); }
2449 unsigned condOffset()
const {
2452 unsigned bodyOffset()
const {
return condOffset() + BodyOffsetFromCond; }
2479 return reinterpret_cast<Expr *
>(getTrailingObjects<Stmt *>()[condOffset()]);
2483 return reinterpret_cast<Expr *
>(getTrailingObjects<Stmt *>()[condOffset()]);
2487 getTrailingObjects<Stmt *>()[condOffset()] =
reinterpret_cast<Stmt *
>(Cond);
2490 Stmt *
getBody() {
return getTrailingObjects<Stmt *>()[bodyOffset()]; }
2492 return getTrailingObjects<Stmt *>()[bodyOffset()];
2496 getTrailingObjects<Stmt *>()[bodyOffset()] = Body;
2500 return hasInitStorage() ? getTrailingObjects<Stmt *>()[initOffset()]
2505 return hasInitStorage() ? getTrailingObjects<Stmt *>()[initOffset()]
2511 "This switch statement has no storage for an init statement!");
2512 getTrailingObjects<Stmt *>()[initOffset()] =
Init;
2537 getTrailingObjects<Stmt *>()[varOffset()])
2543 getTrailingObjects<Stmt *>()[varOffset()])
2549 getTrailingObjects<Stmt *>()[varOffset()] = CondVar;
2570 "case/default already added to a switch");
2594 getTrailingObjects<Stmt *>() +
2595 numTrailingObjects(OverloadToken<Stmt *>()));
2600 getTrailingObjects<Stmt *>() +
2601 numTrailingObjects(OverloadToken<Stmt *>()));
2605 return T->getStmtClass() == SwitchStmtClass;
2611 private llvm::TrailingObjects<WhileStmt, Stmt *> {
2612 friend TrailingObjects;
2629 enum { VarOffset = 0, BodyOffsetFromCond = 1 };
2630 enum { NumMandatoryStmtPtr = 2 };
2634 unsigned varOffset()
const {
return VarOffset; }
2635 unsigned condOffset()
const {
return VarOffset +
hasVarStorage(); }
2636 unsigned bodyOffset()
const {
return condOffset() + BodyOffsetFromCond; }
2638 unsigned numTrailingObjects(OverloadToken<Stmt *>)
const {
2664 return reinterpret_cast<Expr *
>(getTrailingObjects<Stmt *>()[condOffset()]);
2668 return reinterpret_cast<Expr *
>(getTrailingObjects<Stmt *>()[condOffset()]);
2672 getTrailingObjects<Stmt *>()[condOffset()] =
reinterpret_cast<Stmt *
>(Cond);
2675 Stmt *
getBody() {
return getTrailingObjects<Stmt *>()[bodyOffset()]; }
2677 return getTrailingObjects<Stmt *>()[bodyOffset()];
2681 getTrailingObjects<Stmt *>()[bodyOffset()] = Body;
2705 getTrailingObjects<Stmt *>()[varOffset()])
2711 getTrailingObjects<Stmt *>()[varOffset()])
2717 getTrailingObjects<Stmt *>()[varOffset()] = CondVar;
2734 return T->getStmtClass() == WhileStmtClass;
2740 getTrailingObjects<Stmt *>() +
2741 numTrailingObjects(OverloadToken<Stmt *>()));
2746 getTrailingObjects<Stmt *>() +
2747 numTrailingObjects(OverloadToken<Stmt *>()));
2753 enum { BODY, COND, END_EXPR };
2754 Stmt *SubExprs[END_EXPR];
2761 :
Stmt(DoStmtClass), WhileLoc(WL), RParenLoc(RP) {
2772 return reinterpret_cast<Expr *
>(SubExprs[COND]);
2792 return T->getStmtClass() == DoStmtClass;
2797 return child_range(&SubExprs[0], &SubExprs[0] + END_EXPR);
2811 enum { INIT, CONDVAR, COND, INC, BODY, END_EXPR };
2812 Stmt* SubExprs[END_EXPR];
2839 return reinterpret_cast<DeclStmt*
>(SubExprs[CONDVAR]);
2843 return reinterpret_cast<DeclStmt*
>(SubExprs[CONDVAR]);
2847 SubExprs[CONDVAR] = CondVar;
2875 return T->getStmtClass() == ForStmtClass;
2880 return child_range(&SubExprs[0], &SubExprs[0]+END_EXPR);
2895 :
Stmt(GotoStmtClass),
Label(label), LabelLoc(LL) {
2914 return T->getStmtClass() == GotoStmtClass;
2934 :
Stmt(IndirectGotoStmtClass), StarLoc(starLoc) {
2950 return reinterpret_cast<const Expr *
>(
Target);
2965 return T->getStmtClass() == IndirectGotoStmtClass;
2993 return T->getStmtClass() == ContinueStmtClass;
3023 return T->getStmtClass() == BreakStmtClass;
3046 private llvm::TrailingObjects<ReturnStmt, const VarDecl *> {
3047 friend TrailingObjects;
3056 bool hasNRVOCandidate()
const {
return ReturnStmtBits.HasNRVOCandidate; }
3058 unsigned numTrailingObjects(OverloadToken<const VarDecl *>)
const {
3059 return hasNRVOCandidate();
3071 const VarDecl *NRVOCandidate);
3087 return hasNRVOCandidate() ? *getTrailingObjects<const VarDecl *>()
3095 assert(hasNRVOCandidate() &&
3096 "This return statement has no storage for an NRVO candidate!");
3097 *getTrailingObjects<const VarDecl *>() = Var;
3109 return T->getStmtClass() == ReturnStmtClass;
3148 unsigned numoutputs,
unsigned numinputs,
unsigned numclobbers)
3212 return T->getStmtClass() == GCCAsmStmtClass ||
3213 T->getStmtClass() == MSAsmStmtClass;
3296 unsigned NumLabels = 0;
3300 bool isvolatile,
unsigned numoutputs,
unsigned numinputs,
3340 : MyKind(
Operand), Str(S), OperandNo(OpNo),
3354 assert(
isOperand() &&
"Range is currently used only for Operands.");
3380 return II->getName();
3388 return Constraints[i];
3391 return Constraints[i];
3408 return II->getName();
3432 return NumLabels > 0;
3475 void setOutputsAndInputsAndClobbers(
const ASTContext &
C,
3504 return T->getStmtClass() == GCCAsmStmtClass;
3515 unsigned NumAsmToks = 0;
3517 Token *AsmToks =
nullptr;
3518 StringRef *Constraints =
nullptr;
3519 StringRef *Clobbers =
nullptr;
3552 return Constraints[i];
3593 void initialize(
const ASTContext &
C, StringRef AsmString,
3601 return T->getStmtClass() == MSAsmStmtClass;
3620 enum { FILTER_EXPR,
BLOCK };
3626 static SEHExceptStmt*
Create(
const ASTContext &
C,
3627 SourceLocation ExceptLoc,
3637 return reinterpret_cast<Expr*
>(Children[FILTER_EXPR]);
3641 return cast<CompoundStmt>(Children[
BLOCK]);
3653 return T->getStmtClass() == SEHExceptStmtClass;
3688 return T->getStmtClass() == SEHFinallyStmtClass;
3700 enum { TRY = 0, HANDLER = 1 };
3710 static SEHTryStmt*
Create(
const ASTContext &
C,
bool isCXXTry,
3711 SourceLocation TryLoc,
Stmt *TryBlock,
3722 return cast<CompoundStmt>(Children[TRY]);
3740 return T->getStmtClass() == SEHTryStmtClass;
3750 :
Stmt(SEHLeaveStmtClass), LeaveLoc(LL) {}
3762 return T->getStmtClass() == SEHLeaveStmtClass;
3798 llvm::PointerIntPair<VarDecl *, 2, VariableCaptureKind> VarAndKind;
3849 unsigned NumCaptures;
3853 llvm::PointerIntPair<CapturedDecl *, 2, CapturedRegionKind> CapDeclAndKind;
3865 Stmt **getStoredStmts() {
return reinterpret_cast<Stmt **
>(
this + 1); }
3867 Stmt *
const *getStoredStmts()
const {
3868 return reinterpret_cast<Stmt *
const *
>(
this + 1);
3871 Capture *getStoredCaptures()
const;
3873 void setCapturedStmt(
Stmt *S) { getStoredStmts()[NumCaptures] = S; }
3885 unsigned NumCaptures);
3909 assert(
D &&
"null RecordDecl");
3936 return getStoredCaptures() + NumCaptures;
3950 llvm::iterator_range<const_capture_init_iterator>;
3962 return reinterpret_cast<Expr **
>(getStoredStmts());
3966 return reinterpret_cast<Expr *
const *
>(getStoredStmts());
3992 return T->getStmtClass() == CapturedStmtClass;
static StringRef bytes(const std::vector< T, Allocator > &v)
const LambdaCapture * Capture
enum clang::sema::@1718::IndirectLocalPathEntry::EntryKind Kind
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 an rvalue of a non-class type T.
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