Skip to content

Commit f730e9f

Browse files
committed
unified: Join on name and scope simultaneously
1 parent e7772a2 commit f730e9f

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

‎shared/namebinding/codeql/namebinding/LocalNameBinding.qll‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,10 @@ module LocalNameBinding<LocationSig Location, LocalNameBindingInputSig<Location>
484484
override string getName() { result = name }
485485

486486
override Location getLocation() { result = scope.getLocation() }
487+
488+
/** Holds if this variable has the given name and scope. */
489+
pragma[nomagic]
490+
predicate hasNameAndScope(string name_, AstNode scope_) { name = name_ and scope = scope_ }
487491
}
488492

489493
/** A local access. */

‎unified/ql/lib/codeql/unified/internal/LocalNameBinding.qll‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ private module LocalNameBindingInput implements LocalNameBindingInputSig<Locatio
326326
)
327327
}
328328

329+
pragma[nomagic]
329330
additional predicate implicitDeclInScope(string name, AstNode scope, boolean isLocalVariable) {
330331
exists(Callable callable |
331332
isLocalVariable = true and
@@ -407,8 +408,7 @@ module Public {
407408
or
408409
// For implicitly-declared locals we can't expect to find a binding. Check 'implicitDeclInScope' directly.
409410
exists(AstNode scope, string name |
410-
this.getName() = name and
411-
this.(LocalNameBindingOutput::ImplicitLocal).getScope() = scope and
411+
this.(LocalNameBindingOutput::ImplicitLocal).hasNameAndScope(name, scope) and
412412
LocalNameBindingInput::implicitDeclInScope(name, scope, true)
413413
)
414414
}

0 commit comments

Comments
 (0)