Skip to content

Static analyzer cherry picks #21 #2763

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

SavchenkoValeriy
Copy link

Clang Static Analyzer is traditionally kept reasonably fresh on stable branches through continuous cherry-picking.

SavchenkoValeriy and others added 8 commits March 30, 2021 18:19
Additionally, this patch puts an assertion checking for feasible
constraints in every place where constraints are assigned to states.

Differential Revision: https://reviews.llvm.org/D98948

(cherry picked from commit 3085bda)
ImmutableSet doesn't seem like the perfect fit for the RangeSet
data structure.  It is good for saving memory in a persistent
setting, but not for the case when the population of the container
is tiny.  This commit replaces RangeSet implementation and
redesigns the most common operations to be more efficient.

Differential Revision: https://reviews.llvm.org/D86465

(cherry picked from commit 02b51e5)
(cherry picked from commit f8a850c)
Currently, we infer 0 if the divisible of the modulo op is 0:
  int a = x < 0; // a can be 0
  int b = a % y; // b is either 1 % sym or 0
However, we don't when the op is / :
  int a = x < 0; // a can be 0
  int b = a / y; // b is either 1 / sym or 0 / sym

This commit fixes the discrepancy.

Differential Revision: https://reviews.llvm.org/D99343

(cherry picked from commit 015c398)
It makes sense to track rvalue expressions in the case of special
concrete integer values. The most notable special value is zero (later
we may find other values). By tracking the origin of 0, we can provide a
better explanation for users e.g. in case of division by 0 warnings.
When the divisor is a product of a multiplication then now we can show
which operand (or both) was (were) zero and why.

Differential Revision: https://reviews.llvm.org/D99344

(cherry picked from commit efa7df1)
`allocClassWithName` allocates an object with the given type.
The type is actually provided as a string argument (type's name).
This creates a possibility for not particularly useful warnings
from the analyzer.

In order to combat with those, this patch checks for casts of the
`allocClassWithName` results to types mentioned directly as its
argument.  All other uses of this method should be reasoned about
as before.

rdar://72165694

Differential Revision: https://reviews.llvm.org/D99500

(cherry picked from commit 9037730)
rdar://75020762

Differential Revision: https://reviews.llvm.org/D99274

(cherry picked from commit af7e1f0)
@SavchenkoValeriy SavchenkoValeriy requested a review from haoNoQ March 30, 2021 15:27
@SavchenkoValeriy
Copy link
Author

@swift-ci test

@SavchenkoValeriy SavchenkoValeriy merged commit df76373 into swiftlang:apple/stable/20210107 Apr 1, 2021
@SavchenkoValeriy SavchenkoValeriy deleted the april_2021_analyzer_cherry_picks branch April 1, 2021 06:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants