diff --git a/go/ql/lib/semmle/go/controlflow/ControlFlowGraphShared.qll b/go/ql/lib/semmle/go/controlflow/ControlFlowGraphShared.qll index b5c95dc93e8..a5c98645dff 100644 --- a/go/ql/lib/semmle/go/controlflow/ControlFlowGraphShared.qll +++ b/go/ql/lib/semmle/go/controlflow/ControlFlowGraphShared.qll @@ -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) ) diff --git a/go/ql/lib/semmle/go/controlflow/IR.qll b/go/ql/lib/semmle/go/controlflow/IR.qll index 22300f3688b..86df852f7a5 100644 --- a/go/ql/lib/semmle/go/controlflow/IR.qll +++ b/go/ql/lib/semmle/go/controlflow/IR.qll @@ -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) }