|
clang 23.0.0git
|
#include "CoroutineStmtBuilder.h"#include "clang/AST/ASTLambda.h"#include "clang/AST/Decl.h"#include "clang/AST/Expr.h"#include "clang/AST/ExprCXX.h"#include "clang/AST/IgnoreExpr.h"#include "clang/AST/StmtCXX.h"#include "clang/Basic/Builtins.h"#include "clang/Basic/TargetInfo.h"#include "clang/Lex/Preprocessor.h"#include "clang/Sema/EnterExpressionEvaluationContext.h"#include "clang/Sema/Initialization.h"#include "clang/Sema/Overload.h"#include "clang/Sema/ScopeInfo.h"Go to the source code of this file.
Classes | |
| struct | ReadySuspendResumeResult |
Functions | |
| static LookupResult | lookupMember (Sema &S, const char *Name, CXXRecordDecl *RD, SourceLocation Loc, bool &Res) |
| static bool | lookupMember (Sema &S, const char *Name, CXXRecordDecl *RD, SourceLocation Loc) |
| static QualType | lookupPromiseType (Sema &S, const FunctionDecl *FD, SourceLocation KwLoc) |
| Look up the std::coroutine_traits<...>::promise_type for the given function type. | |
| static QualType | lookupCoroutineHandleType (Sema &S, QualType PromiseType, SourceLocation Loc) |
| Look up the std::coroutine_handle<PromiseType>. | |
| static bool | isValidCoroutineContext (Sema &S, SourceLocation Loc, StringRef Keyword) |
| static ExprResult | buildOperatorCoawaitCall (Sema &SemaRef, Scope *S, SourceLocation Loc, Expr *E) |
| static ExprResult | buildCoroutineHandle (Sema &S, QualType PromiseType, SourceLocation Loc) |
| static ExprResult | buildMemberCall (Sema &S, Expr *Base, SourceLocation Loc, StringRef Name, MultiExprArg Args) |
| static Expr * | maybeTailCall (Sema &S, QualType RetType, Expr *E, SourceLocation Loc) |
| static ReadySuspendResumeResult | buildCoawaitCalls (Sema &S, VarDecl *CoroPromise, SourceLocation Loc, Expr *E) |
| Build calls to await_ready, await_suspend, and await_resume for a co_await expression. | |
| static ExprResult | buildPromiseCall (Sema &S, VarDecl *Promise, SourceLocation Loc, StringRef Name, MultiExprArg Args) |
| static FunctionScopeInfo * | checkCoroutineContext (Sema &S, SourceLocation Loc, StringRef Keyword, bool IsImplicit=false) |
| Check that this is a context in which a coroutine suspension can appear. | |
| static void | checkNoThrow (Sema &S, const Stmt *E, llvm::SmallPtrSetImpl< const Decl * > &ThrowingDecls) |
Recursively check E and all its children to see if any call target (including constructor call) is declared noexcept. | |
| static void | checkReturnStmtInCoroutine (Sema &S, FunctionScopeInfo *FSI) |
| static bool | isWithinCatchScope (Scope *S) |
| static bool | checkSuspensionContext (Sema &S, SourceLocation Loc, StringRef Keyword) |
| static bool | isAttributedCoroAwaitElidable (const QualType &QT) |
| static void | applySafeElideContext (Expr *Operand) |
| static Expr * | buildStdNoThrowDeclRef (Sema &S, SourceLocation Loc) |
| Look up the std::nothrow object. | |
| static TypeSourceInfo * | getTypeSourceInfoForStdAlignValT (Sema &S, SourceLocation Loc) |
| static bool | DiagnoseTypeAwareAllocators (Sema &S, SourceLocation Loc, unsigned DiagnosticID, DeclarationName Name, QualType PromiseType) |
| static bool | findDeleteForPromise (Sema &S, SourceLocation Loc, QualType PromiseType, FunctionDecl *&OperatorDelete) |
| static CompoundStmt * | buildCoroutineBody (Stmt *Body, ASTContext &Context) |
| static bool | diagReturnOnAllocFailure (Sema &S, Expr *E, CXXRecordDecl *PromiseRecordDecl, FunctionScopeInfo &Fn) |
| static bool | collectPlacementArgs (Sema &S, FunctionDecl &FD, SourceLocation Loc, SmallVectorImpl< Expr * > &PlacementArgs) |
| static void | noteMemberDeclaredHere (Sema &S, Expr *E, FunctionScopeInfo &Fn) |
| static Expr * | castForMoving (Sema &S, Expr *E, QualType T=QualType()) |
| static VarDecl * | buildVarDecl (Sema &S, SourceLocation Loc, QualType Type, IdentifierInfo *II) |
| Build a variable declaration for move parameter. | |
|
static |
Definition at line 852 of file SemaCoroutine.cpp.
References applySafeElideContext(), clang::Call, clang::IgnoreExprNodes(), clang::IgnoreImplicitSingleStep(), clang::IgnoreParensSingleStep(), and isAttributedCoroAwaitElidable().
Referenced by applySafeElideContext(), and clang::Sema::BuildUnresolvedCoawaitExpr().
|
static |
Build calls to await_ready, await_suspend, and await_resume for a co_await expression.
The generated AST tries to clean up temporary objects as early as possible so that they don't live across suspension points if possible. Having temporary objects living across suspension points unnecessarily can lead to large frame size, and also lead to memory corruptions if the coroutine frame is destroyed after coming back from suspension. This is done by wrapping both the await_ready call and the await_suspend call with ExprWithCleanups. In the end of this function, we also need to explicitly set cleanup state so that the CoawaitExpr is also wrapped with an ExprWithCleanups to clean up the awaiter associated with the co_await expression.
Definition at line 360 of file SemaCoroutine.cpp.
References buildCoroutineHandle(), buildMemberCall(), clang::Sema::Cleanup, clang::Sema::Context, clang::SemaBase::Diag(), clang::Func, clang::ActionResult< PtrTy, Compress >::get(), clang::DeclaratorDecl::getBeginLoc(), clang::CallExpr::getCalleeDecl(), clang::CallExpr::getCallReturnType(), clang::CallExpr::getDirectCallee(), clang::Decl::getLocation(), clang::Expr::getObjectKind(), clang::Stmt::getSourceRange(), clang::Expr::getType(), clang::ValueDecl::getType(), clang::Type::isBooleanType(), clang::Type::isDependentType(), ReadySuspendResumeResult::IsInvalid, clang::ActionResult< PtrTy, Compress >::isInvalid(), clang::Type::isReferenceType(), clang::Type::isVoidType(), clang::Sema::MaybeCreateExprWithCleanups(), maybeTailCall(), clang::Sema::PerformContextuallyConvertToBool(), ReadySuspendResumeResult::Results, clang::CleanupInfo::setExprNeedsCleanups(), and clang::VK_LValue.
Referenced by clang::Sema::BuildCoyieldExpr(), and clang::Sema::BuildResolvedCoawaitExpr().
|
static |
Definition at line 1225 of file SemaCoroutine.cpp.
References clang::CompoundStmt::Create(), and clang::isa().
Referenced by clang::CoroutineStmtBuilder::CoroutineStmtBuilder().
|
static |
Definition at line 264 of file SemaCoroutine.cpp.
References clang::Sema::BuildBuiltinCallExpr(), clang::Sema::BuildCallExpr(), clang::Sema::BuildDeclarationNameExpr(), clang::Sema::computeDeclContext(), clang::SemaBase::Diag(), clang::ExprError(), clang::Found, clang::ActionResult< PtrTy, Compress >::get(), clang::IdentifierTable::get(), clang::Preprocessor::getIdentifierTable(), clang::ActionResult< PtrTy, Compress >::isInvalid(), clang::QualType::isNull(), lookupCoroutineHandleType(), clang::Sema::LookupOrdinaryName, clang::Sema::LookupQualifiedName(), and clang::Sema::PP.
Referenced by buildCoawaitCalls().
|
static |
Definition at line 298 of file SemaCoroutine.cpp.
References clang::Sema::BuildCallExpr(), clang::Sema::BuildMemberReferenceExpr(), clang::ExprError(), clang::IdentifierTable::get(), clang::Preprocessor::getIdentifierTable(), and clang::Sema::PP.
Referenced by buildCoawaitCalls(), buildPromiseCall(), and maybeTailCall().
|
static |
Definition at line 255 of file SemaCoroutine.cpp.
References clang::Sema::BuildOperatorCoawaitCall(), clang::Sema::BuildOperatorCoawaitLookupExpr(), clang::cast(), and clang::ExprError().
Referenced by clang::Sema::ActOnCoroutineBodyStart(), and clang::Sema::ActOnCoyieldExpr().
|
static |
Definition at line 452 of file SemaCoroutine.cpp.
References clang::Sema::BuildDeclRefExpr(), buildMemberCall(), clang::ExprError(), clang::ActionResult< PtrTy, Compress >::get(), clang::QualType::getNonReferenceType(), clang::ValueDecl::getType(), clang::ActionResult< PtrTy, Compress >::isInvalid(), and clang::VK_LValue.
Referenced by clang::Sema::ActOnCoroutineBodyStart(), clang::Sema::ActOnCoyieldExpr(), clang::Sema::BuildCoreturnStmt(), and clang::Sema::BuildUnresolvedCoawaitExpr().
|
static |
Look up the std::nothrow object.
Definition at line 1066 of file SemaCoroutine.cpp.
References clang::Sema::BuildDeclRefExpr(), clang::SemaBase::Diag(), clang::Found, clang::ActionResult< PtrTy, Compress >::get(), clang::IdentifierTable::get(), clang::Preprocessor::getIdentifierTable(), clang::Sema::getStdNamespace(), clang::ActionResult< PtrTy, Compress >::isInvalid(), clang::Sema::LookupOrdinaryName, clang::Sema::LookupQualifiedName(), clang::Sema::PP, clang::Result, and clang::VK_LValue.
|
static |
Build a variable declaration for move parameter.
Definition at line 1953 of file SemaCoroutine.cpp.
References clang::Sema::Context, clang::VarDecl::Create(), clang::Sema::CurContext, clang::ASTContext::getTrivialTypeSourceInfo(), clang::SC_None, and clang::Decl::setImplicit().
Referenced by actOnOMPReductionKindClause(), clang::SemaOpenMP::ActOnOpenMPCopyinClause(), clang::SemaOpenMP::ActOnOpenMPCopyprivateClause(), clang::SemaOpenMP::ActOnOpenMPDeclareReductionCombinerStart(), clang::SemaOpenMP::ActOnOpenMPDeclareReductionInitializerStart(), clang::SemaOpenMP::ActOnOpenMPFirstprivateClause(), clang::SemaOpenMP::ActOnOpenMPFuseDirective(), clang::SemaOpenMP::ActOnOpenMPLastprivateClause(), clang::SemaOpenMP::ActOnOpenMPLinearClause(), clang::SemaOpenMP::ActOnOpenMPPrivateClause(), clang::SemaOpenMP::ActOnOpenMPReverseDirective(), clang::SemaOpenMP::ActOnOpenMPSplitDirective(), clang::SemaOpenMP::ActOnOpenMPStripeDirective(), clang::SemaOpenMP::ActOnOpenMPTileDirective(), clang::SemaOpenMP::ActOnOpenMPUnrollDirective(), clang::SemaOpenMP::ActOnOpenMPUseDevicePtrClause(), clang::Sema::buildCoroutineParameterMoves(), buildImplicitMap(), checkOpenMPLoop(), clang::SemaOpenMP::EndOpenMPDSABlock(), and precomputeExpr().
Definition at line 1937 of file SemaCoroutine.cpp.
References clang::Sema::BuildCXXNamedCast(), clang::Sema::BuildReferenceType(), clang::Sema::Context, clang::ActionResult< PtrTy, Compress >::get(), clang::Stmt::getBeginLoc(), clang::Stmt::getSourceRange(), clang::ASTContext::getTrivialTypeSourceInfo(), and clang::Expr::getType().
Referenced by clang::Sema::buildCoroutineParameterMoves().
|
static |
Check that this is a context in which a coroutine suspension can appear.
Definition at line 569 of file SemaCoroutine.cpp.
References clang::Sema::buildCoroutineParameterMoves(), clang::Sema::buildCoroutinePromise(), clang::Sema::CurContext, clang::Sema::getCurFunction(), clang::isa(), isValidCoroutineContext(), and clang::Keyword.
Referenced by clang::Sema::ActOnCoroutineBodyStart(), clang::Sema::BuildCoreturnStmt(), clang::Sema::BuildCoyieldExpr(), clang::Sema::BuildResolvedCoawaitExpr(), and clang::Sema::BuildUnresolvedCoawaitExpr().
|
static |
Recursively check E and all its children to see if any call target (including constructor call) is declared noexcept.
Also any value returned from the call has a noexcept destructor.
Definition at line 599 of file SemaCoroutine.cpp.
References clang::Sema::canCalleeThrow(), clang::cast(), checkNoThrow(), clang::Stmt::children(), clang::Sema::CurContext, clang::SemaBase::Diag(), clang::QualType::DK_cxx_destructor, clang::Sema::getASTContext(), clang::QualType::getCanonicalType(), clang::CXXRecordDecl::getDestructor(), clang::CXXMethodDecl::getParent(), clang::QualType::getTypePtr(), and clang::QualType::isDestructedType().
Referenced by clang::Sema::checkFinalSuspendNoThrow(), and checkNoThrow().
|
static |
Definition at line 677 of file SemaCoroutine.cpp.
References clang::SemaBase::Diag(), clang::sema::FunctionScopeInfo::FirstCoroutineStmtLoc, clang::sema::FunctionScopeInfo::FirstReturnLoc, clang::sema::FunctionScopeInfo::getFirstCoroutineStmtKeyword(), clang::SourceLocation::isInvalid(), and clang::SourceLocation::isValid().
Referenced by clang::Sema::ActOnCoroutineBodyStart().
|
static |
Definition at line 785 of file SemaCoroutine.cpp.
References clang::Sema::currentEvaluationContext(), clang::SemaBase::Diag(), clang::Sema::ExpressionEvaluationContextRecord::EK_Other, clang::Sema::ExpressionEvaluationContextRecord::EK_VariableInit, clang::Sema::ExpressionEvaluationContextRecord::ExprContext, clang::Sema::getCurScope(), clang::Sema::isUnevaluatedContext(), isWithinCatchScope(), and clang::Keyword.
Referenced by clang::Sema::ActOnCoawaitExpr(), and clang::Sema::ActOnCoyieldExpr().
|
static |
Definition at line 1368 of file SemaCoroutine.cpp.
References clang::Sema::ActOnCXXThis(), clang::Sema::BuildDeclRefExpr(), clang::Sema::CreateBuiltinUnaryOp(), clang::ActionResult< PtrTy, Compress >::get(), clang::ActionResult< PtrTy, Compress >::isInvalid(), clang::isLambdaCallOperator(), clang::FunctionDecl::parameters(), and clang::VK_LValue.
|
static |
Definition at line 1104 of file SemaCoroutine.cpp.
References clang::SemaBase::Diag(), clang::Type::getAsCXXRecordDecl(), clang::Decl::getAsFunction(), clang::Decl::getDeclContext(), clang::Decl::getLocation(), clang::Type::isRecordType(), clang::FunctionDecl::isTypeAwareOperatorNewOrDelete(), clang::Sema::LookupOrdinaryName, and clang::Sema::LookupQualifiedName().
Referenced by findDeleteForPromise().
|
static |
Definition at line 1295 of file SemaCoroutine.cpp.
References clang::SemaBase::Diag(), clang::Expr::getExprLoc(), and clang::Decl::getLocation().
|
static |
Definition at line 1130 of file SemaCoroutine.cpp.
References clang::alignedAllocationModeFromBool(), clang::Sema::Context, clang::ASTContext::DeclarationNames, DiagnoseTypeAwareAllocators(), clang::Sema::FindDeallocationFunction(), clang::Sema::FindUsualDeallocationFunction(), clang::Type::getAsCXXRecordDecl(), clang::DeclarationNameTable::getCXXOperatorName(), clang::Sema::getLangOpts(), clang::Sema::MarkFunctionReferenced(), clang::ImplicitDeallocationParameters::PassSize, and clang::Yes.
|
static |
Definition at line 1095 of file SemaCoroutine.cpp.
References clang::Sema::Context, clang::ASTContext::getCanonicalTagType(), clang::Sema::getStdAlignValT(), and clang::ASTContext::getTrivialTypeSourceInfo().
Definition at line 847 of file SemaCoroutine.cpp.
References clang::Type::getAsCXXRecordDecl().
Referenced by applySafeElideContext(), and clang::Sema::BuildUnresolvedCoawaitExpr().
|
static |
Definition at line 180 of file SemaCoroutine.cpp.
References clang::Sema::CurContext, clang::SemaBase::Diag(), clang::isa(), and clang::Keyword.
Referenced by checkCoroutineContext().
Definition at line 757 of file SemaCoroutine.cpp.
References clang::Scope::getParent(), clang::Scope::isCatchScope(), and clang::Scope::isFunctionScope().
Referenced by checkSuspensionContext().
|
static |
Look up the std::coroutine_handle<PromiseType>.
Definition at line 136 of file SemaCoroutine.cpp.
References clang::TemplateArgumentListInfo::addArgument(), clang::Sema::CheckTemplateIdType(), clang::Sema::Context, clang::SemaBase::Diag(), clang::Found, clang::IdentifierTable::get(), clang::Preprocessor::getIdentifierTable(), clang::Sema::getStdNamespace(), clang::ASTContext::getTrivialTypeSourceInfo(), clang::QualType::isNull(), clang::Sema::LookupOrdinaryName, clang::Sema::LookupQualifiedName(), clang::None, clang::Sema::PP, clang::Sema::RequireCompleteType(), clang::Result, and clang::TemplateName.
Referenced by buildCoroutineHandle().
|
static |
Definition at line 45 of file SemaCoroutine.cpp.
References lookupMember().
|
static |
Definition at line 34 of file SemaCoroutine.cpp.
References clang::Preprocessor::getIdentifierInfo(), clang::Sema::LookupMemberName, clang::Sema::LookupQualifiedName(), clang::Sema::PP, and clang::LookupResult::suppressDiagnostics().
Referenced by clang::Sema::BuildUnresolvedCoawaitExpr(), getTupleLikeElementType(), isTupleLike(), and lookupMember().
|
static |
Look up the std::coroutine_traits<...>::promise_type for the given function type.
Definition at line 54 of file SemaCoroutine.cpp.
References clang::TemplateArgumentListInfo::addArgument(), clang::Type::castAs(), clang::Sema::CheckTemplateIdType(), clang::Sema::Context, clang::SemaBase::Diag(), clang::IdentifierTable::get(), clang::Type::getAsCXXRecordDecl(), clang::Preprocessor::getIdentifierTable(), clang::Decl::getLocation(), clang::ASTContext::getLValueReferenceType(), clang::FunctionProtoType::getParamTypes(), clang::FunctionProtoType::getRefQualifier(), clang::FunctionType::getReturnType(), clang::ASTContext::getRValueReferenceType(), clang::ASTContext::getTrivialTypeSourceInfo(), clang::ValueDecl::getType(), clang::ASTContext::getTypeDeclType(), clang::QualType::getTypePtr(), clang::QualType::isNull(), clang::Sema::lookupCoroutineTraits(), clang::Sema::LookupOrdinaryName, clang::Sema::LookupQualifiedName(), clang::None, clang::Sema::PP, clang::Sema::RequireCompleteType(), clang::RQ_RValue, and clang::TemplateName.
Referenced by clang::Sema::buildCoroutinePromise().
|
static |
Definition at line 319 of file SemaCoroutine.cpp.
References buildMemberCall(), clang::cast(), clang::SemaBase::Diag(), clang::ActionResult< PtrTy, Compress >::get(), clang::Expr::getType(), clang::QualType::getTypePtr(), clang::ActionResult< PtrTy, Compress >::isInvalid(), clang::Type::isReferenceType(), clang::Type::isVoidPointerType(), and clang::Sema::MaybeCreateExprWithCleanups().
Referenced by buildCoawaitCalls().
|
static |
Definition at line 1825 of file SemaCoroutine.cpp.
References clang::SemaBase::Diag().