diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-03-26 23:50:42 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-03-26 23:50:42 +0000 |
commit | ab452ba8323d1985e08bade2bced588cddf2cc28 (patch) | |
tree | 5434985218412826cd26ffd2f8d87857109eb50b /lib/AST/ASTContext.cpp | |
parent | 5bf17cd277db2a253f6012968471064c4f4537a3 (diff) |
Revamp our representation of C++ nested-name-specifiers. We now have a
uniqued representation that should both save some memory and make it
far easier to properly build canonical types for types involving
dependent nested-name-specifiers, e.g., "typename T::Nested::type".
This approach will greatly simplify the representation of
CXXScopeSpec. That'll be next.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67799 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ASTContext.cpp')
-rw-r--r-- | lib/AST/ASTContext.cpp | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index c656d966db..84976a0294 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -33,9 +33,9 @@ ASTContext::ASTContext(const LangOptions& LOpts, SourceManager &SM, TargetInfo &t, IdentifierTable &idents, SelectorTable &sels, bool FreeMem, unsigned size_reserve) : - CFConstantStringTypeDecl(0), ObjCFastEnumerationStateTypeDecl(0), - SourceMgr(SM), LangOpts(LOpts), FreeMemory(FreeMem), Target(t), - Idents(idents), Selectors(sels) + GlobalNestedNameSpecifier(0), CFConstantStringTypeDecl(0), + ObjCFastEnumerationStateTypeDecl(0), SourceMgr(SM), LangOpts(LOpts), + FreeMemory(FreeMem), Target(t), Idents(idents), Selectors(sels) { if (size_reserve > 0) Types.reserve(size_reserve); InitBuiltinTypes(); @@ -77,7 +77,18 @@ ASTContext::~ASTContext() { } } + // Destroy nested-name-specifiers. + for (llvm::FoldingSet<NestedNameSpecifier>::iterator + NNS = NestedNameSpecifiers.begin(), + NNSEnd = NestedNameSpecifiers.end(); + NNS != NNSEnd; ++NNS) + NNS->Destroy(*this); + + if (GlobalNestedNameSpecifier) + GlobalNestedNameSpecifier->Destroy(*this); + TUDecl->Destroy(*this); + } void ASTContext::PrintStats() const { @@ -1376,11 +1387,10 @@ ASTContext::getClassTemplateSpecializationType(TemplateDecl *Template, } QualType -ASTContext::getQualifiedNameType(const NestedNameSpecifier *Components, - unsigned NumComponents, +ASTContext::getQualifiedNameType(NestedNameSpecifier *NNS, QualType NamedType) { llvm::FoldingSetNodeID ID; - QualifiedNameType::Profile(ID, Components, NumComponents, NamedType); + QualifiedNameType::Profile(ID, NNS, NamedType); void *InsertPos = 0; QualifiedNameType *T @@ -1388,11 +1398,8 @@ ASTContext::getQualifiedNameType(const NestedNameSpecifier *Components, if (T) return QualType(T, 0); - void *Mem = Allocate((sizeof(QualifiedNameType) + - sizeof(NestedNameSpecifier) * NumComponents), - 8); - T = new (Mem) QualifiedNameType(Components, NumComponents, NamedType, - getCanonicalType(NamedType)); + T = new (*this) QualifiedNameType(NNS, NamedType, + getCanonicalType(NamedType)); Types.push_back(T); QualifiedNameTypes.InsertNode(T, InsertPos); return QualType(T, 0); |