When to create Contexts (or: how does C++ do it)

David Nolden zwabel at googlemail.com
Wed Feb 13 23:10:48 UTC 2008


On Wednesday 13 February 2008 22:42:22 Andreas Pakulat wrote:
> As far as I can see the code-context doesn't carry the identifier of the
> function (as opposed to the function declaration). Isn't that a bit
> problematic? I mean how does DUChain know that this context belongs to
> the function? Is the context associated to the definition object that
> gets created for a function definition? (I haven't yet dived into
> creating declarations and definitions, just trying to get some contexts
> created first)

It is associated to the definition or declaration, through the owner() member, 
and can be retrieved from the declaration/definition through 
internalContext().

That the context doesn't have the identifier assigned makes the thing a little 
harder to overview, but isn't problematic since you anyway don't need to 
address content of a compound-statement globally in C++. This is the way it 
was when I started working on that stuff, so I've kept it. Maybe assigning 
the identifier to all contexts that belong to a function would be better for 
overview, that's the only use of those context-identifiers anyway, as long as 
you don't need to address members from outside.

Greetings, David




More information about the KDevelop-devel mailing list