Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
93a594e
Cfg: Support Throw expressions.
aschackmull Mar 5, 2026
a53cffc
Cfg: Support GotoStmt.
aschackmull Mar 5, 2026
0b6c416
Cfg: Support short-circuiting compound assignments.
aschackmull Mar 3, 2026
035b83c
C#: Introduce ControlFlowElementOrCallable.
aschackmull Mar 9, 2026
6ffed85
Cfg/Java: Move InstanceOfExpr CFG into shared lib.
aschackmull Mar 11, 2026
88aaff8
Cfg: Extend consistency checks.
aschackmull Mar 12, 2026
61976e3
C#: Rename ControlFlow::Node to ControlFlowNode.
aschackmull Mar 12, 2026
b85b02a
Cfg: Add dominance predicates to shared ControlFlowNode.
aschackmull Mar 18, 2026
03f6bdb
C#: Update some references in preparation for CFG swap.
aschackmull Mar 18, 2026
b878ae3
C#: Update some references to ControlFlow::Nodes.
aschackmull Mar 18, 2026
13a4141
C#: Rename remaining references to ControlFlow::Nodes.
aschackmull Mar 18, 2026
9cf9a36
C#: Rename ControlFlow::BasicBlock to BasicBlock.
aschackmull Mar 18, 2026
ff978d1
C#: Replace CFG.
aschackmull Mar 9, 2026
b179033
C#: Fix test.
aschackmull Mar 20, 2026
700d56f
C#: Fix UncheckedCastInEquals.
aschackmull Mar 20, 2026
ac88b73
C#: Bugfix in enclosing callable.
aschackmull Mar 24, 2026
093eb57
C#: Fix CFG position of property setter calls.
aschackmull Mar 26, 2026
43fe411
C#: Accept SSA location changes.
aschackmull Mar 26, 2026
1a6670a
C#: Phi nodes are not expected to have associated Elements.
aschackmull Mar 26, 2026
6010640
C#: Accept bugfix.
aschackmull Mar 30, 2026
a5c99f9
C#: Accept harmless CFG changes.
aschackmull Mar 30, 2026
5d58909
C#: Accept CFG changes.
aschackmull Mar 30, 2026
49cc931
C#: Compile-time constants no longer have CFG nodes.
aschackmull Mar 30, 2026
e90243c
C#: Accept irrelevant changes.
aschackmull Mar 31, 2026
88256ee
C#: GuardedExpr no longer contains expressions guarded solely by disj…
aschackmull Mar 31, 2026
773881f
C#: Accept data flow inconsistency check for read+write calls.
aschackmull Mar 31, 2026
a997d9f
C#: Accept fixed consistency check.
aschackmull Mar 31, 2026
a695819
C#: Accept CFG changes for "first" relation.
aschackmull Mar 31, 2026
a7d4b00
C#: Accept changed location for phi nodes.
aschackmull Apr 7, 2026
371bc30
C#: CFG and data flow nodes now exist for LHSs.
aschackmull Apr 7, 2026
1d9c0ae
C#: Fix perf.
aschackmull Apr 8, 2026
bfbd0f7
C#: Fix some bad join orders.
aschackmull Apr 9, 2026
bbd403d
C#: Rework DataFlowCallable-to-cfg relation in terms of basic blocks …
aschackmull Apr 9, 2026
2d5a184
C#: Accept new CFG in tests.
aschackmull Apr 9, 2026
aaf9bb2
C#: Accept fewer CallContextSpecificCall due to no splitting.
aschackmull Apr 9, 2026
452913f
C#: Improve perf of UnsynchronizedStaticAccess.ql.
aschackmull Apr 10, 2026
d5c9fd1
C#/Cfg: A bit more qldoc.
aschackmull Apr 10, 2026
88160ef
C#: Add change note.
aschackmull Apr 13, 2026
e928c22
C#/Cfg: Some simple review fixes.
aschackmull Apr 20, 2026
3ceb96a
C#: Eliminate Completion.qll.
aschackmull Apr 20, 2026
b6f50f5
C#: Simplify.
aschackmull Apr 20, 2026
9de02b7
Cfg: Use consistent casing in additional node tags.
aschackmull Apr 21, 2026
a2a4e82
C#: Deprecate ControlFlowElement.getAControlFlowNode and remove some …
aschackmull Apr 21, 2026
67c0515
Cfg: Undo consistency check change.
aschackmull Apr 21, 2026
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
2 changes: 1 addition & 1 deletion csharp/ql/lib/semmle/code/csharp/Callable.qll
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ private import TypeRef
* an anonymous function (`AnonymousFunctionExpr`), or a local function
* (`LocalFunction`).
*/
class Callable extends Parameterizable, ExprOrStmtParent, @callable {
class Callable extends Parameterizable, ControlFlowElementOrCallable, @callable {
/** Gets the return type of this callable. */
Type getReturnType() { none() }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ private import ControlFlow::BasicBlocks
private import semmle.code.csharp.Caching
private import internal.ControlFlowGraphImpl as Impl

private class TControlFlowElementOrCallable = @callable or @control_flow_element;

class ControlFlowElementOrCallable extends ExprOrStmtParent, TControlFlowElementOrCallable { }

/**
* A program element that can possess control flow. That is, either a statement or
* an expression.
Expand All @@ -17,7 +21,7 @@ private import internal.ControlFlowGraphImpl as Impl
* control flow elements and control flow nodes. This allows control flow
* splitting, for example modeling the control flow through `finally` blocks.
*/
class ControlFlowElement extends ExprOrStmtParent, @control_flow_element {
class ControlFlowElement extends ControlFlowElementOrCallable, @control_flow_element {
/** Gets the enclosing callable of this element, if any. */
Callable getEnclosingCallable() { none() }

Expand Down
66 changes: 31 additions & 35 deletions java/ql/lib/semmle/code/java/ControlFlowGraph.qll
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,13 @@ private module Ast implements AstSig<Location> {

class ContinueStmt = J::ContinueStmt;

class GotoStmt extends Stmt {
GotoStmt() { none() }
}

class ReturnStmt = J::ReturnStmt;

class ThrowStmt = J::ThrowStmt;
class Throw = J::ThrowStmt;

final private class FinalTryStmt = J::TryStmt;

Expand Down Expand Up @@ -181,11 +185,37 @@ private module Ast implements AstSig<Location> {

class LogicalNotExpr = LogNotExpr;

class Assignment = J::Assignment;

class AssignExpr = J::AssignExpr;

class CompoundAssignment = J::AssignOp;

class AssignLogicalAndExpr extends CompoundAssignment {
AssignLogicalAndExpr() { none() }
}

class AssignLogicalOrExpr extends CompoundAssignment {
AssignLogicalOrExpr() { none() }
}

class AssignNullCoalescingExpr extends CompoundAssignment {
AssignNullCoalescingExpr() { none() }
}

final private class FinalBooleanLiteral = J::BooleanLiteral;

class BooleanLiteral extends FinalBooleanLiteral {
boolean getValue() { result = this.getBooleanValue() }
}

final private class FinalInstanceOfExpr = J::InstanceOfExpr;

class PatternMatchExpr extends FinalInstanceOfExpr {
PatternMatchExpr() { this.isPattern() }

AstNode getPattern() { result = super.getPattern() }
}
}

private module Exceptions {
Expand Down Expand Up @@ -522,14 +552,8 @@ private module Input implements InputSig1, InputSig2 {

private string assertThrowNodeTag() { result = "[assert-throw]" }

private string instanceofTrueNodeTag() { result = "[instanceof-true]" }

predicate additionalNode(Ast::AstNode n, string tag, NormalSuccessor t) {
n instanceof AssertStmt and tag = assertThrowNodeTag() and t instanceof DirectSuccessor
or
n.(InstanceOfExpr).isPattern() and
tag = instanceofTrueNodeTag() and
t.(BooleanSuccessor).getValue() = true
}

/**
Expand Down Expand Up @@ -571,34 +595,6 @@ private module Input implements InputSig1, InputSig2 {

/** Holds if there is a local non-abrupt step from `n1` to `n2`. */
predicate step(PreControlFlowNode n1, PreControlFlowNode n2) {
exists(InstanceOfExpr ioe |
// common
n1.isBefore(ioe) and
n2.isBefore(ioe.getExpr())
or
n1.isAfter(ioe.getExpr()) and
n2.isIn(ioe)
or
// std postorder:
not ioe.isPattern() and
n1.isIn(ioe) and
n2.isAfter(ioe)
or
// pattern case:
ioe.isPattern() and
n1.isIn(ioe) and
n2.isAfterValue(ioe, any(BooleanSuccessor s | s.getValue() = false))
or
n1.isIn(ioe) and
n2.isAdditional(ioe, instanceofTrueNodeTag())
or
n1.isAdditional(ioe, instanceofTrueNodeTag()) and
n2.isBefore(ioe.getPattern())
or
n1.isAfter(ioe.getPattern()) and
n2.isAfterValue(ioe, any(BooleanSuccessor s | s.getValue() = true))
)
or
exists(AssertStmt assertstmt |
n1.isBefore(assertstmt) and
n2.isBefore(assertstmt.getExpr())
Expand Down
Loading