[cfe-commits] r137309 - in /cfe/trunk: include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h lib/StaticAnalyzer/Core/SymbolManager.cpp

Anna Zaks ganna at apple.com
Thu Aug 11 19:43:32 PDT 2011


On Aug 11, 2011, at 5:32 PM, Jordy Rose wrote:

> 
> On Aug 11, 2011, at 16:29, Anna Zaks wrote:
> 
>> 
>> On Aug 11, 2011, at 3:42 PM, Ted Kremenek wrote:
>> 
>>> On Aug 11, 2011, at 3:04 PM, Jordy Rose wrote:
>>> 
>>>> I'm curious what the motivation was for choosing to store the symbols as Base -> [list of dependents] instead of Dependent -> Base. I doubt many symbols are going to have multiple dependents, especially when they're being ORed together instead of ANDed. I realize that it makes it easy to clear the map when the base symbol dies, but since every dead symbol sweep hits every symbol anyway that doesn't seem to be a problem. (SymbolDerived works the other way around.)
>>> 
>>> I think you have a good point.  Going from base to dependents instead of dependents to base is probably more eager than we need to be.  We only need to care if a dependent's lifetime is extended if we think it might be dead.  If a dependent looks dead, lazily querying to see if a the base symbol is live seems slightly more efficient to me.
>>> 
>>> Anna: what do you think?
>> 
>> I think it would be cleaner to leave the Base -> [list of dependents] mapping:
>> 
>> 1) The algorithm for determining when a symbol is alive or dead is complex, so we might need to wait until all the symbols are processed and then go though the dead ones checking if the dead symbols have the dependencies. I think the current design is cleaner and shouldn't be much slower given the suggested code review cleanups, in particular, "don't mark a symbol/dependents live if it's already live".
>> 
>> 2) I think the checkers might want to specify that multiple symbols depend on one primary one, so keeping the map better represents that.
> 
> All right, sounds good. Just wanted to hear what the reasoning was…thanks!

You brought up very good points. 

I guess, another way of looking at it is that if we have many more live symbols then the dead symbols (during each clean up) then it would be better to go with the approach you suggested (and vice versa). However, the analyzer is very aggressive in pruning the symbols and if, in addition, we increase the intervals at which we do the cleanup, we will end up with more dead symbols then the live symbols.

Anna.

> Jordy





More information about the cfe-commits mailing list