13#ifndef LLVM_CLANG_AST_STMTCXX_H
14#define LLVM_CLANG_AST_STMTCXX_H
20#include "llvm/Support/Compiler.h"
38 :
Stmt(CXXCatchStmtClass), CatchLoc(catchLoc), ExceptionDecl(exDecl),
39 HandlerBlock(handlerBlock) {}
46 return HandlerBlock->getEndLoc();
55 return T->getStmtClass() == CXXCatchStmtClass;
69class CXXTryStmt final :
public Stmt,
70 private llvm::TrailingObjects<CXXTryStmt, Stmt *> {
72 friend TrailingObjects;
77 size_t numTrailingObjects(OverloadToken<Stmt *>)
const {
return NumHandlers; }
82 :
Stmt(CXXTryStmtClass), NumHandlers(numHandlers) { }
84 Stmt *
const *getStmts()
const {
return getTrailingObjects(); }
85 Stmt **getStmts() {
return getTrailingObjects(); }
88 static CXXTryStmt *
Create(
const ASTContext &
C, SourceLocation tryLoc,
92 unsigned numHandlers);
98 return getStmts()[NumHandlers]->getEndLoc();
117 return T->getStmtClass() == CXXTryStmtClass;
137 enum { INIT, RANGE, BEGINSTMT, ENDSTMT, COND, INC, LOOPVAR, BODY, END };
165 return cast_or_null<DeclStmt>(SubExprs[BEGINSTMT]);
177 return cast_or_null<DeclStmt>(SubExprs[BEGINSTMT]);
180 return cast_or_null<DeclStmt>(SubExprs[ENDSTMT]);
183 return cast_or_null<Expr>(SubExprs[COND]);
186 return cast_or_null<Expr>(SubExprs[INC]);
210 return SubExprs[BODY]->getEndLoc();
214 return T->getStmtClass() == CXXForRangeStmtClass;
269 :
Stmt(MSDependentExistsStmtClass),
270 KeywordLoc(KeywordLoc), IsIfExists(IsIfExists),
271 QualifierLoc(QualifierLoc), NameInfo(NameInfo),
272 SubStmt(reinterpret_cast<
Stmt *>(SubStmt)) { }
300 return SubStmt->getEndLoc();
312 return T->getStmtClass() == MSDependentExistsStmtClass;
319class CoroutineBodyStmt final
321 private llvm::TrailingObjects<CoroutineBodyStmt, Stmt *> {
334 ReturnStmtOnAllocFailure,
341 friend TrailingObjects;
343 Stmt **getStoredStmts() {
return getTrailingObjects(); }
345 Stmt *
const *getStoredStmts()
const {
return getTrailingObjects(); }
367 CoroutineBodyStmt(
CtorArgs const& Args);
386 return getStoredStmts()[SubStmt::Promise];
393 return getStoredStmts()[SubStmt::InitSuspend];
396 return getStoredStmts()[SubStmt::FinalSuspend];
400 return getStoredStmts()[SubStmt::OnException];
403 return getStoredStmts()[SubStmt::OnFallthrough];
407 return cast_or_null<Expr>(getStoredStmts()[SubStmt::Allocate]);
410 return cast_or_null<Expr>(getStoredStmts()[SubStmt::Deallocate]);
414 return cast<Expr>(getStoredStmts()[SubStmt::ReturnValue]);
417 auto *RS = dyn_cast_or_null<clang::ReturnStmt>(
getReturnStmt());
418 return RS ? RS->getRetValue() :
nullptr;
422 return getStoredStmts()[SubStmt::ReturnStmtOnAllocFailure];
425 return {getStoredStmts() + SubStmt::FirstParamMove, NumParams};
438 getStoredStmts() + SubStmt::FirstParamMove + NumParams);
443 SubStmt::FirstParamMove +
448 return child_range(getStoredStmts() + SubStmt::Body + 1,
449 getStoredStmts() + SubStmt::FirstParamMove + NumParams);
454 getStoredStmts() + SubStmt::FirstParamMove +
459 return T->getStmtClass() == CoroutineBodyStmtClass;
477 enum SubStmt { Operand, PromiseCall, Count };
478 Stmt *SubStmts[SubStmt::Count];
485 bool IsImplicit =
false)
486 :
Stmt(CoreturnStmtClass), CoreturnLoc(CoreturnLoc),
487 IsImplicit(IsImplicit) {
488 SubStmts[SubStmt::Operand] = Operand;
489 SubStmts[SubStmt::PromiseCall] = PromiseCall;
504 return static_cast<Expr*
>(SubStmts[PromiseCall]);
516 return child_range(SubStmts, SubStmts + SubStmt::Count);
524 return T->getStmtClass() == CoreturnStmtClass;
673class CXXExpansionStmtPattern final
675 llvm::TrailingObjects<CXXExpansionStmtPattern, Stmt *> {
677 friend TrailingObjects;
688 ExpansionStmtKind PatternKind;
712 COUNT_Enumerating = FIRST_CHILD_STMT,
715 EXPANSION_INITIALIZER = FIRST_CHILD_STMT,
719 DECOMP_DECL = FIRST_CHILD_STMT,
723 RANGE = FIRST_CHILD_STMT,
729 CXXExpansionStmtPattern(ExpansionStmtKind PatternKind, EmptyShell
Empty);
730 CXXExpansionStmtPattern(ExpansionStmtKind PatternKind,
731 CXXExpansionStmtDecl *ESD,
Stmt *Init,
732 DeclStmt *ExpansionVar, SourceLocation LParenLoc,
733 SourceLocation ColonLoc, SourceLocation RParenLoc);
736 static CXXExpansionStmtPattern *
740 static CXXExpansionStmtPattern *
742 DeclStmt *ExpansionVar, Expr *ExpansionInitializer,
743 SourceLocation LParenLoc, SourceLocation ColonLoc,
744 SourceLocation RParenLoc);
747 static CXXExpansionStmtPattern *
749 Stmt *Init, DeclStmt *ExpansionVar,
750 Stmt *DecompositionDeclStmt, SourceLocation LParenLoc,
751 SourceLocation ColonLoc, SourceLocation RParenLoc);
754 static CXXExpansionStmtPattern *
756 DeclStmt *ExpansionVar, SourceLocation LParenLoc,
757 SourceLocation ColonLoc, SourceLocation RParenLoc);
760 static CXXExpansionStmtPattern *
762 DeclStmt *ExpansionVar, DeclStmt *Range, DeclStmt *Begin,
763 DeclStmt *Iter, SourceLocation LParenLoc,
764 SourceLocation ColonLoc, SourceLocation RParenLoc);
827 getSubStmt(RANGE) = S;
852 getSubStmt(BEGIN) = S;
877 getSubStmt(ITER) = S;
893 return getSubStmt(DECOMP_DECL);
898 return getSubStmt(DECOMP_DECL);
903 getSubStmt(DECOMP_DECL) = S;
914 return cast<Expr>(getSubStmt(EXPANSION_INITIALIZER));
919 return cast<Expr>(getSubStmt(EXPANSION_INITIALIZER));
924 getSubStmt(EXPANSION_INITIALIZER) = S;
938 return T->getStmtClass() == CXXExpansionStmtPatternClass;
942 template <
typename... Args>
944 ExpansionStmtKind Kind,
945 Args &&...Arguments);
948 Stmt *getSubStmt(
unsigned Idx)
const {
950 return getTrailingObjects()[Idx];
953 Stmt *&getSubStmt(
unsigned Idx) {
955 return getTrailingObjects()[Idx];
1026class CXXExpansionStmtInstantiation final
1028 llvm::TrailingObjects<CXXExpansionStmtInstantiation, Stmt *> {
1030 friend TrailingObjects;
1035 const unsigned NumInstantiations : 20;
1036 const unsigned NumPreambleStmts : 3;
1037 unsigned ShouldApplyLifetimeExtensionToPreamble : 1;
1039 CXXExpansionStmtInstantiation(
EmptyShell Empty,
unsigned NumInstantiations,
1040 unsigned NumPreambleStmts);
1044 bool ShouldApplyLifetimeExtensionToPreamble);
1047 static CXXExpansionStmtInstantiation *
1050 bool ShouldApplyLifetimeExtensionToPreamble);
1054 unsigned NumInstantiations,
1055 unsigned NumPreambleStmts);
1066 return NumInstantiations + NumPreambleStmts;
1070 return getTrailingObjects(NumInstantiations);
1078 return ShouldApplyLifetimeExtensionToPreamble;
1082 ShouldApplyLifetimeExtensionToPreamble = Apply;
1092 Stmt **S = getTrailingObjects();
1097 Stmt *
const *S = getTrailingObjects();
1102 return T->getStmtClass() == CXXExpansionStmtInstantiationClass;
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
CXXCatchStmt - This represents a C++ catch block.
SourceLocation getEndLoc() const LLVM_READONLY
CXXCatchStmt(SourceLocation catchLoc, VarDecl *exDecl, Stmt *handlerBlock)
SourceLocation getCatchLoc() const
Stmt * getHandlerBlock() const
SourceLocation getBeginLoc() const LLVM_READONLY
CXXCatchStmt(EmptyShell Empty)
static bool classof(const Stmt *T)
const_child_range children() const
VarDecl * getExceptionDecl() const
QualType getCaughtType() const
friend class ASTStmtReader
Represents a C++26 expansion statement declaration.
ArrayRef< Stmt * > getInstantiations() const
bool shouldApplyLifetimeExtensionToPreamble() const
CXXExpansionStmtDecl * getParent()
ArrayRef< Stmt * > getPreambleStmts() const
const_child_range children() const
ArrayRef< Stmt * > getAllSubStmts() const
SourceLocation getBeginLoc() const
const CXXExpansionStmtDecl * getParent() const
static bool classof(const Stmt *T)
SourceLocation getEndLoc() const
MutableArrayRef< Stmt * > getAllSubStmts()
friend class ASTStmtReader
unsigned getNumSubStmts() const
static CXXExpansionStmtInstantiation * CreateEmpty(ASTContext &C, EmptyShell Empty, unsigned NumInstantiations, unsigned NumPreambleStmts)
void setShouldApplyLifetimeExtensionToPreamble(bool Apply)
CXXExpansionStmtPattern - Represents an unexpanded C++ expansion statement.
bool isEnumerating() const
ExpansionStmtKind getKind() const
const CXXExpansionStmtDecl * getDecl() const
static CXXExpansionStmtPattern * CreateIterating(ASTContext &Context, CXXExpansionStmtDecl *ESD, Stmt *Init, DeclStmt *ExpansionVar, DeclStmt *Range, DeclStmt *Begin, DeclStmt *Iter, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation RParenLoc)
Create an iterating expansion statement pattern.
SourceLocation getEndLoc() const
SourceLocation getBeginLoc() const
const DeclStmt * getIterVarStmt() const
DeclStmt * getBeginVarStmt()
const Expr * getExpansionInitializer() const
DecompositionDecl * getDecompositionDecl()
DeclStmt * getExpansionVarStmt()
static CXXExpansionStmtPattern * CreateDependent(ASTContext &Context, CXXExpansionStmtDecl *ESD, Stmt *Init, DeclStmt *ExpansionVar, Expr *ExpansionInitializer, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation RParenLoc)
Create a dependent expansion statement pattern.
static CXXExpansionStmtPattern * CreateEmpty(ASTContext &Context, EmptyShell Empty, ExpansionStmtKind Kind)
SourceLocation getRParenLoc() const
const VarDecl * getRangeVar() const
static CXXExpansionStmtPattern * CreateDestructuring(ASTContext &Context, CXXExpansionStmtDecl *ESD, Stmt *Init, DeclStmt *ExpansionVar, Stmt *DecompositionDeclStmt, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation RParenLoc)
Create a destructuring expansion statement pattern.
DeclStmt * getRangeVarStmt()
const Stmt * getBody() const
Stmt * getDecompositionDeclStmt()
const VarDecl * getIterVar() const
const VarDecl * getExpansionVariable() const
const_child_range children() const
const Stmt * getInit() const
void setRangeVarStmt(DeclStmt *S)
const Stmt * getDecompositionDeclStmt() const
void setBeginVarStmt(DeclStmt *S)
unsigned getNumSubStmts() const
void setIterVarStmt(DeclStmt *S)
const DeclStmt * getExpansionVarStmt() const
const DeclStmt * getBeginVarStmt() const
const DecompositionDecl * getDecompositionDecl() const
void setDecompositionDeclStmt(Stmt *S)
void setExpansionInitializer(Expr *S)
SourceLocation getColonLoc() const
Expr * getExpansionInitializer()
void setExpansionVarStmt(Stmt *S)
friend class ASTStmtReader
bool isDestructuring() const
const DeclStmt * getRangeVarStmt() const
CXXExpansionStmtDecl * getDecl()
const VarDecl * getBeginVar() const
static CXXExpansionStmtPattern * CreateEnumerating(ASTContext &Context, CXXExpansionStmtDecl *ESD, Stmt *Init, DeclStmt *ExpansionVar, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation RParenLoc)
Create an enumerating expansion statement pattern.
static bool classof(const Stmt *T)
DeclStmt * getIterVarStmt()
VarDecl * getExpansionVariable()
SourceLocation getLParenLoc() const
void setLoopVarStmt(Stmt *S)
void setRangeStmt(Stmt *S)
DeclStmt * getBeginStmt()
CXXForRangeStmt(Stmt *InitStmt, DeclStmt *Range, DeclStmt *Begin, DeclStmt *End, Expr *Cond, Expr *Inc, DeclStmt *LoopVar, Stmt *Body, SourceLocation FL, SourceLocation CAL, SourceLocation CL, SourceLocation RPL)
DeclStmt * getLoopVarStmt()
const DeclStmt * getRangeStmt() const
SourceLocation getForLoc() const
const DeclStmt * getEndStmt() const
DeclStmt * getRangeStmt()
const DeclStmt * getBeginStmt() const
const Expr * getCond() const
SourceLocation getRParenLoc() const
const Expr * getInc() const
SourceLocation getColonLoc() const
void setBeginStmt(Stmt *S)
const_child_range children() const
VarDecl * getLoopVariable()
SourceLocation getEndLoc() const LLVM_READONLY
CXXForRangeStmt(EmptyShell Empty)
const Stmt * getBody() const
SourceLocation getCoawaitLoc() const
static bool classof(const Stmt *T)
const DeclStmt * getLoopVarStmt() const
friend class ASTStmtReader
void setRangeInit(Expr *E)
const Stmt * getInit() const
SourceLocation getBeginLoc() const LLVM_READONLY
CXXTryStmt - A C++ try block, including all handlers.
SourceLocation getTryLoc() const
const CXXCatchStmt * getHandler(unsigned i) const
static bool classof(const Stmt *T)
const_child_range children() const
CXXCatchStmt * getHandler(unsigned i)
unsigned getNumHandlers() const
SourceLocation getEndLoc() const
friend class ASTStmtReader
SourceLocation getBeginLoc() const LLVM_READONLY
const CompoundStmt * getTryBlock() const
CompoundStmt * getTryBlock()
CompoundStmt - This represents a group of statements like { stmt stmt }.
SourceLocation getBeginLoc() const
SourceLocation getEndLoc() const
Expr * getOperand() const
Retrieve the operand of the 'co_return' statement.
void setIsImplicit(bool value=true)
Expr * getPromiseCall() const
Retrieve the promise call that results from this 'co_return' statement.
SourceLocation getEndLoc() const LLVM_READONLY
SourceLocation getKeywordLoc() const
SourceLocation getBeginLoc() const LLVM_READONLY
CoreturnStmt(SourceLocation CoreturnLoc, Stmt *Operand, Stmt *PromiseCall, bool IsImplicit=false)
static bool classof(const Stmt *T)
friend class ASTStmtReader
const_child_range children() const
CompoundStmt * getBody() const
Retrieve the body of the coroutine as written.
static bool classof(const Stmt *T)
Stmt * getReturnStmtOnAllocFailure() const
Expr * getReturnValueInit() const
Stmt * getReturnStmt() const
bool hasDependentPromiseType() const
Stmt * getResultDecl() const
child_range childrenExclBody()
Stmt * getInitSuspendStmt() const
Expr * getAllocate() const
Stmt * getPromiseDeclStmt() const
VarDecl * getPromiseDecl() const
Expr * getDeallocate() const
Stmt * getFallthroughHandler() const
Stmt * getExceptionHandler() const
SourceLocation getBeginLoc() const LLVM_READONLY
Expr * getReturnValue() const
SourceLocation getEndLoc() const LLVM_READONLY
friend class ASTStmtReader
Stmt * getFinalSuspendStmt() const
const_child_range children() const
ArrayRef< Stmt const * > getParamMoves() const
const_child_range childrenExclBody() const
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
SourceLocation getEndLoc() const LLVM_READONLY
SourceLocation getBeginLoc() const LLVM_READONLY
A decomposition declaration.
This represents one expression.
bool isIfExists() const
Determine whether this is an __if_exists statement.
DeclarationNameInfo getNameInfo() const
Retrieve the name of the entity we're testing for, along with location information.
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies this name, if any.
CompoundStmt * getSubStmt() const
Retrieve the compound statement that will be included in the program only if the existence of the sym...
SourceLocation getEndLoc() const LLVM_READONLY
SourceLocation getKeywordLoc() const
Retrieve the location of the __if_exists or __if_not_exists keyword.
static bool classof(const Stmt *T)
bool isIfNotExists() const
Determine whether this is an __if_exists statement.
const_child_range children() const
MSDependentExistsStmt(SourceLocation KeywordLoc, bool IsIfExists, NestedNameSpecifierLoc QualifierLoc, DeclarationNameInfo NameInfo, CompoundStmt *SubStmt)
friend class ASTStmtReader
SourceLocation getBeginLoc() const LLVM_READONLY
A C++ nested-name-specifier augmented with source location information.
A (possibly-)qualified type.
Encodes a location in the source.
Stmt - This represents one statement.
SourceLocation getEndLoc() const LLVM_READONLY
Stmt(StmtClass SC, EmptyShell)
Construct an empty statement.
llvm::iterator_range< child_iterator > child_range
llvm::iterator_range< const_child_iterator > const_child_range
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
Represents a variable declaration or definition.
The JSON file list parser is used to communicate input to InstallAPI.
@ Create
'create' clause, allowed on Compute and Combined constructs, plus 'data', 'enter data',...
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
U cast(CodeGen::Address addr)
__packed_splat4 __packed_splat2 __packed_splat8 __packed_splat4 __packed_splat2 uint8_t
Stmt * ReturnStmtOnAllocFailure
ArrayRef< Stmt * > ParamMoves
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
A placeholder type used to construct an empty shell of a type, that will be filled in later (e....