Skip to content

Commit e9da755

Browse files
committed
unified: Fix getEnclosingCallable for LocalVariableRef
This should be taken from the CFG node instead of the AST node
1 parent 5f6c461 commit e9da755

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

unified/ql/lib/codeql/unified/internal/dataflow/DataFlowNode.qll

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,7 @@ class Node extends TDataFlowNode {
177177
AstNode getWrappedAstNode() {
178178
result = this.asExpr() or
179179
this = TStrictlyIncomingValue(result) or
180-
this = TExprPostUpdateNode(result) or
181-
this = TLocalVariableRefNode(result, _, _)
180+
this = TExprPostUpdateNode(result)
182181
}
183182

184183
/** Get a string representation of this element. */
@@ -221,6 +220,11 @@ class Node extends TDataFlowNode {
221220
Location getLocation() {
222221
result = this.getWrappedAstNode().getLocation()
223222
or
223+
exists(AstNode repr |
224+
this.isLocalVariableRef(repr, _, _) and
225+
result = repr.getLocation()
226+
)
227+
or
224228
exists(LocalSsaDataFlowOutput::SsaNode node |
225229
this = TLocalSsaNode(node) and
226230
result = node.getLocation()
@@ -241,6 +245,12 @@ class Node extends TDataFlowNode {
241245
DataFlowCallable getEnclosingCallableEx() {
242246
result.asSourceCallable() = this.getWrappedAstNode().getEnclosingCallable()
243247
or
248+
exists(AstNode repr, LocalVariable var, VariableRefKind kind, ControlFlowNode cfgNode |
249+
this.isLocalVariableRef(repr, var, kind) and
250+
performsVariableAccess(repr, var, kind, cfgNode) and
251+
result.asSourceCallable() = cfgNode.getEnclosingCallable()
252+
)
253+
or
244254
exists(LocalSsaDataFlowOutput::SsaNode node |
245255
this = TLocalSsaNode(node) and
246256
result.asSourceCallable() = node.getSourceVariable().getDeclaringCallable()

0 commit comments

Comments
 (0)