JS: Use defSourceNode from getRhsNode

This commit is contained in:
Asger F
2019-07-19 13:02:48 +01:00
parent 747c320c35
commit 28efadea73
4 changed files with 17 additions and 15 deletions

View File

@@ -527,20 +527,7 @@ class SsaExplicitDefinition extends SsaDefinition, TExplicitDef {
* if any.
*/
DataFlow::Node getRhsNode() {
exists(VarDef def | def = getDef() |
result = def.getSource().flow()
or
exists(VarRef ref |
ref = getSourceVariable().getAReference() and
def.getTarget().(BindingPattern).getABindingVarRef() = ref and
result = DataFlow::patternPropRead(ref)
)
or
result = DataFlow::parameterNode(def)
or
// Handle class, function, namespace, and enum declaration statement
result.getAstNode() = def.(Stmt)
)
result = DataFlow::defSourceNode(getDef(), getSourceVariable())
}
}

View File

@@ -1318,10 +1318,12 @@ module DataFlow {
}
/**
* INTERNAL. DO NOT USE.
*
* Gets the data flow node representing the source of the definition of `v` at `def`,
* if any.
*/
private Node defSourceNode(VarDef def, SsaSourceVariable v) {
Node defSourceNode(VarDef def, SsaSourceVariable v) {
exists(BindingPattern lhs, VarRef r |
lhs = def.getTarget() and r = lhs.getABindingVarRef() and r.getVariable() = v
|