Skip to content

Commit

Permalink
Merge pull request #14283 from hvitved/ruby/collapse-stages
Browse files Browse the repository at this point in the history
Ruby: Collapse DIL stages
  • Loading branch information
hvitved authored Sep 22, 2023
2 parents ab54f0c + c2306e6 commit e417e86
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
9 changes: 6 additions & 3 deletions ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowPrivate.qll
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ module VariableCapture {
private import ruby as R
private import codeql.ruby.controlflow.ControlFlowGraph
private import codeql.ruby.controlflow.BasicBlocks as BasicBlocks
private import TaintTrackingPrivate as TaintTrackingPrivate

class Location = R::Location;

Expand All @@ -296,7 +297,10 @@ module VariableCapture {
BasicBlock getABasicBlockSuccessor(BasicBlock bb) { result = bb.getASuccessor() }

class CapturedVariable extends LocalVariable {
CapturedVariable() { this.isCaptured() }
CapturedVariable() {
this.isCaptured() and
TaintTrackingPrivate::forceCachingInSameStage()
}

Callable getCallable() {
exists(Scope scope | scope = this.getDeclaringScope() |
Expand Down Expand Up @@ -426,12 +430,11 @@ module VariableCapture {
/** A collection of cached types and predicates to be evaluated in the same stage. */
cached
private module Cached {
private import TaintTrackingPrivate as TaintTrackingPrivate
private import codeql.ruby.typetracking.TypeTrackerSpecific as TypeTrackerSpecific

cached
newtype TNode =
TExprNode(CfgNodes::ExprCfgNode n) { TaintTrackingPrivate::forceCachingInSameStage() } or
TExprNode(CfgNodes::ExprCfgNode n) or
TReturningNode(CfgNodes::ReturningCfgNode n) or
TSsaDefinitionExtNode(SsaImpl::DefinitionExt def) or
TCapturedVariableNode(VariableCapture::CapturedVariable v) or
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,10 @@ private CfgNodes::ExprNodes::VariableWriteAccessCfgNode variablesInPattern(
cached
private module Cached {
private import codeql.ruby.dataflow.FlowSteps as FlowSteps
private import codeql.ruby.dataflow.internal.DataFlowImplCommon as DataFlowImplCommon

cached
predicate forceCachingInSameStage() { any() }
predicate forceCachingInSameStage() { DataFlowImplCommon::forceCachingInSameStage() }

/**
* Holds if the additional step from `nodeFrom` to `nodeTo` should be included
Expand Down

0 comments on commit e417e86

Please sign in to comment.