Skip to content

Commit 3807da0

Browse files
committed
unified: Also include declaration site access
1 parent 7c7c9ed commit 3807da0

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ private module LocalNameBindingInput implements LocalNameBindingInputSig<Locatio
184184
override AstNode getElse() { none() }
185185
}
186186

187-
private predicate bindingContext(AstNode pattern, AstNode scope) {
187+
additional predicate bindingContext(AstNode pattern, AstNode scope) {
188188
exists(SiblingShadowingDecl decl |
189189
scope = decl and
190190
pattern = decl.getPattern()
@@ -345,11 +345,13 @@ class PotentialLocalNameAccess extends Identifier {
345345
or
346346
this = any(NamedTypeExpr e | not exists(e.getQualifier())).getName()
347347
or
348-
this = any(FunctionDeclaration f).getName()
349-
// TODO: include other declaration kinds here
348+
LocalNameBindingInput::bindingContext(this, _)
350349
}
351350

352351
LocalName getLocalName() { result = this.(LocalNameBindingOutput::LocalAccess).getLocal() }
353352

354353
string getName() { result = this.getValue() }
354+
355+
/** Holds if this is one of the declaration sites for a name, such as the `x` in `let x = 123`. */
356+
predicate isDeclarationSite() { LocalNameBindingInput::bindingContext(this, _) }
355357
}

0 commit comments

Comments
 (0)