[cfe-commits] r63135 - in /cfe/trunk: include/clang/AST/ASTContext.h lib/AST/Decl.cpp lib/AST/DeclBase.cpp lib/AST/DeclCXX.cpp lib/AST/DeclGroup.cpp lib/AST/DeclObjC.cpp lib/AST/DeclSerialization.cpp lib/AST/Type.cpp

Steve Naroff snaroff at apple.com
Tue Jan 27 13:25:57 PST 2009


Author: snaroff
Date: Tue Jan 27 15:25:57 2009
New Revision: 63135

URL: http://llvm.org/viewvc/llvm-project?rev=63135&view=rev
Log:
Remove many references to ASTContext::getAllocator(), replacing them with calls to the recently added placement new (which uses ASTContext's allocator for memory). Also added ASTContext::Deallocate().

This will simplify runtime replacement of ASTContext's allocator. Keeping the allocator private (and removing getAllocator() entirely) is also goodness.

Modified:
    cfe/trunk/include/clang/AST/ASTContext.h
    cfe/trunk/lib/AST/Decl.cpp
    cfe/trunk/lib/AST/DeclBase.cpp
    cfe/trunk/lib/AST/DeclCXX.cpp
    cfe/trunk/lib/AST/DeclGroup.cpp
    cfe/trunk/lib/AST/DeclObjC.cpp
    cfe/trunk/lib/AST/DeclSerialization.cpp
    cfe/trunk/lib/AST/Type.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=63135&r1=63134&r2=63135&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Tue Jan 27 15:25:57 2009
@@ -129,6 +129,8 @@
 
   SourceManager& getSourceManager() { return SourceMgr; }
   llvm::MallocAllocator &getAllocator() { return Allocator; }  
+  void Deallocate(void *Ptr) { Allocator.Deallocate(Ptr); }
+  
   const LangOptions& getLangOptions() const { return LangOpts; }
   
   FullSourceLoc getFullLoc(SourceLocation Loc) const { 
@@ -567,7 +569,7 @@
                                   FieldDecl *Field,
                                   bool OutermostType = false,
                                   bool EncodingProperty = false) const;
-
+                                  
 };
 
 }  // end namespace clang

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=63135&r1=63134&r2=63135&view=diff

