aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/DeclarationName.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2010-05-10 20:40:08 +0000
committerTed Kremenek <kremenek@apple.com>2010-05-10 20:40:08 +0000
commitac9590effa90406767a544005ed1de52e258306b (patch)
tree6220409f8e3d7896f93ce5d03c95422450452eb5 /lib/AST/DeclarationName.cpp
parentd04ed416be7c55bddddab1fa3fd38a0113a6b3da (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103426 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/DeclarationName.cpp')
-rw-r--r--lib/AST/DeclarationName.cpp14
1 files changed, 10 insertions, 4 deletions
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