This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] Simplify BoolAssignmentChecker
ClosedPublic

Authored by mikhail.ramalho on Jan 20 2020, 11:33 AM.

Details

Summary

Instead of checking the range manually, changed the checker to use assumeInclusiveRangeDual instead.

This patch was part of D28955.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptJan 20 2020, 11:33 AM
mikhail.ramalho retitled this revision from Simplify BoolAssignmentChecker to [analyzer] Simplify BoolAssignmentChecker.Jan 20 2020, 11:36 AM
ddcc added a subscriber: ddcc.Jan 20 2020, 2:36 PM
NoQ added a comment.Jan 21 2020, 7:00 AM

Thanks!!! Small patches are so nice to review.

clang/lib/StaticAnalyzer/Checkers/BoolAssignmentChecker.cpp
91

I believe this should be !StIn. I.e., the right check to do is "the value is known to be not boolean" (this is definitely a buggy execution path the static analyzer managed to discover), whereas "the value is not known to be definitely boolean" is the wrong check to do (the static analyzer doesn't have enough information to conclude that the value is definitely boolean, which might be because the value may be non-boolean, but it's more likely that this happens because the static analyzer simply doesn't know enough about the program).

I think this change should fix the regressions on the test suite.

Update the condition to flag an issue.

NoQ accepted this revision.Jan 27 2020, 9:36 AM

That's more like it! :)

This revision is now accepted and ready to land.Jan 27 2020, 9:36 AM
This revision was automatically updated to reflect the committed changes.