File tree Expand file tree Collapse file tree 2 files changed +18
-15
lines changed
cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal Expand file tree Collapse file tree 2 files changed +18
-15
lines changed Original file line number Diff line number Diff line change @@ -734,21 +734,6 @@ predicate simpleLocalFlowStep(Node nodeFrom, Node nodeTo) {
734
734
or
735
735
// Adjacent-def-use and adjacent-use-use flow
736
736
adjacentDefUseFlow ( nodeFrom , nodeTo )
737
- or
738
- // When we want to transfer flow out of a `StoreNode` we perform two steps:
739
- // 1. Find the next use of the address being stored to
740
- // 2. Find the `LoadInstruction` that loads the address
741
- // When the address being stored into doesn't have a `LoadInstruction` associated with it because it's
742
- // passed into a `CallInstruction` we transfer flow to the `ReadSideEffect`, which will then flow into
743
- // the callee. We then pickup the flow from the `InitializeIndirectionInstruction` and use the shared
744
- // SSA library to determine where the next use of the address that received the flow is.
745
- exists ( Node init |
746
- nodeFrom .asInstruction ( ) .( InitializeIndirectionInstruction ) .getIRVariable ( ) =
747
- init .asInstruction ( ) .( InitializeParameterInstruction ) .getIRVariable ( ) and
748
- // No need for the flow if the next use is the instruction that returns the flow out of the callee.
749
- not nodeTo .asInstruction ( ) instanceof ReturnIndirectionInstruction and
750
- Ssa:: ssaFlow ( init , nodeTo )
751
- )
752
737
}
753
738
754
739
private predicate adjacentDefUseFlow ( Node nodeFrom , Node nodeTo ) {
Original file line number Diff line number Diff line change @@ -403,6 +403,24 @@ private module Cached {
403
403
fromPhiNode ( nodeFrom , nodeTo )
404
404
or
405
405
toPhiNode ( nodeFrom , nodeTo )
406
+ or
407
+ // When we want to transfer flow out of a `StoreNode` we perform two steps:
408
+ // 1. Find the next use of the address being stored to
409
+ // 2. Find the `LoadInstruction` that loads the address
410
+ // When the address being stored into doesn't have a `LoadInstruction` associated with it because it's
411
+ // passed into a `CallInstruction` we transfer flow to the `ReadSideEffect`, which will then flow into
412
+ // the callee. We then pickup the flow from the `InitializeIndirectionInstruction` and use the shared
413
+ // SSA library to determine where the next use of the address that received the flow is.
414
+ exists ( Node init , Node mid |
415
+ nodeFrom .asInstruction ( ) .( InitializeIndirectionInstruction ) .getIRVariable ( ) =
416
+ init .asInstruction ( ) .( InitializeParameterInstruction ) .getIRVariable ( ) and
417
+ // No need for the flow if the next use is the instruction that returns the flow out of the callee.
418
+ not mid .asInstruction ( ) instanceof ReturnIndirectionInstruction and
419
+ // Find the next use of the address
420
+ ssaFlow ( init , mid ) and
421
+ // And flow to the next load of that address
422
+ flowOutOfAddressStep ( [ mid .asInstruction ( ) .getAUse ( ) , mid .asOperand ( ) ] , nodeTo )
423
+ )
406
424
}
407
425
408
426
private predicate valueFlow ( Instruction iFrom , Instruction iTo ) {
You can’t perform that action at this time.
0 commit comments