A special generator for coroutines. It is only activated, if -show-coroutines-transformation
is given as a command line option.
More...
#include "CodeGenerator.h"
Public Member Functions | |
CoroutinesCodeGenerator (OutputFormatHelper &_outputFormatHelper, const size_t posBeforeFunc) | |
CoroutinesCodeGenerator (OutputFormatHelper &_outputFormatHelper, const size_t posBeforeFunc, std::string_view fsmName, size_t suspendsCount, CoroutineASTData data) | |
~CoroutinesCodeGenerator () override | |
void | InsertArg (const ImplicitCastExpr *stmt) override |
void | InsertArg (const CallExpr *stmt) override |
void | InsertArg (const CXXRecordDecl *stmt) override |
void | InsertArg (const OpaqueValueExpr *stmt) override |
void | InsertArg (const CoroutineBodyStmt *stmt) override |
void | InsertArg (const CoroutineSuspendExpr *stmt) override |
void | InsertArg (const CoreturnStmt *stmt) override |
void | InsertCoroutine (const FunctionDecl &fd, const CoroutineBodyStmt *body) |
std::string | GetFrameName () const |
virtual void | InsertArg (const Decl *stmt) |
virtual void | InsertArg (const Stmt *stmt) |
![]() | |
constexpr | CodeGenerator (OutputFormatHelper &_outputFormatHelper) |
constexpr | CodeGenerator (OutputFormatHelper &_outputFormatHelper, LambdaInInitCapture lambdaInitCapture) |
constexpr | CodeGenerator (OutputFormatHelper &_outputFormatHelper, LambdaStackType &lambdaStack, ProcessingPrimaryTemplate processingPrimaryTemplate) |
virtual | ~CodeGenerator ()=default |
virtual void | InsertArg (const Decl *stmt) |
virtual void | InsertArg (const Stmt *stmt) |
template<typename T > | |
void | InsertTemplateArgs (const T &t) |
void | InsertTemplateArgs (const ClassTemplateSpecializationDecl &clsTemplateSpe) |
void | InsertFunctionNameWithReturnType (const FunctionDecl &decl, const CXXConstructorDecl *cxxInheritedCtorDecl=nullptr) |
Insert the code for a FunctionDecl. More... | |
template<typename T > | |
void | InsertTemplateArgs (const ArrayRef< T > &array) |
void | InsertAttributes (const Decl *) |
void | InsertAttributes (const Decl::attr_range &) |
void | InsertAttribute (const Attr &) |
void | InsertTemplateArg (const TemplateArgument &arg) |
STRONG_BOOL (TemplateParamsOnly) | |
void | InsertTemplateParameters (const TemplateParameterList &list, const TemplateParamsOnly templateParamsOnly=TemplateParamsOnly::No) |
! Skip template, type constraints and class/typename. More... | |
void | StartLifetimeScope () |
void | LifetimeAddExtended (const VarDecl *, const ValueDecl *) |
void | EndLifetimeScope () |
Protected Member Functions | |
bool | InsertVarDecl (const VarDecl *vd) override |
bool | SkipSpaceAfterVarDecl () override |
![]() | |
STRONG_BOOL (LambdaInInitCapture) | |
STRONG_BOOL (ProcessingPrimaryTemplate) | |
constexpr | CodeGenerator (OutputFormatHelper &_outputFormatHelper, LambdaStackType &lambdaStack, LambdaInInitCapture lambdaInitCapture, ProcessingPrimaryTemplate processingPrimaryTemplate) |
! We do not want to transform a primary template which contains a Coroutine. More... | |
virtual bool | InsertComma () |
virtual bool | InsertSemi () |
virtual bool | InsertNamespace () const |
virtual bool | ShowXValueCasts () const |
Show casts to xvalues independent from the show all casts option. More... | |
void | HandleTemplateParameterPack (const ArrayRef< TemplateArgument > &args) |
void | HandleCompoundStmt (const CompoundStmt *stmt) |
void | HandleLocalStaticNonTrivialClass (const VarDecl *stmt) |
Show what is behind a local static variable. More... | |
virtual void | FormatCast (const std::string_view castName, const QualType &CastDestType, const Expr *SubExpr, const CastKind &castKind) |
void | ForEachArg (const auto &arguments, auto &&lambda) |
void | InsertArgWithParensIfNeeded (const Stmt *stmt) |
void | InsertSuffix (const QualType &type) |
void | InsertTemplateArg (const TemplateArgumentLoc &arg) |
bool | InsertLambdaStaticInvoker (const CXXMethodDecl *cxxMethodDecl) |
STRONG_BOOL (InsertInline) | |
void | InsertConceptConstraint (const llvm::SmallVectorImpl< const Expr * > &constraints, const InsertInline insertInline) |
void | InsertConceptConstraint (const FunctionDecl *tmplDecl) |
void | InsertConceptConstraint (const VarDecl *varDecl) |
void | InsertConceptConstraint (const TemplateParameterList &tmplDecl) |
void | InsertTemplate (const FunctionTemplateDecl *, bool withSpec) |
void | InsertQualifierAndNameWithTemplateArgs (const DeclarationName &declName, const auto *stmt) |
void | InsertQualifierAndName (const DeclarationName &declName, const NestedNameSpecifier *qualifier, const bool hasTemplateKeyword) |
void | InsertCXXMethodHeader (const CXXMethodDecl *stmt, OutputFormatHelper &initOutputFormatHelper) |
void | InsertTemplateGuardBegin (const FunctionDecl *stmt) |
void | InsertTemplateGuardEnd (const FunctionDecl *stmt) |
void | InsertTemplateSpecializationHeader (const Decl &) |
Insert template<> to introduce a template specialization. More... | |
void | InsertTemplateArgsObjectParam (const ArrayRef< TemplateArgument > &array) |
void | InsertTemplateArgsObjectParam (const TemplateParamObjectDecl ¶m) |
void | InsertNamespace (const NestedNameSpecifier *namespaceSpecifier) |
void | ParseDeclContext (const DeclContext *Ctx) |
STRONG_BOOL (SkipBody) | |
virtual void | InsertCXXMethodDecl (const CXXMethodDecl *stmt, SkipBody skipBody) |
void | InsertMethodBody (const FunctionDecl *stmt, const size_t posBeforeFunc) |
template<typename T > | |
void | InsertConstructorExpr (const T *stmt) |
Generalized function to insert either a CXXConstructExpr or CXXUnresolvedConstructExpr . More... | |
void | InsertCurlysIfRequired (const Stmt *stmt) |
Check whether or not this statement will add curlys or parentheses and add them only if required. More... | |
void | InsertIfOrSwitchInitVariables (same_as_any_of< const IfStmt, const SwitchStmt > auto *stmt) |
void | InsertInstantiationPoint (const SourceManager &sm, const SourceLocation &instLoc, std::string_view text={}) |
Inserts the instantiation point of a template. More... | |
STRONG_BOOL (AddNewLineAfter) | |
void | WrapInCompoundIfNeeded (const Stmt *stmt, const AddNewLineAfter addNewLineAfter) |
STRONG_BOOL (AddSpaceAtTheEnd) | |
void | WrapInParens (void_func_ref lambda, const AddSpaceAtTheEnd addSpaceAtTheEnd=AddSpaceAtTheEnd::No) |
void | WrapInParensIfNeeded (bool needsParens, void_func_ref lambda, const AddSpaceAtTheEnd addSpaceAtTheEnd=AddSpaceAtTheEnd::No) |
void | WrapInCurliesIfNeeded (bool needsParens, void_func_ref lambda, const AddSpaceAtTheEnd addSpaceAtTheEnd=AddSpaceAtTheEnd::No) |
void | WrapInCurlys (void_func_ref lambda, const AddSpaceAtTheEnd addSpaceAtTheEnd=AddSpaceAtTheEnd::No) |
void | WrapInParensOrCurlys (const BraceKind curlys, void_func_ref lambda, const AddSpaceAtTheEnd addSpaceAtTheEnd=AddSpaceAtTheEnd::No) |
void | UpdateCurrentPos (std::optional< size_t > &pos) |
void | HandleLambdaExpr (const LambdaExpr *stmt, LambdaHelper &lambdaHelper) |
bool | InsideDecltype () const |
STRONG_BOOL (SkipVarDecl) | |
STRONG_BOOL (UseCommaInsteadOfSemi) | |
STRONG_BOOL (NoEmptyInitList) | |
STRONG_BOOL (ShowConstantExprValue) | |
Additional Inherited Members | |
![]() | |
const Decl * | mLastDecl {} |
![]() | |
enum class | LambdaCallerType { VarDecl , InitCapture , CallExpr , OperatorCallExpr , MemberCallExpr , LambdaExpr , ReturnStmt , BinaryOperator , CXXMethodDecl , TemplateHead , Decltype } |
enum class | BraceKind { Parens , Curlys } |
using | LambdaStackType = StackList< class LambdaHelper > |
![]() | |
static std::string_view | GetBuiltinTypeSuffix (const BuiltinType::Kind &kind) |
static std::string | FillConstantArray (const ConstantArrayType *ct, const std::string &value, const uint64_t startAt) |
static std::string | GetValueOfValueInit (const QualType &t) |
![]() | |
LifetimeTracker | mLifeTimeTracker {} |
const Stmt * | mLastStmt {} |
const Expr * | mLastExpr {} |
bool | mProcessingVarDecl {} |
OutputFormatHelper & | mOutputFormatHelper |
LambdaStackType | mLambdaStackThis |
LambdaStackType & | mLambdaStack |
LambdaInInitCapture | mLambdaInitCapture {LambdaInInitCapture::No} |
ShowConstantExprValue | mShowConstantExprValue {ShowConstantExprValue::No} |
SkipVarDecl | mSkipVarDecl {SkipVarDecl::No} |
UseCommaInsteadOfSemi | mUseCommaInsteadOfSemi {UseCommaInsteadOfSemi::No} |
NoEmptyInitList | mNoEmptyInitList |
At least in case if a requires-clause containing T{} we don't want to get T{{}}. More... | |
const LambdaExpr * | mLambdaExpr {} |
std::optional< size_t > | mCurrentVarDeclPos {} |
std::optional< size_t > | mCurrentCallExprPos {} |
std::optional< size_t > | mCurrentReturnPos {} |
std::optional< size_t > | mCurrentFieldPos {} |
OutputFormatHelper * | mOutputFormatHelperOutside |
Helper output buffer for std::initializer_list expansion. More... | |
bool | mRequiresImplicitReturnZero {} |
Track whether this is a function with an imlpicit return 0. More... | |
bool | mSkipSemi {} |
ProcessingPrimaryTemplate | mProcessingPrimaryTemplate {} |
![]() | |
static constexpr auto | MAX_FILL_VALUES_FOR_ARRAYS |
static std::map< std::string, bool > | mSeenDecls {} |
A special generator for coroutines. It is only activated, if -show-coroutines-transformation
is given as a command line option.
Definition at line 531 of file CodeGenerator.h.
|
inlineexplicit |
Definition at line 534 of file CodeGenerator.h.
|
inlineexplicit |
Definition at line 539 of file CodeGenerator.h.
|
override |
Definition at line 44 of file CoroutinesCodeGenerator.cpp.
References clang::insights::CodeGenerator::InsertArg(), and RETURN_IF.
|
inline |
Definition at line 567 of file CodeGenerator.h.
|
override |
|
override |
|
override |
Definition at line 704 of file CoroutinesCodeGenerator.cpp.
References clang::insights::asthelpers::StmtsContainer::Add(), clang::insights::AddField(), clang::insights::asthelpers::Break(), clang::insights::asthelpers::Case(), clang::insights::asthelpers::Catch(), clang::insights::asthelpers::Comment(), clang::insights::FINAL_SUSPEND_NAME, clang::insights::asthelpers::Goto(), clang::insights::asthelpers::If(), kwInternalThis, clang::insights::asthelpers::Label(), clang::insights::asthelpers::mkCompoundStmt(), clang::insights::asthelpers::Not(), clang::insights::asthelpers::Switch(), clang::insights::asthelpers::Throw(), and clang::insights::asthelpers::Try().
|
override |
Represents an expression that might suspend coroutine execution; either a co_await or co_yield expression.
Evaluation of this expression first evaluates its 'ready' expression. If that returns 'false': – execution of the coroutine is suspended – the 'suspend' expression is evaluated – if the 'suspend' expression returns 'false', the coroutine is resumed – otherwise, control passes back to the resumer. If the coroutine is not suspended, or when it is resumed, the 'resume' expression is evaluated, and its result is the result of the overall expression.
Definition at line 881 of file CoroutinesCodeGenerator.cpp.
References GetGlobalAST().
|
override |
Definition at line 775 of file CoroutinesCodeGenerator.cpp.
References clang::insights::CodeGenerator::InsertArg().
void clang::insights::CodeGenerator::InsertArg |
Definition at line 214 of file CodeGenerator.cpp.
Referenced by InsertArg().
|
override |
Definition at line 784 of file CoroutinesCodeGenerator.cpp.
References clang::insights::CodeGenerator::InsertArg().
|
override |
Definition at line 828 of file CoroutinesCodeGenerator.cpp.
References clang::insights::AddField(), clang::insights::asthelpers::Assign(), clang::insights::BuildSuspendVarName(), clang::insights::CORO_FRAME_ACCESS, clang::insights::FindDeclRef(), clang::insights::FindValue(), and clang::insights::StrCat().
void clang::insights::CodeGenerator::InsertArg |
Definition at line 215 of file CodeGenerator.cpp.
void clang::insights::CoroutinesCodeGenerator::InsertCoroutine | ( | const FunctionDecl & | fd, |
const CoroutineBodyStmt * | body | ||
) |
Definition at line 410 of file CoroutinesCodeGenerator.cpp.
References clang::insights::asthelpers::AccessMember(), clang::insights::AddField(), clang::insights::asthelpers::AddrOf(), clang::insights::asthelpers::Assign(), clang::insights::asthelpers::Bool(), clang::insights::BuildInternalVarName(), clang::insights::BuildTemplateParamObjectName(), clang::insights::asthelpers::Call(), clang::insights::asthelpers::CallMemberFun(), clang::insights::asthelpers::Comment(), clang::insights::CORO_FRAME_ACCESS, clang::insights::CORO_FRAME_ACCESS_THIS, clang::insights::CORO_FRAME_NAME, clang::insights::CreateCoroFunctionDecl(), clang::insights::asthelpers::Dref(), clang::insights::EnableGlobalInsert(), clang::insights::asthelpers::Equal(), clang::insights::asthelpers::Function(), GetGlobalAST(), clang::insights::GetName(), clang::insights::HeaderNew, hlpDestroyFn, hlpResumeFn, clang::insights::asthelpers::If(), clang::insights::CodeGenerator::InsertTemplateArg(), clang::insights::asthelpers::Int32(), clang::insights::MakeLineColumnName(), clang::insights::asthelpers::mkDeclRefExpr(), clang::insights::asthelpers::mkVarDeclRefExpr(), clang::insights::asthelpers::New(), clang::insights::asthelpers::Parameter(), clang::insights::asthelpers::Ptr(), clang::insights::asthelpers::Ref(), clang::insights::asthelpers::ReinterpretCast(), clang::insights::ReplaceAll(), clang::insights::SetFunctionBody(), clang::insights::StrCat(), clang::insights::asthelpers::Struct(), clang::insights::asthelpers::Variable(), and clang::insights::asthelpers::VoidTy().
|
inlineoverrideprotectedvirtual |
Reimplemented from clang::insights::CodeGenerator.
Definition at line 570 of file CodeGenerator.h.
|
inlineoverrideprotectedvirtual |
Reimplemented from clang::insights::CodeGenerator.
Definition at line 571 of file CodeGenerator.h.