Skip to content

Commit 40a2148

Browse files
committed
C#: Introduce additional nodes to carry the boolean successor state.
1 parent c42b274 commit 40a2148

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

shared/controlflow/codeql/controlflow/ControlFlowGraph.qll

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,10 @@ module Make0<LocationSig Location, AstSig<Location> Ast> {
634634

635635
private string patternMatchTrueTag() { result = "[MatchTrue]" }
636636

637+
private string logicalNotTag(Boolean value) {
638+
if value = true then result = "[LogicalNotTrue]" else result = "[LogicalNotFalse]"
639+
}
640+
637641
/**
638642
* Holds if an additional node tagged with `tag` should be created for
639643
* `n`. Edges targeting such nodes are labeled with `t` and therefore `t`
@@ -649,6 +653,12 @@ module Make0<LocationSig Location, AstSig<Location> Ast> {
649653
n instanceof PatternMatchExpr and
650654
tag = patternMatchTrueTag() and
651655
t.(BooleanSuccessor).getValue() = true
656+
or
657+
n instanceof LogicalNotExpr and
658+
exists(Boolean b |
659+
tag = logicalNotTag(b) and
660+
t.(BooleanSuccessor).getValue() = b
661+
)
652662
}
653663

654664
/**
@@ -1455,13 +1465,11 @@ module Make0<LocationSig Location, AstSig<Location> Ast> {
14551465
n1.isBefore(notexpr) and
14561466
n2.isBefore(notexpr.getOperand())
14571467
or
1458-
exists(BooleanSuccessor t, PreControlFlowNode operand |
1459-
operand.isAfterValue(notexpr.getOperand(), t)
1460-
|
1461-
n1 = operand and
1462-
n2.isIn(notexpr)
1468+
exists(BooleanSuccessor t |
1469+
n1.isAfterValue(notexpr.getOperand(), t) and
1470+
n2.isAdditional(notexpr, logicalNotTag(t.getValue()))
14631471
or
1464-
n1.isIn(notexpr) and
1472+
n1.isAdditional(notexpr, logicalNotTag(t.getValue())) and
14651473
n2.isAfterValue(notexpr, t.getDual())
14661474
)
14671475
)

0 commit comments

Comments
 (0)