mirror of
https://github.com/github/codeql.git
synced 2026-04-29 18:55:14 +02:00
JS: move default parameter values to the DefUse graph
This commit is contained in:
@@ -12,6 +12,7 @@ import javascript
|
||||
* <tr><td><code>x = y</code><td><code>x = y</code><td><code>x</code><td><code>y</code></tr>
|
||||
* <tr><td><code>var a = b</code><td><code>var a = b</code><td><code>a</code><td><code>b</code></tr>
|
||||
* <tr><td><code>function f { ... }</code><td><code>f</code><td><code>f</code><td><code>function f { ... }</code></tr>
|
||||
* <tr><td><code>function f ( x = y ){ ... }</code><td><code>x</code><td><code>x</code><td><code>y</code></tr>
|
||||
* <tr><td><code>class C { ... }</code><td><code>C</code><td><code>C</code><td><code>class C { ... }</code></tr>
|
||||
* <tr><td><code>namespace N { ... }</code><td><code>N</code><td><code>N</code><td><code>namespace N { ... }</code></tr>
|
||||
* <tr><td><code>enum E { ... }</code><td><code>E</code><td><code>E</code><td><code>enum E { ... }</code></tr>
|
||||
@@ -42,6 +43,8 @@ private predicate defn(ControlFlowNode def, Expr lhs, AST::ValueNode rhs) {
|
||||
exists(EnumMember member | def = member.getIdentifier() |
|
||||
lhs = def and rhs = member.getInitializer()
|
||||
)
|
||||
or
|
||||
lhs = def and def.(Parameter).getDefault() = rhs
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -104,7 +104,12 @@ module RangeAnalysis {
|
||||
pragma[noinline]
|
||||
private predicate hasUniquePredecessor(DataFlow::Node node) {
|
||||
isRelevant(node) and
|
||||
strictcount(node.getAPredecessor()) = 1
|
||||
strictcount(node.getAPredecessor()) = 1 and
|
||||
// exclude parameters with default values
|
||||
not exists (Parameter p |
|
||||
DataFlow::parameterNode(p) = node and
|
||||
exists(p.getDefault())
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -143,7 +143,7 @@ private class AnalyzedParameter extends AnalyzedVarDef, @vardecl {
|
||||
|
||||
override DataFlow::AnalyzedNode getRhs() {
|
||||
getFunction().argumentPassing(this, result.asExpr()) or
|
||||
result = this.(Parameter).getDefault().analyze()
|
||||
result = AnalyzedVarDef.super.getRhs()
|
||||
}
|
||||
|
||||
override AbstractValue getAnRhsValue() {
|
||||
|
||||
Reference in New Issue
Block a user