File tree Expand file tree Collapse file tree
src/semmle/javascript/dataflow/internal
test/query-tests/Statements/UselessConditional Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -41,6 +41,27 @@ private class SsaVarAccessAnalysis extends DataFlow::AnalyzedValueNode {
4141 override AbstractValue getALocalValue ( ) { result = def .getAnRhsValue ( ) }
4242}
4343
44+ /**
45+ * Flow analysis for accesses to SSA variables.
46+ *
47+ * Unlike `SsaVarAccessAnalysis`, this only contributes to `getAValue()`, not `getALocalValue()`.
48+ */
49+ private class SsaVarAccessWithNonLocalAnalysis extends SsaVarAccessAnalysis {
50+ DataFlow:: AnalyzedValueNode src ;
51+
52+ SsaVarAccessWithNonLocalAnalysis ( ) {
53+ exists ( VarDef varDef |
54+ varDef = def .( SsaExplicitDefinition ) .getDef ( ) and
55+ varDef .getSource ( ) .flow ( ) = src and
56+ src instanceof CallWithNonLocalAnalyzedReturnFlow and
57+ // avoid relating `v` and `f()` in `var {v} = f();`
58+ not varDef .getTarget ( ) instanceof DestructuringPattern
59+ )
60+ }
61+
62+ override AbstractValue getAValue ( ) { result = src .getAValue ( ) }
63+ }
64+
4465/**
4566 * Flow analysis for `VarDef`s.
4667 */
Original file line number Diff line number Diff line change 2626| UselessConditional.js:135:6:135:32 | constan ... ined1() | This call to constantFalseOrUndefined1 always evaluates to false. |
2727| UselessConditional.js:139:6:139:32 | constan ... ined2() | This call to constantFalseOrUndefined2 always evaluates to false. |
2828| UselessConditional.js:148:6:148:8 | p() | This call to p always evaluates to true. |
29+ | UselessConditional.js:151:6:151:6 | v | This use of variable 'v' always evaluates to true. |
2930| UselessConditional.js:163:5:163:17 | findOrThrow() | This call to findOrThrow always evaluates to true. |
31+ | UselessConditional.js:166:6:166:6 | v | This use of variable 'v' always evaluates to true. |
3032| UselessConditionalGood.js:58:12:58:13 | x2 | This use of variable 'x2' always evaluates to false. |
3133| UselessConditionalGood.js:69:12:69:13 | xy | This use of variable 'xy' always evaluates to false. |
3234| UselessConditionalGood.js:85:12:85:13 | xy | This use of variable 'xy' always evaluates to false. |
You can’t perform that action at this time.
0 commit comments