diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2010-07-20 13:59:28 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2010-07-20 13:59:28 +0000 |
commit | 47470f2f3fbd4a2aaeef404d3fb6a1fbcd392e4d (patch) | |
tree | 5d2993fb3a89118d33d10f54b517c734b474580b /clang/lib/AST/DeclTemplate.cpp | |
parent | 38360b3ff7fee601db91636b2ac889593357b08e (diff) | |
download | bcm5719-llvm-47470f2f3fbd4a2aaeef404d3fb6a1fbcd392e4d.tar.gz bcm5719-llvm-47470f2f3fbd4a2aaeef404d3fb6a1fbcd392e4d.zip |
Hide the specializations folding sets of ClassTemplateDecl as an implementation detail (InsertPos
leaks though) and add methods to its interface for adding/finding specializations.
Simplifies its users a bit and we no longer need to replace specializations in the folding set with
their redeclarations. We just return the most recent redeclarations.
As a bonus, it fixes http://llvm.org/PR7670.
llvm-svn: 108832
Diffstat (limited to 'clang/lib/AST/DeclTemplate.cpp')
-rw-r--r-- | clang/lib/AST/DeclTemplate.cpp | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/clang/lib/AST/DeclTemplate.cpp b/clang/lib/AST/DeclTemplate.cpp index 9e1d79d79d6..a75c1c0d582 100644 --- a/clang/lib/AST/DeclTemplate.cpp +++ b/clang/lib/AST/DeclTemplate.cpp @@ -171,6 +171,28 @@ void ClassTemplateDecl::Destroy(ASTContext& C) { Decl::Destroy(C); } +ClassTemplateSpecializationDecl * +ClassTemplateDecl::findSpecialization(const TemplateArgument *Args, + unsigned NumArgs, void *&InsertPos) { + llvm::FoldingSetNodeID ID; + ClassTemplateSpecializationDecl::Profile(ID, Args, NumArgs, getASTContext()); + ClassTemplateSpecializationDecl *D + = getSpecializations().FindNodeOrInsertPos(ID, InsertPos); + return D ? D->getMostRecentDeclaration() : 0; +} + +ClassTemplatePartialSpecializationDecl * +ClassTemplateDecl::findPartialSpecialization(const TemplateArgument *Args, + unsigned NumArgs, + void *&InsertPos) { + llvm::FoldingSetNodeID ID; + ClassTemplatePartialSpecializationDecl::Profile(ID, Args, NumArgs, + getASTContext()); + ClassTemplatePartialSpecializationDecl *D + = getPartialSpecializations().FindNodeOrInsertPos(ID, InsertPos); + return D ? D->getMostRecentDeclaration() : 0; +} + void ClassTemplateDecl::getPartialSpecializations( llvm::SmallVectorImpl<ClassTemplatePartialSpecializationDecl *> &PS) { llvm::FoldingSet<ClassTemplatePartialSpecializationDecl> &PartialSpecs @@ -181,7 +203,7 @@ void ClassTemplateDecl::getPartialSpecializations( P = PartialSpecs.begin(), PEnd = PartialSpecs.end(); P != PEnd; ++P) { assert(!PS[P->getSequenceNumber()]); - PS[P->getSequenceNumber()] = &*P; + PS[P->getSequenceNumber()] = P->getMostRecentDeclaration(); } } @@ -194,7 +216,22 @@ ClassTemplateDecl::findPartialSpecialization(QualType T) { PEnd = getPartialSpecializations().end(); P != PEnd; ++P) { if (Context.hasSameType(P->getInjectedSpecializationType(), T)) - return &*P; + return P->getMostRecentDeclaration(); + } + + return 0; +} + +ClassTemplatePartialSpecializationDecl * +ClassTemplateDecl::findPartialSpecInstantiatedFromMember( + ClassTemplatePartialSpecializationDecl *D) { + Decl *DCanon = D->getCanonicalDecl(); + for (llvm::FoldingSet<ClassTemplatePartialSpecializationDecl>::iterator + P = getPartialSpecializations().begin(), + PEnd = getPartialSpecializations().end(); + P != PEnd; ++P) { + if (P->getInstantiatedFromMember()->getCanonicalDecl() == DCanon) + return P->getMostRecentDeclaration(); } return 0; |