Repository navigation
C++: Small cleanup on FlowSummaryImpl.qll - #23118
Conversation
There was a problem hiding this comment.
🔵 Needs a closer look
The core C++ source-node matching change requires query validation across all ArgumentNode implementations, conversions, indirect arguments, and post-update representations to establish behavioral parity.
No open issues 🎉
What changed in this PR
Cleans up C++ flow-summary source-node matching by reusing the existing ArgumentNode.sourceArgumentOf predicate, preserving the intended argument-position behavior.
Changes:
- Replaces duplicated expression and indirection checks with
sourceArgumentOf. - Retains existing call and summary-component filtering.
| File | Description |
|---|---|
| cpp/ql/lib/semmle/code/cpp/dataflow/internal/FlowSummaryImpl.qll | Simplifies source data-flow node resolution for call arguments by using the existing ArgumentNode.sourceArgumentOf predicate. |
Review effort: Lite (auto)
| pos.getArgument(call.asCallInstruction().getUnconvertedResultExpression()) = e | ||
| | | ||
| pos.getIndirectionIndex() = 0 and | ||
| result.(PostUpdateNode).getPreUpdateNode().asExpr() = e | ||
| or | ||
| result.(PostUpdateNode).getPreUpdateNode().asIndirectExpr(pos.getIndirectionIndex()) = e | ||
| pos.getArgument(call.asCallInstruction().getUnconvertedResultExpression()) = e and | ||
| result | ||
| .(PostUpdateNode) | ||
| .getPreUpdateNode() | ||
| .(ArgumentNode) | ||
| .sourceArgumentOf(call.asCallInstruction(), pos) |
There was a problem hiding this comment.
I think I need some explanation as to why this works just as well.
There was a problem hiding this comment.
We had the logic of sourceArgumentOf duplicated in FlowSummaryImpl. If the indirection index was 0 we picked the asExpr node, and otherwise we used the indirection index to get the indirect node. The same logic is implemented in the sourceArgumentOf predicate (where PrimaryArgumentNode implements the direct case, and SideEffectArgumentNode represents the indirect case).
Should have no impact on the any results.
DCA was uneventful