Go to the documentation of this file.
13 #ifndef LLVM_CLANG_AST_STMT_H
14 #define LLVM_CLANG_AST_STMT_H
24 #include "llvm/ADT/ArrayRef.h"
25 #include "llvm/ADT/BitmaskEnum.h"
26 #include "llvm/ADT/PointerIntPair.h"
27 #include "llvm/ADT/StringRef.h"
28 #include "llvm/ADT/iterator.h"
29 #include "llvm/ADT/iterator_range.h"
30 #include "llvm/Support/Casting.h"
31 #include "llvm/Support/Compiler.h"
32 #include "llvm/Support/ErrorHandling.h"
41 class FoldingSetNodeID;
56 struct PrintingPolicy;
69 class alignas(void *)
Stmt {
73 #define STMT(CLASS, PARENT) CLASS##Class,
74 #define STMT_RANGE(BASE, FIRST, LAST) \
75 first##BASE##Constant=FIRST##Class, last##BASE##Constant=LAST##Class,
76 #define LAST_STMT_RANGE(BASE, FIRST, LAST) \
77 first##BASE##Constant=FIRST##Class, last##BASE##Constant=LAST##Class
78 #define ABSTRACT_STMT(STMT)
79 #include "clang/AST/StmtNodes.inc"
87 void *
operator new(
size_t bytes) noexcept {
88 llvm_unreachable(
"Stmts cannot be allocated with regular 'new'.");
91 void operator delete(
void *data) noexcept {
92 llvm_unreachable(
"Stmts cannot be released with regular 'delete'.");
119 unsigned HasLeadingEmptyMacro : 1;
165 unsigned HasElse : 1;
171 unsigned HasInit : 1;
183 unsigned HasInit : 1;
191 unsigned AllEnumCasesCovered : 1;
262 unsigned HasNRVOCandidate : 1;
276 unsigned CaseStmtIsGNURange : 1;
310 unsigned ValueKind : 2;
311 unsigned ObjectKind : 3;
312 unsigned Dependent : llvm::BitWidth<ExprDependence>;
324 unsigned ResultKind : 2;
327 unsigned APValueKind : 4;
331 unsigned IsUnsigned : 1;
336 unsigned BitWidth : 7;
340 unsigned HasCleanup : 1;
343 unsigned IsImmediateInvocation : 1;
358 unsigned HasFunctionName : 1;
370 unsigned HasQualifier : 1;
371 unsigned HasTemplateKWAndArgsInfo : 1;
372 unsigned HasFoundDecl : 1;
373 unsigned HadMultipleCandidates : 1;
374 unsigned RefersToEnclosingVariableOrCapture : 1;
387 unsigned Semantics : 3;
388 unsigned IsExact : 1;
404 unsigned CharByteWidth : 3;
406 unsigned IsPascal : 1;
410 unsigned NumConcatenated;
427 unsigned CanOverflow : 1;
432 unsigned HasFPFeatures : 1;
460 unsigned NumPreArgs : 1;
463 unsigned UsesADL : 1;
466 unsigned HasFPFeatures : 1;
474 unsigned OffsetToTrailingObjects : 8;
485 unsigned IsArrow : 1;
491 unsigned HasQualifierOrFoundDecl : 1;
498 unsigned HasTemplateKWAndArgsInfo : 1;
502 unsigned HadMultipleCandidates : 1;
520 unsigned PartOfExplicitCast : 1;
523 unsigned HasFPFeatures : 1;
527 unsigned BasePathSize;
540 unsigned HasFPFeatures : 1;
552 unsigned HadArrayRangeDesignator : 1;
583 unsigned NumSubExprs : 8;
607 unsigned TemplateDepth;
620 unsigned OperatorKind : 6;
629 unsigned IsReversed : 1;
659 unsigned IsImplicit : 1;
672 unsigned IsThrownVariableInScope : 1;
715 unsigned IsGlobalNew : 1;
719 unsigned IsArray : 1;
722 unsigned ShouldPassAlignment : 1;
726 unsigned UsualArrayDeleteWantsSize : 1;
731 unsigned StoredInitializationStyle : 2;
734 unsigned IsParenTypeId : 1;
737 unsigned NumPlacementArgs;
747 unsigned GlobalDelete : 1;
750 unsigned ArrayForm : 1;
755 unsigned ArrayFormAsWritten : 1;
759 unsigned UsualArrayDeleteWantsSize : 1;
794 unsigned HasTemplateKWAndArgsInfo : 1;
803 unsigned Elidable : 1;
804 unsigned HadMultipleCandidates : 1;
805 unsigned ListInitialization : 1;
806 unsigned StdInitListInitialization : 1;
807 unsigned ZeroInitialization : 1;
808 unsigned ConstructionKind : 3;
820 unsigned CleanupsHaveSideEffects : 1;
843 unsigned IsArrow : 1;
847 unsigned HasTemplateKWAndArgsInfo : 1;
851 unsigned HasFirstQualifierFoundInScope : 1;
865 unsigned HasTemplateKWAndArgsInfo : 1;
885 unsigned RequiresADL : 1;
889 unsigned Overloaded : 1;
892 "UnresolvedLookupExprBitfields must be <= than 4 bytes to"
893 "avoid trashing OverloadExprBitfields::NumResults!");
903 unsigned IsArrow : 1;
906 unsigned HasUnresolvedUsing : 1;
909 "UnresolvedMemberExprBitfields must be <= than 4 bytes to"
910 "avoid trashing OverloadExprBitfields::NumResults!");
940 unsigned CaptureDefault : 2;
944 unsigned ExplicitParams : 1;
947 unsigned ExplicitResultType : 1;
950 unsigned NumCaptures : 16;
960 unsigned IsSatisfied : 1;
971 unsigned IsImplicit : 1;
981 unsigned ShouldCopy : 1;
994 unsigned IsUnique : 1;
1082 unsigned alignment = 8);
1085 unsigned alignment = 8) {
1086 return operator new(
bytes, *C, alignment);
1089 void *
operator new(
size_t bytes,
void *mem) noexcept {
return mem; }
1093 void operator delete(
void *,
size_t) noexcept {}
1094 void operator delete(
void *,
void *) noexcept {}
1115 template<
typename T,
typename TPtr = T *,
typename StmtPtr = Stmt *>
1117 : llvm::iterator_adaptor_base<CastIterator<T, TPtr, StmtPtr>, StmtPtr *,
1118 std::random_access_iterator_tag, TPtr> {
1119 using Base =
typename CastIterator::iterator_adaptor_base;
1125 return cast_or_null<T>(*this->I);
1130 template <
typename T>
1138 static bool StatisticsEnabled;
1152 static_assert(
sizeof(*
this) <= 8,
1153 "changing bitfields changed sizeof(Stmt)");
1154 static_assert(
sizeof(*
this) %
alignof(
void *) == 0,
1155 "Insufficient alignment!");
1195 static
std::tuple<
bool, const
Attr *, const
Attr *>
1214 StringRef NewlineSymbol = "\n",
1218 unsigned Indentation = 0,
1219 StringRef NewlineSymbol = "\n",
1239 return const_cast<Stmt*
>(
1278 bool Canonical)
const;
1300 :
Stmt(DeclStmtClass), DG(dg), StartLoc(startLoc), EndLoc(endLoc) {}
1369 :
Stmt(NullStmtClass) {
1402 private llvm::TrailingObjects<CompoundStmt, Stmt *> {
1404 friend TrailingObjects;
1423 :
Stmt(CompoundStmtClass), LBraceLoc(Loc), RBraceLoc(Loc) {
1453 return getTrailingObjects<Stmt *>();
1477 std::reverse_iterator<const_body_iterator>;
1496 for (
auto *B : llvm::reverse(
body())) {
1497 if (!isa<NullStmt>(B))
1564 return T->getStmtClass() == CaseStmtClass ||
1565 T->getStmtClass() == DefaultStmtClass;
1573 private llvm::TrailingObjects<CaseStmt, Stmt *, SourceLocation> {
1574 friend TrailingObjects;
1591 enum { LhsOffset = 0, SubStmtOffsetFromRhs = 1 };
1592 enum { NumMandatoryStmtPtr = 2 };
1594 unsigned numTrailingObjects(OverloadToken<Stmt *>)
const {
1598 unsigned numTrailingObjects(OverloadToken<SourceLocation>)
const {
1602 unsigned lhsOffset()
const {
return LhsOffset; }
1604 unsigned subStmtOffset()
const {
return rhsOffset() + SubStmtOffsetFromRhs; }
1610 :
SwitchCase(CaseStmtClass, caseLoc, colonLoc) {
1612 bool IsGNURange = rhs !=
nullptr;
1656 "setEllipsisLoc but this is not a case stmt of the form LHS ... RHS!");
1657 *getTrailingObjects<SourceLocation>() = L;
1661 return reinterpret_cast<Expr *
>(getTrailingObjects<Stmt *>()[lhsOffset()]);
1665 return reinterpret_cast<Expr *
>(getTrailingObjects<Stmt *>()[lhsOffset()]);
1669 getTrailingObjects<Stmt *>()[lhsOffset()] =
reinterpret_cast<Stmt *
>(Val);
1674 getTrailingObjects<Stmt *>()[rhsOffset()])
1680 getTrailingObjects<Stmt *>()[rhsOffset()])
1686 "setRHS but this is not a case stmt of the form LHS ... RHS!");
1687 getTrailingObjects<Stmt *>()[rhsOffset()] =
reinterpret_cast<Stmt *
>(Val);
1692 return getTrailingObjects<Stmt *>()[subStmtOffset()];
1696 getTrailingObjects<Stmt *>()[subStmtOffset()] = S;
1703 while (
const auto *CS2 = dyn_cast<CaseStmt>(CS->
getSubStmt()))
1716 getTrailingObjects<Stmt *>() +
1717 numTrailingObjects(OverloadToken<Stmt *>()));
1722 getTrailingObjects<Stmt *>() +
1723 numTrailingObjects(OverloadToken<Stmt *>()));
1732 :
SwitchCase(DefaultStmtClass, DL, CL), SubStmt(substmt) {}
1763 if (
const auto *CS = dyn_cast<CaseStmt>(
this))
1764 return CS->getEndLoc();
1765 else if (
const auto *DS = dyn_cast<DefaultStmt>(
this))
1766 return DS->getEndLoc();
1767 llvm_unreachable(
"SwitchCase is neither a CaseStmt nor a DefaultStmt!");
1771 if (
auto *CS = dyn_cast<CaseStmt>(
this))
1772 return CS->getSubStmt();
1773 else if (
auto *DS = dyn_cast<DefaultStmt>(
this))
1774 return DS->getSubStmt();
1775 llvm_unreachable(
"SwitchCase is neither a CaseStmt nor a DefaultStmt!");
1806 bool SideEntry =
false;
1811 :
ValueStmt(LabelStmtClass), TheDecl(D), SubStmt(substmt) {
1852 private llvm::TrailingObjects<AttributedStmt, const Attr *> {
1854 friend TrailingObjects;
1860 :
ValueStmt(AttributedStmtClass), SubStmt(SubStmt) {
1863 std::copy(Attrs.begin(), Attrs.end(), getAttrArrayPtr());
1867 :
ValueStmt(AttributedStmtClass, Empty) {
1870 std::fill_n(getAttrArrayPtr(), NumAttrs,
nullptr);
1873 const Attr *
const *getAttrArrayPtr()
const {
1874 return getTrailingObjects<const Attr *>();
1876 const Attr **getAttrArrayPtr() {
return getTrailingObjects<const Attr *>(); }
1879 static AttributedStmt *
Create(
const ASTContext &
C, SourceLocation Loc,
1880 ArrayRef<const Attr *> Attrs,
Stmt *SubStmt);
1883 static AttributedStmt *
CreateEmpty(
const ASTContext &
C,
unsigned NumAttrs);
1910 private llvm::TrailingObjects<IfStmt, Stmt *, SourceLocation> {
1911 friend TrailingObjects;
1935 enum { InitOffset = 0, ThenOffsetFromCond = 1, ElseOffsetFromCond = 2 };
1936 enum { NumMandatoryStmtPtr = 2 };
1940 unsigned numTrailingObjects(OverloadToken<Stmt *>)
const {
1945 unsigned numTrailingObjects(OverloadToken<SourceLocation>)
const {
1949 unsigned initOffset()
const {
return InitOffset; }
1950 unsigned varOffset()
const {
return InitOffset +
hasInitStorage(); }
1951 unsigned condOffset()
const {
1954 unsigned thenOffset()
const {
return condOffset() + ThenOffsetFromCond; }
1955 unsigned elseOffset()
const {
return condOffset() + ElseOffsetFromCond; }
1963 explicit IfStmt(
EmptyShell Empty,
bool HasElse,
bool HasVar,
bool HasInit);
1971 Stmt *Else =
nullptr);
1988 return reinterpret_cast<Expr *
>(getTrailingObjects<Stmt *>()[condOffset()]);
1992 return reinterpret_cast<Expr *
>(getTrailingObjects<Stmt *>()[condOffset()]);
1996 getTrailingObjects<Stmt *>()[condOffset()] =
reinterpret_cast<Stmt *
>(Cond);
1999 Stmt *
getThen() {
return getTrailingObjects<Stmt *>()[thenOffset()]; }
2001 return getTrailingObjects<Stmt *>()[thenOffset()];
2005 getTrailingObjects<Stmt *>()[thenOffset()] = Then;
2009 return hasElseStorage() ? getTrailingObjects<Stmt *>()[elseOffset()]
2014 return hasElseStorage() ? getTrailingObjects<Stmt *>()[elseOffset()]
2020 "This if statement has no storage for an else statement!");
2021 getTrailingObjects<Stmt *>()[elseOffset()] = Else;
2045 getTrailingObjects<Stmt *>()[varOffset()])
2051 getTrailingObjects<Stmt *>()[varOffset()])
2056 return hasInitStorage() ? getTrailingObjects<Stmt *>()[initOffset()]
2061 return hasInitStorage() ? getTrailingObjects<Stmt *>()[initOffset()]
2067 "This if statement has no storage for an init statement!");
2068 getTrailingObjects<Stmt *>()[initOffset()] = Init;
2081 "This if statement has no storage for an else statement!");
2082 *getTrailingObjects<SourceLocation>() = ElseLoc;
2135 getTrailingObjects<Stmt *>() +
2136 numTrailingObjects(OverloadToken<Stmt *>()));
2144 getTrailingObjects<Stmt *>() +
2145 numTrailingObjects(OverloadToken<Stmt *>()));
2155 private llvm::TrailingObjects<SwitchStmt, Stmt *> {
2156 friend TrailingObjects;
2178 enum { InitOffset = 0, BodyOffsetFromCond = 1 };
2179 enum { NumMandatoryStmtPtr = 2 };
2183 unsigned numTrailingObjects(OverloadToken<Stmt *>)
const {
2187 unsigned initOffset()
const {
return InitOffset; }
2188 unsigned varOffset()
const {
return InitOffset +
hasInitStorage(); }
2189 unsigned condOffset()
const {
2192 unsigned bodyOffset()
const {
return condOffset() + BodyOffsetFromCond; }
2219 return reinterpret_cast<Expr *
>(getTrailingObjects<Stmt *>()[condOffset()]);
2223 return reinterpret_cast<Expr *
>(getTrailingObjects<Stmt *>()[condOffset()]);
2227 getTrailingObjects<Stmt *>()[condOffset()] =
reinterpret_cast<Stmt *
>(Cond);
2230 Stmt *
getBody() {
return getTrailingObjects<Stmt *>()[bodyOffset()]; }
2232 return getTrailingObjects<Stmt *>()[bodyOffset()];
2236 getTrailingObjects<Stmt *>()[bodyOffset()] = Body;
2240 return hasInitStorage() ? getTrailingObjects<Stmt *>()[initOffset()]
2245 return hasInitStorage() ? getTrailingObjects<Stmt *>()[initOffset()]
2251 "This switch statement has no storage for an init statement!");
2252 getTrailingObjects<Stmt *>()[initOffset()] = Init;
2277 getTrailingObjects<Stmt *>()[varOffset()])
2283 getTrailingObjects<Stmt *>()[varOffset()])
2305 "case/default already added to a switch");
2329 getTrailingObjects<Stmt *>() +
2330 numTrailingObjects(OverloadToken<Stmt *>()));
2335 getTrailingObjects<Stmt *>() +
2336 numTrailingObjects(OverloadToken<Stmt *>()));
2346 private llvm::TrailingObjects<WhileStmt, Stmt *> {
2347 friend TrailingObjects;
2364 enum { VarOffset = 0, BodyOffsetFromCond = 1 };
2365 enum { NumMandatoryStmtPtr = 2 };
2369 unsigned varOffset()
const {
return VarOffset; }
2370 unsigned condOffset()
const {
return VarOffset +
hasVarStorage(); }
2371 unsigned bodyOffset()
const {
return condOffset() + BodyOffsetFromCond; }
2373 unsigned numTrailingObjects(OverloadToken<Stmt *>)
const {
2399 return reinterpret_cast<Expr *
>(getTrailingObjects<Stmt *>()[condOffset()]);
2403 return reinterpret_cast<Expr *
>(getTrailingObjects<Stmt *>()[condOffset()]);
2407 getTrailingObjects<Stmt *>()[condOffset()] =
reinterpret_cast<Stmt *
>(Cond);
2410 Stmt *
getBody() {
return getTrailingObjects<Stmt *>()[bodyOffset()]; }
2412 return getTrailingObjects<Stmt *>()[bodyOffset()];
2416 getTrailingObjects<Stmt *>()[bodyOffset()] = Body;
2440 getTrailingObjects<Stmt *>()[varOffset()])
2446 getTrailingObjects<Stmt *>()[varOffset()])
2470 getTrailingObjects<Stmt *>() +
2471 numTrailingObjects(OverloadToken<Stmt *>()));
2476 getTrailingObjects<Stmt *>() +
2477 numTrailingObjects(OverloadToken<Stmt *>()));
2483 enum { BODY, COND, END_EXPR };
2484 Stmt *SubExprs[END_EXPR];
2491 :
Stmt(DoStmtClass), WhileLoc(WL), RParenLoc(RP) {
2502 return reinterpret_cast<Expr *
>(SubExprs[COND]);
2527 return child_range(&SubExprs[0], &SubExprs[0] + END_EXPR);
2539 enum { INIT, CONDVAR, COND, INC, BODY, END_EXPR };
2540 Stmt* SubExprs[END_EXPR];
2567 return reinterpret_cast<DeclStmt*
>(SubExprs[CONDVAR]);
2600 return child_range(&SubExprs[0], &SubExprs[0]+END_EXPR);
2615 :
Stmt(GotoStmtClass),
Label(label), LabelLoc(LL) {
2654 :
Stmt(IndirectGotoStmtClass), StarLoc(starLoc) {
2661 :
Stmt(IndirectGotoStmtClass, Empty) {}
2670 return reinterpret_cast<const Expr *
>(
Target);
2766 private llvm::TrailingObjects<ReturnStmt, const VarDecl *> {
2767 friend TrailingObjects;
2776 bool hasNRVOCandidate()
const {
return ReturnStmtBits.HasNRVOCandidate; }
2778 unsigned numTrailingObjects(OverloadToken<const VarDecl *>)
const {
2779 return hasNRVOCandidate();
2791 const VarDecl *NRVOCandidate);
2807 return hasNRVOCandidate() ? *getTrailingObjects<const VarDecl *>()
2815 assert(hasNRVOCandidate() &&
2816 "This return statement has no storage for an NRVO candidate!");
2817 *getTrailingObjects<const VarDecl *>() = Var;
2868 unsigned numoutputs,
unsigned numinputs,
unsigned numclobbers)
3016 unsigned NumLabels = 0;
3020 bool isvolatile,
unsigned numoutputs,
unsigned numinputs,
3060 : MyKind(
Operand), Str(S), OperandNo(OpNo),
3074 assert(
isOperand() &&
"Range is currently used only for Operands.");
3089 const ASTContext &C,
unsigned &DiagOffs)
const;
3100 return II->getName();
3108 return Constraints[i];
3111 return Constraints[i];
3128 return II->getName();
3152 return NumLabels > 0;
3195 void setOutputsAndInputsAndClobbers(
const ASTContext &C,
3235 unsigned NumAsmToks = 0;
3237 Token *AsmToks =
nullptr;
3238 StringRef *Constraints =
nullptr;
3239 StringRef *Clobbers =
nullptr;
3272 return Constraints[i];
3306 return llvm::makeArrayRef(
reinterpret_cast<Expr**
>(
Exprs),
3340 enum { FILTER_EXPR,
BLOCK };
3346 static SEHExceptStmt*
Create(
const ASTContext &
C,
3347 SourceLocation ExceptLoc,
3357 return reinterpret_cast<Expr*
>(Children[FILTER_EXPR]);
3361 return cast<CompoundStmt>(Children[
BLOCK]);
3420 enum { TRY = 0, HANDLER = 1 };
3430 static SEHTryStmt*
Create(
const ASTContext &
C,
bool isCXXTry,
3431 SourceLocation TryLoc,
Stmt *TryBlock,
3442 return cast<CompoundStmt>(Children[TRY]);
3470 :
Stmt(SEHLeaveStmtClass), LeaveLoc(LL) {}
3518 llvm::PointerIntPair<VarDecl *, 2, VariableCaptureKind> VarAndKind;
3566 unsigned NumCaptures;
3570 llvm::PointerIntPair<CapturedDecl *, 2, CapturedRegionKind> CapDeclAndKind;
3582 Stmt **getStoredStmts() {
return reinterpret_cast<Stmt **
>(
this + 1); }
3584 Stmt *
const *getStoredStmts()
const {
3585 return reinterpret_cast<Stmt *
const *
>(
this + 1);
3588 Capture *getStoredCaptures()
const;
3590 void setCapturedStmt(
Stmt *S) { getStoredStmts()[NumCaptures] = S; }
3602 unsigned NumCaptures);
3626 assert(D &&
"null RecordDecl");
3653 return getStoredCaptures() + NumCaptures;
3667 llvm::iterator_range<const_capture_init_iterator>;
3679 return reinterpret_cast<Expr **
>(getStoredStmts());
3683 return reinterpret_cast<Expr *
const *
>(getStoredStmts());
3719 #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.
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
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
Optional< const Stmt * > getNondiscardedCase(const ASTContext &Ctx) const
If this is an 'if constexpr', determine which substatement will be taken.
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....
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
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.
static CompoundStmt * CreateEmpty(const ASTContext &C, unsigned NumStmts)
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
ContinueStmt(SourceLocation CL)
SourceLocation getBeginLoc() const
void setInputExpr(unsigned i, Expr *E)
StmtClass getStmtClass() const
ArrayRef< const Attr * > getAttrs() const
const DeclStmt * getConditionVariableDeclStmt() const
If this ForStmt has a condition variable, return the faux DeclStmt associated with the creation of th...
SourceLocation getBeginLoc() const LLVM_READONLY
SourceLocation getBeginLoc() const
const_child_iterator child_begin() const
void setAsmLoc(SourceLocation L)
void setRParenLoc(SourceLocation Loc)
SourceLocation getLParenLoc() const