[cfe-commits] r74717 - in /cfe/trunk: include/clang/AST/DeclCXX.h lib/AST/DeclCXX.cpp lib/Sema/SemaDeclCXX.cpp
Fariborz Jahanian
fjahanian at apple.com
Thu Jul 2 11:26:19 PDT 2009
Author: fjahanian
Date: Thu Jul 2 13:26:15 2009
New Revision: 74717
URL: http://llvm.org/viewvc/llvm-project?rev=74717&view=rev
Log:
Patch to allocate list of bases in CXXRecordDecl
using ASTContxt allocation.
Modified:
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=74717&r1=74716&r2=74717&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Thu Jul 2 13:26:15 2009
@@ -297,8 +297,11 @@
CXXRecordDecl* PrevDecl=0,
bool DelayTypeCreation = false);
+ virtual void Destroy(ASTContext& C);
+
/// setBases - Sets the base classes of this struct or class.
- void setBases(CXXBaseSpecifier const * const *Bases, unsigned NumBases);
+ void setBases(ASTContext &C,
+ CXXBaseSpecifier const * const *Bases, unsigned NumBases);
/// getNumBases - Retrieves the number of base classes of this
/// class.
Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=74717&r1=74716&r2=74717&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Thu Jul 2 13:26:15 2009
@@ -44,11 +44,16 @@
}
CXXRecordDecl::~CXXRecordDecl() {
- delete [] Bases;
+}
+
+void CXXRecordDecl::Destroy(ASTContext &C) {
+ C.Deallocate(Bases);
+ this->RecordDecl::Destroy(C);
}
void
-CXXRecordDecl::setBases(CXXBaseSpecifier const * const *Bases,
+CXXRecordDecl::setBases(ASTContext &C,
+ CXXBaseSpecifier const * const *Bases,
unsigned NumBases) {
// C++ [dcl.init.aggr]p1:
// An aggregate is an array or a class (clause 9) with [...]
@@ -56,10 +61,9 @@
Aggregate = false;
if (this->Bases)
- delete [] this->Bases;
+ C.Deallocate(this->Bases);
- // FIXME: allocate using the ASTContext
- this->Bases = new CXXBaseSpecifier[NumBases];
+ this->Bases = new(C) CXXBaseSpecifier [NumBases];
this->NumBases = NumBases;
for (unsigned i = 0; i < NumBases; ++i)
this->Bases[i] = *Bases[i];
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=74717&r1=74716&r2=74717&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Thu Jul 2 13:26:15 2009
@@ -481,7 +481,7 @@
}
// Attach the remaining base class specifiers to the derived class.
- Class->setBases(Bases, NumGoodBases);
+ Class->setBases(Context, Bases, NumGoodBases);
// Delete the remaining (good) base class specifiers, since their
// data has been copied into the CXXRecordDecl.
More information about the cfe-commits
mailing list