Skip to content

Commit 96b6dde

Browse files
authored
Merge pull request #16751 from aschackmull/java/sndlevelscope-fix
Java: Calculate 2nd level scopes for implicit instance accesses.
2 parents e1317dd + b8b95fd commit 96b6dde

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* A bug has been fixed in the heuristic identification of uncertain control
5+
flow, which is used to filter data flow in order to improve performance and
6+
reduce false positives. This fix means that slightly more code is identified
7+
and hence pruned from data flow.

java/ql/lib/semmle/code/java/dataflow/internal/DataFlowPrivate.qll

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ private import ContainerFlow
88
private import semmle.code.java.dataflow.FlowSteps
99
private import semmle.code.java.dataflow.FlowSummary
1010
private import semmle.code.java.dataflow.ExternalFlow
11+
private import semmle.code.java.dataflow.InstanceAccess
1112
private import FlowSummaryImpl as FlowSummaryImpl
1213
private import DataFlowNodes
1314
private import codeql.dataflow.VariableCapture as VariableCapture
@@ -710,8 +711,14 @@ class DataFlowSecondLevelScope extends TDataFlowSecondLevelScope {
710711
}
711712

712713
private Expr getRelatedExpr(Node n) {
713-
n.asExpr() = result or
714-
n.(PostUpdateNode).getPreUpdateNode().asExpr() = result
714+
n.asExpr() = result
715+
or
716+
exists(InstanceAccessExt iae | iae = n.(ImplicitInstanceAccess).getInstanceAccess() |
717+
iae.isImplicitFieldQualifier(result) or
718+
iae.isImplicitMethodQualifier(result)
719+
)
720+
or
721+
getRelatedExpr(n.(PostUpdateNode).getPreUpdateNode()) = result
715722
}
716723

717724
/** Gets the second-level scope containing the node `n`, if any. */

0 commit comments

Comments
 (0)