File tree Expand file tree Collapse file tree
cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -382,6 +382,24 @@ private module Cached {
382382 fromPhiNode ( nodeFrom , nodeTo )
383383 or
384384 toPhiNode ( nodeFrom , nodeTo )
385+ or
386+ // When we want to transfer flow out of a `StoreNode` we perform two steps:
387+ // 1. Find the next use of the address being stored to
388+ // 2. Find the `LoadInstruction` that loads the address
389+ // When the address being stored into doesn't have a `LoadInstruction` associated with it because it's
390+ // passed into a `CallInstruction` we transfer flow to the `ReadSideEffect`, which will then flow into
391+ // the callee. We then pickup the flow from the `InitializeIndirectionInstruction` and use the shared
392+ // SSA library to determine where the next use of the address that received the flow is.
393+ exists ( Node init , Node mid |
394+ nodeFrom .asInstruction ( ) .( InitializeIndirectionInstruction ) .getIRVariable ( ) =
395+ init .asInstruction ( ) .( InitializeParameterInstruction ) .getIRVariable ( ) and
396+ // No need for the flow if the next use is the instruction that returns the flow out of the callee.
397+ not mid .asInstruction ( ) instanceof ReturnIndirectionInstruction and
398+ // Find the next use of the address
399+ ssaFlow ( init , mid ) and
400+ // And flow to the next load of that address
401+ flowOutOfAddressStep ( [ mid .asInstruction ( ) .getAUse ( ) , mid .asOperand ( ) ] , nodeTo )
402+ )
385403 }
386404
387405 private predicate flowOutOfAddressStep ( Operand operand , Node nTo ) {
You can’t perform that action at this time.
0 commit comments