Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion shared/controlflow/codeql/controlflow/ControlFlowGraph.qll
Original file line number Diff line number Diff line change
Expand Up @@ -519,13 +519,14 @@ module Make0<LocationSig Location, AstSig<Location> Ast> {
or
n instanceof GotoStmt
or
n instanceof LogicalNotExpr
or
n instanceof Expr and
exists(getChild(n, _)) and
not Input1::preOrderExpr(n) and
not n instanceof LogicalAndExpr and
not n instanceof LogicalOrExpr and
not n instanceof NullCoalescingExpr and
not n instanceof LogicalNotExpr and
not n instanceof ConditionalExpr and
not n instanceof Switch and
not n instanceof Case
Expand Down Expand Up @@ -633,6 +634,10 @@ module Make0<LocationSig Location, AstSig<Location> Ast> {

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

private string logicalNotTag(Boolean value) {
if value = true then result = "[LogicalNotTrue]" else result = "[LogicalNotFalse]"
}

/**
* Holds if an additional node tagged with `tag` should be created for
* `n`. Edges targeting such nodes are labeled with `t` and therefore `t`
Expand All @@ -648,6 +653,12 @@ module Make0<LocationSig Location, AstSig<Location> Ast> {
n instanceof PatternMatchExpr and
tag = patternMatchTrueTag() and
t.(BooleanSuccessor).getValue() = true
or
n instanceof LogicalNotExpr and
exists(Boolean b |
tag = logicalNotTag(b) and
t.(BooleanSuccessor).getValue() = b
)
}

/**
Expand Down Expand Up @@ -1456,6 +1467,9 @@ module Make0<LocationSig Location, AstSig<Location> Ast> {
or
exists(BooleanSuccessor t |
n1.isAfterValue(notexpr.getOperand(), t) and
n2.isAdditional(notexpr, logicalNotTag(t.getValue()))
or
n1.isAdditional(notexpr, logicalNotTag(t.getValue())) and
n2.isAfterValue(notexpr, t.getDual())
)
)
Expand Down
Loading