Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
cc1d45e
Go: Lower defer evaluations and unnamed returns in CFG and IR
owen-mc Nov 29, 2026
e62a999
Go: Connect saved defer values to SSA and data flow
owen-mc Dec 1, 2026
1ecbeb5
Go: Propagate deferred mutations through the epilogue
owen-mc Dec 1, 2026
9b47b7c
Go: Preserve value numbers across defer temporaries
owen-mc Dec 1, 2026
6c85608
Go: Adapt guards and return inference for defer
owen-mc Dec 1, 2026
6c8b09f
Go: Model clear sanitization across deferred calls
owen-mc Dec 1, 2026
e98f194
Go: Model deferred scanner output sources
owen-mc Dec 1, 2026
d20cbd4
Go: Adapt regexp and allocation models for saved inputs
owen-mc Dec 1, 2026
c58c5f1
Go: Avoid duplicate alerts on synthetic defer values
owen-mc Dec 1, 2026
0b0d55b
Go: Preserve receiver identity in deferred file-close checks
owen-mc Dec 1, 2026
d6d23c6
Go: Trace deferred SSH callback return values
owen-mc Dec 1, 2026
76013b2
Go: Document defer modeling and query precision changes
owen-mc Dec 1, 2026
892427e
Go: Widen XPathInjection Sink and Sanitizer to DataFlow::Node
owen-mc Dec 4, 2026
737b2ad
Go: Fix join order in IR::TempVariable.getType
owen-mc Dec 5, 2026
6515ea6
Go: Fix join order in IR::reachableFromDeferSave
owen-mc Dec 5, 2026
146f089
Go: Avoid GVN fanout in ParameterizedBarrierGuardValue
owen-mc Dec 5, 2026
ef4ae0f
Go: Avoid recursion in AllocationSizeCheckBarrier
owen-mc Dec 5, 2026
b8cdacf
Go: Avoid magic specialization of StructType.hasOwnField
owen-mc Dec 5, 2026
dcc281e
Go: Cache CfgImpl defer and unnamed-result helpers
owen-mc Dec 5, 2026
59e3665
Go: Fix join order and cache deferSaved*Instruction in IR
owen-mc Dec 5, 2026
45787c2
Go: Cache insnHasSyncPostUpdateNode and insnHasPostUpdateNode
owen-mc Dec 5, 2026
332f2b5
Go: Cache insnReadsSsaDef in SsaImpl
owen-mc Dec 5, 2026
3729998
Go: Avoid materializing all IR instructions in temporary SSA
owen-mc Dec 5, 2026
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
1 change: 1 addition & 0 deletions go/ql/lib/semmle/go/Types.qll
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ class StructType extends @structtype, CompositeType {
*
* Note that this predicate does not take promoted fields into account.
*/
pragma[nomagic]
predicate hasOwnField(int i, string name, Type tp, boolean isEmbedded) {
exists(string n | component_types(this, i, n, tp) |
if n = ""
Expand Down
Loading
Loading