[cfe-dev] CFG blocks and variable scope

Chris Lattner clattner at apple.com
Sat Mar 28 15:57:24 PDT 2009


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



More information about the cfe-dev mailing list