diff --git a/ql/src/semmle/go/dataflow/SSA.qll b/ql/src/semmle/go/dataflow/SSA.qll index 4f31c197ef2..519b281893a 100644 --- a/ql/src/semmle/go/dataflow/SSA.qll +++ b/ql/src/semmle/go/dataflow/SSA.qll @@ -42,14 +42,22 @@ class SsaSourceVariable extends LocalVariable { */ private predicate unresolvedReference(string name, FuncDef fn) { exists(Ident unresolved | - unresolved.getName() = name and - unresolved instanceof ReferenceExpr and + unresolvedIdentifier(unresolved, name) and not unresolved = any(SelectorExpr sel).getSelector() and - not unresolved.refersTo(_) and fn = unresolved.getEnclosingFunction() ) } +/** + * Holds if `id` is an unresolved identifier with the given `name`. + */ +pragma[noinline] +private predicate unresolvedIdentifier(Ident id, string name) { + id.getName() = name and + id instanceof ReferenceExpr and + not id.refersTo(_) +} + /** * An SSA variable. */