==============================================================================
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Tue Jan 27 15:25:57 2009
@@ -24,14 +24,12 @@
 //===----------------------------------------------------------------------===//
  
 TranslationUnitDecl *TranslationUnitDecl::Create(ASTContext &C) {
-  void *Mem = C.getAllocator().Allocate<TranslationUnitDecl>();
-  return new (Mem) TranslationUnitDecl();
+  return new (C) TranslationUnitDecl();
 }
 
 NamespaceDecl *NamespaceDecl::Create(ASTContext &C, DeclContext *DC,
                                      SourceLocation L, IdentifierInfo *Id) {
-  void *Mem = C.getAllocator().Allocate<NamespaceDecl>();
-  return new (Mem) NamespaceDecl(DC, L, Id);
+  return new (C) NamespaceDecl(DC, L, Id);
 }
 
 void NamespaceDecl::Destroy(ASTContext& C) {
@@ -39,22 +37,20 @@
   // together. They are all top-level Decls.
   
   this->~NamespaceDecl();
-  C.getAllocator().Deallocate((void *)this);
+  C.Deallocate((void *)this);
 }
 
 
 ImplicitParamDecl *ImplicitParamDecl::Create(ASTContext &C, DeclContext *DC,
     SourceLocation L, IdentifierInfo *Id, QualType T) {
-  void *Mem = C.getAllocator().Allocate<ImplicitParamDecl>();
-  return new (Mem) ImplicitParamDecl(ImplicitParam, DC, L, Id, T);
+  return new (C) ImplicitParamDecl(ImplicitParam, DC, L, Id, T);
 }
 
 ParmVarDecl *ParmVarDecl::Create(ASTContext &C, DeclContext *DC,
                                  SourceLocation L, IdentifierInfo *Id,
                                  QualType T, StorageClass S,
                                  Expr *DefArg) {
-  void *Mem = C.getAllocator().Allocate<ParmVarDecl>();
-  return new (Mem) ParmVarDecl(ParmVar, DC, L, Id, T, S, DefArg);
+  return new (C) ParmVarDecl(ParmVar, DC, L, Id, T, S, DefArg);
 }
 
 QualType ParmVarDecl::getOriginalType() const {
@@ -69,8 +65,7 @@
                                  SourceLocation L, IdentifierInfo *Id,
                                  QualType T, QualType OT, StorageClass S,
                                  Expr *DefArg) {
-  void *Mem = C.getAllocator().Allocate<ParmVarWithOriginalTypeDecl>();
-  return new (Mem) ParmVarWithOriginalTypeDecl(DC, L, Id, T, OT, S, DefArg);
+  return new (C) ParmVarWithOriginalTypeDecl(DC, L, Id, T, OT, S, DefArg);
 }
 
 FunctionDecl *FunctionDecl::Create(ASTContext &C, DeclContext *DC,
@@ -78,21 +73,18 @@
                                    DeclarationName N, QualType T, 
                                    StorageClass S, bool isInline, 
                                    SourceLocation TypeSpecStartLoc) {
-  void *Mem = C.getAllocator().Allocate<FunctionDecl>();
-  return new (Mem) FunctionDecl(Function, DC, L, N, T, S, isInline,
+  return new (C) FunctionDecl(Function, DC, L, N, T, S, isInline,
                                 TypeSpecStartLoc);
 }
 
 BlockDecl *BlockDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L) {
-  void *Mem = C.getAllocator().Allocate<BlockDecl>();
-  return new (Mem) BlockDecl(DC, L);
+  return new (C) BlockDecl(DC, L);
 }
 
 FieldDecl *FieldDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L,
                              IdentifierInfo *Id, QualType T, Expr *BW,
                              bool Mutable) {
-  void *Mem = C.getAllocator().Allocate<FieldDecl>();
-  return new (Mem) FieldDecl(Decl::Field, DC, L, Id, T, BW, Mutable);
+  return new (C) FieldDecl(Decl::Field, DC, L, Id, T, BW, Mutable);
 }
 
 bool FieldDecl::isAnonymousStructOrUnion() const {
@@ -109,8 +101,7 @@
                                            SourceLocation L,
                                            IdentifierInfo *Id, QualType T,
                                            Expr *E, const llvm::APSInt &V) {
-  void *Mem = C.getAllocator().Allocate<EnumConstantDecl>();
-  return new (Mem) EnumConstantDecl(CD, L, Id, T, E, V);
+  return new (C) EnumConstantDecl(CD, L, Id, T, E, V);
 }
 
 void EnumConstantDecl::Destroy(ASTContext& C) {
@@ -121,8 +112,7 @@
 TypedefDecl *TypedefDecl::Create(ASTContext &C, DeclContext *DC,
                                  SourceLocation L,
                                  IdentifierInfo *Id, QualType T) {
-  void *Mem = C.getAllocator().Allocate<TypedefDecl>();
-  return new (Mem) TypedefDecl(DC, L, Id, T);
+  return new (C) TypedefDecl(DC, L, Id, T);
 }
 
 EnumDecl *EnumDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L,
@@ -147,8 +137,7 @@
 FileScopeAsmDecl *FileScopeAsmDecl::Create(ASTContext &C, DeclContext *DC,
                                            SourceLocation L,
                                            StringLiteral *Str) {
-  void *Mem = C.getAllocator().Allocate<FileScopeAsmDecl>();
-  return new (Mem) FileScopeAsmDecl(DC, L, Str);
+  return new (C) FileScopeAsmDecl(DC, L, Str);
 }
 
 //===----------------------------------------------------------------------===//
@@ -176,13 +165,12 @@
 VarDecl *VarDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L,
                          IdentifierInfo *Id, QualType T, StorageClass S, 
                          SourceLocation TypeSpecStartLoc) {
-  void *Mem = C.getAllocator().Allocate<VarDecl>();
-  return new (Mem) VarDecl(Var, DC, L, Id, T, S, TypeSpecStartLoc);
+  return new (C) VarDecl(Var, DC, L, Id, T, S, TypeSpecStartLoc);
 }
 
 void VarDecl::Destroy(ASTContext& C) {
   this->~VarDecl();
-  C.getAllocator().Deallocate((void *)this);
+  C.Deallocate((void *)this);
 }
 
 VarDecl::~VarDecl() {
@@ -200,7 +188,7 @@
   for (param_iterator I=param_begin(), E=param_end(); I!=E; ++I)
     (*I)->Destroy(C);
 
-  C.getAllocator().Deallocate(ParamInfo);
+  C.Deallocate(ParamInfo);
 
   Decl::Destroy(C);
 }
