mirror of
https://github.com/github/codeql.git
synced 2026-04-29 02:35:15 +02:00
JS: support default destructuring values in the dataflow graph
This commit is contained in:
@@ -1004,15 +1004,19 @@ module DataFlow {
|
||||
private Node defSourceNode(VarDef def, SsaSourceVariable v) {
|
||||
exists(BindingPattern lhs, VarRef r |
|
||||
lhs = def.getTarget() and r = lhs.getABindingVarRef() and r.getVariable() = v
|
||||
|
|
||||
|
|
||||
// follow one step of the def-use chain if the lhs is a simple variable reference
|
||||
lhs = r and
|
||||
result = TValueNode(defSourceNode(def))
|
||||
or
|
||||
// handle destructuring assignments
|
||||
exists(PropertyPattern pp | r = pp.getValuePattern() | result = TPropNode(pp))
|
||||
exists(PropertyPattern pp | r = pp.getValuePattern() |
|
||||
result = TPropNode(pp) or result = pp.getDefault().flow()
|
||||
)
|
||||
or
|
||||
result = TElementPatternNode(_, r)
|
||||
or
|
||||
exists(ArrayPattern ap, int i | ap.getElement(i) = r and result = ap.getDefault(i).flow())
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -127,14 +127,18 @@
|
||||
| tst.js:108:6:108:38 | v1c | tst.js:109:14:109:16 | v1c |
|
||||
| tst.js:108:7:108:9 | v1a | tst.js:108:6:108:38 | v1a |
|
||||
| tst.js:108:12:108:20 | v1b = o1b | tst.js:108:6:108:38 | v1b |
|
||||
| tst.js:108:18:108:20 | o1b | tst.js:108:6:108:38 | v1b |
|
||||
| tst.js:108:23:108:31 | v1c = o1c | tst.js:108:6:108:38 | v1c |
|
||||
| tst.js:108:29:108:31 | o1c | tst.js:108:6:108:38 | v1c |
|
||||
| tst.js:108:36:108:38 | o1d | tst.js:108:6:108:32 | {v1a, v ... = o1c} |
|
||||
| tst.js:111:6:111:38 | v2a | tst.js:112:2:112:4 | v2a |
|
||||
| tst.js:111:6:111:38 | v2b | tst.js:112:8:112:10 | v2b |
|
||||
| tst.js:111:6:111:38 | v2c | tst.js:112:14:112:16 | v2c |
|
||||
| tst.js:111:7:111:9 | v2a | tst.js:111:6:111:38 | v2a |
|
||||
| tst.js:111:12:111:14 | v2b | tst.js:111:6:111:38 | v2b |
|
||||
| tst.js:111:18:111:20 | o2b | tst.js:111:6:111:38 | v2b |
|
||||
| tst.js:111:23:111:25 | v2c | tst.js:111:6:111:38 | v2c |
|
||||
| tst.js:111:29:111:31 | o2c | tst.js:111:6:111:38 | v2c |
|
||||
| tst.js:111:36:111:38 | o2d | tst.js:111:6:111:32 | [v2a, v ... = o2c] |
|
||||
| tst.ts:1:1:1:1 | A | tst.ts:1:11:1:11 | A |
|
||||
| tst.ts:1:1:1:1 | A | tst.ts:7:1:7:0 | A |
|
||||
|
||||
Reference in New Issue
Block a user