Skip to content

Commit

Permalink
Add location for implicitly declared variables
Browse files Browse the repository at this point in the history
  • Loading branch information
owen-mc committed Apr 6, 2024
1 parent 828b811 commit 3614a62
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions go/ql/lib/semmle/go/Scopes.qll
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,16 @@ class Entity extends @object {
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
// take the location of the declaration if there is one
this.getDeclaration().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
or
// otherwise fall back on dummy location
not exists(this.getDeclaration()) and
filepath = "" and
startline = 0 and
startcolumn = 0 and
endline = 0 and
endcolumn = 0
if this.hasRealLocationInfo(_, _, _, _, _)
then this.hasRealLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
else (
// otherwise fall back on dummy location
filepath = "" and
startline = 0 and
startcolumn = 0 and
endline = 0 and
endcolumn = 0
)
}
}

Expand Down

0 comments on commit 3614a62

Please sign in to comment.