From 76c011315531c1a0bafe3cc89e15909410a19050 Mon Sep 17 00:00:00 2001 From: Taus Brock-Nannestad Date: Sat, 24 Aug 2019 15:32:26 +0200 Subject: [PATCH 1/2] Python: Update change note for 1.22. --- change-notes/1.22/analysis-python.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/change-notes/1.22/analysis-python.md b/change-notes/1.22/analysis-python.md index f85815ffed36..3938faa99184 100644 --- a/change-notes/1.22/analysis-python.md +++ b/change-notes/1.22/analysis-python.md @@ -6,9 +6,26 @@ ### Points-to Tracking of "unknown" values from modules that are absent from the database has been improved. Particularly when an "unknown" value is used as a decorator, the decorated function is tracked. +### Loop unrolling +The extractor now unrolls a single iteration of loops that are known to run at least once. This improves analysis in cases like the following -### Impact on existing queries. +```python +if seq: + for x in seq: + y = x + y # y is defined here +``` +### Better API for function parameter annotations +Instances of the `Parameter` and `ParameterDefinition` class now have a `getAnnotation` method that returns the corresponding parameter annotation, if one exists. + +### Improvements to the Value API +The Value API has been extended with classes representing functions, classes, tuples, and other types. + +### Other improvements + +- Short flags for regexes (e.g. `re.M` for multiline regexes) are now handled correctly. +- Modules with multiple import roots no longer get multiple names. ## New queries From f08d8573c76ec71c4b09ff1f2f7e7c3c62efa23b Mon Sep 17 00:00:00 2001 From: Taus Brock-Nannestad Date: Sun, 25 Aug 2019 13:55:42 +0200 Subject: [PATCH 2/2] Address review comments and add missing notes. --- change-notes/1.22/analysis-python.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/change-notes/1.22/analysis-python.md b/change-notes/1.22/analysis-python.md index 3938faa99184..4e9a1010d7ad 100644 --- a/change-notes/1.22/analysis-python.md +++ b/change-notes/1.22/analysis-python.md @@ -20,12 +20,15 @@ if seq: Instances of the `Parameter` and `ParameterDefinition` class now have a `getAnnotation` method that returns the corresponding parameter annotation, if one exists. ### Improvements to the Value API -The Value API has been extended with classes representing functions, classes, tuples, and other types. +- The Value API has been extended with classes representing functions, classes, tuples, and other types. + +- `Value::forInt(int x)` and `Value::forString(string s)` have been added to make it easier to refer to the `Value` entities for common constants. ### Other improvements -- Short flags for regexes (e.g. `re.M` for multiline regexes) are now handled correctly. +- Short flags for regexes (for example, `re.M` for multiline regexes) are now handled correctly. - Modules with multiple import roots no longer get multiple names. +- A new `NegativeIntegerLiteral` class has been added as a subtype of `ImmutableLiteral`, so that `-1` is treated as an `ImmutableLiteral`. This means that queries looking for the use of constant integers will automatically handle negative numbers. ## New queries