[PATCH] [analyzer] Do not reinitialize static globals when the function is called more than once along a path

Ted Kremenek kremenek at apple.com
Wed Feb 6 15:21:40 PST 2013

On Feb 6, 2013, at 3:15 PM, Anna Zaks <ganna at apple.com> wrote:

> Currently, we reset the static variables with initializers on every visit to the function along a path. The solution might be a bit hacky as we check if the region has been stored something other than a LazyCompoundVal to find out if the static variable has been assigned to previously.

Hi Anna,

Why not just record the initialization in a side-table in the GDM?  That seems a lot cleaner.  This patch seems to rely on all the other pieces working correctly.  It also doesn't seem correct.  A static variable for an Objective-C pointer is guaranteed to be a valid value (it is zero-initialized), even if we haven't visited the initializer yet.  For example:

  static id x;  // this is always zero-initialized

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130206/d9718e48/attachment.html>

More information about the cfe-commits mailing list