[PATCH] D48232: [analyzer] Fix symbolic-pointer-to-boolean casts during load.

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 15 12:42:10 PDT 2018


NoQ created this revision.
NoQ added reviewers: dcoughlin, xazax.hun, a.sidorin, george.karpenkov, szepet, rnkovacs.
Herald added subscribers: cfe-commits, mikhail.ramalho, baloghadamsoftware.

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 https://reviews.llvm.org/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.


Repository:
  rC Clang

https://reviews.llvm.org/D48232

Files:
  lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  test/Analysis/casts.cpp
  test/Analysis/pr37802.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48232.151542.patch
Type: text/x-patch
Size: 2937 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180615/9a295165/attachment.bin>


More information about the cfe-commits mailing list