[cfe-commits] r49142 - in /cfe/trunk: include/clang/AST/TranslationUnit.h lib/AST/TranslationUnit.cpp

Chris Lattner clattner at apple.com
Thu Apr 3 09:40:35 PDT 2008


On Apr 3, 2008, at 8:39 AM, Sam Bishop wrote:
> Sam Bishop wrote:
>> +TranslationUnit::~TranslationUnit() {
>> +  for (iterator I=begin(), E=end(); I!=E; ++I)
>> +    delete *I;
>> +}
>
> Meh.  I'm already over my head...

:)

Eventually we want to use Decl->destroy(ASTContext&) instead of  
calling delete directly.  This was the second half of the  
"Creatification" patch that I haven't gotten to yet.

> I expect that we would like serializing to be transparent.  In other
> words, a new decl and a deserialized decl ought to be equivalent.

Yes.

> Decls are usually created using Create() calls, which takes a  
> pointer to
> an ASTContext object.  The deserialization code can't use those  
> Create()
> calls, because it's generic LLVM code which doesn't know anything  
> about
> the ASTContext class.
>
> The reason that's a problem is because the ASTContext object  
> determines
> the allocator to use, at least in the "from source code" case.
> Currently, the allocator is llvm::MallocAllocator, but the
> deserialization code uses new.

Right, we need the ASTContext to be available to the deserialization  
logic.  Ted, any ideas?

-Chris



More information about the cfe-commits mailing list