@@ -309,8 +297,7 @@
                                SourceLocation L, IdentifierInfo *Id,
                                RecordDecl* PrevDecl) {
   
-  void *Mem = C.getAllocator().Allocate<RecordDecl>();
-  RecordDecl* R = new (Mem) RecordDecl(Record, TK, DC, L, Id);
+  RecordDecl* R = new (C) RecordDecl(Record, TK, DC, L, Id);
   C.getTypeDeclType(R, PrevDecl);
   return R;
 }

Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=63135&r1=63134&r2=63135&view=diff

==============================================================================
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Tue Jan 27 15:25:57 2009
@@ -405,7 +405,7 @@
   }  
 
   this->~Decl();
-  C.getAllocator().Deallocate((void *)this);
+  C.Deallocate((void *)this);
 #endif
 }
 

Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=63135&r1=63134&r2=63135&view=diff

==============================================================================
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Tue Jan 27 15:25:57 2009
@@ -25,16 +25,14 @@
 TemplateTypeParmDecl::Create(ASTContext &C, DeclContext *DC,
                              SourceLocation L, IdentifierInfo *Id,
                              bool Typename) {
-  void *Mem = C.getAllocator().Allocate<TemplateTypeParmDecl>();
-  return new (Mem) TemplateTypeParmDecl(DC, L, Id, Typename);
+  return new (C) TemplateTypeParmDecl(DC, L, Id, Typename);
 }
 
 NonTypeTemplateParmDecl *
 NonTypeTemplateParmDecl::Create(ASTContext &C, DeclContext *DC, 
                                 SourceLocation L, IdentifierInfo *Id,
                                 QualType T, SourceLocation TypeSpecStartLoc) {
-  void *Mem = C.getAllocator().Allocate<NonTypeTemplateParmDecl>();
-  return new (Mem) NonTypeTemplateParmDecl(DC, L, Id, T, TypeSpecStartLoc);
+  return new (C) NonTypeTemplateParmDecl(DC, L, Id, T, TypeSpecStartLoc);
 }
 
 TemplateParameterList::TemplateParameterList(Decl **Params, unsigned NumParams)
