Skip to content

Commit 75dd4c8

Browse files
committed
C#: Filter away use-use steps from a node into itself
1 parent b214003 commit 75dd4c8

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowPrivate.qll

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,8 @@ module LocalFlow {
440440
exists(CIL::ReadAccess readFrom, CIL::ReadAccess readTo |
441441
CilSsaImpl::hasAdjacentReadsExt(def, readFrom, readTo) and
442442
nodeTo = TCilExprNode(readTo) and
443-
nodeFrom = TCilExprNode(readFrom)
443+
nodeFrom = TCilExprNode(readFrom) and
444+
nodeFrom != nodeTo
444445
)
445446
or
446447
// Flow into phi (read) node
@@ -483,7 +484,8 @@ module LocalFlow {
483484
or
484485
hasNodePath(any(LocalExprStepConfiguration x), nodeFrom, nodeTo)
485486
or
486-
ThisFlow::adjacentThisRefs(nodeFrom, nodeTo)
487+
ThisFlow::adjacentThisRefs(nodeFrom, nodeTo) and
488+
nodeFrom != nodeTo
487489
or
488490
ThisFlow::adjacentThisRefs(nodeFrom.(PostUpdateNode).getPreUpdateNode(), nodeTo)
489491
or
@@ -541,7 +543,8 @@ predicate simpleLocalFlowStep(Node nodeFrom, Node nodeTo) {
541543
exists(SsaImpl::DefinitionExt def |
542544
LocalFlow::localSsaFlowStepUseUse(def, nodeFrom, nodeTo) and
543545
not FlowSummaryImpl::Private::Steps::prohibitsUseUseFlow(nodeFrom, _) and
544-
not LocalFlow::usesInstanceField(def)
546+
not LocalFlow::usesInstanceField(def) and
547+
nodeFrom != nodeTo
545548
)
546549
or
547550
// Flow into phi (read)/uncertain SSA definition node from read
@@ -880,7 +883,8 @@ private module Cached {
880883
predicate localFlowStepImpl(Node nodeFrom, Node nodeTo) {
881884
LocalFlow::localFlowStepCommon(nodeFrom, nodeTo)
882885
or
883-
LocalFlow::localSsaFlowStepUseUse(_, nodeFrom, nodeTo)
886+
LocalFlow::localSsaFlowStepUseUse(_, nodeFrom, nodeTo) and
887+
nodeFrom != nodeTo
884888
or
885889
exists(SsaImpl::DefinitionExt def |
886890
LocalFlow::localSsaFlowStep(def, nodeFrom, nodeTo) and

0 commit comments

Comments
 (0)