Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.

Commit 5de55d0

Browse files
author
Sauyon Lee
authored
Merge pull request #273 from max-schaefer/unresolved-reference
Speed up `unresolvedReference`.
2 parents 7e65575 + f6da34b commit 5de55d0

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

ql/src/semmle/go/dataflow/SSA.qll

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,22 @@ class SsaSourceVariable extends LocalVariable {
4242
*/
4343
private predicate unresolvedReference(string name, FuncDef fn) {
4444
exists(Ident unresolved |
45-
unresolved.getName() = name and
46-
unresolved instanceof ReferenceExpr and
45+
unresolvedIdentifier(unresolved, name) and
4746
not unresolved = any(SelectorExpr sel).getSelector() and
48-
not unresolved.refersTo(_) and
4947
fn = unresolved.getEnclosingFunction()
5048
)
5149
}
5250

51+
/**
52+
* Holds if `id` is an unresolved identifier with the given `name`.
53+
*/
54+
pragma[noinline]
55+
private predicate unresolvedIdentifier(Ident id, string name) {
56+
id.getName() = name and
57+
id instanceof ReferenceExpr and
58+
not id.refersTo(_)
59+
}
60+
5361
/**
5462
* An SSA variable.
5563
*/

0 commit comments

Comments
 (0)