Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #518: Support for co_await in a VarDecl and more. #542

Merged
merged 1 commit into from
Jun 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions CodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2136,7 +2136,15 @@ void CodeGenerator::InsertArg(const CXXOperatorCallExpr* stmt)
if(isCXXMethod) {
const OverloadedOperatorKind opKind = stmt->getOperator();

mOutputFormatHelper.Append("."sv, kwOperator, getOperatorSpelling(opKind), "("sv);
const std::string_view operatorKw{[&] {
if(OO_Coawait == opKind) {
return kwOperatorSpace;
}

return kwOperator;
}()};

mOutputFormatHelper.Append("."sv, operatorKw, getOperatorSpelling(opKind), "("sv);
}

// consume all remaining arguments
Expand Down Expand Up @@ -2705,7 +2713,8 @@ void CodeGenerator::InsertArg(const FieldDecl* stmt)
// - get next field
// - if this fields offset + size is equal to the next fields offset we are good,
// - if not we insert padding bytes
// - in case there is no next field this is the last field, check this field's offset + size against the records
// - in case there is no next field this is the last field, check this field's offset + size against the
// records
// size. If unequal padding is needed

const auto expectedOffset = fieldOffset + effectiveFieldSize;
Expand Down
26 changes: 11 additions & 15 deletions CodeGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -470,16 +470,17 @@ class MultiStmtDeclCodeGenerator final : public CodeGenerator

struct CoroutineASTData
{
CXXRecordDecl* mFrameType{};
FieldDecl* mResumeFnField{};
FieldDecl* mDestroyFnField{};
FieldDecl* mPromiseField{};
FieldDecl* mSuspendIndexField{};
FieldDecl* mInitialAwaitResumeCalledField{};
MemberExpr* mInitialAwaitResumeCalledAccess{};
DeclRefExpr* mFrameAccessDeclRef{};
MemberExpr* mSuspendIndexAccess{};
bool mDoInsertInDtor{};
CXXRecordDecl* mFrameType{};
FieldDecl* mResumeFnField{};
FieldDecl* mDestroyFnField{};
FieldDecl* mPromiseField{};
FieldDecl* mSuspendIndexField{};
FieldDecl* mInitialAwaitResumeCalledField{};
MemberExpr* mInitialAwaitResumeCalledAccess{};
DeclRefExpr* mFrameAccessDeclRef{};
MemberExpr* mSuspendIndexAccess{};
bool mDoInsertInDtor{};
std::vector<const CXXThisExpr*> mThisExprs{};
};

///
Expand Down Expand Up @@ -512,11 +513,8 @@ class CoroutinesCodeGenerator final : public CodeGenerator

void InsertArg(const ImplicitCastExpr* stmt) override;
void InsertArg(const CallExpr* stmt) override;
void InsertArg(const CStyleCastExpr* stmt) override;
void InsertArg(const CXXRecordDecl* stmt) override;
void InsertArg(const CXXThisExpr* stmt) override;
void InsertArg(const OpaqueValueExpr* stmt) override;
void InsertArg(const BinaryOperator* stmt) override;

void InsertArg(const CoroutineBodyStmt* stmt) override;
void InsertArg(const CoroutineSuspendExpr* stmt) override;
Expand Down Expand Up @@ -547,8 +545,6 @@ class CoroutinesCodeGenerator final : public CodeGenerator
bool mInsertVarDecl{true};
bool mSupressCasts{};
bool mSupressRecordDecls{};
bool mNameOnly{};
bool mCorosOnly{};
std::string mFrameName{};
std::string mFSMName{};
CoroutineASTData mASTData{};
Expand Down
Loading