[cfe-dev] CFG blocks and variable scope

Ted Kremenek kremenek at apple.com
Sat Mar 28 17:23:08 PDT 2009


On Mar 28, 2009, at 3:57 PM, Chris Lattner wrote:

>
> On Mar 28, 2009, at 3:14 PM, Martin Doucha wrote:
>>> Within a single basic block multiple scopes may be "pushed" and
>>> "popped".  The CFG only corresponds to control-flow, and thus nested
>>> compound statements are flattened.  Note that C++ also introduces
>>> scopes in many places that C does not.
>>
>> I am aware of that. That's why I've proposed the list of "scopes"  
>> that
>> live inside a basic block. And the "scopes" don't have to follow the
>> language concept of scope to the letter. "Scopes" with exactly the  
>> same
>> exit points can be merged into one and empty "scopes" can be removed
>> completely. I am interested in the effects, I just don't see any  
>> other
>> efficient way of storing this information.
>
> Would it make sense for the CFG to contain a "virtual statement"  
> saying "variable x destroyed here"?  This would be a natural way to  
> handle C++ dtors and would also be useful in C, because you'd know  
> the end of the variable's life.  CFG construction would handle this  
> as it is walking the scopes.
>
> -Chris

Yes, this is the approach I was envisioning.  We still need the scope  
information to be available during CFG construction.



More information about the cfe-dev mailing list