Skip to content

Commit 5213c51

Browse files
committed
JS: Improve perf of GlobalVarUse.isIncomplete
1 parent 7d99230 commit 5213c51

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

javascript/ql/src/semmle/javascript/dataflow/DataFlow.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1533,7 +1533,7 @@ module DataFlow {
15331533
not e.(Parameter).isRestParameter()
15341534
)
15351535
or
1536-
nd.(AnalyzedParameter).hasIncompleteness(cause)
1536+
nd.(AnalyzedNode).hasAdditionalIncompleteness(cause)
15371537
or
15381538
nd.asExpr() instanceof ExternalModuleReference and
15391539
cause = "import"

javascript/ql/src/semmle/javascript/dataflow/TypeInference.qll

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,14 @@ class AnalyzedNode extends DataFlow::Node {
156156

157157
/** Holds if the flow analysis can infer at least one abstract value for this node. */
158158
predicate hasFlow() { exists(getAValue()) }
159+
160+
/**
161+
* INTERNAL. Use `isIncomplete()` instead.
162+
*
163+
* Subclasses may override this to contribute additional incompleteness to this node
164+
* without overriding `isIncomplete()`.
165+
*/
166+
predicate hasAdditionalIncompleteness(DataFlow::Incompleteness cause) { none() }
159167
}
160168

161169
/**

javascript/ql/src/semmle/javascript/dataflow/internal/AnalyzedParameters.qll

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,7 @@ class AnalyzedParameter extends AnalyzedValueNode {
3434
result = astNode.getDefault().analyze().getALocalValue()
3535
}
3636

37-
/**
38-
* Whether this node should be considered incomplete with the given cause.
39-
*
40-
* For performance reasons, this is not an override of `isIncomplete`, but is
41-
* explicitly included in that predicate.
42-
*/
43-
predicate hasIncompleteness(DataFlow::Incompleteness cause) {
37+
override predicate hasAdditionalIncompleteness(DataFlow::Incompleteness cause) {
4438
getFunction().isIncomplete(cause)
4539
or
4640
not getFunction().argumentPassing(astNode, _) and

javascript/ql/src/semmle/javascript/dataflow/internal/VariableTypeInference.qll

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -387,9 +387,7 @@ private class AnalyzedGlobalVarUse extends DataFlow::AnalyzedValueNode {
387387
result.getBase().analyze().getALocalValue() instanceof AbstractGlobalObject
388388
}
389389

390-
override predicate isIncomplete(DataFlow::Incompleteness reason) {
391-
super.isIncomplete(reason)
392-
or
390+
override predicate hasAdditionalIncompleteness(DataFlow::Incompleteness reason) {
393391
clobberedProp(gv, reason)
394392
}
395393

0 commit comments

Comments
 (0)