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 | cc0b1bc979b650a8a8b34b2032a074fd7724a90d (patch) | |
tree | 2c33daacbe150bd65d09100ca2f5d388be8157ce /lib/Sema/SemaTemplateInstantiateDecl.cpp | |
parent | 405861d4ae824795f506d03cd7578f011cbf5b87 (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108832 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplateInstantiateDecl.cpp')
-rw-r--r-- | lib/Sema/SemaTemplateInstantiateDecl.cpp | 25 |
1 files changed, 5 insertions, 20 deletions
diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp index 79b5532aef..7e0617568b 100644 --- a/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -857,16 +857,7 @@ TemplateDeclInstantiator::VisitClassTemplatePartialSpecializationDecl( if (!InstClassTemplate) return 0; - Decl *DCanon = D->getCanonicalDecl(); - for (llvm::FoldingSet<ClassTemplatePartialSpecializationDecl>::iterator - P = InstClassTemplate->getPartialSpecializations().begin(), - PEnd = InstClassTemplate->getPartialSpecializations().end(); - P != PEnd; ++P) { - if (P->getInstantiatedFromMember()->getCanonicalDecl() == DCanon) - return &*P; - } - - return 0; + return InstClassTemplate->findPartialSpecInstantiatedFromMember(D); } Decl * @@ -1804,15 +1795,10 @@ TemplateDeclInstantiator::InstantiateClassTemplatePartialSpecialization( // Figure out where to insert this class template partial specialization // in the member template's set of class template partial specializations. - llvm::FoldingSetNodeID ID; - ClassTemplatePartialSpecializationDecl::Profile(ID, - Converted.getFlatArguments(), - Converted.flatSize(), - SemaRef.Context); void *InsertPos = 0; ClassTemplateSpecializationDecl *PrevDecl - = ClassTemplate->getPartialSpecializations().FindNodeOrInsertPos(ID, - InsertPos); + = ClassTemplate->findPartialSpecialization(Converted.getFlatArguments(), + Converted.flatSize(), InsertPos); // Build the canonical type that describes the converted template // arguments of the class template partial specialization. @@ -1871,7 +1857,7 @@ TemplateDeclInstantiator::InstantiateClassTemplatePartialSpecialization( InstTemplateArgs, CanonType, 0, - ClassTemplate->getPartialSpecializations().size()); + ClassTemplate->getNextPartialSpecSequenceNumber()); // Substitute the nested name specifier, if any. if (SubstQualifier(PartialSpec, InstPartialSpec)) return 0; @@ -1881,8 +1867,7 @@ TemplateDeclInstantiator::InstantiateClassTemplatePartialSpecialization( // Add this partial specialization to the set of class template partial // specializations. - ClassTemplate->getPartialSpecializations().InsertNode(InstPartialSpec, - InsertPos); + ClassTemplate->AddPartialSpecialization(InstPartialSpec, InsertPos); return false; } |