Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 817a142

Browse files
committed
Python: Add getLocation to EssaVariable.
This may be a slightly "bogus" location to provide for ESSA variables, but it can be useful for debugging. For instance, where previously you might just see ``` SSA variable x | ... SSA variable x | ... SSA variable x | ... SSA variable x | ... SSA variable x | ... SSA variable x | ... ``` where each instance of `SSA variable x` was just a bare string, now each occurrence will tell you (via its location) _where_ this variable is being (re)defined.
1 parent 04a3c3d commit 817a142

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

  • python/ql/src/semmle/python/essa

python/ql/src/semmle/python/essa/Essa.qll

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@ class EssaVariable extends TEssaDefinition {
6161
* defined by `from ... import *` and the like.
6262
*/
6363
predicate isMetaVariable() { this.getName() = "$" }
64+
65+
/**
66+
* Gets the location of this variable.
67+
*
68+
* Yields the location of the corresponding definition of this variable.
69+
*/
70+
Location getLocation() { result = this.getDefinition().getLocation() }
6471
}
6572

6673
/*

0 commit comments

Comments
 (0)