This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] Fix assertion failure after getKnownValue call
ClosedPublic

Authored by martong on Jun 8 2022, 3:16 AM.

Details

Summary

Depends on D126560. getKnownValue has been changed by the parent patch
in a way that simplification was removed. This is not correct when the
function is called by the Checkers. Thus, a new internal function is
introduced, getConstValue, which simply queries the constraint manager.
This getConstValue is used internally in the SimpleSValBuilder when a
binop is evaluated, this way we avoid the recursion into the Simplifier.

Diff Detail

Event Timeline

martong created this revision.Jun 8 2022, 3:16 AM
Herald added a project: Restricted Project. · View Herald Transcript
martong requested review of this revision.Jun 8 2022, 3:16 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 8 2022, 3:16 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
martong retitled this revision from [analyzer] Fix assertion failure after getKnwonValue call to [analyzer] Fix assertion failure after getKnownValue call.Jun 8 2022, 3:17 AM

LGTM
Schedule a measurement to see what changes. Let's hope it won't introduce more crashes.
If everything checks out, it gets approved.

clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
25–28

I'm also wondering if this should be at the top. I would rather put it below simplifySValOnce().

Check the summary for typos. Try to mark named entities like this.

uabelho added a subscriber: uabelho.Jun 8 2022, 3:47 AM
martong edited the summary of this revision. (Show Details)Jun 8 2022, 4:56 AM

... Try to mark named entities like this.

Could you please elaborate?

... Try to mark named entities like this.

Could you please elaborate?

Oh sure. The SimpleSValBuilder is not escaped like code or class entities should be in the summary. But it's really not that important.

... Try to mark named entities like this.

Could you please elaborate?

Oh sure. The SimpleSValBuilder is not escaped like code or class entities should be in the summary. But it's really not that important.

Ok, thanks!

martong edited the summary of this revision. (Show Details)Jun 8 2022, 6:41 AM
martong updated this revision to Diff 435154.Jun 8 2022, 7:28 AM
martong marked an inline comment as done.
  • Add one more sentence in the comments.
clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
25–28

It is a good idea to draw the checker writer's attention to use getKnownValue, however, this is a private function deliberately for this exact reason.

I'm also wondering if this should be at the top. I would rather put it below simplifySValOnce().

I've put it here because simplifySValOnce references this even in its header comment.

steakhal accepted this revision.Jun 8 2022, 7:32 AM
steakhal added inline comments.
clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
25–28

It is a good idea to draw the checker writer's attention to use getKnownValue, however, this is a private function deliberately for this exact reason.

I know. My point is that the name of those two functions won't express the difference; thus I wanted to have a more verbose way of expressing that the private impl. fn. should not be exposed. I won't insist though.

I've put it here because simplifySValOnce references this even in its header comment.

Well, it also refers to simplifySValOnce(), yet that's below that comment.

This revision is now accepted and ready to land.Jun 8 2022, 7:32 AM

LGTM
Schedule a measurement to see what changes. Let's hope it won't introduce more crashes.
If everything checks out, it gets approved.

Results are good. No new assertion failures, neither crashes. Runtime is the same (in the margin of error). Redis has been added to the set of analyzed projects this time.

This revision was landed with ongoing or failed builds.Jun 9 2022, 7:14 AM
This revision was automatically updated to reflect the committed changes.