Skip to content
Open
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
4 changes: 4 additions & 0 deletions go/ql/consistency-queries/TempSsaConsistency.ql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import go
import semmle.go.dataflow.SsaImpl
import TempConsistency
import TempDataFlowIntegration::DfConsistency
4 changes: 4 additions & 0 deletions go/ql/lib/change-notes/2026-11-28-defer-temporaries.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
category: minorAnalysis
---
* Improved control-flow, IR, SSA, and data-flow modeling of `defer` statements by saving evaluated callees, receivers, and arguments into synthetic temporaries at `defer` registration, reading them before deferred invocation, and saving unnamed `return` values across deferred calls. Mutations performed by deferred calls on arguments and receivers now propagate to function results and subsequent deferred calls in LIFO order rather than appearing in the function body before the `defer` runs. As a result, `CallNode.getArgument`, `CallNode.getSyntacticArgument`, `CallNode.getCalleeNode`, `MethodCallNode.getReceiver`, and `ResultNode` in functions containing `defer` may now return synthetic `InstructionNode`s rather than `ExprNode`s.
14 changes: 13 additions & 1 deletion go/ql/lib/semmle/go/Expr.qll
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,16 @@ class ConversionExpr extends CallOrConversionExpr {
override string getAPrimaryQlClass() { result = "ConversionExpr" }
}

private Expr unwrapCalleeExpr(Expr e) {
result = unwrapCalleeExpr(e.(ParenExpr).getExpr())
or
result = unwrapCalleeExpr(e.(GenericFunctionInstantiationExpr).getBase())
or
not e instanceof ParenExpr and
not e instanceof GenericFunctionInstantiationExpr and
result = e
}

/**
* A function call expression.
*
Expand Down Expand Up @@ -923,8 +933,10 @@ class CallExpr extends CallOrConversionExpr {
*/
SignatureType getCalleeType() { result = this.getCalleeExpr().getType() }

private Expr getUnwrappedCalleeExpr() { result = unwrapCalleeExpr(this.getChildExpr(0)) }

/** Gets the declared target of this call. */
Function getTarget() { this.getCalleeExpr() = result.getAReference() }
Function getTarget() { this.getUnwrappedCalleeExpr() = result.getAReference() }

/** Holds if this call has an ellipsis after its last argument. */
predicate hasEllipsis() { has_ellipsis(this) }
Expand Down
Loading
Loading