Skip to content

Commit 480ae61

Browse files
authored
Merge pull request #21116 from github/tausbn/python-add-dataflow-overlay-annotations
Add `overlay[local]` annotations
2 parents 8947f7a + 3d4785f commit 480ae61

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+225
-21
lines changed

python/ql/lib/analysis/DefinitionTracking.qll

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -471,11 +471,10 @@ Definition getUniqueDefinition(Expr use) {
471471
not result = TLocalDefinition(use)
472472
}
473473

474-
/** A helper class to get suitable locations for attributes */
475-
class NiceLocationExpr extends Expr {
476-
/** Gets a textual representation of this element. */
477-
override string toString() { result = this.(Expr).toString() }
474+
final class FinalExpr = Expr;
478475

476+
/** A helper class to get suitable locations for attributes */
477+
class NiceLocationExpr extends FinalExpr {
479478
/**
480479
* Holds if this element is at the specified location.
481480
* The location spans column `bc` of line `bl` to
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
category: majorAnalysis
3+
---
4+
5+
- The CodeQL Python libraries have been updated to be compatible with overlay evaluation. This should result in a significant speedup on analyses for which a base database already exists. Note that it may be necessary to add `overlay[local?] module;` to user-managed libraries that extend classes that are now marked as `overlay[local]`.

python/ql/lib/semmle/python/ApiGraphs.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,7 @@ module API {
451451
* allowing this predicate to be used in a negative
452452
* context when constructing new nodes.
453453
*/
454+
overlay[local]
454455
predicate moduleImportExists(string m) {
455456
Impl::isImported(m) and
456457
// restrict `moduleImport` so it will never give results for a dotted name. Note
@@ -695,6 +696,7 @@ module API {
695696
*
696697
* This is determined syntactically.
697698
*/
699+
overlay[local]
698700
cached
699701
predicate isImported(string name) {
700702
// Ignore the following module name for Python 2, as we alias `__builtin__` to `builtins` elsewhere

python/ql/lib/semmle/python/AstExtended.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
overlay[local]
2+
module;
3+
14
import python
25
private import semmle.python.internal.CachedStages
36

python/ql/lib/semmle/python/AstGenerated.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* WARNING: Any modifications to this file will be lost.
44
* Relations can be changed by modifying master.py.
55
*/
6+
overlay[local]
7+
module;
68

79
import python
810

python/ql/lib/semmle/python/Class.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
/**
22
* Provides classes representing Python classes.
33
*/
4+
overlay[local]
5+
module;
46

57
import python
68

python/ql/lib/semmle/python/Comment.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
/**
22
* Provides classes representing comments in Python.
33
*/
4+
overlay[local]
5+
module;
46

57
import python
68

python/ql/lib/semmle/python/Comprehensions.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
overlay[local]
2+
module;
3+
14
import python
25

36
/** The base class for list, set and dictionary comprehensions, and generator expressions. */

python/ql/lib/semmle/python/Constants.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/** Standard builtin types and modules */
2+
overlay[local]
3+
module;
24

35
import python
46

python/ql/lib/semmle/python/Exprs.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
overlay[local]
2+
module;
3+
14
private import python
25
private import semmle.python.internal.CachedStages
36

0 commit comments

Comments
 (0)