mirror of
https://github.com/github/codeql.git
synced 2026-05-30 02:51:24 +02:00
Fix CFG for return instructions
This commit is contained in:
@@ -432,9 +432,6 @@ module GoCfg {
|
||||
or
|
||||
n instanceof Go::IncDecStmt and tag = "incdec-rhs"
|
||||
or
|
||||
// Return node
|
||||
n instanceof Go::ReturnStmt and tag = "return"
|
||||
or
|
||||
// Result write nodes in return statements
|
||||
exists(int i, Go::ReturnStmt ret |
|
||||
n = ret and
|
||||
@@ -950,7 +947,7 @@ module GoCfg {
|
||||
n2.isAdditional(ret, tag2)
|
||||
)
|
||||
or
|
||||
// Last return epilogue → In(ret) (the return itself)
|
||||
// Last return epilogue → return node
|
||||
n1.isAdditional(ret, getLastReturnEpilogueTag(ret)) and
|
||||
n2.isIn(ret)
|
||||
)
|
||||
|
||||
@@ -893,7 +893,7 @@ module IR {
|
||||
class ReturnInstruction extends Instruction {
|
||||
ReturnStmt ret;
|
||||
|
||||
ReturnInstruction() { this.isAdditional(ret, "return") }
|
||||
ReturnInstruction() { this.isIn(ret) }
|
||||
|
||||
/** Gets the corresponding `ReturnStmt`. */
|
||||
ReturnStmt getReturnStmt() { result = ret }
|
||||
@@ -938,9 +938,7 @@ module IR {
|
||||
exists(retStmt.getAnExpr())
|
||||
}
|
||||
|
||||
private ReturnInstruction getReturnInstruction() {
|
||||
result.(ReturnInstruction).isAdditional(retStmt, "return")
|
||||
}
|
||||
private ReturnInstruction getReturnInstruction() { result.getReturnStmt() = retStmt }
|
||||
|
||||
override Instruction getRhs() { result = this.getReturnInstruction().getResult(idx) }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user