Skip to content

Commit 25ef3ed

Browse files
committed
combine stages by introducing extended stages
1 parent aeb1314 commit 25ef3ed

19 files changed

+375
-12
lines changed

javascript/ql/src/javascript.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import semmle.javascript.Errors
2525
import semmle.javascript.ES2015Modules
2626
import semmle.javascript.Expr
2727
import semmle.javascript.Extend
28+
import semmle.javascript.ExtendedStaging
2829
import semmle.javascript.Externs
2930
import semmle.javascript.Files
3031
import semmle.javascript.Functions

javascript/ql/src/semmle/javascript/AMD.qll

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,10 @@ private class AmdDependencyImport extends Import {
298298
*/
299299
class AmdModule extends Module {
300300
cached
301-
AmdModule() { exists(unique(AmdModuleDefinition def | amdModuleTopLevel(def, this))) }
301+
AmdModule() {
302+
ExtendedStaging::DataFlowStage::ref() and
303+
exists(unique(AmdModuleDefinition def | amdModuleTopLevel(def, this)))
304+
}
302305

303306
/** Gets the definition of this module. */
304307
AmdModuleDefinition getDefine() { amdModuleTopLevel(result, this) }

javascript/ql/src/semmle/javascript/AST.qll

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class ASTNode extends @ast_node, NodeInStmtContainer {
7575

7676
/** Gets the toplevel syntactic unit to which this element belongs. */
7777
cached
78-
TopLevel getTopLevel() { result = getParent().getTopLevel() }
78+
TopLevel getTopLevel() { ExtendedStaging::Ast::ref() and result = getParent().getTopLevel() }
7979

8080
/**
8181
* Gets the `i`th child node of this node.
@@ -119,7 +119,7 @@ class ASTNode extends @ast_node, NodeInStmtContainer {
119119

120120
/** Gets the parent node of this node, if any. */
121121
cached
122-
ASTNode getParent() { this = result.getAChild() }
122+
ASTNode getParent() { ExtendedStaging::Ast::ref() and this = result.getAChild() }
123123

124124
/** Gets the first control flow node belonging to this syntactic entity. */
125125
ControlFlowNode getFirstControlFlowNode() { result = this }
@@ -135,6 +135,7 @@ class ASTNode extends @ast_node, NodeInStmtContainer {
135135
*/
136136
cached
137137
private predicate isAmbientInternal() {
138+
ExtendedStaging::Ast::ref() and
138139
getParent().isAmbientInternal()
139140
or
140141
not isAmbientTopLevel(getTopLevel()) and
@@ -186,7 +187,9 @@ class ASTNode extends @ast_node, NodeInStmtContainer {
186187
* Holds if the given file is a `.d.ts` file.
187188
*/
188189
cached
189-
private predicate isAmbientTopLevel(TopLevel tl) { tl.getFile().getBaseName().matches("%.d.ts") }
190+
private predicate isAmbientTopLevel(TopLevel tl) {
191+
ExtendedStaging::Ast::ref() and tl.getFile().getBaseName().matches("%.d.ts")
192+
}
190193

191194
/**
192195
* A toplevel syntactic unit; that is, a stand-alone script, an inline script

javascript/ql/src/semmle/javascript/BasicBlocks.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ private module Internal {
6060

6161
cached
6262
predicate useAt(BasicBlock bb, int i, Variable v, VarUse u) {
63-
v = u.getVariable() and bbIndex(bb, u, i)
63+
ExtendedStaging::BasicBlocks::ref() and
64+
v = u.getVariable() and
65+
bbIndex(bb, u, i)
6466
}
6567

6668
cached

javascript/ql/src/semmle/javascript/Expr.qll

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class Expr extends @expr, ExprOrStmt, ExprOrType, AST::ValueNode {
109109

110110
/** Gets the constant string value this expression evaluates to, if any. */
111111
cached
112-
string getStringValue() { result = getStringValue(this) }
112+
string getStringValue() { ExtendedStaging::Ast::ref() and result = getStringValue(this) }
113113

114114
/** Holds if this expression is impure, that is, its evaluation could have side effects. */
115115
predicate isImpure() { any() }
@@ -257,6 +257,7 @@ class Expr extends @expr, ExprOrStmt, ExprOrType, AST::ValueNode {
257257

258258
cached
259259
private DataFlow::Node getCatchParameterFromStmt(Stmt stmt) {
260+
ExtendedStaging::DataFlowStage::ref() and
260261
result =
261262
DataFlow::parameterNode(stmt.getEnclosingTryCatchStmt().getACatchClause().getAParameter())
262263
}
@@ -806,7 +807,9 @@ class FunctionExpr extends @function_expr, Expr, Function {
806807
/** Gets the statement in which this function expression appears. */
807808
override Stmt getEnclosingStmt() { result = Expr.super.getEnclosingStmt() }
808809

809-
override StmtContainer getEnclosingContainer() { result = Expr.super.getContainer() }
810+
override StmtContainer getEnclosingContainer() {
811+
ExtendedStaging::Ast::ref() and result = Expr.super.getContainer()
812+
}
810813

811814
override predicate isImpure() { none() }
812815

0 commit comments

Comments
 (0)