[cfe-dev] destroy() information?

Sam Bishop sam at bishop.dhs.org
Wed Apr 9 11:11:40 PDT 2008


Chris,

Chris Lattner wrote:
> Cool!   I was thinking of something sleazy like a non-virtual, const
> Destroy method in Decl.  Something like this:
>
> void Decl::Destroy(ASTContext &C) const {
>    switch (getKind()) {
>    case FieldDecl:  cast<FieldDecl>(this)->~FieldDecl(); break;
>    ... one case for each concrete Decl class ...
>    }
>
>    C.getAllocator().Delete(this);
> }

I've got one, silly question...  Where should this code go?  It needs to
have the declarations for all concrete classes in scope.

> Incidentally, things like this are very
> mechanical: maybe we should have a DeclNodes.def file like
> StmtNodes.def to automate it?

I'm leaning toward just a simple macro.  I looked for other uses for a
.def file, and all I could come up with was the Decl::Kind enum.  But
after trying to create the *First/*Last members using the C
preprocessor, I decided it wasn't worth it.

Thanks,
Sam




More information about the cfe-dev mailing list