File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed
javascript/ql/lib/semmle/javascript/dataflow Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -1693,7 +1693,11 @@ module DataFlow {
16931693 exists ( Expr predExpr , Expr succExpr |
16941694 pred = valueNode ( predExpr ) and succ = valueNode ( succExpr )
16951695 |
1696- predExpr = succExpr .( LogicalBinaryExpr ) .getAnOperand ( )
1696+ predExpr = succExpr .( LogicalOrExpr ) .getAnOperand ( )
1697+ or
1698+ predExpr = succExpr .( NullishCoalescingExpr ) .getAnOperand ( )
1699+ or
1700+ predExpr = succExpr .( LogicalAndExpr ) .getRightOperand ( )
16971701 or
16981702 predExpr = succExpr .( ConditionalExpr ) .getABranch ( )
16991703 or
Original file line number Diff line number Diff line change @@ -238,6 +238,26 @@ private class AnalyzedBinaryExpr extends DataFlow::AnalyzedValueNode {
238238 }
239239}
240240
241+ pragma [ nomagic]
242+ private predicate falsyValue ( AbstractValue value ) { value .getBooleanValue ( ) = false }
243+
244+ /**
245+ * Flow analysis for `&&` operators.
246+ */
247+ private class AnalyzedLogicalAndExpr extends DataFlow:: AnalyzedValueNode {
248+ override LogicalAndExpr astNode ;
249+
250+ pragma [ nomagic]
251+ private AnalyzedValueNode leftOperand ( ) { result = astNode .getLeftOperand ( ) .analyze ( ) }
252+
253+ override AbstractValue getALocalValue ( ) {
254+ result = super .getALocalValue ( )
255+ or
256+ result = this .leftOperand ( ) .getALocalValue ( ) and
257+ falsyValue ( result )
258+ }
259+ }
260+
241261/**
242262 * Gets the `n`th operand of the given `+` or `+=` expression.
243263 */
You can’t perform that action at this time.
0 commit comments