mirror of
https://github.com/github/codeql.git
synced 2026-05-02 04:05:14 +02:00
JS: Improve perf of GlobalVarUse.isIncomplete
This commit is contained in:
@@ -1533,7 +1533,7 @@ module DataFlow {
|
||||
not e.(Parameter).isRestParameter()
|
||||
)
|
||||
or
|
||||
nd.(AnalyzedParameter).hasIncompleteness(cause)
|
||||
nd.(AnalyzedNode).hasAdditionalIncompleteness(cause)
|
||||
or
|
||||
nd.asExpr() instanceof ExternalModuleReference and
|
||||
cause = "import"
|
||||
|
||||
@@ -156,6 +156,14 @@ class AnalyzedNode extends DataFlow::Node {
|
||||
|
||||
/** Holds if the flow analysis can infer at least one abstract value for this node. */
|
||||
predicate hasFlow() { exists(getAValue()) }
|
||||
|
||||
/**
|
||||
* INTERNAL. Use `isIncomplete()` instead.
|
||||
*
|
||||
* Subclasses may override this to contribute additional incompleteness to this node
|
||||
* without overriding `isIncomplete()`.
|
||||
*/
|
||||
predicate hasAdditionalIncompleteness(DataFlow::Incompleteness cause) { none() }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,13 +34,7 @@ class AnalyzedParameter extends AnalyzedValueNode {
|
||||
result = astNode.getDefault().analyze().getALocalValue()
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this node should be considered incomplete with the given cause.
|
||||
*
|
||||
* For performance reasons, this is not an override of `isIncomplete`, but is
|
||||
* explicitly included in that predicate.
|
||||
*/
|
||||
predicate hasIncompleteness(DataFlow::Incompleteness cause) {
|
||||
override predicate hasAdditionalIncompleteness(DataFlow::Incompleteness cause) {
|
||||
getFunction().isIncomplete(cause)
|
||||
or
|
||||
not getFunction().argumentPassing(astNode, _) and
|
||||
|
||||
@@ -387,9 +387,7 @@ private class AnalyzedGlobalVarUse extends DataFlow::AnalyzedValueNode {
|
||||
result.getBase().analyze().getALocalValue() instanceof AbstractGlobalObject
|
||||
}
|
||||
|
||||
override predicate isIncomplete(DataFlow::Incompleteness reason) {
|
||||
super.isIncomplete(reason)
|
||||
or
|
||||
override predicate hasAdditionalIncompleteness(DataFlow::Incompleteness reason) {
|
||||
clobberedProp(gv, reason)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user