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 | f21eb49a0404949c481c671965149e9cbdbc376d (patch) | |
tree | 23fbe9fba1983929ee3ba4883042a907a695e3d5 /clang/lib/AST/ASTContext.cpp | |
parent | fe7c0492a066a2bb5e91ef1a6b2ed413678abbcd (diff) | |
download | bcm5719-llvm-f21eb49a0404949c481c671965149e9cbdbc376d.tar.gz bcm5719-llvm-f21eb49a0404949c481c671965149e9cbdbc376d.zip |
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.
llvm-svn: 67799
Diffstat (limited to 'clang/lib/AST/ASTContext.cpp')
-rw-r--r-- | clang/lib/AST/ASTContext.cpp | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index c656d966db3..84976a02944 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/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); |