Merge pull request #5382 from erik-krogh/moreCache

Approved by asgerf
This commit is contained in:
CodeQL CI
2021-03-16 05:53:03 -07:00
committed by GitHub
5 changed files with 18 additions and 2 deletions

View File

@@ -119,7 +119,8 @@ private predicate bbIPostDominates(BasicBlock dom, BasicBlock bb) =
* At the database level, a basic block is represented by its first control flow node.
*/
class BasicBlock extends @cfg_node, NodeInStmtContainer {
BasicBlock() { startsBB(this) }
cached
BasicBlock() { Stages::BasicBlocks::ref() and startsBB(this) }
/** Gets a basic block succeeding this one. */
BasicBlock getASuccessor() { succBB(this, result) }

View File

@@ -627,6 +627,7 @@ abstract class SsaPseudoDefinition extends SsaImplicitDefinition {
/**
* Gets an input of this pseudo-definition.
*/
cached
abstract SsaVariable getAnInput();
override VarDef getAContributingVarDef() {
@@ -649,6 +650,7 @@ class SsaPhiNode extends SsaPseudoDefinition, TPhi {
/**
* Gets the input to this phi node coming from the given predecessor block.
*/
cached
SsaVariable getInputFromBlock(BasicBlock bb) {
bb = getBasicBlock().getAPredecessor() and
result = getDefReachingEndOf(bb, getSourceVariable())

View File

@@ -149,6 +149,7 @@ module DataFlow {
* For more information, see
* [Locations](https://help.semmle.com/QL/learn-ql/ql/locations.html).
*/
cached
predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
@@ -171,6 +172,7 @@ module DataFlow {
int getEndColumn() { hasLocationInfo(_, _, _, _, result) }
/** Gets a textual representation of this element. */
cached
string toString() { none() }
/**
@@ -294,12 +296,13 @@ module DataFlow {
override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
Stages::DataFlowStage::ref() and
astNode.getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
override File getFile() { result = astNode.getFile() }
override string toString() { result = astNode.toString() }
override string toString() { Stages::DataFlowStage::ref() and result = astNode.toString() }
}
/**

View File

@@ -16,6 +16,7 @@
*/
import javascript
private import semmle.javascript.internal.CachedStages
/**
* A representation of a property name that is either statically known or is
@@ -88,7 +89,9 @@ class AccessPath extends TAccessPath {
/**
* Gets an expression in `bb` represented by this access path.
*/
cached
Expr getAnInstanceIn(BasicBlock bb) {
Stages::DataFlowStage::ref() and
exists(SsaVariable var |
this = MkSsaRoot(var) and
result = getARefinementOf*(var).getAUseIn(bb)

View File

@@ -24,6 +24,7 @@ import javascript
private import StmtContainers
private import semmle.javascript.dataflow.internal.PreCallGraphStep
private import semmle.javascript.dataflow.internal.FlowSteps
private import semmle.javascript.dataflow.internal.AccessPaths
/**
* Contains a `cached module` for each stage.
@@ -126,6 +127,12 @@ module Stages {
exists(any(Expr e).getExceptionTarget())
or
exists(DataFlow::ssaDefinitionNode(_))
or
any(DataFlow::Node node).hasLocationInfo(_, _, _, _, _)
or
exists(any(DataFlow::Node node).toString())
or
exists(any(AccessPath a).getAnInstanceIn(_))
}
}