Go to the documentation of this file.
13 #ifndef LLVM_CLANG_AST_STMT_H
14 #define LLVM_CLANG_AST_STMT_H
25 #include "llvm/ADT/APFloat.h"
26 #include "llvm/ADT/ArrayRef.h"
27 #include "llvm/ADT/BitmaskEnum.h"
28 #include "llvm/ADT/PointerIntPair.h"
29 #include "llvm/ADT/StringRef.h"
30 #include "llvm/ADT/iterator.h"
31 #include "llvm/ADT/iterator_range.h"
32 #include "llvm/Support/Casting.h"
33 #include "llvm/Support/Compiler.h"
34 #include "llvm/Support/ErrorHandling.h"
44 class FoldingSetNodeID;
59 struct PrintingPolicy;
72 class alignas(void *)
Stmt {
76 #define STMT(CLASS, PARENT) CLASS##Class,
77 #define STMT_RANGE(BASE, FIRST, LAST) \
78 first##BASE##Constant=FIRST##Class, last##BASE##Constant=LAST##Class,
79 #define LAST_STMT_RANGE(BASE, FIRST, LAST) \
80 first##BASE##Constant=FIRST##Class, last##BASE##Constant=LAST##Class
81 #define ABSTRACT_STMT(STMT)
82 #include "clang/AST/StmtNodes.inc"
90 void *
operator new(
size_t bytes) noexcept {
91 llvm_unreachable(
"Stmts cannot be allocated with regular 'new'.");
94 void operator delete(
void *data) noexcept {
95 llvm_unreachable(
"Stmts cannot be released with regular 'delete'.");
122 unsigned HasLeadingEmptyMacro : 1;
136 unsigned HasFPFeatures : 1;
172 unsigned HasElse : 1;
178 unsigned HasInit : 1;
190 unsigned HasInit : 1;
198 unsigned AllEnumCasesCovered : 1;
269 unsigned HasNRVOCandidate : 1;
283 unsigned CaseStmtIsGNURange : 1;
317 unsigned ValueKind : 2;
318 unsigned ObjectKind : 3;
319 unsigned Dependent : llvm::BitWidth<ExprDependence>;
331 unsigned ResultKind : 2;
334 unsigned APValueKind : 4;
338 unsigned IsUnsigned : 1;
343 unsigned BitWidth : 7;
347 unsigned HasCleanup : 1;
350 unsigned IsImmediateInvocation : 1;
365 unsigned HasFunctionName : 1;
377 unsigned HasQualifier : 1;
378 unsigned HasTemplateKWAndArgsInfo : 1;
379 unsigned HasFoundDecl : 1;
380 unsigned HadMultipleCandidates : 1;
381 unsigned RefersToEnclosingVariableOrCapture : 1;
395 llvm::APFloat::S_MaxSemantics < 16,
396 "Too many Semantics enum values to fit in bitfield of size 4");
397 unsigned Semantics : 4;
398 unsigned IsExact : 1;
414 unsigned CharByteWidth : 3;
416 unsigned IsPascal : 1;
420 unsigned NumConcatenated;
437 unsigned CanOverflow : 1;
442 unsigned HasFPFeatures : 1;
470 unsigned NumPreArgs : 1;
473 unsigned UsesADL : 1;
476 unsigned HasFPFeatures : 1;
484 unsigned OffsetToTrailingObjects : 8;
495 unsigned IsArrow : 1;
501 unsigned HasQualifierOrFoundDecl : 1;
508 unsigned HasTemplateKWAndArgsInfo : 1;
512 unsigned HadMultipleCandidates : 1;
530 unsigned PartOfExplicitCast : 1;
533 unsigned HasFPFeatures : 1;
537 unsigned BasePathSize;
550 unsigned HasFPFeatures : 1;
562 unsigned HadArrayRangeDesignator : 1;
593 unsigned NumSubExprs : 8;
617 unsigned TemplateDepth;
630 unsigned OperatorKind : 6;
639 unsigned IsReversed : 1;
669 unsigned IsImplicit : 1;
682 unsigned IsThrownVariableInScope : 1;
695 unsigned HasRewrittenInit : 1;
709 unsigned HasRewrittenInit : 1;
732 unsigned IsGlobalNew : 1;
736 unsigned IsArray : 1;
739 unsigned ShouldPassAlignment : 1;
743 unsigned UsualArrayDeleteWantsSize : 1;
748 unsigned StoredInitializationStyle : 2;
751 unsigned IsParenTypeId : 1;
754 unsigned NumPlacementArgs;
764 unsigned GlobalDelete : 1;
767 unsigned ArrayForm : 1;
772 unsigned ArrayFormAsWritten : 1;
776 unsigned UsualArrayDeleteWantsSize : 1;
811 unsigned HasTemplateKWAndArgsInfo : 1;
820 unsigned Elidable : 1;
821 unsigned HadMultipleCandidates : 1;
822 unsigned ListInitialization : 1;
823 unsigned StdInitListInitialization : 1;
824 unsigned ZeroInitialization : 1;
825 unsigned ConstructionKind : 3;
837 unsigned CleanupsHaveSideEffects : 1;
860 unsigned IsArrow : 1;
864 unsigned HasTemplateKWAndArgsInfo : 1;
868 unsigned HasFirstQualifierFoundInScope : 1;
882 unsigned HasTemplateKWAndArgsInfo : 1;
902 unsigned RequiresADL : 1;
906 unsigned Overloaded : 1;
909 "UnresolvedLookupExprBitfields must be <= than 4 bytes to"
910 "avoid trashing OverloadExprBitfields::NumResults!");
920 unsigned IsArrow : 1;
923 unsigned HasUnresolvedUsing : 1;
926 "UnresolvedMemberExprBitfields must be <= than 4 bytes to"
927 "avoid trashing OverloadExprBitfields::NumResults!");
957 unsigned CaptureDefault : 2;
961 unsigned ExplicitParams : 1;
964 unsigned ExplicitResultType : 1;
967 unsigned NumCaptures : 16;
977 unsigned IsSatisfied : 1;
988 unsigned IsImplicit : 1;
998 unsigned ShouldCopy : 1;
1011 unsigned IsUnique : 1;
1099 unsigned alignment = 8);
1102 unsigned alignment = 8) {
1103 return operator new(
bytes, *C, alignment);
1106 void *
operator new(
size_t bytes,
void *mem) noexcept {
return mem; }
1110 void operator delete(
void *,
size_t) noexcept {}
1111 void operator delete(
void *,
void *) noexcept {}
1132 template<
typename T,
typename TPtr = T *,
typename StmtPtr = Stmt *>
1134 : llvm::iterator_adaptor_base<CastIterator<T, TPtr, StmtPtr>, StmtPtr *,
1135 std::random_access_iterator_tag, TPtr> {
1136 using Base =
typename CastIterator::iterator_adaptor_base;
1142 return cast_or_null<T>(*this->I);
1147 template <
typename T>
1155 static bool StatisticsEnabled;
1169 static_assert(
sizeof(*
this) <= 8,
1170 "changing bitfields changed sizeof(Stmt)");
1171 static_assert(
sizeof(*
this) %
alignof(
void *) == 0,
1172 "Insufficient alignment!");
1212 static
std::tuple<
bool, const
Attr *, const
Attr *>
1231 StringRef NewlineSymbol = "\n",
1235 unsigned Indentation = 0,
1236 StringRef NewlineSymbol = "\n",
1256 return const_cast<Stmt*
>(
1295 bool Canonical)
const;
1317 :
Stmt(DeclStmtClass), DG(dg), StartLoc(startLoc), EndLoc(endLoc) {}
1386 :
Stmt(NullStmtClass) {
1420 private llvm::TrailingObjects<CompoundStmt, Stmt *, FPOptionsOverride> {
1422 friend TrailingObjects;
1439 *getTrailingObjects<FPOptionsOverride>() = F;
1442 size_t numTrailingObjects(OverloadToken<Stmt *>)
const {
1447 static CompoundStmt *
Create(
const ASTContext &
C, ArrayRef<Stmt *> Stmts,
1448 FPOptionsOverride FPFeatures, SourceLocation LB,
1453 :
Stmt(CompoundStmtClass), LBraceLoc(Loc), RBraceLoc(Loc) {
1460 bool HasFPFeatures);
1470 return *getTrailingObjects<FPOptionsOverride>();
1493 return getTrailingObjects<Stmt *>();
1517 std::reverse_iterator<const_body_iterator>;
1536 for (
auto *B : llvm::reverse(
body())) {
1537 if (!isa<NullStmt>(B))
1604 return T->getStmtClass() == CaseStmtClass ||
1605 T->getStmtClass() == DefaultStmtClass;
1613 private llvm::TrailingObjects<CaseStmt, Stmt *, SourceLocation> {
1614 friend TrailingObjects;
1631 enum { LhsOffset = 0, SubStmtOffsetFromRhs = 1 };
1632 enum { NumMandatoryStmtPtr = 2 };
1634 unsigned numTrailingObjects(OverloadToken<Stmt *>)
const {
1638 unsigned numTrailingObjects(OverloadToken<SourceLocation>)
const {
1642 unsigned lhsOffset()
const {
return LhsOffset; }
1644 unsigned subStmtOffset()
const {
return rhsOffset() + SubStmtOffsetFromRhs; }
1650 :
SwitchCase(CaseStmtClass, caseLoc, colonLoc) {
1652 bool IsGNURange = rhs !=
nullptr;
1696 "setEllipsisLoc but this is not a case stmt of the form LHS ... RHS!");
1697 *getTrailingObjects<SourceLocation>() = L;
1701 return reinterpret_cast<Expr *
>(getTrailingObjects<Stmt *>()[lhsOffset()]);
1705 return reinterpret_cast<Expr *
>(getTrailingObjects<Stmt *>()[lhsOffset()]);
1709 getTrailingObjects<Stmt *>()[lhsOffset()] =
reinterpret_cast<Stmt *
>(Val);
1714 getTrailingObjects<Stmt *>()[rhsOffset()])
1720 getTrailingObjects<Stmt *>()[rhsOffset()])
1726 "setRHS but this is not a case stmt of the form LHS ... RHS!");
1727 getTrailingObjects<Stmt *>()[rhsOffset()] =
reinterpret_cast<Stmt *
>(Val);
1732 return getTrailingObjects<Stmt *>()[subStmtOffset()];
1736 getTrailingObjects<Stmt *>()[subStmtOffset()] = S;
1743 while (
const auto *CS2 = dyn_cast<CaseStmt>(CS->
getSubStmt()))
1756 getTrailingObjects<Stmt *>() +
1757 numTrailingObjects(OverloadToken<Stmt *>()));
1762 getTrailingObjects<Stmt *>() +
1763 numTrailingObjects(OverloadToken<Stmt *>()));
1772 :
SwitchCase(DefaultStmtClass, DL, CL), SubStmt(substmt) {}
1803 if (
const auto *CS = dyn_cast<CaseStmt>(
this))
1804 return CS->getEndLoc();
1805 else if (
const auto *DS = dyn_cast<DefaultStmt>(
this))
1806 return DS->getEndLoc();
1807 llvm_unreachable(
"SwitchCase is neither a CaseStmt nor a DefaultStmt!");
1811 if (
auto *CS = dyn_cast<CaseStmt>(
this))
1812 return CS->getSubStmt();
1813 else if (
auto *DS = dyn_cast<DefaultStmt>(
this))
1814 return DS->getSubStmt();
1815 llvm_unreachable(
"SwitchCase is neither a CaseStmt nor a DefaultStmt!");
1846 bool SideEntry =
false;
1851 :
ValueStmt(LabelStmtClass), TheDecl(D), SubStmt(substmt) {
1892 private llvm::TrailingObjects<AttributedStmt, const Attr *> {
1894 friend TrailingObjects;
1900 :
ValueStmt(AttributedStmtClass), SubStmt(SubStmt) {
1903 std::copy(Attrs.begin(), Attrs.end(), getAttrArrayPtr());
1907 :
ValueStmt(AttributedStmtClass, Empty) {
1910 std::fill_n(getAttrArrayPtr(), NumAttrs,
nullptr);
1913 const Attr *
const *getAttrArrayPtr()
const {
1914 return getTrailingObjects<const Attr *>();
1916 const Attr **getAttrArrayPtr() {
return getTrailingObjects<const Attr *>(); }
1919 static AttributedStmt *
Create(
const ASTContext &
C, SourceLocation Loc,
1920 ArrayRef<const Attr *> Attrs,
Stmt *SubStmt);
1923 static AttributedStmt *
CreateEmpty(
const ASTContext &
C,
unsigned NumAttrs);
1950 private llvm::TrailingObjects<IfStmt, Stmt *, SourceLocation> {
1951 friend TrailingObjects;
1975 enum { InitOffset = 0, ThenOffsetFromCond = 1, ElseOffsetFromCond = 2 };
1976 enum { NumMandatoryStmtPtr = 2 };
1980 unsigned numTrailingObjects(OverloadToken<Stmt *>)
const {
1985 unsigned numTrailingObjects(OverloadToken<SourceLocation>)
const {
1989 unsigned initOffset()
const {
return InitOffset; }
1990 unsigned varOffset()
const {
return InitOffset +
hasInitStorage(); }
1991 unsigned condOffset()
const {
1994 unsigned thenOffset()
const {
return condOffset() + ThenOffsetFromCond; }
1995 unsigned elseOffset()
const {
return condOffset() + ElseOffsetFromCond; }
2003 explicit IfStmt(
EmptyShell Empty,
bool HasElse,
bool HasVar,
bool HasInit);
2011 Stmt *Else =
nullptr);
2028 return reinterpret_cast<Expr *
>(getTrailingObjects<Stmt *>()[condOffset()]);
2032 return reinterpret_cast<Expr *
>(getTrailingObjects<Stmt *>()[condOffset()]);
2036 getTrailingObjects<Stmt *>()[condOffset()] =
reinterpret_cast<Stmt *
>(Cond);
2039 Stmt *
getThen() {
return getTrailingObjects<Stmt *>()[thenOffset()]; }
2041 return getTrailingObjects<Stmt *>()[thenOffset()];
2045 getTrailingObjects<Stmt *>()[thenOffset()] = Then;
2049 return hasElseStorage() ? getTrailingObjects<Stmt *>()[elseOffset()]
2054 return hasElseStorage() ? getTrailingObjects<Stmt *>()[elseOffset()]
2060 "This if statement has no storage for an else statement!");
2061 getTrailingObjects<Stmt *>()[elseOffset()] = Else;
2085 getTrailingObjects<Stmt *>()[varOffset()])
2091 getTrailingObjects<Stmt *>()[varOffset()])
2096 return hasInitStorage() ? getTrailingObjects<Stmt *>()[initOffset()]
2101 return hasInitStorage() ? getTrailingObjects<Stmt *>()[initOffset()]
2107 "This if statement has no storage for an init statement!");
2108 getTrailingObjects<Stmt *>()[initOffset()] = Init;
2121 "This if statement has no storage for an else statement!");
2122 *getTrailingObjects<SourceLocation>() = ElseLoc;
2175 getTrailingObjects<Stmt *>() +
2176 numTrailingObjects(OverloadToken<Stmt *>()));
2184 getTrailingObjects<Stmt *>() +
2185 numTrailingObjects(OverloadToken<Stmt *>()));
2195 private llvm::TrailingObjects<SwitchStmt, Stmt *> {
2196 friend TrailingObjects;
2218 enum { InitOffset = 0, BodyOffsetFromCond = 1 };
2219 enum { NumMandatoryStmtPtr = 2 };
2223 unsigned numTrailingObjects(OverloadToken<Stmt *>)
const {
2227 unsigned initOffset()
const {
return InitOffset; }
2228 unsigned varOffset()
const {
return InitOffset +
hasInitStorage(); }
2229 unsigned condOffset()
const {
2232 unsigned bodyOffset()
const {
return condOffset() + BodyOffsetFromCond; }
2259 return reinterpret_cast<Expr *
>(getTrailingObjects<Stmt *>()[condOffset()]);
2263 return reinterpret_cast<Expr *
>(getTrailingObjects<Stmt *>()[condOffset()]);
2267 getTrailingObjects<Stmt *>()[condOffset()] =
reinterpret_cast<Stmt *
>(Cond);
2270 Stmt *
getBody() {
return getTrailingObjects<Stmt *>()[bodyOffset()]; }
2272 return getTrailingObjects<Stmt *>()[bodyOffset()];
2276 getTrailingObjects<Stmt *>()[bodyOffset()] = Body;
2280 return hasInitStorage() ? getTrailingObjects<Stmt *>()[initOffset()]
2285 return hasInitStorage() ? getTrailingObjects<Stmt *>()[initOffset()]
2291 "This switch statement has no storage for an init statement!");
2292 getTrailingObjects<Stmt *>()[initOffset()] = Init;
2317 getTrailingObjects<Stmt *>()[varOffset()])
2323 getTrailingObjects<Stmt *>()[varOffset()])
2345 "case/default already added to a switch");
2369 getTrailingObjects<Stmt *>() +
2370 numTrailingObjects(OverloadToken<Stmt *>()));
2375 getTrailingObjects<Stmt *>() +
2376 numTrailingObjects(OverloadToken<Stmt *>()));
2386 private llvm::TrailingObjects<WhileStmt, Stmt *> {
2387 friend TrailingObjects;
2404 enum { VarOffset = 0, BodyOffsetFromCond = 1 };
2405 enum { NumMandatoryStmtPtr = 2 };
2409 unsigned varOffset()
const {
return VarOffset; }
2410 unsigned condOffset()
const {
return VarOffset +
hasVarStorage(); }
2411 unsigned bodyOffset()
const {
return condOffset() + BodyOffsetFromCond; }
2413 unsigned numTrailingObjects(OverloadToken<Stmt *>)
const {
2439 return reinterpret_cast<Expr *
>(getTrailingObjects<Stmt *>()[condOffset()]);
2443 return reinterpret_cast<Expr *
>(getTrailingObjects<Stmt *>()[condOffset()]);
2447 getTrailingObjects<Stmt *>()[condOffset()] =
reinterpret_cast<Stmt *
>(Cond);
2450 Stmt *
getBody() {
return getTrailingObjects<Stmt *>()[bodyOffset()]; }
2452 return getTrailingObjects<Stmt *>()[bodyOffset()];
2456 getTrailingObjects<Stmt *>()[bodyOffset()] = Body;
2480 getTrailingObjects<Stmt *>()[varOffset()])
2486 getTrailingObjects<Stmt *>()[varOffset()])
2510 getTrailingObjects<Stmt *>() +
2511 numTrailingObjects(OverloadToken<Stmt *>()));
2516 getTrailingObjects<Stmt *>() +
2517 numTrailingObjects(OverloadToken<Stmt *>()));
2523 enum { BODY, COND, END_EXPR };
2524 Stmt *SubExprs[END_EXPR];
2531 :
Stmt(DoStmtClass), WhileLoc(WL), RParenLoc(RP) {
2542 return reinterpret_cast<Expr *
>(SubExprs[COND]);
2567 return child_range(&SubExprs[0], &SubExprs[0] + END_EXPR);
2579 enum { INIT, CONDVAR, COND, INC, BODY, END_EXPR };
2580 Stmt* SubExprs[END_EXPR];
2607 return reinterpret_cast<DeclStmt*
>(SubExprs[CONDVAR]);
2640 return child_range(&SubExprs[0], &SubExprs[0]+END_EXPR);
2655 :
Stmt(GotoStmtClass),
Label(label), LabelLoc(LL) {
2694 :
Stmt(IndirectGotoStmtClass), StarLoc(starLoc) {
2701 :
Stmt(IndirectGotoStmtClass, Empty) {}
2710 return reinterpret_cast<const Expr *
>(
Target);
2806 private llvm::TrailingObjects<ReturnStmt, const VarDecl *> {
2807 friend TrailingObjects;
2816 bool hasNRVOCandidate()
const {
return ReturnStmtBits.HasNRVOCandidate; }
2818 unsigned numTrailingObjects(OverloadToken<const VarDecl *>)
const {
2819 return hasNRVOCandidate();
2831 const VarDecl *NRVOCandidate);
2847 return hasNRVOCandidate() ? *getTrailingObjects<const VarDecl *>()
2855 assert(hasNRVOCandidate() &&
2856 "This return statement has no storage for an NRVO candidate!");
2857 *getTrailingObjects<const VarDecl *>() = Var;
2908 unsigned numoutputs,
unsigned numinputs,
unsigned numclobbers)
3056 unsigned NumLabels = 0;
3060 bool isvolatile,
unsigned numoutputs,
unsigned numinputs,
3100 : MyKind(
Operand), Str(S), OperandNo(OpNo),
3114 assert(
isOperand() &&
"Range is currently used only for Operands.");
3129 const ASTContext &C,
unsigned &DiagOffs)
const;
3140 return II->getName();
3148 return Constraints[i];
3151 return Constraints[i];
3168 return II->getName();
3192 return NumLabels > 0;
3235 void setOutputsAndInputsAndClobbers(
const ASTContext &C,
3275 unsigned NumAsmToks = 0;
3277 Token *AsmToks =
nullptr;
3278 StringRef *Constraints =
nullptr;
3279 StringRef *Clobbers =
nullptr;
3312 return Constraints[i];
3380 enum { FILTER_EXPR,
BLOCK };
3386 static SEHExceptStmt*
Create(
const ASTContext &
C,
3387 SourceLocation ExceptLoc,
3397 return reinterpret_cast<Expr*
>(Children[FILTER_EXPR]);
3401 return cast<CompoundStmt>(Children[
BLOCK]);
3460 enum { TRY = 0, HANDLER = 1 };
3470 static SEHTryStmt*
Create(
const ASTContext &
C,
bool isCXXTry,
3471 SourceLocation TryLoc,
Stmt *TryBlock,
3482 return cast<CompoundStmt>(Children[TRY]);
3510 :
Stmt(SEHLeaveStmtClass), LeaveLoc(LL) {}
3558 llvm::PointerIntPair<VarDecl *, 2, VariableCaptureKind> VarAndKind;
3606 unsigned NumCaptures;
3610 llvm::PointerIntPair<CapturedDecl *, 2, CapturedRegionKind> CapDeclAndKind;
3622 Stmt **getStoredStmts() {
return reinterpret_cast<Stmt **
>(
this + 1); }
3624 Stmt *
const *getStoredStmts()
const {
3625 return reinterpret_cast<Stmt *
const *
>(
this + 1);
3628 Capture *getStoredCaptures()
const;
3630 void setCapturedStmt(
Stmt *S) { getStoredStmts()[NumCaptures] = S; }
3642 unsigned NumCaptures);
3666 assert(D &&
"null RecordDecl");
3693 return getStoredCaptures() + NumCaptures;
3707 llvm::iterator_range<const_capture_init_iterator>;
3719 return reinterpret_cast<Expr **
>(getStoredStmts());
3723 return reinterpret_cast<Expr *
const *
>(getStoredStmts());
3759 #endif // LLVM_CLANG_AST_STMT_H
void setElseLoc(SourceLocation ElseLoc)
IndirectGotoStmt - This represents an indirect goto.
const_child_range children() const
bool hasVarStorage() const
True if this SwitchStmt has storage for a condition variable.
int getNamedOperand(StringRef SymbolicName) const
getNamedOperand - Given a symbolic operand reference like %[foo], translate this into a numeric value...
LabelStmt - Represents a label, which has a substatement.
SourceLocation getCaseLoc() const
NullStmtBitfields NullStmtBits
VarDecl * getConditionVariable() const
Retrieve the variable declared in this "for" statement, if any.
NonOdrUseReason
The reason why a DeclRefExpr does not constitute an odr-use.
static CompoundStmt * CreateEmpty(const ASTContext &C, unsigned NumStmts, bool HasFPFeatures)
BreakStmt(EmptyShell Empty)
Build an empty break statement.
MatrixSubscriptExpr - Matrix subscript expression for the MatrixType extension.
Represents a reference to a non-type template parameter that has been substituted with a template arg...
reverse_decl_iterator decl_rend()
ArrayOrMatrixSubscriptExprBitfields ArrayOrMatrixSubscriptExprBits
void setNRVOCandidate(const VarDecl *Var)
Set the variable that might be used for the named return value optimization.
capture_iterator capture_end() const
Retrieve an iterator pointing past the end of the sequence of captures.
Stmt * getStmtExprResult()
unsigned capture_size() const
Retrieve the number of captures, including 'this'.
AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*, __atomic_load,...
capture_iterator capture_begin()
Retrieve an iterator pointing to the first capture.
CaseStmt - Represent a case statement.
SourceLocation getRParenLoc() const
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.
SourceLocation getBeginLoc() const
StringRef getInputConstraint(unsigned i) const
getInputConstraint - Return the specified input constraint.
YAML serialization mapping.
llvm::iterator_range< body_iterator > body_range
unsigned getOperandNo() const
void setRParenLoc(SourceLocation L)
CharacterLiteralBitfields CharacterLiteralBits
static CaseStmt * CreateEmpty(const ASTContext &Ctx, bool CaseStmtIsGNURange)
Build an empty case statement.
bool caseStmtIsGNURange() const
True if this case statement is of the form case LHS ...
A boolean literal, per ([C++ lex.bool] Boolean literals).
void setColonLoc(SourceLocation L)
SourceLocation getBeginLoc() const
DefaultStmt(SourceLocation DL, SourceLocation CL, Stmt *substmt)
OffsetOfExpr - [C99 7.17] - This represents an expression of the form offsetof(record-type,...
SourceLocation getEndLoc() const
SEHFinallyStmt * getFinallyHandler() const
AddrLabelExpr * getLabelExpr(unsigned i) const
InitListExprBitfields InitListExprBits
void setDeclGroup(DeclGroupRef DGR)
void addSwitchCase(SwitchCase *SC)
SwitchStmt - This represents a 'switch' stmt.
SourceLocation getBeginLoc() const
std::string generateAsmString(const ASTContext &C) const
Assemble final IR asm string.
ParenListExprBitfields ParenListExprBits
void initialize(TemplateInstantiationCallbackPtrs &Callbacks, const Sema &TheSema)
static bool classof(const Stmt *T)
SourceLocation getBeginLoc() const
void dumpPretty(const ASTContext &Context) const
dumpPretty/printPretty - These two methods do a "pretty print" of the AST back to its original source...
A trivial tuple used to represent a source range.
static bool classof(const Stmt *T)
body_const_range body() const
static bool classof(const Stmt *T)
bool hasVarStorage() const
True if this IfStmt has storage for a variable declaration.
CXXNewExprBitfields CXXNewExprBits
PseudoObjectExprBitfields PseudoObjectExprBits
StringRef getClobber(unsigned i) const
WhileStmt - This represents a 'while' stmt.
NullStmt - This is the null statement ";": C99 6.8.3p3.
capture_init_iterator capture_init_end()
Retrieve the iterator pointing one past the last initialization argument.
DeclGroupRef::const_iterator const_decl_iterator
bool isObjCAvailabilityCheck() const
SEHExceptStmt * getExceptHandler() const
Returns 0 if not defined.
llvm::iterator_range< decl_iterator > decl_range
static bool classof(const Stmt *T)
void setCapturedRegionKind(CapturedRegionKind Kind)
Set the captured region kind.
void setLabel(LabelDecl *D)
llvm::iterator_range< outputs_iterator > outputs_range
DeclStmt(DeclGroupRef dg, SourceLocation startLoc, SourceLocation endLoc)
DoStmt(Stmt *Body, Expr *Cond, SourceLocation DL, SourceLocation WL, SourceLocation RP)
Represents a C99 designated initializer expression.
void setLParenLoc(SourceLocation L)
Encodes a location in the source.
std::reverse_iterator< const_body_iterator > const_reverse_body_iterator
Stmt * stripLabelLikeStatements()
const Stmt * getBody() const
GenericSelectionExprBitfields GenericSelectionExprBits
static AttributedStmt * CreateEmpty(const ASTContext &C, unsigned NumAttrs)
body_iterator body_begin()
static void EnableStatistics()
CXXOperatorCallExprBitfields CXXOperatorCallExprBits
static CompoundStmt * Create(const ASTContext &C, ArrayRef< Stmt * > Stmts, FPOptionsOverride FPFeatures, SourceLocation LB, SourceLocation RB)
SourceLocation getElseLoc() const
bool hasVarStorage() const
True if this WhileStmt has storage for a condition variable.
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
StringRef getLabelName(unsigned i) const
Represents a C++ member access expression for which lookup produced a set of overloaded functions.
IndirectGotoStmt(EmptyShell Empty)
Build an empty indirect goto statement.
const_reverse_body_iterator body_rend() const
void setEndLoc(SourceLocation L)
const VarDecl * getConditionVariable() const
TypeTraitExprBitfields TypeTraitExprBits
StringRef getOutputConstraint(unsigned i) const
getOutputConstraint - Return the constraint string for the specified output operand.
A type trait used in the implementation of various C++11 and Library TR1 trait templates.
SourceLocation getLParenLoc() const
SourceLocation getBeginLoc() const LLVM_READONLY
const VarDecl * getConditionVariable() const
std::reverse_iterator< body_iterator > reverse_body_iterator
GotoStmtBitfields GotoStmtBits
C++2a [expr.prim.req]: A requires-expression provides a concise way to express requirements on templa...
ConstantExprBitfields ConstantExprBits
SourceLocation getKeywordLoc() const
const_child_range children() const
static bool classof(const Stmt *T)
bool isSingleDecl() const
StringLiteralBitfields StringLiteralBits
SourceLocation getRParenLoc() const
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)".
const_child_range children() const
IfStmt - This represents an if/then/else.
ContinueStmt(EmptyShell Empty)
Build an empty continue statement.
DefaultStmt(EmptyShell Empty)
Build an empty default statement.
bool hasElseStorage() const
True if this IfStmt has storage for an else statement.
void setContinueLoc(SourceLocation L)
Expr *const * const_capture_init_iterator
Const iterator that walks over the capture initialization arguments.
labels_const_range labels() const
ArrayRef< StringRef > getAllConstraints() const
CapturedRegionKind
The different kinds of captured statement.
GotoStmt - This represents a direct goto.
Describes an C or C++ initializer list.
SourceLocation getReturnLoc() const
CXXScalarValueInitExprBitfields CXXScalarValueInitExprBits
child_iterator child_end()
SEHLeaveStmt(SourceLocation LL)
LabelStmtBitfields LabelStmtBits
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
SwitchCaseBitfields SwitchCaseBits
capture_const_range captures() const
bool hasInitStorage() const
True if this IfStmt has the storage for an init statement.
SourceLocation getRParenLoc() const
void ProcessODRHash(llvm::FoldingSetNodeID &ID, ODRHash &Hash) const
Calculate a unique representation for a statement that is stable across compiler invocations.
const_inputs_iterator end_inputs() const
void setRParenLoc(SourceLocation Loc)
SourceLocation getBeginLoc() const LLVM_READONLY
BreakStmtBitfields BreakStmtBits
labels_iterator begin_labels()
SourceLocExprBitfields SourceLocExprBits
void dump() const
Dumps the specified AST fragment and all subtrees to llvm::errs().
IdentifierInfo * getOutputIdentifier(unsigned i) const
SourceLocation getBeginLoc() const
static bool classof(const Stmt *T)
Describes how types, statements, expressions, and declarations should be printed.
const_capture_init_range capture_inits() const
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)
const_child_range children() const
SourceLocation getLBracLoc() const
void setReturnLoc(SourceLocation L)
SubstNonTypeTemplateParmExprBitfields SubstNonTypeTemplateParmExprBits
const Stmt * getInit() const
LabelStmt(SourceLocation IL, LabelDecl *D, Stmt *substmt)
Build a label statement.
Represents the body of a CapturedStmt, and serves as its DeclContext.
const Stmt * body_front() const
Token - This structure provides full information about a lexed token.
static SEHExceptStmt * Create(const ASTContext &C, SourceLocation ExceptLoc, Expr *FilterExpr, Stmt *Block)
SwitchCase(StmtClass SC, EmptyShell)
void setCapturedRecordDecl(RecordDecl *D)
Set the record declaration for captured variables.
CompoundStmt * getBlock() const
SourceLocation getEndLoc() const LLVM_READONLY
UnaryOperatorBitfields UnaryOperatorBits
void setBody(Stmt *S, SourceLocation SL)
CapturedRegionKind getCapturedRegionKind() const
Retrieve the captured region kind.
ExprWithCleanupsBitfields ExprWithCleanupsBits
A placeholder type used to construct an empty shell of a type, that will be filled in later (e....
bool hasStoredFPFeatures() const
void setSwitchCaseList(SwitchCase *SC)
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.
const_child_range children() const
const_child_range children() const
void setLabelLoc(SourceLocation L)
void setRetValue(Expr *E)
SourceLocation getLParenLoc() const
CXXUnresolvedConstructExprBitfields CXXUnresolvedConstructExprBits
BinaryOperatorBitfields BinaryOperatorBits
ObjCIndirectCopyRestoreExpr - Represents the passing of a function argument by indirect copy-restore ...
A C++ throw-expression (C++ [except.throw]).
SourceLocation getEndLoc() const LLVM_READONLY
ObjCArrayLiteral - used for objective-c array containers; as in: @["Hello", NSApp,...
SourceLocation getBeginLoc() const
const Stmt * getBody() const
IdentifierInfo * getInputIdentifier(unsigned i) const
SourceLocation getLabelLoc() const
const DeclGroupRef getDeclGroup() const
ForStmt(const ASTContext &C, Stmt *Init, Expr *Cond, VarDecl *condVar, Expr *Inc, Stmt *Body, SourceLocation FL, SourceLocation LP, SourceLocation RP)
const Expr * getOutputExpr(unsigned i) const
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
__SIZE_TYPE__ size_t
The unsigned integer type of the result of the sizeof operator.
FloatingLiteralBitfields FloatingLiteralBits
SourceLocation getAsmLoc() const
void setLParenLoc(SourceLocation Loc)
const SwitchCase * getSwitchCaseList() const
const std::string & getString() const
const Expr * getLHS() const
Represents an attribute applied to a statement.
static bool classof(const Stmt *T)
bool capturesVariable(const VarDecl *Var) const
True if this variable has been captured.
const_child_range children() const
#define BLOCK(DERIVED, BASE)
Stmt * getCapturedStmt()
Retrieve the statement being captured.
SourceLocation getBeginLoc() const LLVM_READONLY
const Stmt * getSubStmt() const
StmtIterator child_iterator
Child Iterators: All subclasses must implement 'children' to permit easy iteration over the substatem...
NullStmt(EmptyShell Empty)
Build an empty null statement.
const Stmt * getBody() const
const Stmt * getCapturedStmt() const
SourceLocation getRParenLoc() const
bool capturesVariableByCopy() const
Determine whether this capture handles a variable by copy.
static ReturnStmt * Create(const ASTContext &Ctx, SourceLocation RL, Expr *E, const VarDecl *NRVOCandidate)
Create a return statement.
const_child_range children() const
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand.
llvm::iterator_range< inputs_iterator > inputs_range
static bool classof(const Stmt *T)
void setSideEntry(bool SE)
const Expr * getCond() const
CompoundStmt - This represents a group of statements like { stmt stmt }.
void setGotoLoc(SourceLocation L)
SourceLocation getEndLoc() const
CallExprBitfields CallExprBits
const_child_iterator child_end() const
StringRef getOutputConstraint(unsigned i) const
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
StringRef getAsmString() const
void setAllEnumCasesCovered()
Set a flag in the SwitchStmt indicating that if the 'switch (X)' is a switch over an enum value then ...
A rewritten comparison expression that was originally written using operator syntax.
SwitchCase(StmtClass SC, SourceLocation KWLoc, SourceLocation ColonLoc)
SourceLocation getEndLoc() const
LabelDecl * getConstantTarget()
getConstantTarget - Returns the fixed target of this indirect goto, if one exists.
void printPretty(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation=0, StringRef NewlineSymbol="\n", const ASTContext *Context=nullptr) const
SourceLocation getBeginLoc() const
static WhileStmt * Create(const ASTContext &Ctx, VarDecl *Var, Expr *Cond, Stmt *Body, SourceLocation WL, SourceLocation LParenLoc, SourceLocation RParenLoc)
Create a while statement.
const_capture_init_iterator capture_init_end() const
SwitchStmtBitfields SwitchStmtBits
A builtin binary operation expression such as "x + y" or "x <= y".
StringRef getClobber(unsigned i) const
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
SourceLocation getEndLoc() const LLVM_READONLY
Capture(SourceLocation Loc, VariableCaptureKind Kind, VarDecl *Var=nullptr)
Create a new capture.
std::reverse_iterator< decl_iterator > reverse_decl_iterator
void setRParenLoc(SourceLocation L)
const Expr * getInputExpr(unsigned i) const
const_child_range children() const
const Expr * getCond() const
bool isNonNegatedConsteval() const
PredefinedExprBitfields PredefinedExprBits
const_child_range children() const
reverse_body_iterator body_rend()
const StringLiteral * getAsmString() const
ArrayRef< Expr * > getAllExprs() const
SourceLocation getIdentLoc() const
CXXDefaultInitExprBitfields CXXDefaultInitExprBits
Represents difference between two FPOptions values.
std::optional< const Stmt * > getNondiscardedCase(const ASTContext &Ctx) const
If this is an 'if constexpr', determine which substatement will be taken.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
llvm::iterator_range< const_decl_iterator > decl_const_range
Represents a statement that could possibly have a value and type.
Iterator for iterating over Stmt * arrays that contain only T *.
ObjCDictionaryLiteral - AST node to represent objective-c dictionary literals; as in:"name" : NSUserN...
SourceLocation getEndLoc() const LLVM_READONLY
MemberExprBitfields MemberExprBits
unsigned getNumClobbers() const
StmtExprBitfields StmtExprBits
SourceLocation getBeginLoc() const LLVM_READONLY
SourceLocation getIfLoc() const
LabelDecl * getLabel() const
CXXConstructExprBitfields CXXConstructExprBits
DeclStmt * getConditionVariableDeclStmt()
If this IfStmt has a condition variable, return the faux DeclStmt associated with the creation of tha...
void setLBraceLoc(SourceLocation L)
void setDoLoc(SourceLocation L)
Stmt *const * const_body_iterator
DeclStmt(EmptyShell Empty)
Build an empty declaration statement.
AsmStringPiece - this is part of a decomposed asm string specification (for use with the AnalyzeAsmSt...
IndirectGotoStmt(SourceLocation gotoLoc, SourceLocation starLoc, Expr *target)
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...
SourceLocation getEndLoc() const
const_child_range children() const
ForStmt - This represents a 'for (init;cond;inc)' stmt.
SourceLocation getGotoLoc() const
SwitchCase * getNextSwitchCase()
SourceLocation getEndLoc() const
void setCapturedDecl(CapturedDecl *D)
Set the outlined function declaration.
const_child_range children() const
Represents the declaration of a label.
CXXRewrittenBinaryOperatorBitfields CXXRewrittenBinaryOperatorBits
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
const Stmt * stripLabelLikeStatements() const
Strip off all label-like statements.
static CaseStmt * Create(const ASTContext &Ctx, Expr *lhs, Expr *rhs, SourceLocation caseLoc, SourceLocation ellipsisLoc, SourceLocation colonLoc)
Build a case statement.
StringRef getOutputName(unsigned i) const
IfStatementKind getStatementKind() const
SourceLocation getBeginLoc() const
@ LH_None
No attribute set or branches of the IfStmt have the same attribute.
SourceLocation getEndLoc() const LLVM_READONLY
VariableCaptureKind
The different capture forms: by 'this', by reference, capture for variable-length array type etc.
const Expr * getExprStmt() const
DeclStmt * getConditionVariableDeclStmt()
If this SwitchStmt has a condition variable, return the faux DeclStmt associated with the creation of...
SourceLocation getDoLoc() const
static AttributedStmt * Create(const ASTContext &C, SourceLocation Loc, ArrayRef< const Attr * > Attrs, Stmt *SubStmt)
DoStmtBitfields DoStmtBits
RequiresExprBitfields RequiresExprBits
const Expr * getRetValue() const
ArrayRef< StringRef > getClobbers() const
SourceLocation getEndLoc() const LLVM_READONLY
const_child_range children() const
static bool classof(const Stmt *T)
StringLiteral * getAsmString()
IfStmtBitfields IfStmtBits
Represents a variable declaration or definition.
SourceLocation getEndLoc() const LLVM_READONLY
void setWhileLoc(SourceLocation L)
static CapturedStmt * CreateDeserialized(const ASTContext &Context, unsigned NumCaptures)
SourceLocation ColonLoc
The location of the ":".
StringLiteral - This represents a string literal expression, e.g.
void setSwitchLoc(SourceLocation L)
const Stmt * getInit() const
const Expr * getCond() const
Represents an expression – generally a full-expression – that introduces cleanups to be run at the en...
@ LH_Likely
Branch has the [[likely]] attribute.
This captures a statement into a function.
bool IsSimple
True if the assembly statement does not have any input or output operands.
void setRParenLoc(SourceLocation L)
static bool classof(const Stmt *T)
Describes the capture of either a variable, or 'this', or variable-length array type.
ContinueStmtBitfields ContinueStmtBits
void setStarLoc(SourceLocation L)
static SwitchStmt * Create(const ASTContext &Ctx, Stmt *Init, VarDecl *Var, Expr *Cond, SourceLocation LParenLoc, SourceLocation RParenLoc)
Create a switch statement.
Stmt(StmtClass SC, EmptyShell)
Construct an empty statement.
IdentifierInfo * getLabelIdentifier(unsigned i) const
SourceLocation getEndLoc() const LLVM_READONLY
SourceLocation getFinallyLoc() const
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context, bool Canonical) const
Produce a unique representation of the given statement.
void setAsmString(StringLiteral *E)
bool hasLeadingEmptyMacro() const
static ReturnStmt * CreateEmpty(const ASTContext &Ctx, bool HasNRVOCandidate)
Create an empty return statement, optionally with storage for an NRVO candidate.
SourceLocation getLBraceLoc() const
llvm::iterator_range< child_iterator > child_range
const Expr * getInputExpr(unsigned i) const
A default argument (C++ [dcl.fct.default]).
SourceLocation getBeginLoc() const LLVM_READONLY
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...
const_body_iterator body_begin() const
WhileStmtBitfields WhileStmtBits
NullStmt(SourceLocation L, bool hasLeadingEmptyMacro=false)
unsigned AnalyzeAsmString(SmallVectorImpl< AsmStringPiece > &Pieces, const ASTContext &C, unsigned &DiagOffs) const
AnalyzeAsmString - Analyze the asm string of the current asm, decomposing it into pieces.
SourceLocation getTryLoc() const
outputs_iterator end_outputs()
DependentScopeDeclRefExprBitfields DependentScopeDeclRefExprBits
const_child_range children() const
const Expr * getCond() const
ConstantExpr - An expression that occurs in a constant context and optionally the result of evaluatin...
void setDecl(LabelDecl *D)
An expression that sends a message to the given Objective-C object or class.
CoawaitExprBitfields CoawaitBits
LabelStmt(EmptyShell Empty)
Build an empty label statement.
VarDecl * getConditionVariable()
Retrieve the variable declared in this "while" statement, if any.
StringRef getInputName(unsigned i) const
std::string generateAsmString(const ASTContext &C) const
Assemble final IR asm string.
unsigned getNumOutputs() const
SourceLocation getLeaveLoc() const
CXXDefaultArgExprBitfields CXXDefaultArgExprBits
const_child_range children() const
llvm::iterator_range< const_capture_iterator > capture_const_range
const StringLiteral * getInputConstraintLiteral(unsigned i) const
SourceLocation getEndLoc() const
SourceLocation getEndLoc() const LLVM_READONLY
llvm::iterator_range< const_child_iterator > const_child_range
const Stmt * getThen() const
static bool classof(const Stmt *T)
const_child_range children() const
SwitchCase * NextSwitchCase
A pointer to the following CaseStmt or DefaultStmt class, used by SwitchStmt.
void setCaseLoc(SourceLocation L)
SourceLocation getBeginLoc() const
bool capturesThis() const
Determine whether this capture handles the C++ 'this' pointer.
void viewAST() const
viewAST - Visualize an AST rooted at this Stmt* using GraphViz.
void setGotoLoc(SourceLocation L)
SourceLocation getEndLoc() const LLVM_READONLY
static bool classof(const Stmt *T)
const DeclStmt * getConditionVariableDeclStmt() const
AttributedStmtBitfields AttributedStmtBits
const_decl_iterator decl_begin() const
decl_const_range decls() const
const_child_range children() const
StringRef getInputConstraint(unsigned i) const
getInputConstraint - Return the specified input constraint.
void setConditionVariable(const ASTContext &Ctx, VarDecl *V)
Set the condition variable of this while statement.
const_child_range children() const
CXXDependentScopeMemberExprBitfields CXXDependentScopeMemberExprBits
This represents a GCC inline-assembly statement extension.
const_reverse_body_iterator body_rbegin() const
const VarDecl * getNRVOCandidate() const
Retrieve the variable that might be used for the named return value optimization.
capture_init_range capture_inits()
SourceLocation getEndLoc() const
child_iterator child_begin()
void setLParenLoc(SourceLocation L)
llvm::iterator_range< const_labels_iterator > labels_const_range
const_child_range children() const
AsmStmt is the base class for GCCAsmStmt and MSAsmStmt.
const Decl * getSingleDecl() const
SourceLocation getEndLoc() const LLVM_READONLY
SourceLocation getContinueLoc() const
bool isSingleDecl() const
isSingleDecl - This method returns true if this DeclStmt refers to a single Decl.
StringRef getOutputConstraint(unsigned i) const
getOutputConstraint - Return the constraint string for the specified output operand.
int64_t getID(const ASTContext &Context) const
bool isNegatedConsteval() const