diff options
Diffstat (limited to 'contrib/llvm/tools/clang/lib/AST/StmtCXX.cpp')
-rw-r--r-- | contrib/llvm/tools/clang/lib/AST/StmtCXX.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/contrib/llvm/tools/clang/lib/AST/StmtCXX.cpp b/contrib/llvm/tools/clang/lib/AST/StmtCXX.cpp index 4a04fc2..666f5dc 100644 --- a/contrib/llvm/tools/clang/lib/AST/StmtCXX.cpp +++ b/contrib/llvm/tools/clang/lib/AST/StmtCXX.cpp @@ -86,3 +86,46 @@ VarDecl *CXXForRangeStmt::getLoopVariable() { const VarDecl *CXXForRangeStmt::getLoopVariable() const { return const_cast<CXXForRangeStmt *>(this)->getLoopVariable(); } + +CoroutineBodyStmt *CoroutineBodyStmt::Create( + const ASTContext &C, CoroutineBodyStmt::CtorArgs const &Args) { + std::size_t Size = totalSizeToAlloc<Stmt *>( + CoroutineBodyStmt::FirstParamMove + Args.ParamMoves.size()); + + void *Mem = C.Allocate(Size, alignof(CoroutineBodyStmt)); + return new (Mem) CoroutineBodyStmt(Args); +} + +CoroutineBodyStmt *CoroutineBodyStmt::Create(const ASTContext &C, EmptyShell, + unsigned NumParams) { + std::size_t Size = totalSizeToAlloc<Stmt *>( + CoroutineBodyStmt::FirstParamMove + NumParams); + + void *Mem = C.Allocate(Size, alignof(CoroutineBodyStmt)); + auto *Result = new (Mem) CoroutineBodyStmt(CtorArgs()); + Result->NumParams = NumParams; + auto *ParamBegin = Result->getStoredStmts() + SubStmt::FirstParamMove; + std::uninitialized_fill(ParamBegin, ParamBegin + NumParams, + static_cast<Stmt *>(nullptr)); + return Result; +} + +CoroutineBodyStmt::CoroutineBodyStmt(CoroutineBodyStmt::CtorArgs const &Args) + : Stmt(CoroutineBodyStmtClass), NumParams(Args.ParamMoves.size()) { + Stmt **SubStmts = getStoredStmts(); + SubStmts[CoroutineBodyStmt::Body] = Args.Body; + SubStmts[CoroutineBodyStmt::Promise] = Args.Promise; + SubStmts[CoroutineBodyStmt::InitSuspend] = Args.InitialSuspend; + SubStmts[CoroutineBodyStmt::FinalSuspend] = Args.FinalSuspend; + SubStmts[CoroutineBodyStmt::OnException] = Args.OnException; + SubStmts[CoroutineBodyStmt::OnFallthrough] = Args.OnFallthrough; + SubStmts[CoroutineBodyStmt::Allocate] = Args.Allocate; + SubStmts[CoroutineBodyStmt::Deallocate] = Args.Deallocate; + SubStmts[CoroutineBodyStmt::ReturnValue] = Args.ReturnValue; + SubStmts[CoroutineBodyStmt::ResultDecl] = Args.ResultDecl; + SubStmts[CoroutineBodyStmt::ReturnStmt] = Args.ReturnStmt; + SubStmts[CoroutineBodyStmt::ReturnStmtOnAllocFailure] = + Args.ReturnStmtOnAllocFailure; + std::copy(Args.ParamMoves.begin(), Args.ParamMoves.end(), + const_cast<Stmt **>(getParamMoves().data())); +} |