Path: blob/main/contrib/llvm-project/clang/lib/Sema/CoroutineStmtBuilder.h
35233 views
//===- CoroutineStmtBuilder.h - Implicit coroutine stmt builder -*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//===----------------------------------------------------------------------===//6//7// This file defines CoroutineStmtBuilder, a class for building the implicit8// statements required for building a coroutine body.9//10//===----------------------------------------------------------------------===//1112#ifndef LLVM_CLANG_LIB_SEMA_COROUTINESTMTBUILDER_H13#define LLVM_CLANG_LIB_SEMA_COROUTINESTMTBUILDER_H1415#include "clang/AST/Decl.h"16#include "clang/AST/ExprCXX.h"17#include "clang/AST/StmtCXX.h"18#include "clang/Lex/Preprocessor.h"19#include "clang/Sema/SemaInternal.h"2021namespace clang {2223class CoroutineStmtBuilder : public CoroutineBodyStmt::CtorArgs {24Sema &S;25FunctionDecl &FD;26sema::FunctionScopeInfo &Fn;27bool IsValid = true;28SourceLocation Loc;29SmallVector<Stmt *, 4> ParamMovesVector;30const bool IsPromiseDependentType;31CXXRecordDecl *PromiseRecordDecl = nullptr;3233public:34/// Construct a CoroutineStmtBuilder and initialize the promise35/// statement and initial/final suspends from the FunctionScopeInfo.36CoroutineStmtBuilder(Sema &S, FunctionDecl &FD, sema::FunctionScopeInfo &Fn,37Stmt *Body);3839/// Build the coroutine body statements, including the40/// "promise dependent" statements when the promise type is not dependent.41bool buildStatements();4243/// Build the coroutine body statements that require a non-dependent44/// promise type in order to construct.45///46/// For example different new/delete overloads are selected depending on47/// if the promise type provides `unhandled_exception()`, and therefore they48/// cannot be built until the promise type is complete so that we can perform49/// name lookup.50bool buildDependentStatements();5152bool isInvalid() const { return !this->IsValid; }5354private:55bool makePromiseStmt();56bool makeInitialAndFinalSuspend();57bool makeNewAndDeleteExpr();58bool makeOnFallthrough();59bool makeOnException();60bool makeReturnObject();61bool makeGroDeclAndReturnStmt();62bool makeReturnOnAllocFailure();63};6465} // end namespace clang6667#endif // LLVM_CLANG_LIB_SEMA_COROUTINESTMTBUILDER_H686970