This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] pr37802: Fix symbolic-pointer-to-boolean casts during load.
ClosedPublic

Authored by NoQ on Jun 15 2018, 12:42 PM.

Details

Summary

The canonical way to represent the result of casting &SymRegion{$x} to bool is ($x != 0), not $x. In fact $x is an ill-formed SVal (when`$x` is a loc-type symbol) and it gets caught by D48205. Fix the cast procedure.

Because our cast code is a spaghetti, the code that was fixed was in fact executed very rarely, because there's a duplicate guard in evalCast() that's written correctly. But when evalCastFromLoc() is called directly (eg., from CastRetrievedVal()), this becomes a problem.

Fixes https://bugs.llvm.org/show_bug.cgi?id=37802.

Diff Detail

Repository
rL LLVM

Event Timeline

NoQ created this revision.Jun 15 2018, 12:42 PM
NoQ retitled this revision from [analyzer] Fix symbolic-pointer-to-boolean casts during load. to [analyzer] pr37802: Fix symbolic-pointer-to-boolean casts during load..Jun 15 2018, 12:42 PM
NoQ edited the summary of this revision. (Show Details)
george.karpenkov accepted this revision.Jun 26 2018, 6:16 PM
This revision is now accepted and ready to land.Jun 26 2018, 6:16 PM
This revision was automatically updated to reflect the committed changes.