[PATCH] D25326: [StaticAnalyser] Don't merge different returns in ExplodedGraph

Devin Coughlin via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 14 08:42:28 PDT 2016


dcoughlin added a comment.

In https://reviews.llvm.org/D25326#569061, @danielmarjamaki wrote:

> > You could also try to add a canary with clang analyzer eval after the if statement to force the test to fail if we do add this symbolic reasoning.
>
> sounds good. sorry but I don't see how to do it.


The trick is to not first store the UnknownVal into a local (the analyzer will automatically create a symbol for that when read).

Instead you can do something like:

  if (table[i] != 0) { }
  clang_analyzer_eval((table[i] != 0)) // expected-warning {{UNKNOWN}}

This way if the analyzer ever starts generating symbols for a read from table[i] then the case split will change the eval to emit TRUE on one path and FALSE on the other.


Repository:
  rL LLVM

https://reviews.llvm.org/D25326





More information about the cfe-commits mailing list