22 return ExceptionDecl->getType();
29 const size_t Size = totalSizeToAlloc<Stmt *>(handlers.size() + 1);
30 void *Mem =
C.Allocate(Size,
alignof(CXXTryStmt));
31 return new (Mem) CXXTryStmt(tryLoc, tryBlock, handlers);
35 unsigned numHandlers) {
36 const size_t Size = totalSizeToAlloc<Stmt *>(numHandlers + 1);
37 void *Mem =
C.Allocate(Size,
alignof(CXXTryStmt));
38 return new (Mem) CXXTryStmt(
Empty, numHandlers);
43 :
Stmt(CXXTryStmtClass), TryLoc(tryLoc), NumHandlers(handlers.size()) {
44 Stmt **Stmts = getStmts();
46 llvm::copy(handlers, Stmts + 1);
55 :
Stmt(CXXForRangeStmtClass), ForLoc(FL), CoawaitLoc(CAL), ColonLoc(
CL),
57 SubExprs[INIT] =
Init;
58 SubExprs[RANGE] = Range;
59 SubExprs[BEGINSTMT] = BeginStmt;
60 SubExprs[ENDSTMT] = EndStmt;
61 SubExprs[COND] =
Cond;
63 SubExprs[LOOPVAR] = LoopVar;
64 SubExprs[BODY] = Body;
70 assert(RangeDecl &&
"for-range should have a single var decl");
80 assert(LV &&
"No loop variable in CXXForRangeStmt");
90 std::size_t Size = totalSizeToAlloc<Stmt *>(
91 CoroutineBodyStmt::FirstParamMove + Args.
ParamMoves.size());
93 void *Mem =
C.Allocate(Size,
alignof(CoroutineBodyStmt));
94 return new (Mem) CoroutineBodyStmt(Args);
99 std::size_t Size = totalSizeToAlloc<Stmt *>(
100 CoroutineBodyStmt::FirstParamMove + NumParams);
102 void *Mem =
C.Allocate(Size,
alignof(CoroutineBodyStmt));
104 Result->NumParams = NumParams;
105 auto *ParamBegin =
Result->getStoredStmts() + SubStmt::FirstParamMove;
106 std::uninitialized_fill(ParamBegin, ParamBegin + NumParams,
107 static_cast<Stmt *
>(
nullptr));
112 :
Stmt(CoroutineBodyStmtClass), NumParams(Args.ParamMoves.size()) {
113 Stmt **SubStmts = getStoredStmts();
114 SubStmts[CoroutineBodyStmt::Body] = Args.
Body;
115 SubStmts[CoroutineBodyStmt::Promise] = Args.
Promise;
117 SubStmts[CoroutineBodyStmt::FinalSuspend] = Args.
FinalSuspend;
118 SubStmts[CoroutineBodyStmt::OnException] = Args.
OnException;
119 SubStmts[CoroutineBodyStmt::OnFallthrough] = Args.
OnFallthrough;
120 SubStmts[CoroutineBodyStmt::Allocate] = Args.
Allocate;
121 SubStmts[CoroutineBodyStmt::Deallocate] = Args.
Deallocate;
122 SubStmts[CoroutineBodyStmt::ResultDecl] = Args.
ResultDecl;
123 SubStmts[CoroutineBodyStmt::ReturnValue] = Args.
ReturnValue;
124 SubStmts[CoroutineBodyStmt::ReturnStmt] = Args.
ReturnStmt;
125 SubStmts[CoroutineBodyStmt::ReturnStmtOnAllocFailure] =
130CXXExpansionStmtPattern::CXXExpansionStmtPattern(ExpansionStmtKind PatternKind,
132 :
Stmt(CXXExpansionStmtPatternClass,
Empty), PatternKind(PatternKind) {}
134CXXExpansionStmtPattern::CXXExpansionStmtPattern(
138 :
Stmt(CXXExpansionStmtPatternClass), PatternKind(PatternKind),
139 LParenLoc(LParenLoc), ColonLoc(ColonLoc), RParenLoc(RParenLoc),
142 setExpansionVarStmt(ExpansionVar);
146template <
typename... Args>
148 ASTContext &Context, ExpansionStmtKind Kind, Args &&...Arguments) {
150 void *Mem = Context.
Allocate(Size,
alignof(CXXExpansionStmtPattern));
152 CXXExpansionStmtPattern(Kind, std::forward<Args>(Arguments)...);
160 CXXExpansionStmtPattern *Pattern =
162 ExpansionVar, LParenLoc, ColonLoc, RParenLoc);
172 CXXExpansionStmtPattern *Pattern =
174 ExpansionVar, LParenLoc, ColonLoc, RParenLoc);
182 return AllocateAndConstruct(Context, Kind,
Empty);
190 Init, ExpansionVar, LParenLoc, ColonLoc,
199 CXXExpansionStmtPattern *Pattern =
201 ExpansionVar, LParenLoc, ColonLoc, RParenLoc);
209 return ParentDecl->getLocation();
220 assert(LV &&
"No expansion variable in CXXExpansionStmtPattern");
226 switch (PatternKind) {
228 return COUNT_Enumerating;
230 return COUNT_Iterating;
232 return COUNT_Destructuring;
234 return COUNT_Dependent;
237 llvm_unreachable(
"invalid pattern kind");
240CXXExpansionStmtInstantiation::CXXExpansionStmtInstantiation(
241 EmptyShell
Empty,
unsigned NumInstantiations,
unsigned NumPreambleStmts)
242 :
Stmt(CXXExpansionStmtInstantiationClass,
Empty),
243 NumInstantiations(NumInstantiations), NumPreambleStmts(NumPreambleStmts) {
244 assert(NumPreambleStmts <= 4 &&
"might have to allocate more bits for this");
247CXXExpansionStmtInstantiation::CXXExpansionStmtInstantiation(
249 ArrayRef<Stmt *> PreambleStmts,
bool ShouldApplyLifetimeExtensionToPreamble)
250 :
Stmt(CXXExpansionStmtInstantiationClass), Parent(Parent),
251 NumInstantiations(unsigned(Instantiations.size())),
252 NumPreambleStmts(unsigned(PreambleStmts.size())),
253 ShouldApplyLifetimeExtensionToPreamble(
254 ShouldApplyLifetimeExtensionToPreamble) {
255 assert(NumPreambleStmts <= 4 &&
"might have to allocate more bits for this");
256 llvm::uninitialized_copy(Instantiations, getTrailingObjects());
257 llvm::uninitialized_copy(PreambleStmts,
258 getTrailingObjects() + NumInstantiations);
264 bool ShouldApplyLifetimeExtensionToPreamble) {
265 void *Mem =
C.Allocate(
266 totalSizeToAlloc<Stmt *>(Instantiations.size() + PreambleStmts.size()),
267 alignof(CXXExpansionStmtInstantiation));
269 CXXExpansionStmtInstantiation(Parent, Instantiations, PreambleStmts,
270 ShouldApplyLifetimeExtensionToPreamble);
275 unsigned NumInstantiations,
276 unsigned NumPreambleStmts) {
278 C.Allocate(totalSizeToAlloc<Stmt *>(NumInstantiations + NumPreambleStmts),
279 alignof(CXXExpansionStmtInstantiation));
281 CXXExpansionStmtInstantiation(
Empty, NumInstantiations, NumPreambleStmts);
285 return Parent->getExpansionPattern()->getBeginLoc();
289 return Parent->getExpansionPattern()->getEndLoc();
Defines the clang::ASTContext interface.
Defines the clang::Expr interface and subclasses for C++ expressions.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
void * Allocate(size_t Size, unsigned Align=8) const
QualType getCaughtType() const
Represents a C++26 expansion statement declaration.
Represents the code generated for an expanded expansion statement.
SourceLocation getBeginLoc() const
SourceLocation getEndLoc() const
static CXXExpansionStmtInstantiation * Create(ASTContext &C, CXXExpansionStmtDecl *Parent, ArrayRef< Stmt * > Instantiations, ArrayRef< Stmt * > PreambleStmts, bool ShouldApplyLifetimeExtensionToPreamble)
static CXXExpansionStmtInstantiation * CreateEmpty(ASTContext &C, EmptyShell Empty, unsigned NumInstantiations, unsigned NumPreambleStmts)
CXXExpansionStmtPattern - Represents an unexpanded C++ expansion statement.
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 getBeginLoc() 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)
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.
Stmt * getDecompositionDeclStmt()
void setRangeVarStmt(DeclStmt *S)
void setBeginVarStmt(DeclStmt *S)
unsigned getNumSubStmts() const
void setIterVarStmt(DeclStmt *S)
void setDecompositionDeclStmt(Stmt *S)
void setExpansionInitializer(Expr *S)
bool isDestructuring() const
static CXXExpansionStmtPattern * CreateEnumerating(ASTContext &Context, CXXExpansionStmtDecl *ESD, Stmt *Init, DeclStmt *ExpansionVar, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation RParenLoc)
Create an enumerating expansion statement pattern.
VarDecl * getExpansionVariable()
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()
DeclStmt * getRangeStmt()
VarDecl * getLoopVariable()
static CXXTryStmt * Create(const ASTContext &C, SourceLocation tryLoc, CompoundStmt *tryBlock, ArrayRef< Stmt * > handlers)
CompoundStmt - This represents a group of statements like { stmt stmt }.
static CoroutineBodyStmt * Create(const ASTContext &C, CtorArgs const &Args)
ArrayRef< Stmt const * > getParamMoves() const
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
const Decl * getSingleDecl() const
Decl - This represents one declaration (or definition), e.g.
A decomposition declaration.
This represents one expression.
A (possibly-)qualified type.
Encodes a location in the source.
Stmt - This represents one statement.
Stmt(StmtClass SC, EmptyShell)
Construct an empty statement.
Represents a variable declaration or definition.
const Expr * getInit() const
The JSON file list parser is used to communicate input to InstallAPI.
@ Result
The result type of a method or function.
U cast(CodeGen::Address addr)
Stmt * ReturnStmtOnAllocFailure
ArrayRef< Stmt * > ParamMoves
A placeholder type used to construct an empty shell of a type, that will be filled in later (e....