Page MenuHomePhabricator

[analyzer][solver] Do not negate unsigned ranges
AbandonedPublic

Authored by martong on May 11 2022, 5:29 AM.

Details

Summary

This is a bugfix. Simply put, 2u - 1u != 2u - 1u. See the static
assertion in the test file. The fix simply ban the negation of unsigned
expressions. This way the we are getting a little bit more conservatie,
but at least we do not infer wrong values.

Diff Detail

Event Timeline

martong created this revision.May 11 2022, 5:29 AM
Herald added a project: Restricted Project. · View Herald Transcript
martong requested review of this revision.May 11 2022, 5:29 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 11 2022, 5:29 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Seems reasonable.

clang/test/Analysis/constraint_manager_negate_difference.c
145–148

It's not immediately clear what you refer to by the TRUE case. The two evals the opposite condition, consequently one of them should be FALSE. Same for the next case.

martong abandoned this revision.May 11 2022, 8:22 AM
martong added inline comments.
clang/test/Analysis/constraint_manager_negate_difference.c
125–130

Actually, this test case was correct, because UINT_MID is a special value and for that

_Static_assert(UINT_MID == -UINT_MID, "");

holds.
So, this patch is meaningless.