File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -382,6 +382,24 @@ private module Cached {
382
382
fromPhiNode ( nodeFrom , nodeTo )
383
383
or
384
384
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
+ )
385
403
}
386
404
387
405
private predicate flowOutOfAddressStep ( Operand operand , Node nTo ) {
You can’t perform that action at this time.
0 commit comments