Skip to content

Commit 6dd3dbd

Browse files
committed
unified: Replace getDefiningNode() with isDeclarationSite()
1 parent 3807da0 commit 6dd3dbd

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,9 +316,6 @@ module Public {
316316
/** Gets the location of this local name's first declaration */
317317
Location getLocation() { result = super.getLocation() }
318318

319-
/** Gets the AST node defining this local name. */
320-
AstNode getDefiningNode() { result = super.getDefiningNode() }
321-
322319
/** Gets the name of this local, as a string. */
323320
string getName() { result = super.getName() }
324321
}

unified/ql/test/library-tests/local-name-binding/test.ql

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,15 @@ module VariableAccessTest implements TestSig {
3737
)
3838
}
3939

40+
private PotentialLocalNameAccess getUniqueDeclarationSite(LocalName name) {
41+
result =
42+
unique(PotentialLocalNameAccess ac | ac.isDeclarationSite() and ac.getLocalName() = name)
43+
}
44+
4045
predicate hasActualResult(Location location, string element, string tag, string value) {
4146
exists(PotentialLocalNameAccess va, LocalName v |
4247
v = va.getLocalName() and
43-
not va = v.getDefiningNode() and
48+
not va = getUniqueDeclarationSite(v) and // no need to annotate declaration site, if there is only one
4449
location = va.getLocation() and
4550
element = va.toString() and
4651
decl(v, value) and

0 commit comments

Comments
 (0)