[cfe-dev] destroy() information?

Chris Lattner clattner at apple.com
Wed Apr 9 11:17:24 PDT 2008


On Apr 9, 2008, at 11:11 AM, Sam Bishop wrote:

> 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.

Probably just Decl.cpp, you can #include all the language-specific  
decl.h files there.
>
>
>> 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.

Ok!

-Chris



More information about the cfe-dev mailing list