Skip to content

Commit d8bd18f

Browse files
committed
C++: IR translation of 'co_return' statements.
1 parent 3e1359b commit d8bd18f

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedStmt.qll

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,3 +1501,41 @@ class TranslatedVlaDeclarationStmt extends TranslatedStmt {
15011501

15021502
override Instruction getChildSuccessorInternal(TranslatedElement child, EdgeKind kind) { none() }
15031503
}
1504+
1505+
class TranslatedCoReturnStmt extends TranslatedStmt {
1506+
override CoReturnStmt stmt;
1507+
1508+
private TranslatedExpr getTranslatedOperand() {
1509+
result = getTranslatedExpr(stmt.getOperand().getFullyConverted())
1510+
}
1511+
1512+
override TranslatedExpr getChildInternal(int id) {
1513+
id = 0 and
1514+
result = this.getTranslatedOperand()
1515+
}
1516+
1517+
override Instruction getFirstInstruction(EdgeKind kind) {
1518+
result = this.getTranslatedOperand().getFirstInstruction(kind)
1519+
}
1520+
1521+
override Instruction getALastInstructionInternal() {
1522+
result = this.getInstruction(OnlyInstructionTag())
1523+
}
1524+
1525+
override predicate hasInstruction(Opcode opcode, InstructionTag tag, CppType resultType) {
1526+
tag = OnlyInstructionTag() and
1527+
opcode instanceof Opcode::NoOp and
1528+
resultType = getVoidType()
1529+
}
1530+
1531+
override Instruction getInstructionSuccessorInternal(InstructionTag tag, EdgeKind kind) {
1532+
tag = OnlyInstructionTag() and
1533+
result = this.getParent().getChildSuccessor(this, kind)
1534+
}
1535+
1536+
override Instruction getChildSuccessorInternal(TranslatedElement child, EdgeKind kind) {
1537+
child = this.getTranslatedOperand() and
1538+
kind instanceof GotoEdge and
1539+
result = this.getInstruction(OnlyInstructionTag())
1540+
}
1541+
}

0 commit comments

Comments
 (0)