Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruby: Collapse DIL stages #14283

Merged
merged 1 commit into from
Sep 22, 2023
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 @@ -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