aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaTemplateInstantiateDecl.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-04-30 05:56:50 +0000
committerDouglas Gregor <dgregor@apple.com>2010-04-30 05:56:50 +0000
commitdc60c1eb4acbde6edcec9760de92f9098593d915 (patch)
treedcb92305ce572104a838a8a160ad99fbd9476170 /lib/Sema/SemaTemplateInstantiateDecl.cpp
parentc743571e24c864b5930ef1290d71b03ccfde80a1 (diff)
Introduce a sequence number into class template partial
specializations, which keeps track of the order in which they were originally declared. We use this number so that we can always walk the list of partial specializations in a predictable order during matching or template instantiation. This also fixes a failure in Boost.Proto, where SourceManager::isBeforeInTranslationUnit was behaving poorly in inconsistent ways. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102693 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplateInstantiateDecl.cpp')
-rw-r--r--lib/Sema/SemaTemplateInstantiateDecl.cpp31
1 files changed, 4 insertions, 27 deletions
diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 4575d47329..25ba2829ce 100644
--- a/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -620,21 +620,6 @@ Decl *TemplateDeclInstantiator::VisitEnumConstantDecl(EnumConstantDecl *D) {
return 0;
}
-namespace {
- class SortDeclByLocation {
- SourceManager &SourceMgr;
-
- public:
- explicit SortDeclByLocation(SourceManager &SourceMgr)
- : SourceMgr(SourceMgr) { }
-
- bool operator()(const Decl *X, const Decl *Y) const {
- return SourceMgr.isBeforeInTranslationUnit(X->getLocation(),
- Y->getLocation());
- }
- };
-}
-
Decl *TemplateDeclInstantiator::VisitClassTemplateDecl(ClassTemplateDecl *D) {
bool isFriend = (D->getFriendObjectKind() != Decl::FOK_None);
@@ -791,19 +776,10 @@ Decl *TemplateDeclInstantiator::VisitClassTemplateDecl(ClassTemplateDecl *D) {
Owner->addDecl(Inst);
- // First, we sort the partial specializations by location, so
- // that we instantiate them in the order they were declared.
- llvm::SmallVector<ClassTemplatePartialSpecializationDecl *, 4> PartialSpecs;
- for (llvm::FoldingSet<ClassTemplatePartialSpecializationDecl>::iterator
- P = D->getPartialSpecializations().begin(),
- PEnd = D->getPartialSpecializations().end();
- P != PEnd; ++P)
- PartialSpecs.push_back(&*P);
- std::sort(PartialSpecs.begin(), PartialSpecs.end(),
- SortDeclByLocation(SemaRef.SourceMgr));
-
// Instantiate all of the partial specializations of this member class
// template.
+ llvm::SmallVector<ClassTemplatePartialSpecializationDecl *, 4> PartialSpecs;
+ D->getPartialSpecializations(PartialSpecs);
for (unsigned I = 0, N = PartialSpecs.size(); I != N; ++I)
InstantiateClassTemplatePartialSpecialization(Inst, PartialSpecs[I]);
@@ -1768,7 +1744,8 @@ TemplateDeclInstantiator::InstantiateClassTemplatePartialSpecialization(
Converted,
InstTemplateArgs,
CanonType,
- 0);
+ 0,
+ ClassTemplate->getPartialSpecializations().size());
// Substitute the nested name specifier, if any.
if (SubstQualifier(PartialSpec, InstPartialSpec))
return 0;