forked from OSchip/llvm-project
Allocate most of DeclarationNamesTable using ASTContext's allcocator. The only things that
aren't allocated this way are the internal FoldingSets. llvm-svn: 103429
This commit is contained in:
parent
58aff8fb57
commit
7e550caf4e
|
@ -314,6 +314,7 @@ inline bool operator>=(DeclarationName LHS, DeclarationName RHS) {
|
|||
/// retrieved using its member functions (e.g.,
|
||||
/// getCXXConstructorName).
|
||||
class DeclarationNameTable {
|
||||
ASTContext &Ctx;
|
||||
void *CXXSpecialNamesImpl; // Actually a FoldingSet<CXXSpecialName> *
|
||||
CXXOperatorIdName *CXXOperatorNames; // Operator names
|
||||
void *CXXLiteralOperatorNames; // Actually a CXXOperatorIdName*
|
||||
|
@ -325,10 +326,6 @@ public:
|
|||
DeclarationNameTable(ASTContext &C);
|
||||
~DeclarationNameTable();
|
||||
|
||||
/// Free all memory allocated associated with this DeclarationTable that
|
||||
// is used allocated using the specified ASTContext object.
|
||||
void DoDestroy(ASTContext &C);
|
||||
|
||||
/// getIdentifier - Create a declaration name that is a simple
|
||||
/// identifier.
|
||||
DeclarationName getIdentifier(const IdentifierInfo *ID) {
|
||||
|
|
|
@ -110,9 +110,6 @@ ASTContext::~ASTContext() {
|
|||
if (GlobalNestedNameSpecifier)
|
||||
GlobalNestedNameSpecifier->Destroy(*this);
|
||||
|
||||
// Deallocate the memory associated with the DeclarationNameTable.
|
||||
DeclarationNames.DoDestroy(*this);
|
||||
|
||||
TUDecl->Destroy(*this);
|
||||
}
|
||||
|
||||
|
|
|
@ -384,12 +384,12 @@ void DeclarationName::dump() const {
|
|||
llvm::errs() << '\n';
|
||||
}
|
||||
|
||||
DeclarationNameTable::DeclarationNameTable(ASTContext &C) {
|
||||
DeclarationNameTable::DeclarationNameTable(ASTContext &C) : Ctx(C) {
|
||||
CXXSpecialNamesImpl = new llvm::FoldingSet<CXXSpecialName>;
|
||||
CXXLiteralOperatorNames = new llvm::FoldingSet<CXXLiteralOperatorIdName>;
|
||||
|
||||
// Initialize the overloaded operator names.
|
||||
CXXOperatorNames = new (C) CXXOperatorIdName[NUM_OVERLOADED_OPERATORS];
|
||||
CXXOperatorNames = new (Ctx) CXXOperatorIdName[NUM_OVERLOADED_OPERATORS];
|
||||
for (unsigned Op = 0; Op < NUM_OVERLOADED_OPERATORS; ++Op) {
|
||||
CXXOperatorNames[Op].ExtraKindOrNumArgs
|
||||
= Op + DeclarationNameExtra::CXXConversionFunction;
|
||||
|
@ -400,36 +400,34 @@ DeclarationNameTable::DeclarationNameTable(ASTContext &C) {
|
|||
DeclarationNameTable::~DeclarationNameTable() {
|
||||
llvm::FoldingSet<CXXSpecialName> *SpecialNames =
|
||||
static_cast<llvm::FoldingSet<CXXSpecialName>*>(CXXSpecialNamesImpl);
|
||||
llvm::FoldingSetIterator<CXXSpecialName>
|
||||
SI = SpecialNames->begin(), SE = SpecialNames->end();
|
||||
|
||||
while (SI != SE) {
|
||||
CXXSpecialName *n = &*SI++;
|
||||
delete n;
|
||||
}
|
||||
|
||||
|
||||
llvm::FoldingSet<CXXLiteralOperatorIdName> *LiteralNames
|
||||
= static_cast<llvm::FoldingSet<CXXLiteralOperatorIdName>*>
|
||||
(CXXLiteralOperatorNames);
|
||||
llvm::FoldingSetIterator<CXXLiteralOperatorIdName>
|
||||
LI = LiteralNames->begin(), LE = LiteralNames->end();
|
||||
(CXXLiteralOperatorNames);
|
||||
|
||||
while (LI != LE) {
|
||||
CXXLiteralOperatorIdName *n = &*LI++;
|
||||
delete n;
|
||||
if (Ctx.FreeMemory) {
|
||||
llvm::FoldingSetIterator<CXXSpecialName>
|
||||
SI = SpecialNames->begin(), SE = SpecialNames->end();
|
||||
|
||||
while (SI != SE) {
|
||||
CXXSpecialName *n = &*SI++;
|
||||
Ctx.Deallocate(n);
|
||||
}
|
||||
|
||||
llvm::FoldingSetIterator<CXXLiteralOperatorIdName>
|
||||
LI = LiteralNames->begin(), LE = LiteralNames->end();
|
||||
|
||||
while (LI != LE) {
|
||||
CXXLiteralOperatorIdName *n = &*LI++;
|
||||
Ctx.Deallocate(n);
|
||||
}
|
||||
|
||||
Ctx.Deallocate(CXXOperatorNames);
|
||||
}
|
||||
|
||||
delete SpecialNames;
|
||||
delete LiteralNames;
|
||||
}
|
||||
|
||||
void DeclarationNameTable::DoDestroy(ASTContext &C) {
|
||||
if (C.FreeMemory) {
|
||||
C.Deallocate(CXXOperatorNames);
|
||||
}
|
||||
}
|
||||
|
||||
DeclarationName
|
||||
DeclarationNameTable::getCXXSpecialName(DeclarationName::NameKind Kind,
|
||||
CanQualType Ty) {
|
||||
|
@ -465,7 +463,7 @@ DeclarationNameTable::getCXXSpecialName(DeclarationName::NameKind Kind,
|
|||
if (CXXSpecialName *Name = SpecialNames->FindNodeOrInsertPos(ID, InsertPos))
|
||||
return DeclarationName(Name);
|
||||
|
||||
CXXSpecialName *SpecialName = new CXXSpecialName;
|
||||
CXXSpecialName *SpecialName = new (Ctx) CXXSpecialName;
|
||||
SpecialName->ExtraKindOrNumArgs = EKind;
|
||||
SpecialName->Type = Ty;
|
||||
SpecialName->FETokenInfo = 0;
|
||||
|
@ -493,7 +491,7 @@ DeclarationNameTable::getCXXLiteralOperatorName(IdentifierInfo *II) {
|
|||
LiteralNames->FindNodeOrInsertPos(ID, InsertPos))
|
||||
return DeclarationName (Name);
|
||||
|
||||
CXXLiteralOperatorIdName *LiteralName = new CXXLiteralOperatorIdName;
|
||||
CXXLiteralOperatorIdName *LiteralName = new (Ctx) CXXLiteralOperatorIdName;
|
||||
LiteralName->ExtraKindOrNumArgs = DeclarationNameExtra::CXXLiteralOperator;
|
||||
LiteralName->ID = II;
|
||||
|
||||
|
|
Loading…
Reference in New Issue