@@ -46,6 +44,7 @@
 TemplateParameterList *
 TemplateParameterList::Create(ASTContext &C, Decl **Params, 
                               unsigned NumParams) {
+  // FIXME: how do I pass in Size to ASTContext::new?
   unsigned Size = sizeof(TemplateParameterList) + sizeof(Decl *) * NumParams;
   unsigned Align = llvm::AlignOf<TemplateParameterList>::Alignment;
   void *Mem = C.getAllocator().Allocate(Size, Align);
@@ -63,8 +62,7 @@
 CXXRecordDecl *CXXRecordDecl::Create(ASTContext &C, TagKind TK, DeclContext *DC,
                                      SourceLocation L, IdentifierInfo *Id,
                                      CXXRecordDecl* PrevDecl) {
-  void *Mem = C.getAllocator().Allocate<CXXRecordDecl>();
-  CXXRecordDecl* R = new (Mem) CXXRecordDecl(TK, DC, L, Id);
+  CXXRecordDecl* R = new (C) CXXRecordDecl(TK, DC, L, Id);
   C.getTypeDeclType(R, PrevDecl);  
   return R;
 }
@@ -211,8 +209,7 @@
 CXXMethodDecl::Create(ASTContext &C, CXXRecordDecl *RD,
                       SourceLocation L, DeclarationName N,
                       QualType T, bool isStatic, bool isInline) {
-  void *Mem = C.getAllocator().Allocate<CXXMethodDecl>();
-  return new (Mem) CXXMethodDecl(CXXMethod, RD, L, N, T, isStatic, isInline);
+  return new (C) CXXMethodDecl(CXXMethod, RD, L, N, T, isStatic, isInline);
 }
 
 QualType CXXMethodDecl::getThisType(ASTContext &C) const {
@@ -268,8 +265,7 @@
                            bool isInline, bool isImplicitlyDeclared) {
   assert(N.getNameKind() == DeclarationName::CXXConstructorName &&
          "Name must refer to a constructor");
-  void *Mem = C.getAllocator().Allocate<CXXConstructorDecl>();
-  return new (Mem) CXXConstructorDecl(RD, L, N, T, isExplicit, isInline,
+  return new (C) CXXConstructorDecl(RD, L, N, T, isExplicit, isInline,
                                       isImplicitlyDeclared);
 }
 
@@ -336,9 +332,8 @@
                           bool isImplicitlyDeclared) {
   assert(N.getNameKind() == DeclarationName::CXXDestructorName &&
          "Name must refer to a destructor");
-  void *Mem = C.getAllocator().Allocate<CXXDestructorDecl>();
-  return new (Mem) CXXDestructorDecl(RD, L, N, T, isInline, 
-                                     isImplicitlyDeclared);
+  return new (C) CXXDestructorDecl(RD, L, N, T, isInline, 
+                                   isImplicitlyDeclared);
 }
 
 CXXConversionDecl *
@@ -347,28 +342,24 @@
                           QualType T, bool isInline, bool isExplicit) {
   assert(N.getNameKind() == DeclarationName::CXXConversionFunctionName &&
          "Name must refer to a conversion function");
-  void *Mem = C.getAllocator().Allocate<CXXConversionDecl>();
-  return new (Mem) CXXConversionDecl(RD, L, N, T, isInline, isExplicit);
+  return new (C) CXXConversionDecl(RD, L, N, T, isInline, isExplicit);
 }
 
 CXXClassVarDecl *CXXClassVarDecl::Create(ASTContext &C, CXXRecordDecl *RD,
                                    SourceLocation L, IdentifierInfo *Id,
                                    QualType T) {
-  void *Mem = C.getAllocator().Allocate<CXXClassVarDecl>();
-  return new (Mem) CXXClassVarDecl(RD, L, Id, T);
+  return new (C) CXXClassVarDecl(RD, L, Id, T);
 }
 
 OverloadedFunctionDecl *
 OverloadedFunctionDecl::Create(ASTContext &C, DeclContext *DC,
                                DeclarationName N) {
-  void *Mem = C.getAllocator().Allocate<OverloadedFunctionDecl>();
-  return new (Mem) OverloadedFunctionDecl(DC, N);
+  return new (C) OverloadedFunctionDecl(DC, N);
 }
 
 LinkageSpecDecl *LinkageSpecDecl::Create(ASTContext &C,
                                          DeclContext *DC, 
                                          SourceLocation L,
                                          LanguageIDs Lang, bool Braces) {
-  void *Mem = C.getAllocator().Allocate<LinkageSpecDecl>();
-  return new (Mem) LinkageSpecDecl(DC, L, Lang, Braces);
+  return new (C) LinkageSpecDecl(DC, L, Lang, Braces);
 }

Modified: cfe/trunk/lib/AST/DeclGroup.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclGroup.cpp?rev=63135&r1=63134&r2=63135&view=diff

==============================================================================
--- cfe/trunk/lib/AST/DeclGroup.cpp (original)
+++ cfe/trunk/lib/AST/DeclGroup.cpp Tue Jan 27 15:25:57 2009
@@ -60,7 +60,7 @@
     Decls[i]->Destroy(C);
   
   this->~DeclGroup();
