-
Notifications
You must be signed in to change notification settings - Fork 1.8k
C++: Placeholder CFG for coroutines #16187
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
Changes from all commits
4c4d241
3e1359b
d8bd18f
33364a8
d030f0b
2a91477
65b69fe
8842b97
846eac8
477322d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1501,3 +1501,41 @@ class TranslatedVlaDeclarationStmt extends TranslatedStmt { | |
|
||
override Instruction getChildSuccessorInternal(TranslatedElement child, EdgeKind kind) { none() } | ||
} | ||
|
||
class TranslatedCoReturnStmt extends TranslatedStmt { | ||
override CoReturnStmt stmt; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did not know you can do this (override the type of a member variable in QL). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's extremely useful! We do it a lot in both C/C++ IR construction and in the Swift CFG construction code |
||
|
||
private TranslatedExpr getTranslatedOperand() { | ||
result = getTranslatedExpr(stmt.getOperand().getFullyConverted()) | ||
} | ||
|
||
override TranslatedExpr getChildInternal(int id) { | ||
id = 0 and | ||
result = this.getTranslatedOperand() | ||
} | ||
|
||
override Instruction getFirstInstruction(EdgeKind kind) { | ||
result = this.getTranslatedOperand().getFirstInstruction(kind) | ||
} | ||
|
||
override Instruction getALastInstructionInternal() { | ||
result = this.getInstruction(OnlyInstructionTag()) | ||
} | ||
|
||
override predicate hasInstruction(Opcode opcode, InstructionTag tag, CppType resultType) { | ||
tag = OnlyInstructionTag() and | ||
opcode instanceof Opcode::NoOp and | ||
resultType = getVoidType() | ||
} | ||
|
||
override Instruction getInstructionSuccessorInternal(InstructionTag tag, EdgeKind kind) { | ||
tag = OnlyInstructionTag() and | ||
result = this.getParent().getChildSuccessor(this, kind) | ||
} | ||
|
||
override Instruction getChildSuccessorInternal(TranslatedElement child, EdgeKind kind) { | ||
child = this.getTranslatedOperand() and | ||
kind instanceof GotoEdge and | ||
result = this.getInstruction(OnlyInstructionTag()) | ||
} | ||
} |
Large diffs are not rendered by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be:
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually no.
co_yield
is just syntactic sugar for:co_await promise.yield_value(expr)
(see here) and the "yielding" is done by the call to
yield_value
.So whatever instruction we come up with to use the above TODO should also be used here since a
co_yield
ultimately does something equivalent to a special kind ofco_await
.