[cfe-dev] Who owns declarations?

Sebastian Redl sebastian.redl at getdesigned.at
Mon Dec 22 10:22:27 PST 2008


Hi,

I'm currently implementing Sema and AST support for C++ try-catch 
statements, and I'm confused about ownership.

A basic C++ try-catch looks like this:

try { ... }
catch (exception_type exception_var) { ... }

"exception_type exception_var" is a 'exception-declaration' production; 
very much like a function parameter declaration, actually. I use VarDecl 
to represent it in the AST, though.
However, I'm somewhat confused as to who owns the VarDecl. Should I 
destroy it when the CXXCatchStmt is destroyed? Should I serialize it as 
owned or as unowned?

Sebastian



More information about the cfe-dev mailing list