Skip to content

Commit cc6da7e

Browse files
authored
Merge pull request github#13031 from hvitved/identity-consistency-check
C#: Remove local identity flow steps
2 parents b214003 + 027cb2d commit cc6da7e

File tree

23 files changed

+13
-38
lines changed

23 files changed

+13
-38
lines changed

csharp/ql/consistency-queries/DataFlowConsistency.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,5 @@ private class MyConsistencyConfiguration extends ConsistencyConfiguration {
7272

7373
override predicate reverseReadExclude(Node n) { n.asExpr() = any(AwaitExpr ae).getExpr() }
7474

75-
override predicate identityLocalStepExclude(Node n) { n.getLocation().getFile().fromLibrary() }
75+
override predicate identityLocalStepExclude(Node n) { none() }
7676
}

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,8 @@ module LocalFlow {
335335
exists(ControlFlow::BasicBlock bb, int i |
336336
SsaImpl::lastRefBeforeRedefExt(def, bb, i, next.getDefinitionExt()) and
337337
def.definesAt(_, bb, i, _) and
338-
def = getSsaDefinitionExt(nodeFrom)
338+
def = getSsaDefinitionExt(nodeFrom) and
339+
nodeFrom != next
339340
)
340341
}
341342

@@ -414,7 +415,8 @@ module LocalFlow {
414415
) {
415416
exists(CIL::BasicBlock bb, int i | CilSsaImpl::lastRefBeforeRedefExt(def, bb, i, next) |
416417
def.definesAt(_, bb, i, _) and
417-
def = nodeFrom.(CilSsaDefinitionExtNode).getDefinition()
418+
def = nodeFrom.(CilSsaDefinitionExtNode).getDefinition() and
419+
def != next
418420
or
419421
nodeFrom = TCilExprNode(bb.getNode(i).(CIL::ReadAccess))
420422
)
@@ -440,7 +442,8 @@ module LocalFlow {
440442
exists(CIL::ReadAccess readFrom, CIL::ReadAccess readTo |
441443
CilSsaImpl::hasAdjacentReadsExt(def, readFrom, readTo) and
442444
nodeTo = TCilExprNode(readTo) and
443-
nodeFrom = TCilExprNode(readFrom)
445+
nodeFrom = TCilExprNode(readFrom) and
446+
nodeFrom != nodeTo
444447
)
445448
or
446449
// Flow into phi (read) node
@@ -483,7 +486,8 @@ module LocalFlow {
483486
or
484487
hasNodePath(any(LocalExprStepConfiguration x), nodeFrom, nodeTo)
485488
or
486-
ThisFlow::adjacentThisRefs(nodeFrom, nodeTo)
489+
ThisFlow::adjacentThisRefs(nodeFrom, nodeTo) and
490+
nodeFrom != nodeTo
487491
or
488492
ThisFlow::adjacentThisRefs(nodeFrom.(PostUpdateNode).getPreUpdateNode(), nodeTo)
489493
or
@@ -541,7 +545,8 @@ predicate simpleLocalFlowStep(Node nodeFrom, Node nodeTo) {
541545
exists(SsaImpl::DefinitionExt def |
542546
LocalFlow::localSsaFlowStepUseUse(def, nodeFrom, nodeTo) and
543547
not FlowSummaryImpl::Private::Steps::prohibitsUseUseFlow(nodeFrom, _) and
544-
not LocalFlow::usesInstanceField(def)
548+
not LocalFlow::usesInstanceField(def) and
549+
nodeFrom != nodeTo
545550
)
546551
or
547552
// Flow into phi (read)/uncertain SSA definition node from read
@@ -880,7 +885,8 @@ private module Cached {
880885
predicate localFlowStepImpl(Node nodeFrom, Node nodeTo) {
881886
LocalFlow::localFlowStepCommon(nodeFrom, nodeTo)
882887
or
883-
LocalFlow::localSsaFlowStepUseUse(_, nodeFrom, nodeTo)
888+
LocalFlow::localSsaFlowStepUseUse(_, nodeFrom, nodeTo) and
889+
nodeFrom != nodeTo
884890
or
885891
exists(SsaImpl::DefinitionExt def |
886892
LocalFlow::localSsaFlowStep(def, nodeFrom, nodeTo) and

csharp/ql/test/experimental/ir/offbyone/CONSISTENCY/DataFlowConsistency.expected

Lines changed: 0 additions & 7 deletions
This file was deleted.

csharp/ql/test/library-tests/cil/attributes/CONSISTENCY/DataFlowConsistency.expected

Whitespace-only changes.

csharp/ql/test/library-tests/cil/consistency/CONSISTENCY/DataFlowConsistency.expected

Whitespace-only changes.

csharp/ql/test/library-tests/cil/dataflow/CONSISTENCY/DataFlowConsistency.expected

Whitespace-only changes.

csharp/ql/test/library-tests/cil/enums/CONSISTENCY/DataFlowConsistency.expected

Whitespace-only changes.

csharp/ql/test/library-tests/cil/functionPointers/CONSISTENCY/DataFlowConsistency.expected

Whitespace-only changes.

csharp/ql/test/library-tests/cil/init-only-prop/CONSISTENCY/DataFlowConsistency.expected

Whitespace-only changes.

csharp/ql/test/library-tests/cil/pdbs/CONSISTENCY/DataFlowConsistency.expected

Whitespace-only changes.

0 commit comments

Comments
 (0)