Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -2182,17 +2182,6 @@ module IteratorFlow {
private module DataFlowIntegrationInput implements IteratorSsa::DataFlowIntegrationInputSig {
private import codeql.util.Void

class Expr extends Instruction {
Expr() {
exists(IRBlock bb, int i |
SsaInput::variableRead(bb, i, _, true) and
this = bb.getInstruction(i)
)
}

predicate hasCfgNode(IRCfg::BasicBlock bb, int i) { bb.getInstruction(i) = this }
}

predicate ssaDefHasSource(IteratorSsa::WriteDefinition def) { none() }

predicate allowFlowIntoUncertainDef(IteratorSsa::UncertainWriteDefinition def) { any() }
Expand Down Expand Up @@ -2280,7 +2269,7 @@ module IteratorFlow {
result = n.(SsaIteratorNode).getIteratorFlowNode()
or
exists(Ssa::UseImpl use, IRBlock bb, int i |
result.(DataFlowIntegrationImpl::ExprNode).getExpr().hasCfgNode(bb, i) and
result.(DataFlowIntegrationImpl::ReadNode).readsAt(bb, i, v) and
use.hasIndexInBlock(bb, i, v) and
use.getNode() = n
)
Expand Down
11 changes: 0 additions & 11 deletions cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/SsaImpl.qll
Original file line number Diff line number Diff line change
Expand Up @@ -1154,17 +1154,6 @@ private module SsaImpl = Ssa::Make<Location, IRCfg, SsaInput>;
private module DataFlowIntegrationInput implements SsaImpl::DataFlowIntegrationInputSig {
private import codeql.util.Boolean

class Expr extends Instruction {
Expr() {
exists(IRBlock bb, int i |
variableRead(bb, i, _, true) and
this = bb.getInstruction(i)
)
}

predicate hasCfgNode(IRCfg::BasicBlock bb, int i) { bb.getInstruction(i) = this }
}

predicate ssaDefHasSource(SsaImpl::WriteDefinition def) { none() }

predicate allowFlowIntoUncertainDef(SsaImpl::UncertainWriteDefinition def) { any() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -494,9 +494,9 @@ module SsaFlow {
Impl::Node asNode(Node n) {
n = TSsaNode(result)
or
result.(Impl::ExprNode).getExpr() = n.(ExprNode).getControlFlowNode()
result.(Impl::ReadNode).getControlFlowNode() = n.(ExprNode).getControlFlowNode()
or
result.(Impl::ExprPostUpdateNode).getExpr() =
result.(Impl::PostUpdateReadNode).getControlFlowNode() =
n.(PostUpdateNode).getPreUpdateNode().(ExprNode).getControlFlowNode()
or
result.(Impl::WriteDefSourceNode).getDefinition() = n.(ExplicitParameterNode).getSsaDefinition()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1012,10 +1012,6 @@ deprecated Definition uncertainWriteDefinitionInput(UncertainWriteDefinition def
private module DataFlowIntegrationInput implements Impl::DataFlowIntegrationInputSig {
private import codeql.util.Boolean

class Expr extends ControlFlowNode {
predicate hasCfgNode(BasicBlock bb, int i) { this = bb.getNode(i) }
}

predicate ssaDefHasSource(Impl::WriteDefinition def) {
// exclude flow directly from RHS to SSA definition, as we instead want to
// go from RHS to matching assignable definition, and from there to SSA definition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ module SsaFlow {
Impl::Node asNode(Node n) {
n = TSsaNode(result)
or
result.(Impl::ExprNode).getExpr() = n.asExpr()
result.(Impl::ReadNode).getControlFlowNode() = n.asExpr().getControlFlowNode()
or
result.(Impl::ExprPostUpdateNode).getExpr() = n.(PostUpdateNode).getPreUpdateNode().asExpr()
result.(Impl::PostUpdateReadNode).getControlFlowNode() =
n.(PostUpdateNode).getPreUpdateNode().asExpr().getControlFlowNode()
or
exists(Parameter p |
n = TExplicitParameterNode(p) and
Expand Down
10 changes: 0 additions & 10 deletions java/ql/lib/semmle/code/java/dataflow/internal/SsaImpl.qll
Original file line number Diff line number Diff line change
Expand Up @@ -636,16 +636,6 @@ private class TrackedSsaDef extends Definition {
private module DataFlowIntegrationInput implements Impl::DataFlowIntegrationInputSig {
private import java as J

class Expr instanceof J::Expr {
string toString() { result = super.toString() }

Location getLocation() { result = super.getLocation() }

predicate hasCfgNode(BasicBlock bb, int i) {
super.getControlFlowNode() = bb.(J::BasicBlock).getNode(i)
}
}

predicate ssaDefHasSource(WriteDefinition def) { def instanceof SsaExplicitWrite }

predicate allowFlowIntoUncertainDef(UncertainWriteDefinition def) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1230,12 +1230,12 @@ private predicate samePhi(SsaPhiNode legacyPhi, Ssa2::PhiNode newPhi) {

cached
Node getNodeFromSsa2(Ssa2::Node node) {
result = TSsaUseNode(node.(Ssa2::ExprNode).getExpr())
result = TSsaUseNode(node.(Ssa2::ReadNode).getControlFlowNode())
or
result = TExprPostUpdateNode(node.(Ssa2::ExprPostUpdateNode).getExpr())
result = TExprPostUpdateNode(node.(Ssa2::PostUpdateReadNode).getControlFlowNode())
or
exists(ImplicitThisUse use |
node.(Ssa2::ExprPostUpdateNode).getExpr() = use and
node.(Ssa2::PostUpdateReadNode).getControlFlowNode() = use and
result = TImplicitThisUse(use, true)
)
or
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,6 @@ js::ControlFlowNode getARead(Definition def) {
module SsaDataflowInput implements DataFlowIntegrationInputSig {
private import codeql.util.Boolean

class Expr extends js::ControlFlowNode {
Expr() { this = any(SsaConfig::SourceVariable v).getAUse() }

predicate hasCfgNode(js::Cfg::BasicBlock bb, int i) { this = bb.getNode(i) }
}

predicate ssaDefHasSource(WriteDefinition def) {
// This library only handles use-use flow after a post-update, there are no definitions, only uses.
none()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,10 @@ module SsaFlow {
Impl::Node asNode(Node n) {
n = TSsaNode(result)
or
result.(Impl::ExprNode).getExpr() = n.asExpr()
result.(Impl::ReadNode).getControlFlowNode() = n.asExpr()
or
result.(Impl::ExprPostUpdateNode).getExpr() = n.(PostUpdateNode).getPreUpdateNode().asExpr()
result.(Impl::PostUpdateReadNode).getControlFlowNode() =
n.(PostUpdateNode).getPreUpdateNode().asExpr()
or
exists(SsaImpl::ParameterExt p |
n = toParameterNode(p) and
Expand Down
4 changes: 0 additions & 4 deletions ruby/ql/lib/codeql/ruby/dataflow/internal/SsaImpl.qll
Original file line number Diff line number Diff line change
Expand Up @@ -434,10 +434,6 @@ private module DataFlowIntegrationInput implements Impl::DataFlowIntegrationInpu
private import codeql.ruby.controlflow.internal.Guards as Guards
private import codeql.util.Boolean

class Expr extends Cfg::CfgNodes::ExprCfgNode {
predicate hasCfgNode(BasicBlock bb, int i) { this = bb.getNode(i) }
}

predicate ssaDefHasSource(WriteDefinition def) {
any(ParameterExt p).isInitializedBy(def) or def.(Ssa::WriteDefinition).assigns(_)
}
Expand Down
5 changes: 3 additions & 2 deletions rust/ql/lib/codeql/rust/dataflow/internal/DataFlowImpl.qll
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,10 @@ module SsaFlow {
SsaFlow::Node asNode(Node n) {
n = TSsaNode(result)
or
result.(SsaFlow::ExprNode).getExpr() = n.asExpr()
result.(SsaFlow::ReadNode).getControlFlowNode() = n.asExpr().getACfgNode()
or
result.(SsaFlow::ExprPostUpdateNode).getExpr() = n.(PostUpdateNode).getPreUpdateNode().asExpr()
result.(SsaFlow::PostUpdateReadNode).getControlFlowNode() =
n.(PostUpdateNode).getPreUpdateNode().asExpr().getACfgNode()
}

predicate localFlowStep(
Expand Down
6 changes: 0 additions & 6 deletions rust/ql/lib/codeql/rust/dataflow/internal/SsaImpl.qll
Original file line number Diff line number Diff line change
Expand Up @@ -328,16 +328,10 @@ private module Cached {
import Cached
private import codeql.rust.dataflow.Ssa

private class ExprAlias = Expr;

private module DataFlowIntegrationInput implements Impl::DataFlowIntegrationInputSig {
private import codeql.rust.dataflow.internal.DataFlowImpl as DataFlowImpl
private import codeql.util.Boolean

class Expr extends ExprAlias {
predicate hasCfgNode(BasicBlock bb, int i) { this.getACfgNode() = bb.getNode(i) }
}

predicate ssaDefHasSource(WriteDefinition def) { none() } // handled in `DataFlowImpl.qll` instead

private predicate isArg(Call call, Expr e) {
Expand Down
10 changes: 2 additions & 8 deletions shared/dataflow/codeql/dataflow/VariableCapture.qll
Original file line number Diff line number Diff line change
Expand Up @@ -748,12 +748,6 @@ module Flow<
private module DataFlowIntegrationInput implements CaptureSsa::DataFlowIntegrationInputSig {
private import codeql.util.Void

class Expr instanceof Cfg::ControlFlowNode {
string toString() { result = super.toString() }

predicate hasCfgNode(Cfg::BasicBlock bb, int i) { bb.getNode(i) = this }
}

class GuardValue = Void;

class Guard extends Void {
Expand Down Expand Up @@ -982,12 +976,12 @@ module Flow<
n = TSynthSsa(result)
or
exists(BasicBlock bb, int i |
result.(SsaFlow::ExprNode).getExpr().hasCfgNode(bb, i) and
result.(SsaFlow::ReadNode).readsAt(bb, i, cc) and
ssaReadAt(n, cc, false, bb, i)
)
or
exists(BasicBlock bb, int i |
result.(SsaFlow::ExprPostUpdateNode).getExpr().hasCfgNode(bb, i) and
result.(SsaFlow::PostUpdateReadNode).readsAt(bb, i, cc) and
ssaReadAt(n, cc, true, bb, i)
)
or
Expand Down
Loading
Loading