-  C.getAllocator().Deallocate((void*) this);
+  C.Deallocate((void*) this);
 }
 
 DeclGroupOwningRef::~DeclGroupOwningRef() {

Modified: cfe/trunk/lib/AST/DeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclObjC.cpp?rev=63135&r1=63134&r2=63135&view=diff

==============================================================================
--- cfe/trunk/lib/AST/DeclObjC.cpp (original)
+++ cfe/trunk/lib/AST/DeclObjC.cpp Tue Jan 27 15:25:57 2009
@@ -29,8 +29,7 @@
                                        bool isVariadic,
                                        bool isSynthesized,
                                        ImplementationControl impControl) {
-  void *Mem = C.getAllocator().Allocate<ObjCMethodDecl>();
-  return new (Mem) ObjCMethodDecl(beginLoc, endLoc,
+  return new (C) ObjCMethodDecl(beginLoc, endLoc,
                                   SelInfo, T, contextDecl,
                                   isInstance, 
                                   isVariadic, isSynthesized, impControl);
@@ -56,8 +55,7 @@
                                              IdentifierInfo *Id, 
                                              SourceLocation ClassLoc,
                                              bool ForwardDecl, bool isInternal){
-  void *Mem = C.getAllocator().Allocate<ObjCInterfaceDecl>();
-  return new (Mem) ObjCInterfaceDecl(DC, atLoc, Id, ClassLoc, ForwardDecl,
+  return new (C) ObjCInterfaceDecl(DC, atLoc, Id, ClassLoc, ForwardDecl,
                                      isInternal);
 }
 
@@ -83,28 +81,25 @@
 ObjCIvarDecl *ObjCIvarDecl::Create(ASTContext &C, SourceLocation L,
                                    IdentifierInfo *Id, QualType T, 
                                    AccessControl ac, Expr *BW) {
-  void *Mem = C.getAllocator().Allocate<ObjCIvarDecl>();
-  return new (Mem) ObjCIvarDecl(L, Id, T, ac, BW);
+  return new (C) ObjCIvarDecl(L, Id, T, ac, BW);
 }
 
 
 ObjCAtDefsFieldDecl
 *ObjCAtDefsFieldDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L,
                              IdentifierInfo *Id, QualType T, Expr *BW) {
-  void *Mem = C.getAllocator().Allocate<ObjCAtDefsFieldDecl>();
-  return new (Mem) ObjCAtDefsFieldDecl(DC, L, Id, T, BW);
+  return new (C) ObjCAtDefsFieldDecl(DC, L, Id, T, BW);
 }
 
 void ObjCAtDefsFieldDecl::Destroy(ASTContext& C) {
   this->~ObjCAtDefsFieldDecl();
-  C.getAllocator().Deallocate((void *)this); 
+  C.Deallocate((void *)this); 
 }
 
 ObjCProtocolDecl *ObjCProtocolDecl::Create(ASTContext &C, DeclContext *DC,
                                            SourceLocation L, 
                                            IdentifierInfo *Id) {
-  void *Mem = C.getAllocator().Allocate<ObjCProtocolDecl>();
-  return new (Mem) ObjCProtocolDecl(DC, L, Id);
+  return new (C) ObjCProtocolDecl(DC, L, Id);
 }
 
 ObjCProtocolDecl::~ObjCProtocolDecl() {
@@ -115,8 +110,7 @@
 ObjCClassDecl *ObjCClassDecl::Create(ASTContext &C, DeclContext *DC,
                                      SourceLocation L,
                                      ObjCInterfaceDecl **Elts, unsigned nElts) {
-  void *Mem = C.getAllocator().Allocate<ObjCClassDecl>();
-  return new (Mem) ObjCClassDecl(DC, L, Elts, nElts);
+  return new (C) ObjCClassDecl(DC, L, Elts, nElts);
 }
 
 ObjCClassDecl::~ObjCClassDecl() {
@@ -140,8 +134,7 @@
 ObjCForwardProtocolDecl::Create(ASTContext &C, DeclContext *DC,
                                 SourceLocation L, 
                                 ObjCProtocolDecl **Elts, unsigned NumElts) {
-  void *Mem = C.getAllocator().Allocate<ObjCForwardProtocolDecl>();
-  return new (Mem) ObjCForwardProtocolDecl(DC, L, Elts, NumElts);
+  return new (C) ObjCForwardProtocolDecl(DC, L, Elts, NumElts);
 }
 
 ObjCForwardProtocolDecl::~ObjCForwardProtocolDecl() {
@@ -151,16 +144,14 @@
 ObjCCategoryDecl *ObjCCategoryDecl::Create(ASTContext &C, DeclContext *DC,
                                            SourceLocation L,
                                            IdentifierInfo *Id) {
-  void *Mem = C.getAllocator().Allocate<ObjCCategoryDecl>();
-  return new (Mem) ObjCCategoryDecl(DC, L, Id);
+  return new (C) ObjCCategoryDecl(DC, L, Id);
 }
 
 ObjCCategoryImplDecl *
 ObjCCategoryImplDecl::Create(ASTContext &C, DeclContext *DC,
                              SourceLocation L,IdentifierInfo *Id,
                              ObjCInterfaceDecl *ClassInterface) {
-  void *Mem = C.getAllocator().Allocate<ObjCCategoryImplDecl>();
-  return new (Mem) ObjCCategoryImplDecl(DC, L, Id, ClassInterface);
+  return new (C) ObjCCategoryImplDecl(DC, L, Id, ClassInterface);
 }
 
 ObjCImplementationDecl *
@@ -168,8 +159,7 @@
                                SourceLocation L,
                                ObjCInterfaceDecl *ClassInterface,
                                ObjCInterfaceDecl *SuperDecl) {
-  void *Mem = C.getAllocator().Allocate<ObjCImplementationDecl>();
-  return new (Mem) ObjCImplementationDecl(DC, L, ClassInterface, SuperDecl);
+  return new (C) ObjCImplementationDecl(DC, L, ClassInterface, SuperDecl);
 }
 
 ObjCCompatibleAliasDecl *
@@ -177,8 +167,7 @@
                                 SourceLocation L,
                                 IdentifierInfo *Id, 
                                 ObjCInterfaceDecl* AliasedClass) {
-  void *Mem = C.getAllocator().Allocate<ObjCCompatibleAliasDecl>();
-  return new (Mem) ObjCCompatibleAliasDecl(DC, L, Id, AliasedClass);
+  return new (C) ObjCCompatibleAliasDecl(DC, L, Id, AliasedClass);
 }
 
 ObjCPropertyDecl *ObjCPropertyDecl::Create(ASTContext &C, DeclContext *DC,
@@ -186,8 +175,7 @@
                                            IdentifierInfo *Id,
                                            QualType T,
                                            PropertyControl propControl) {
-  void *Mem = C.getAllocator().Allocate<ObjCPropertyDecl>();
-  return new (Mem) ObjCPropertyDecl(DC, L, Id, T);
+  return new (C) ObjCPropertyDecl(DC, L, Id, T);
 }
 
 //===----------------------------------------------------------------------===//
@@ -638,8 +626,7 @@
                                                    ObjCPropertyDecl *property,
                                                    Kind PK,
                                                    ObjCIvarDecl *ivar) {
-  void *Mem = C.getAllocator().Allocate<ObjCPropertyImplDecl>();
-  return new (Mem) ObjCPropertyImplDecl(DC, atLoc, L, property, PK, ivar);
+  return new (C) ObjCPropertyImplDecl(DC, atLoc, L, property, PK, ivar);
 }
 
 

Modified: cfe/trunk/lib/AST/DeclSerialization.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclSerialization.cpp?rev=63135&r1=63134&r2=63135&view=diff

==============================================================================
--- cfe/trunk/lib/AST/DeclSerialization.cpp (original)
+++ cfe/trunk/lib/AST/DeclSerialization.cpp Tue Jan 27 15:25:57 2009
@@ -303,10 +303,7 @@
 
 TranslationUnitDecl* TranslationUnitDecl::CreateImpl(Deserializer& D,
                                                      ASTContext& C) {  
-  void *Mem = C.getAllocator().Allocate<TranslationUnitDecl>();
-  TranslationUnitDecl* decl = new (Mem) TranslationUnitDecl();
- 
-  return decl;
+  return new (C) TranslationUnitDecl();
 }
 
 //===----------------------------------------------------------------------===//
@@ -321,8 +318,7 @@
 }
 
 NamespaceDecl* NamespaceDecl::CreateImpl(Deserializer& D, ASTContext& C) {  
-  void *Mem = C.getAllocator().Allocate<NamespaceDecl>();
-  NamespaceDecl* decl = new (Mem) NamespaceDecl(0, SourceLocation(), 0);
+  NamespaceDecl* decl = new (C) NamespaceDecl(0, SourceLocation(), 0);
  
   decl->NamedDecl::ReadInRec(D, C);
   decl->LBracLoc = SourceLocation::ReadVal(D);
@@ -336,9 +332,8 @@
 //===----------------------------------------------------------------------===//
 
 VarDecl* VarDecl::CreateImpl(Deserializer& D, ASTContext& C) {  
-  void *Mem = C.getAllocator().Allocate<VarDecl>();
   VarDecl* decl =
-    new (Mem) VarDecl(Var, 0, SourceLocation(), NULL, QualType(), None);
+    new (C) VarDecl(Var, 0, SourceLocation(), NULL, QualType(), None);
  
   decl->VarDecl::ReadImpl(D, C);
   return decl;
@@ -355,8 +350,7 @@
 }
 
 ParmVarDecl* ParmVarDecl::CreateImpl(Deserializer& D, ASTContext& C) {
-  void *Mem = C.getAllocator().Allocate<ParmVarDecl>();
-  ParmVarDecl* decl = new (Mem)
+  ParmVarDecl* decl = new (C)
     ParmVarDecl(ParmVar,
                 0, SourceLocation(), NULL, QualType(), None, NULL);
   
@@ -377,8 +371,7 @@
 
 ParmVarWithOriginalTypeDecl* ParmVarWithOriginalTypeDecl::CreateImpl(
                                               Deserializer& D, ASTContext& C) {
-  void *Mem = C.getAllocator().Allocate<ParmVarWithOriginalTypeDecl>();
-  ParmVarWithOriginalTypeDecl* decl = new (Mem)
+  ParmVarWithOriginalTypeDecl* decl = new (C)
     ParmVarWithOriginalTypeDecl(0, SourceLocation(), NULL, QualType(), 
                                 QualType(), None, NULL);
   
@@ -397,8 +390,7 @@
 }
 
 EnumDecl* EnumDecl::CreateImpl(Deserializer& D, ASTContext& C) {
-  void *Mem = C.getAllocator().Allocate<EnumDecl>();
-  EnumDecl* decl = new (Mem) EnumDecl(0, SourceLocation(), NULL);
+  EnumDecl* decl = new (C) EnumDecl(0, SourceLocation(), NULL);
   
   decl->NamedDecl::ReadInRec(D, C);
   decl->setDefinition(D.ReadBool());
@@ -421,8 +413,7 @@
   llvm::APSInt val(1);
   D.Read(val);
   
-  void *Mem = C.getAllocator().Allocate<EnumConstantDecl>();
-  EnumConstantDecl* decl = new (Mem)
+  EnumConstantDecl* decl = new (C)
     EnumConstantDecl(0, SourceLocation(), NULL, QualType(), NULL, val);
   
   decl->ValueDecl::ReadInRec(D, C);
@@ -442,8 +433,7 @@
 }
 
 FieldDecl* FieldDecl::CreateImpl(Deserializer& D, ASTContext& C) {
-  void *Mem = C.getAllocator().Allocate<FieldDecl>();
-  FieldDecl* decl = new (Mem) FieldDecl(Field, 0, SourceLocation(), NULL, 
+  FieldDecl* decl = new (C) FieldDecl(Field, 0, SourceLocation(), NULL, 
                                         QualType(), 0, false);
   decl->Mutable = D.ReadBool();
   decl->DeclType.ReadBackpatch(D);  
@@ -480,8 +470,7 @@
   StorageClass SClass = static_cast<StorageClass>(D.ReadInt());
   bool IsInline = D.ReadBool();
   
-  void *Mem = C.getAllocator().Allocate<FunctionDecl>();
-  FunctionDecl* decl = new (Mem)
+  FunctionDecl* decl = new (C)
     FunctionDecl(Function, 0, SourceLocation(), DeclarationName(),
                  QualType(), SClass, IsInline);
   
@@ -537,8 +526,7 @@
 
 OverloadedFunctionDecl * 
 OverloadedFunctionDecl::CreateImpl(Deserializer& D, ASTContext& C) {
-  void *Mem = C.getAllocator().Allocate<OverloadedFunctionDecl>();
-  OverloadedFunctionDecl* decl = new (Mem)
+  OverloadedFunctionDecl* decl = new (C)
     OverloadedFunctionDecl(0, DeclarationName());
   
   decl->NamedDecl::ReadInRec(D, C);
@@ -567,8 +555,7 @@
 RecordDecl* RecordDecl::CreateImpl(Deserializer& D, ASTContext& C) {
   TagKind TK = TagKind(D.ReadInt());
 
-  void *Mem = C.getAllocator().Allocate<RecordDecl>();
-  RecordDecl* decl = new (Mem) RecordDecl(Record, TK, 0, SourceLocation(), NULL);
+  RecordDecl* decl = new (C) RecordDecl(Record, TK, 0, SourceLocation(), NULL);
     
   decl->NamedDecl::ReadInRec(D, C);
   decl->setDefinition(D.ReadBool());
@@ -590,8 +577,7 @@
 TypedefDecl* TypedefDecl::CreateImpl(Deserializer& D, ASTContext& C) {
   QualType T = QualType::ReadVal(D);
   
-  void *Mem = C.getAllocator().Allocate<TypedefDecl>();
-  TypedefDecl* decl = new (Mem) TypedefDecl(0, SourceLocation(), NULL, T);
+  TypedefDecl* decl = new (C) TypedefDecl(0, SourceLocation(), NULL, T);
   
   decl->NamedDecl::ReadInRec(D, C);
 
@@ -610,9 +596,8 @@
 TemplateTypeParmDecl *
 TemplateTypeParmDecl::CreateImpl(Deserializer& D, ASTContext& C) {
   bool Typename = D.ReadBool();
-  void *Mem = C.getAllocator().Allocate<TemplateTypeParmDecl>();
   TemplateTypeParmDecl *decl
-    = new (Mem) TemplateTypeParmDecl(0, SourceLocation(), NULL, Typename);
+    = new (C) TemplateTypeParmDecl(0, SourceLocation(), NULL, Typename);
   decl->NamedDecl::ReadInRec(D, C);
   return decl;
 }
@@ -641,8 +626,7 @@
 }
 
 FileScopeAsmDecl* FileScopeAsmDecl::CreateImpl(Deserializer& D, ASTContext& C) { 
-  void *Mem = C.getAllocator().Allocate<FileScopeAsmDecl>();
-  FileScopeAsmDecl* decl = new (Mem) FileScopeAsmDecl(0, SourceLocation(), 0);
+  FileScopeAsmDecl* decl = new (C) FileScopeAsmDecl(0, SourceLocation(), 0);
 
   decl->AsmString = cast<StringLiteral>(D.ReadOwnedPtr<Expr>(C));
 //  D.ReadOwnedPtr(D.ReadOwnedPtr<StringLiteral>())<#T * * Ptr#>, <#bool AutoRegister#>)(decl->AsmString);

Modified: cfe/trunk/lib/AST/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=63135&r1=63134&r2=63135&view=diff

==============================================================================
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Tue Jan 27 15:25:57 2009
@@ -32,19 +32,19 @@
 
 void Type::Destroy(ASTContext& C) {
   this->~Type();
-  C.getAllocator().Deallocate(this);
+  C.Deallocate(this);
 }
 
 void VariableArrayType::Destroy(ASTContext& C) {
   SizeExpr->Destroy(C);
   this->~VariableArrayType();
-  C.getAllocator().Deallocate(this);
+  C.Deallocate(this);
 }
 
 void DependentSizedArrayType::Destroy(ASTContext& C) {
   SizeExpr->Destroy(C);
   this->~DependentSizedArrayType();
-  C.getAllocator().Deallocate(this);
+  C.Deallocate(this);
 }
 
 /// getArrayElementTypeNoTypeQual - If this is an array type, return the





More information about the cfe-commits mailing list