[cfe-dev] Reference-counted statements

Daniel Dunbar daniel at zuster.org
Fri Aug 7 10:43:25 PDT 2009


Hi Doug,

I'd like to clarify one point:

On Fri, Aug 7, 2009 at 9:26 AM, Douglas Gregor<dgregor at apple.com> wrote:
> Most AST clients will still use simple Stmt or Expr pointers and will not
> need to increase or decrease the reference counts. In those few places where
> we are explicitly sharing statements or expressions (e.g., as part of a tree
> transform), we will call the statement's Retain operation to increase the
> reference count. In the attached patch, I've introduced Retain calls in a
> few places to illustrate the idea:

I think this amounts to an extension of our "strong" ownership model,
right? The precise rule for when clients need to handle the reference
count themselves is when passing an owned expression into another
context (e.g., a constructor) expecting to resolve a strong reference
itself. I haven't thought it through, but this may even be something
we could eventually enforce via the static type system.

 - Daniel



More information about the cfe-dev mailing list