diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/AST/ASTContext.cpp | 7 | ||||
-rw-r--r-- | lib/AST/DeclarationName.cpp | 14 |
2 files changed, 16 insertions, 5 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index 141f1b9bf9..3a8084833e 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -46,7 +46,9 @@ ASTContext::ASTContext(const LangOptions& LOpts, SourceManager &SM, sigjmp_bufDecl(0), BlockDescriptorType(0), BlockDescriptorExtendedType(0), SourceMgr(SM), LangOpts(LOpts), FreeMemory(FreeMem), Target(t), Idents(idents), Selectors(sels), - BuiltinInfo(builtins), ExternalSource(0), PrintingPolicy(LOpts), + BuiltinInfo(builtins), + DeclarationNames(*this), + ExternalSource(0), PrintingPolicy(LOpts), LastSDM(0, 0) { ObjCIdRedefinitionType = QualType(); ObjCClassRedefinitionType = QualType(); @@ -108,6 +110,9 @@ ASTContext::~ASTContext() { if (GlobalNestedNameSpecifier) GlobalNestedNameSpecifier->Destroy(*this); + // Deallocate the memory associated with the DeclarationNameTable. + DeclarationNames.DoDestroy(*this); + TUDecl->Destroy(*this); } diff --git a/lib/AST/DeclarationName.cpp b/lib/AST/DeclarationName.cpp index 4f85fca538..0623283385 100644 --- a/lib/AST/DeclarationName.cpp +++ b/lib/AST/DeclarationName.cpp @@ -11,10 +11,11 @@ // classes. // //===----------------------------------------------------------------------===// +#include "clang/AST/ASTContext.h" +#include "clang/AST/Decl.h" #include "clang/AST/DeclarationName.h" #include "clang/AST/Type.h" #include "clang/AST/TypeOrdering.h" -#include "clang/AST/Decl.h" #include "clang/Basic/IdentifierTable.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/FoldingSet.h" @@ -383,12 +384,12 @@ void DeclarationName::dump() const { llvm::errs() << '\n'; } -DeclarationNameTable::DeclarationNameTable() { +DeclarationNameTable::DeclarationNameTable(ASTContext &C) { CXXSpecialNamesImpl = new llvm::FoldingSet<CXXSpecialName>; CXXLiteralOperatorNames = new llvm::FoldingSet<CXXLiteralOperatorIdName>; // Initialize the overloaded operator names. - CXXOperatorNames = new CXXOperatorIdName[NUM_OVERLOADED_OPERATORS]; + CXXOperatorNames = new (C) CXXOperatorIdName[NUM_OVERLOADED_OPERATORS]; for (unsigned Op = 0; Op < NUM_OVERLOADED_OPERATORS; ++Op) { CXXOperatorNames[Op].ExtraKindOrNumArgs = Op + DeclarationNameExtra::CXXConversionFunction; @@ -421,7 +422,12 @@ DeclarationNameTable::~DeclarationNameTable() { delete SpecialNames; delete LiteralNames; - delete [] CXXOperatorNames; +} + +void DeclarationNameTable::DoDestroy(ASTContext &C) { + if (C.FreeMemory) { + C.Deallocate(CXXOperatorNames); + } } DeclarationName |