diff options
author | Ted Kremenek <kremenek@apple.com> | 2010-05-10 20:40:08 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2010-05-10 20:40:08 +0000 |
commit | 6aead3a051a4d7c43e74b96ec25dbbf983f62d4e (patch) | |
tree | 1af29e55f9bf62d88460337bec4f725dbfa75062 /clang/lib/AST/DeclarationName.cpp | |
parent | 103d4b43e9c19baab8db0388f72aa86bf013ec9e (diff) | |
download | bcm5719-llvm-6aead3a051a4d7c43e74b96ec25dbbf983f62d4e.tar.gz bcm5719-llvm-6aead3a051a4d7c43e74b96ec25dbbf983f62d4e.zip |
Start converting pieces of DeclarationNameTable to be allocated using ASTContext's allocator.
While DeclarationNameTable doesn't leak, it uses 'malloc' too often. Start with having
'CXXLiteralOperatorNames' allocated using ASTContext's allocator and add a 'DoDestroy()' method
to DeclarationNameTable that is called by ~ASTContext.
llvm-svn: 103426
Diffstat (limited to 'clang/lib/AST/DeclarationName.cpp')
-rw-r--r-- | clang/lib/AST/DeclarationName.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/clang/lib/AST/DeclarationName.cpp b/clang/lib/AST/DeclarationName.cpp index 4f85fca5386..06232833852 100644 --- a/clang/lib/AST/DeclarationName.cpp +++ b/clang/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 |